@quikit/quikpilot-runner 9.3.0-rc.35 → 9.3.0-rc.36
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/README.md +2 -0
- package/dist/index.js +254 -98
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -144,8 +144,8 @@ var require_types = __commonJS({
|
|
|
144
144
|
TokenType4[TokenType4["IS_POSTFIX"] = IS_POSTFIX] = "IS_POSTFIX";
|
|
145
145
|
const IS_EXPRESSION_START = 1 << 9;
|
|
146
146
|
TokenType4[TokenType4["IS_EXPRESSION_START"] = IS_EXPRESSION_START] = "IS_EXPRESSION_START";
|
|
147
|
-
const
|
|
148
|
-
TokenType4[TokenType4["num"] =
|
|
147
|
+
const num2 = 512;
|
|
148
|
+
TokenType4[TokenType4["num"] = num2] = "num";
|
|
149
149
|
const bigint = 1536;
|
|
150
150
|
TokenType4[TokenType4["bigint"] = bigint] = "bigint";
|
|
151
151
|
const decimal = 2560;
|
|
@@ -12785,8 +12785,8 @@ var require_sourcemap_codec_umd = __commonJS({
|
|
|
12785
12785
|
}
|
|
12786
12786
|
return relative10 + value;
|
|
12787
12787
|
}
|
|
12788
|
-
function encodeInteger(builder,
|
|
12789
|
-
let delta =
|
|
12788
|
+
function encodeInteger(builder, num2, relative10) {
|
|
12789
|
+
let delta = num2 - relative10;
|
|
12790
12790
|
delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
|
|
12791
12791
|
do {
|
|
12792
12792
|
let clamped = delta & 31;
|
|
@@ -12794,7 +12794,7 @@ var require_sourcemap_codec_umd = __commonJS({
|
|
|
12794
12794
|
if (delta > 0) clamped |= 32;
|
|
12795
12795
|
builder.write(intToChar[clamped]);
|
|
12796
12796
|
} while (delta > 0);
|
|
12797
|
-
return
|
|
12797
|
+
return num2;
|
|
12798
12798
|
}
|
|
12799
12799
|
function hasMoreVlq(reader, max) {
|
|
12800
12800
|
if (reader.pos >= max) return false;
|
|
@@ -12851,7 +12851,7 @@ var require_sourcemap_codec_umd = __commonJS({
|
|
|
12851
12851
|
return idx === -1 ? buffer.length : idx;
|
|
12852
12852
|
}
|
|
12853
12853
|
};
|
|
12854
|
-
var
|
|
12854
|
+
var EMPTY2 = [];
|
|
12855
12855
|
function decodeOriginalScopes(input) {
|
|
12856
12856
|
const { length } = input;
|
|
12857
12857
|
const reader = new StringReader(input);
|
|
@@ -12871,7 +12871,7 @@ var require_sourcemap_codec_umd = __commonJS({
|
|
|
12871
12871
|
const fields = decodeInteger(reader, 0);
|
|
12872
12872
|
const hasName = fields & 1;
|
|
12873
12873
|
const scope = hasName ? [line, column, 0, 0, kind, decodeInteger(reader, 0)] : [line, column, 0, 0, kind];
|
|
12874
|
-
let vars =
|
|
12874
|
+
let vars = EMPTY2;
|
|
12875
12875
|
if (hasMoreVlq(reader, length)) {
|
|
12876
12876
|
vars = [];
|
|
12877
12877
|
do {
|
|
@@ -12947,7 +12947,7 @@ var require_sourcemap_codec_umd = __commonJS({
|
|
|
12947
12947
|
const hasCallsite = fields & 2;
|
|
12948
12948
|
const hasScope = fields & 4;
|
|
12949
12949
|
let callsite = null;
|
|
12950
|
-
let bindings =
|
|
12950
|
+
let bindings = EMPTY2;
|
|
12951
12951
|
let range;
|
|
12952
12952
|
if (hasDefinition) {
|
|
12953
12953
|
const defSourcesIndex = decodeInteger(reader, definitionSourcesIndex);
|
|
@@ -24436,7 +24436,7 @@ async function describeQuikTrackFailure(res) {
|
|
|
24436
24436
|
|
|
24437
24437
|
// src/callback.ts
|
|
24438
24438
|
async function reportBack(params) {
|
|
24439
|
-
const { callbackUrl, runToken, status, branch, warnings, targeting, baselineFindings, vanishedTests, unsuppliedInputs, changesNoTestDependsOn, testsCorrected, codegenLoop, unresolved } = params;
|
|
24439
|
+
const { callbackUrl, runToken, status, branch, warnings, targeting, baselineFindings, vanishedTests, unsuppliedInputs, changesNoTestDependsOn, testsCorrected, codegenLoop, unresolved, aiCostUsd } = params;
|
|
24440
24440
|
const body = { status };
|
|
24441
24441
|
if (branch) body.branch = branch;
|
|
24442
24442
|
if (warnings && warnings.length > 0) body.warnings = warnings;
|
|
@@ -24448,6 +24448,7 @@ async function reportBack(params) {
|
|
|
24448
24448
|
if (changesNoTestDependsOn && changesNoTestDependsOn.hunks.length > 0) body.changesNoTestDependsOn = changesNoTestDependsOn;
|
|
24449
24449
|
if (testsCorrected && testsCorrected.files.length > 0) body.testsCorrected = testsCorrected;
|
|
24450
24450
|
if (codegenLoop) body.codegenLoop = codegenLoop;
|
|
24451
|
+
if (typeof aiCostUsd === "number" && Number.isFinite(aiCostUsd) && aiCostUsd > 0) body.aiCostUsd = Math.round(aiCostUsd * 1e6) / 1e6;
|
|
24451
24452
|
const res = await fetch(callbackUrl, {
|
|
24452
24453
|
method: "POST",
|
|
24453
24454
|
headers: { Authorization: `Bearer ${runToken}`, "Content-Type": "application/json" },
|
|
@@ -26348,6 +26349,144 @@ function commitAndPush(branch, runId, installationToken, targeted, issueKey, iss
|
|
|
26348
26349
|
return { changed: true, branch };
|
|
26349
26350
|
}
|
|
26350
26351
|
|
|
26352
|
+
// src/tokenEstimate.ts
|
|
26353
|
+
var TOKENS_PER_ALPHA_CHAR = 0.3;
|
|
26354
|
+
var TOKENS_PER_DIGIT_CHAR = 0.18;
|
|
26355
|
+
var TOKENS_PER_SPACE_CHAR = 0.05;
|
|
26356
|
+
var TOKENS_PER_PUNCTUATION_CHAR = 1.05;
|
|
26357
|
+
var TOKENS_PER_NON_ASCII_CHAR = 1;
|
|
26358
|
+
var PROMPT_OVERHEAD_TOKENS = 5e3;
|
|
26359
|
+
function estimateTokens(text) {
|
|
26360
|
+
let alpha = 0;
|
|
26361
|
+
let digit = 0;
|
|
26362
|
+
let space = 0;
|
|
26363
|
+
let punct = 0;
|
|
26364
|
+
let nonAscii = 0;
|
|
26365
|
+
for (const ch of text) {
|
|
26366
|
+
const code = ch.codePointAt(0);
|
|
26367
|
+
if (code >= 128) nonAscii++;
|
|
26368
|
+
else if (code >= 65 && code <= 90 || code >= 97 && code <= 122) alpha++;
|
|
26369
|
+
else if (code >= 48 && code <= 57) digit++;
|
|
26370
|
+
else if (code === 32 || code === 9 || code === 13 || code === 10) space++;
|
|
26371
|
+
else punct++;
|
|
26372
|
+
}
|
|
26373
|
+
return Math.ceil(
|
|
26374
|
+
alpha * TOKENS_PER_ALPHA_CHAR + digit * TOKENS_PER_DIGIT_CHAR + space * TOKENS_PER_SPACE_CHAR + punct * TOKENS_PER_PUNCTUATION_CHAR + nonAscii * TOKENS_PER_NON_ASCII_CHAR
|
|
26375
|
+
);
|
|
26376
|
+
}
|
|
26377
|
+
function estimateRequestTokens(contextData) {
|
|
26378
|
+
return PROMPT_OVERHEAD_TOKENS + estimateTokens(JSON.stringify(contextData ?? {}, null, 2));
|
|
26379
|
+
}
|
|
26380
|
+
|
|
26381
|
+
// src/turnUsage.ts
|
|
26382
|
+
var MAX_TURN_ROWS = 30;
|
|
26383
|
+
var num = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 ? v : void 0;
|
|
26384
|
+
function usageOf(envelope) {
|
|
26385
|
+
if (typeof envelope !== "object" || envelope === null) return {};
|
|
26386
|
+
const e = envelope;
|
|
26387
|
+
const tokensIn = num(e.tokensInput);
|
|
26388
|
+
const tokensOut = num(e.tokensOutput);
|
|
26389
|
+
const costUsd = num(e.costEstimateUsd);
|
|
26390
|
+
const ms = num(e.latencyMs);
|
|
26391
|
+
return {
|
|
26392
|
+
...tokensIn !== void 0 ? { tokensIn: Math.round(tokensIn) } : {},
|
|
26393
|
+
...tokensOut !== void 0 ? { tokensOut: Math.round(tokensOut) } : {},
|
|
26394
|
+
...costUsd !== void 0 ? { costUsd } : {},
|
|
26395
|
+
...ms !== void 0 ? { ms: Math.round(ms) } : {}
|
|
26396
|
+
};
|
|
26397
|
+
}
|
|
26398
|
+
var sizeOf = (value) => value === void 0 ? 0 : estimateTokens(JSON.stringify(value, null, 2));
|
|
26399
|
+
var RESULT_KEYS = /* @__PURE__ */ new Set(["transcript", "toolResults", "previousAttempt"]);
|
|
26400
|
+
function requestParts(contextData) {
|
|
26401
|
+
const parts = { fixed: PROMPT_OVERHEAD_TOKENS, map: 0, cases: 0, task: 0, results: 0, notes: 0, other: 0 };
|
|
26402
|
+
for (const [key, value] of Object.entries(contextData)) {
|
|
26403
|
+
if (key === "repoMap" || key === "workspaceListing") parts.map += sizeOf(value);
|
|
26404
|
+
else if (key === "requiredTests") parts.cases += sizeOf(value);
|
|
26405
|
+
else if (key === "loop" && typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
26406
|
+
for (const [loopKey, loopValue] of Object.entries(value)) {
|
|
26407
|
+
if (RESULT_KEYS.has(loopKey)) parts.results += sizeOf(loopValue);
|
|
26408
|
+
else if (loopKey === "recap") parts.notes += sizeOf(loopValue);
|
|
26409
|
+
else parts.other += sizeOf(loopValue);
|
|
26410
|
+
}
|
|
26411
|
+
} else parts.task += sizeOf(value);
|
|
26412
|
+
}
|
|
26413
|
+
return parts;
|
|
26414
|
+
}
|
|
26415
|
+
var TurnUsage = class {
|
|
26416
|
+
rows = [];
|
|
26417
|
+
rowsCut = false;
|
|
26418
|
+
totals = { calls: 0, tokensIn: 0, tokensOut: 0, costUsd: 0 };
|
|
26419
|
+
record(turn, contextData, estTokens, envelope, elapsedMs) {
|
|
26420
|
+
const used = usageOf(envelope);
|
|
26421
|
+
this.totals.calls += 1;
|
|
26422
|
+
this.totals.tokensIn += used.tokensIn ?? 0;
|
|
26423
|
+
this.totals.tokensOut += used.tokensOut ?? 0;
|
|
26424
|
+
this.totals.costUsd += used.costUsd ?? 0;
|
|
26425
|
+
if (this.rows.length >= MAX_TURN_ROWS) {
|
|
26426
|
+
this.rowsCut = true;
|
|
26427
|
+
return;
|
|
26428
|
+
}
|
|
26429
|
+
this.rows.push({
|
|
26430
|
+
turn,
|
|
26431
|
+
estTokens,
|
|
26432
|
+
parts: requestParts(contextData),
|
|
26433
|
+
...used.tokensIn !== void 0 ? { tokensIn: used.tokensIn } : {},
|
|
26434
|
+
...used.tokensOut !== void 0 ? { tokensOut: used.tokensOut } : {},
|
|
26435
|
+
...used.costUsd !== void 0 ? { costUsd: used.costUsd } : {},
|
|
26436
|
+
seconds: Math.max(0, Math.round(elapsedMs / 1e3))
|
|
26437
|
+
});
|
|
26438
|
+
}
|
|
26439
|
+
};
|
|
26440
|
+
function addTotals(a, b) {
|
|
26441
|
+
return {
|
|
26442
|
+
calls: (a?.calls ?? 0) + (b?.calls ?? 0),
|
|
26443
|
+
tokensIn: (a?.tokensIn ?? 0) + (b?.tokensIn ?? 0),
|
|
26444
|
+
tokensOut: (a?.tokensOut ?? 0) + (b?.tokensOut ?? 0),
|
|
26445
|
+
costUsd: (a?.costUsd ?? 0) + (b?.costUsd ?? 0)
|
|
26446
|
+
};
|
|
26447
|
+
}
|
|
26448
|
+
var whole = (n, max) => typeof n === "number" && Number.isFinite(n) && n >= 0 ? Math.min(Math.round(n), max) : 0;
|
|
26449
|
+
var money = (n) => typeof n === "number" && Number.isFinite(n) && n >= 0 ? Math.min(Math.round(n * 1e6) / 1e6, 1e3) : 0;
|
|
26450
|
+
function clampTurnRows(rows) {
|
|
26451
|
+
if (!rows || rows.length === 0) return void 0;
|
|
26452
|
+
return rows.slice(0, MAX_TURN_ROWS).map((r) => ({
|
|
26453
|
+
turn: whole(r.turn, 1e3),
|
|
26454
|
+
estTokens: whole(r.estTokens, 1e7),
|
|
26455
|
+
parts: {
|
|
26456
|
+
fixed: whole(r.parts.fixed, 1e7),
|
|
26457
|
+
map: whole(r.parts.map, 1e7),
|
|
26458
|
+
cases: whole(r.parts.cases, 1e7),
|
|
26459
|
+
task: whole(r.parts.task, 1e7),
|
|
26460
|
+
results: whole(r.parts.results, 1e7),
|
|
26461
|
+
notes: whole(r.parts.notes, 1e7),
|
|
26462
|
+
other: whole(r.parts.other, 1e7)
|
|
26463
|
+
},
|
|
26464
|
+
...r.tokensIn !== void 0 ? { tokensIn: whole(r.tokensIn, 1e7) } : {},
|
|
26465
|
+
...r.tokensOut !== void 0 ? { tokensOut: whole(r.tokensOut, 1e7) } : {},
|
|
26466
|
+
...r.costUsd !== void 0 ? { costUsd: money(r.costUsd) } : {},
|
|
26467
|
+
seconds: whole(r.seconds, 1e5)
|
|
26468
|
+
}));
|
|
26469
|
+
}
|
|
26470
|
+
function clampTotals(t) {
|
|
26471
|
+
if (!t || t.calls <= 0) return void 0;
|
|
26472
|
+
return { calls: whole(t.calls, 1e4), tokensIn: whole(t.tokensIn, 1e8), tokensOut: whole(t.tokensOut, 1e8), costUsd: money(t.costUsd) };
|
|
26473
|
+
}
|
|
26474
|
+
|
|
26475
|
+
// src/aiSpend.ts
|
|
26476
|
+
var EMPTY = { calls: 0, tokensIn: 0, tokensOut: 0, costUsd: 0 };
|
|
26477
|
+
var byStep = { targeting: { ...EMPTY }, codegen: { ...EMPTY }, investigate: { ...EMPTY } };
|
|
26478
|
+
function noteSpend(envelope, step) {
|
|
26479
|
+
const used = usageOf(envelope);
|
|
26480
|
+
byStep[step] = addTotals(byStep[step], { calls: 1, tokensIn: used.tokensIn ?? 0, tokensOut: used.tokensOut ?? 0, costUsd: used.costUsd ?? 0 });
|
|
26481
|
+
return envelope;
|
|
26482
|
+
}
|
|
26483
|
+
function spendOf(step) {
|
|
26484
|
+
return { ...byStep[step] };
|
|
26485
|
+
}
|
|
26486
|
+
function spendSoFar() {
|
|
26487
|
+
return addTotals(addTotals(byStep.targeting, byStep.codegen), byStep.investigate);
|
|
26488
|
+
}
|
|
26489
|
+
|
|
26351
26490
|
// src/codegen.ts
|
|
26352
26491
|
var import_node_fs7 = require("node:fs");
|
|
26353
26492
|
var import_node_path9 = require("node:path");
|
|
@@ -26884,7 +27023,7 @@ async function runCodegen(gateway, targets, workspaceListing, requiredTests, den
|
|
|
26884
27023
|
if (!res.ok) {
|
|
26885
27024
|
throw new Error(`Codegen call failed for ${target.path}: ${res.status} ${res.statusText}`);
|
|
26886
27025
|
}
|
|
26887
|
-
let envelope = await res.json();
|
|
27026
|
+
let envelope = noteSpend(await res.json(), "codegen");
|
|
26888
27027
|
checkHardFailure(envelope, "pilot.codegen", target.path);
|
|
26889
27028
|
if (envelope?.errorCode === JUDGED_BY_TOO_LARGE_CODE && contextData.judgedBy) {
|
|
26890
27029
|
const before = contextData.judgedBy.length;
|
|
@@ -26899,7 +27038,7 @@ async function runCodegen(gateway, targets, workspaceListing, requiredTests, den
|
|
|
26899
27038
|
if (!res.ok) {
|
|
26900
27039
|
throw new Error(`Codegen call failed for ${target.path}: ${res.status} ${res.statusText}`);
|
|
26901
27040
|
}
|
|
26902
|
-
envelope = await res.json();
|
|
27041
|
+
envelope = noteSpend(await res.json(), "codegen");
|
|
26903
27042
|
checkHardFailure(envelope, "pilot.codegen", target.path);
|
|
26904
27043
|
}
|
|
26905
27044
|
if (envelope?.errorCode === CONTEXT_TOO_LARGE_CODE && added.entries.length > 0) {
|
|
@@ -26912,7 +27051,7 @@ async function runCodegen(gateway, targets, workspaceListing, requiredTests, den
|
|
|
26912
27051
|
if (!res.ok) {
|
|
26913
27052
|
throw new Error(`Codegen call failed for ${target.path}: ${res.status} ${res.statusText}`);
|
|
26914
27053
|
}
|
|
26915
|
-
envelope = await res.json();
|
|
27054
|
+
envelope = noteSpend(await res.json(), "codegen");
|
|
26916
27055
|
checkHardFailure(envelope, "pilot.codegen", target.path);
|
|
26917
27056
|
}
|
|
26918
27057
|
throwOnTerminalRefusal(envelope, target.path);
|
|
@@ -26964,14 +27103,14 @@ async function runCodegen(gateway, targets, workspaceListing, requiredTests, den
|
|
|
26964
27103
|
if (!res.ok) {
|
|
26965
27104
|
throw new Error(`Codegen call failed for ${target.path}: ${res.status} ${res.statusText}`);
|
|
26966
27105
|
}
|
|
26967
|
-
envelope = await res.json();
|
|
27106
|
+
envelope = noteSpend(await res.json(), "codegen");
|
|
26968
27107
|
checkHardFailure(envelope, "pilot.codegen", target.path);
|
|
26969
27108
|
throwOnTerminalRefusal(envelope, target.path);
|
|
26970
|
-
const
|
|
26971
|
-
if (
|
|
26972
|
-
throw codegenRefusedError(target.path,
|
|
27109
|
+
const whole4 = unwrapExecute(envelope, "pilot.codegen");
|
|
27110
|
+
if (whole4.outcome !== "GENERATED" || typeof whole4.newContent !== "string") {
|
|
27111
|
+
throw codegenRefusedError(target.path, whole4);
|
|
26973
27112
|
}
|
|
26974
|
-
newContent =
|
|
27113
|
+
newContent = whole4.newContent;
|
|
26975
27114
|
} catch (error) {
|
|
26976
27115
|
if (error instanceof RuntimeReplyError) {
|
|
26977
27116
|
throw new RuntimeReplyError(
|
|
@@ -35508,8 +35647,8 @@ function readFileText(fs, path) {
|
|
|
35508
35647
|
function clampNotesRecord(n) {
|
|
35509
35648
|
if (typeof n !== "object" || n === null) return void 0;
|
|
35510
35649
|
const { chars, stubbed, guidance } = n;
|
|
35511
|
-
const
|
|
35512
|
-
return { chars:
|
|
35650
|
+
const whole4 = (v, max) => typeof v === "number" && Number.isInteger(v) && v >= 0 ? Math.min(v, max) : 0;
|
|
35651
|
+
return { chars: whole4(chars, NOTES_KEPT_CHARS), stubbed: whole4(stubbed, 1e5), guidance: whole4(guidance, GUIDANCE_PER_RUN) };
|
|
35513
35652
|
}
|
|
35514
35653
|
|
|
35515
35654
|
// ../../../../quikit1926/node_modules/eslint-scope/lib/index.js
|
|
@@ -36924,9 +37063,9 @@ function placementWhy(find, k, added) {
|
|
|
36924
37063
|
if (!DECLARES_TEST.test(added)) return "not_a_test_or_import";
|
|
36925
37064
|
return bracketsBalance(added) ? null : "unbalanced_block";
|
|
36926
37065
|
}
|
|
36927
|
-
function isSubsequence(part,
|
|
37066
|
+
function isSubsequence(part, whole4) {
|
|
36928
37067
|
let i2 = 0;
|
|
36929
|
-
for (let j = 0; j <
|
|
37068
|
+
for (let j = 0; j < whole4.length && i2 < part.length; j++) if (whole4.charCodeAt(j) === part.charCodeAt(i2)) i2++;
|
|
36930
37069
|
return i2 === part.length;
|
|
36931
37070
|
}
|
|
36932
37071
|
function lostTextWhy(find, replace) {
|
|
@@ -39385,40 +39524,12 @@ var TargetingHttpError = class extends Error {
|
|
|
39385
39524
|
}
|
|
39386
39525
|
};
|
|
39387
39526
|
|
|
39388
|
-
// src/tokenEstimate.ts
|
|
39389
|
-
var TOKENS_PER_ALPHA_CHAR = 0.3;
|
|
39390
|
-
var TOKENS_PER_DIGIT_CHAR = 0.18;
|
|
39391
|
-
var TOKENS_PER_SPACE_CHAR = 0.05;
|
|
39392
|
-
var TOKENS_PER_PUNCTUATION_CHAR = 1.05;
|
|
39393
|
-
var TOKENS_PER_NON_ASCII_CHAR = 1;
|
|
39394
|
-
var PROMPT_OVERHEAD_TOKENS = 5e3;
|
|
39395
|
-
function estimateTokens(text) {
|
|
39396
|
-
let alpha = 0;
|
|
39397
|
-
let digit = 0;
|
|
39398
|
-
let space = 0;
|
|
39399
|
-
let punct = 0;
|
|
39400
|
-
let nonAscii = 0;
|
|
39401
|
-
for (const ch of text) {
|
|
39402
|
-
const code = ch.codePointAt(0);
|
|
39403
|
-
if (code >= 128) nonAscii++;
|
|
39404
|
-
else if (code >= 65 && code <= 90 || code >= 97 && code <= 122) alpha++;
|
|
39405
|
-
else if (code >= 48 && code <= 57) digit++;
|
|
39406
|
-
else if (code === 32 || code === 9 || code === 13 || code === 10) space++;
|
|
39407
|
-
else punct++;
|
|
39408
|
-
}
|
|
39409
|
-
return Math.ceil(
|
|
39410
|
-
alpha * TOKENS_PER_ALPHA_CHAR + digit * TOKENS_PER_DIGIT_CHAR + space * TOKENS_PER_SPACE_CHAR + punct * TOKENS_PER_PUNCTUATION_CHAR + nonAscii * TOKENS_PER_NON_ASCII_CHAR
|
|
39411
|
-
);
|
|
39412
|
-
}
|
|
39413
|
-
function estimateRequestTokens(contextData) {
|
|
39414
|
-
return PROMPT_OVERHEAD_TOKENS + estimateTokens(JSON.stringify(contextData ?? {}, null, 2));
|
|
39415
|
-
}
|
|
39416
|
-
|
|
39417
39527
|
// src/turnTimeout.ts
|
|
39418
39528
|
var FIRST_TURN_TIMEOUT_MS = 42e4;
|
|
39419
|
-
|
|
39529
|
+
var INVESTIGATE_FIRST_TURN_TIMEOUT_MS = 15e4;
|
|
39530
|
+
function turnTimeoutFor(turn, perTurnMs, setByCaller, firstTurnMs = FIRST_TURN_TIMEOUT_MS) {
|
|
39420
39531
|
if (setByCaller || turn > 1) return perTurnMs;
|
|
39421
|
-
return Math.max(perTurnMs,
|
|
39532
|
+
return Math.max(perTurnMs, firstTurnMs);
|
|
39422
39533
|
}
|
|
39423
39534
|
|
|
39424
39535
|
// src/targetingLoop.ts
|
|
@@ -39508,6 +39619,7 @@ async function runTargetingLoop(args, deps) {
|
|
|
39508
39619
|
const refusedTurns = [];
|
|
39509
39620
|
let refusedStreak = 0;
|
|
39510
39621
|
let peakRequestTokens = 0;
|
|
39622
|
+
const usage = new TurnUsage();
|
|
39511
39623
|
let turns = 0;
|
|
39512
39624
|
let noProgressStreak = 0;
|
|
39513
39625
|
let forced = null;
|
|
@@ -39543,7 +39655,9 @@ async function runTargetingLoop(args, deps) {
|
|
|
39543
39655
|
...refusedTurns.length > 0 ? { refusedTurns: refusedTurns.map((t) => ({ turn: t.turn, rules: [...t.rules] })) } : {},
|
|
39544
39656
|
...peakRequestTokens > 0 ? { peakRequestTokens } : {},
|
|
39545
39657
|
...args.tools2 ? { contractVersion: args.contractVersion ?? TOOLS2_LOOP_CONTRACT_VERSION } : {},
|
|
39546
|
-
...notesOn ? { notes: { chars: notes.length, stubbed, guidance: env2.guidance?.shown() ?? 0 } } : {}
|
|
39658
|
+
...notesOn ? { notes: { chars: notes.length, stubbed, guidance: env2.guidance?.shown() ?? 0 } } : {},
|
|
39659
|
+
...usage.totals.calls > 0 ? { turnUsage: usage.rows.map((r) => ({ ...r, parts: { ...r.parts } })), usage: { ...usage.totals } } : {},
|
|
39660
|
+
...usage.rowsCut ? { turnUsageCut: true } : {}
|
|
39547
39661
|
});
|
|
39548
39662
|
log({ event: "targeting.loop_start", mode: "loop", maxTurns: limits.maxTurns, maxToolCalls: limits.maxToolCalls, listingFiles: args.listing.length });
|
|
39549
39663
|
try {
|
|
@@ -39567,6 +39681,7 @@ async function runTargetingLoop(args, deps) {
|
|
|
39567
39681
|
} catch (err) {
|
|
39568
39682
|
throw classifyTransport(err);
|
|
39569
39683
|
}
|
|
39684
|
+
usage.record(turn, contextData, requestTokens, envelope, now() - turnStarted);
|
|
39570
39685
|
const code = envelope?.errorCode;
|
|
39571
39686
|
try {
|
|
39572
39687
|
checkHardFailure(envelope, "pilot.targeting");
|
|
@@ -39854,6 +39969,7 @@ async function runCodegenLoop(args, deps) {
|
|
|
39854
39969
|
const notesOn = harness && args.tools2?.notes === true;
|
|
39855
39970
|
const contractVersion = harness ? args.tools2 ? notesOn ? CODEGEN_LOOP_6_CONTRACT_VERSION : CODEGEN_LOOP_5_CONTRACT_VERSION : args.readRoots ? CODEGEN_LOOP_4_CONTRACT_VERSION : CODEGEN_LOOP_3_CONTRACT_VERSION : tests ? CODEGEN_LOOP_2_CONTRACT_VERSION : CODEGEN_LOOP_CONTRACT_VERSION;
|
|
39856
39971
|
let peakRequestTokens = 0;
|
|
39972
|
+
const usage = new TurnUsage();
|
|
39857
39973
|
let notes = "";
|
|
39858
39974
|
let stubbed = 0;
|
|
39859
39975
|
const turnOfId = /* @__PURE__ */ new Map();
|
|
@@ -39961,7 +40077,9 @@ async function runCodegenLoop(args, deps) {
|
|
|
39961
40077
|
...refusedTurns.length > 0 ? { refusedTurns: refusedTurns.map((t) => ({ turn: t.turn, rules: [...t.rules] })) } : {},
|
|
39962
40078
|
reasoning: [...reasoning],
|
|
39963
40079
|
...args.repoView ? { repoView: args.repoView, peakRequestTokens } : {},
|
|
39964
|
-
...notesOn ? { notes: { chars: notes.length, stubbed, guidance: env2.guidance?.shown() ?? 0 } } : {}
|
|
40080
|
+
...notesOn ? { notes: { chars: notes.length, stubbed, guidance: env2.guidance?.shown() ?? 0 } } : {},
|
|
40081
|
+
...usage.totals.calls > 0 ? { turnUsage: usage.rows.map((r) => ({ ...r, parts: { ...r.parts } })), usage: { ...usage.totals } } : {},
|
|
40082
|
+
...usage.rowsCut ? { turnUsageCut: true } : {}
|
|
39965
40083
|
});
|
|
39966
40084
|
const makeRoom = (nextTurn, nextFinal, finalReason) => {
|
|
39967
40085
|
const under = (limit) => estimateRequestTokens(buildContext(nextTurn, nextFinal, finalReason)) <= limit;
|
|
@@ -40059,6 +40177,7 @@ async function runCodegenLoop(args, deps) {
|
|
|
40059
40177
|
} catch (err) {
|
|
40060
40178
|
throw classifyTransport2(err);
|
|
40061
40179
|
}
|
|
40180
|
+
usage.record(turn, contextData, requestTokens, envelope, now() - turnStarted);
|
|
40062
40181
|
const code = envelope?.errorCode;
|
|
40063
40182
|
try {
|
|
40064
40183
|
checkHardFailure(envelope, "pilot.codegen");
|
|
@@ -40496,8 +40615,11 @@ function mergePhaseSummaries(parts, phases) {
|
|
|
40496
40615
|
for (const [k, v] of Object.entries(summary.statusCounts)) statusCounts[k] = (statusCounts[k] ?? 0) + v;
|
|
40497
40616
|
}
|
|
40498
40617
|
let n = 0;
|
|
40499
|
-
const testRuns = parts.flatMap(({ phase, summary }) => (summary.testRuns ?? []).map((
|
|
40618
|
+
const testRuns = parts.flatMap(({ phase, summary }) => (summary.testRuns ?? []).map((t2) => ({ ...t2, n: ++n, phase })));
|
|
40500
40619
|
const refusedTurns = parts.flatMap(({ summary }) => summary.refusedTurns ?? []);
|
|
40620
|
+
let t = 0;
|
|
40621
|
+
const turnUsage = parts.flatMap(({ summary }) => (summary.turnUsage ?? []).map((r) => ({ ...r, turn: ++t })));
|
|
40622
|
+
const turnUsageCut = parts.some(({ summary }) => summary.turnUsageCut) || turnUsage.length > MAX_TURN_ROWS;
|
|
40501
40623
|
return {
|
|
40502
40624
|
...last,
|
|
40503
40625
|
turns: parts.reduce((s, p) => s + p.summary.turns, 0),
|
|
@@ -40511,7 +40633,9 @@ function mergePhaseSummaries(parts, phases) {
|
|
|
40511
40633
|
...testRuns.length > 0 ? { testRuns } : {},
|
|
40512
40634
|
...refusedTurns.length > 0 ? { refusedTurns } : {},
|
|
40513
40635
|
reasoning: parts.flatMap((p) => p.summary.reasoning),
|
|
40514
|
-
phases
|
|
40636
|
+
phases,
|
|
40637
|
+
...turnUsage.length > 0 ? { turnUsage: turnUsage.slice(0, MAX_TURN_ROWS) } : {},
|
|
40638
|
+
...turnUsageCut ? { turnUsageCut: true } : {}
|
|
40515
40639
|
};
|
|
40516
40640
|
}
|
|
40517
40641
|
|
|
@@ -40519,19 +40643,23 @@ function mergePhaseSummaries(parts, phases) {
|
|
|
40519
40643
|
var MAX_ROOTS = 8;
|
|
40520
40644
|
var MAX_ROOT_CHARS = 300;
|
|
40521
40645
|
var MAX_REASON_CHARS2 = 40;
|
|
40522
|
-
var
|
|
40646
|
+
var whole2 = (n) => typeof n === "number" && Number.isFinite(n) && n >= 0 ? Math.floor(n) : 0;
|
|
40523
40647
|
function repoViewOf(scope) {
|
|
40524
|
-
if (!scope
|
|
40525
|
-
|
|
40648
|
+
if (!scope) return void 0;
|
|
40649
|
+
if (scope.view !== "map") {
|
|
40650
|
+
return { view: "listing", writeRoot: scope.writeRoot, fileCount: scope.writeListing.length, readRoots: [scope.writeRoot] };
|
|
40651
|
+
}
|
|
40652
|
+
return { view: "map", writeRoot: scope.writeRoot, fileCount: scope.readListing.length, readRoots: [...scope.readRoots], mapTokens: scope.mapTokens ?? 0 };
|
|
40526
40653
|
}
|
|
40527
40654
|
function clampRepoView(facts, peakRequestTokens) {
|
|
40528
40655
|
if (!facts) return {};
|
|
40529
40656
|
return {
|
|
40530
|
-
view: "map",
|
|
40531
|
-
|
|
40657
|
+
view: facts.view === "map" ? "map" : "listing",
|
|
40658
|
+
...facts.writeRoot.length <= MAX_ROOT_CHARS ? { writeRoot: facts.writeRoot } : {},
|
|
40659
|
+
fileCount: whole2(facts.fileCount),
|
|
40532
40660
|
readRoots: facts.readRoots.filter((r) => r.length <= MAX_ROOT_CHARS).slice(0, MAX_ROOTS),
|
|
40533
|
-
mapTokens:
|
|
40534
|
-
...peakRequestTokens && peakRequestTokens > 0 ? { peakRequestTokens:
|
|
40661
|
+
...facts.view === "map" ? { mapTokens: whole2(facts.mapTokens) } : {},
|
|
40662
|
+
...peakRequestTokens && peakRequestTokens > 0 ? { peakRequestTokens: whole2(peakRequestTokens) } : {},
|
|
40535
40663
|
...facts.failReason ? { failReason: facts.failReason.slice(0, MAX_REASON_CHARS2) } : {}
|
|
40536
40664
|
};
|
|
40537
40665
|
}
|
|
@@ -40567,11 +40695,11 @@ function gateOf(g) {
|
|
|
40567
40695
|
alreadyFailing: gateCount(x.alreadyFailing)
|
|
40568
40696
|
};
|
|
40569
40697
|
}
|
|
40570
|
-
function
|
|
40698
|
+
function whole3(n) {
|
|
40571
40699
|
return typeof n === "number" && Number.isInteger(n) && n >= 0 ? n : 0;
|
|
40572
40700
|
}
|
|
40573
40701
|
function small(n) {
|
|
40574
|
-
return Math.min(MAX_ATTEMPT_COUNT,
|
|
40702
|
+
return Math.min(MAX_ATTEMPT_COUNT, whole3(n));
|
|
40575
40703
|
}
|
|
40576
40704
|
function pathOk(p) {
|
|
40577
40705
|
return typeof p === "string" && p.length > 0 && p.length <= MAX_RECORD_PATH_CHARS;
|
|
@@ -40597,14 +40725,14 @@ function buildCodegenLoopRecord(loop) {
|
|
|
40597
40725
|
path: r.path.trim(),
|
|
40598
40726
|
...Number.isInteger(r.startLine) ? { startLine: r.startLine } : {},
|
|
40599
40727
|
...Number.isInteger(r.endLine) ? { endLine: r.endLine } : {},
|
|
40600
|
-
chars:
|
|
40728
|
+
chars: whole3(r.chars),
|
|
40601
40729
|
...r.refused ? { refused: true } : {}
|
|
40602
40730
|
}));
|
|
40603
|
-
const edits = room(loop.edits).map((e) => ({ path: e.path, count:
|
|
40604
|
-
const created = room(loop.created).map((c) => ({ path: c.path, chars:
|
|
40731
|
+
const edits = room(loop.edits).map((e) => ({ path: e.path, count: whole3(e.count) }));
|
|
40732
|
+
const created = room(loop.created).map((c) => ({ path: c.path, chars: whole3(c.chars) }));
|
|
40605
40733
|
const statusCounts = {};
|
|
40606
40734
|
for (const [k, v] of Object.entries(loop.statusCounts).slice(0, MAX_STATUS_KEYS)) {
|
|
40607
|
-
if (k.length > 0 && k.length <= MAX_STATUS_KEY_CHARS) statusCounts[k] =
|
|
40735
|
+
if (k.length > 0 && k.length <= MAX_STATUS_KEY_CHARS) statusCounts[k] = whole3(v);
|
|
40608
40736
|
else cut = true;
|
|
40609
40737
|
}
|
|
40610
40738
|
if (Object.keys(loop.statusCounts).length > MAX_STATUS_KEYS) cut = true;
|
|
@@ -40617,7 +40745,7 @@ function buildCodegenLoopRecord(loop) {
|
|
|
40617
40745
|
const text = typeof r.text === "string" ? r.text.trim() : "";
|
|
40618
40746
|
if (text.length === 0) continue;
|
|
40619
40747
|
const over = text.length > MAX_RECORD_REASONING_CHARS;
|
|
40620
|
-
reasoning.push({ turn:
|
|
40748
|
+
reasoning.push({ turn: whole3(r.turn), text: over ? text.slice(0, MAX_RECORD_REASONING_CHARS) : text, ...over ? { truncated: true } : {} });
|
|
40621
40749
|
}
|
|
40622
40750
|
const testRuns = [];
|
|
40623
40751
|
for (const t of loop.testRuns ?? []) {
|
|
@@ -40626,16 +40754,16 @@ function buildCodegenLoopRecord(loop) {
|
|
|
40626
40754
|
break;
|
|
40627
40755
|
}
|
|
40628
40756
|
testRuns.push({
|
|
40629
|
-
n:
|
|
40757
|
+
n: whole3(t.n),
|
|
40630
40758
|
status: String(t.status).slice(0, MAX_STATUS_KEY_CHARS),
|
|
40631
40759
|
...t.reason ? { reason: String(t.reason).slice(0, MAX_STATUS_KEY_CHARS) } : {},
|
|
40632
|
-
passed:
|
|
40633
|
-
failed:
|
|
40634
|
-
regressions:
|
|
40635
|
-
newFailures:
|
|
40636
|
-
alreadyFailing:
|
|
40760
|
+
passed: whole3(t.passed),
|
|
40761
|
+
failed: whole3(t.failed),
|
|
40762
|
+
regressions: whole3(t.regressions),
|
|
40763
|
+
newFailures: whole3(t.newFailures),
|
|
40764
|
+
alreadyFailing: whole3(t.alreadyFailing),
|
|
40637
40765
|
timedOut: t.timedOut === true,
|
|
40638
|
-
seconds:
|
|
40766
|
+
seconds: whole3(t.seconds),
|
|
40639
40767
|
...t.scope === "file" ? { scope: "file" } : {},
|
|
40640
40768
|
...t.phase && PHASES.has(t.phase) ? { phase: t.phase } : {}
|
|
40641
40769
|
});
|
|
@@ -40652,7 +40780,7 @@ function buildCodegenLoopRecord(loop) {
|
|
|
40652
40780
|
outcome: ph.outcome.slice(0, MAX_STATUS_KEY_CHARS),
|
|
40653
40781
|
turns: small(ph.turns),
|
|
40654
40782
|
toolCalls: small(ph.toolCalls),
|
|
40655
|
-
...
|
|
40783
|
+
...whole3(ph.redUnproven) > 0 ? { redUnproven: small(ph.redUnproven) } : {}
|
|
40656
40784
|
});
|
|
40657
40785
|
}
|
|
40658
40786
|
const refused2 = clampRefusedTurns(loop.refusedTurns);
|
|
@@ -40683,15 +40811,15 @@ function buildCodegenLoopRecord(loop) {
|
|
|
40683
40811
|
const healIn = loop.heal;
|
|
40684
40812
|
const healed = healIn && typeof healIn.stop === "string" && HEAL_STOPS.has(healIn.stop) ? {
|
|
40685
40813
|
stop: healIn.stop,
|
|
40686
|
-
allowed: Math.min(3,
|
|
40687
|
-
made: Math.min(3,
|
|
40814
|
+
allowed: Math.min(3, whole3(healIn.allowed)),
|
|
40815
|
+
made: Math.min(3, whole3(healIn.made)),
|
|
40688
40816
|
...gateOf(healIn.startedFrom) ? { startedFrom: gateOf(healIn.startedFrom) } : {},
|
|
40689
40817
|
...typeof healIn.failureReason === "string" && healIn.failureReason.length > 0 ? { failureReason: healIn.failureReason.slice(0, MAX_STATUS_KEY_CHARS) } : {}
|
|
40690
40818
|
} : void 0;
|
|
40691
40819
|
return {
|
|
40692
|
-
turns:
|
|
40693
|
-
toolCalls:
|
|
40694
|
-
refused:
|
|
40820
|
+
turns: whole3(loop.turns),
|
|
40821
|
+
toolCalls: whole3(loop.toolCalls),
|
|
40822
|
+
refused: whole3(loop.refused),
|
|
40695
40823
|
stopReason: loop.stopReason,
|
|
40696
40824
|
...loop.fellBack ? { fellBack: true } : {},
|
|
40697
40825
|
...loop.fallbackReason ? { fallbackReason: String(loop.fallbackReason).slice(0, MAX_RECORD_FALLBACK_REASON_CHARS) } : {},
|
|
@@ -40699,10 +40827,13 @@ function buildCodegenLoopRecord(loop) {
|
|
|
40699
40827
|
edits,
|
|
40700
40828
|
created,
|
|
40701
40829
|
statusCounts,
|
|
40702
|
-
...
|
|
40830
|
+
...whole3(loop.syntaxWarnings) > 0 ? { syntaxWarnings: whole3(loop.syntaxWarnings) } : {},
|
|
40703
40831
|
...typeof loop.contractVersion === "string" && loop.contractVersion.length > 0 ? { contractVersion: loop.contractVersion.slice(0, 40) } : {},
|
|
40704
40832
|
...clampNotesRecord(loop.notes) ? { notes: clampNotesRecord(loop.notes) } : {},
|
|
40705
40833
|
...clampRepoView(loop.repoView, loop.peakRequestTokens),
|
|
40834
|
+
...clampTurnRows(loop.turnUsage) ? { turnUsage: clampTurnRows(loop.turnUsage) } : {},
|
|
40835
|
+
...loop.turnUsageCut ? { turnUsageCut: true } : {},
|
|
40836
|
+
...clampTotals(loop.usage) ? { usage: clampTotals(loop.usage) } : {},
|
|
40706
40837
|
...testRuns.length > 0 ? { testRuns } : {},
|
|
40707
40838
|
...refused2.rows.length > 0 ? { refusedTurns: refused2.rows } : {},
|
|
40708
40839
|
...attempts.length > 0 ? { attempts } : {},
|
|
@@ -40933,7 +41064,7 @@ async function postCodegenTurn(gateway, contextData, signal) {
|
|
|
40933
41064
|
...signal ? { signal } : {}
|
|
40934
41065
|
});
|
|
40935
41066
|
if (!res.ok) throw new TargetingHttpError(res.status, res.statusText);
|
|
40936
|
-
return res.json();
|
|
41067
|
+
return noteSpend(await res.json(), "codegen");
|
|
40937
41068
|
}
|
|
40938
41069
|
function protectedTestFiles(listing, testDiscovery) {
|
|
40939
41070
|
const inListing2 = new Set(listing);
|
|
@@ -41011,7 +41142,9 @@ function buildCodegenLoopArgs(p, context = collectLoopContext({
|
|
|
41011
41142
|
targets: p.targets,
|
|
41012
41143
|
requiredAutomationIds: requiredTests.map((tc) => tc.automationId),
|
|
41013
41144
|
listing: p.workspaceListing,
|
|
41014
|
-
...map ? { readRoots: map.readRoots, readListing: map.readListing
|
|
41145
|
+
...map ? { readRoots: map.readRoots, readListing: map.readListing } : {},
|
|
41146
|
+
// QUIKTR-1582: how the run saw the repository, in both views (the record says which folder it could change).
|
|
41147
|
+
...p.scope ? { repoView: repoViewOf(p.scope) } : {},
|
|
41015
41148
|
deniedPaths: p.deniedPaths,
|
|
41016
41149
|
protectedTestPaths,
|
|
41017
41150
|
...discoveredTests ? { discoveredTests } : {},
|
|
@@ -43046,7 +43179,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
|
|
|
43046
43179
|
var REPORT_COPY = "final-test-report.xml";
|
|
43047
43180
|
var MAX_REPORT_BYTES = 5 * 1024 * 1024;
|
|
43048
43181
|
var MAX_FILES = 200;
|
|
43049
|
-
var RUNNER_VERSION = true ? "9.3.0-rc.
|
|
43182
|
+
var RUNNER_VERSION = true ? "9.3.0-rc.36" : "dev";
|
|
43050
43183
|
function safeDestination(base, repoPath) {
|
|
43051
43184
|
if (!repoPath || (0, import_node_path21.isAbsolute)(repoPath)) return null;
|
|
43052
43185
|
const destination = (0, import_node_path21.resolve)(base, repoPath);
|
|
@@ -43303,7 +43436,7 @@ async function postTargeting(gateway, contextData, signal) {
|
|
|
43303
43436
|
if (!res.ok) {
|
|
43304
43437
|
throw new TargetingHttpError(res.status, res.statusText);
|
|
43305
43438
|
}
|
|
43306
|
-
return res.json();
|
|
43439
|
+
return noteSpend(await res.json(), "targeting");
|
|
43307
43440
|
}
|
|
43308
43441
|
function finalizeTargeting(body, workspaceRoot, workspaceListing, deniedPaths) {
|
|
43309
43442
|
if (body.outcome === "NO_TARGET") {
|
|
@@ -43386,6 +43519,7 @@ async function runTargeting(gateway, design, workspaceRoot, workspaceListing, re
|
|
|
43386
43519
|
return runSingleShot(gateway, design, workspaceRoot, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings);
|
|
43387
43520
|
}
|
|
43388
43521
|
const baseContext = buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings);
|
|
43522
|
+
const listingView = repoViewOf(options.scope);
|
|
43389
43523
|
let summary;
|
|
43390
43524
|
let runtimeCode;
|
|
43391
43525
|
let reason;
|
|
@@ -43397,7 +43531,7 @@ async function runTargeting(gateway, design, workspaceRoot, workspaceListing, re
|
|
|
43397
43531
|
);
|
|
43398
43532
|
summary = looped.summary;
|
|
43399
43533
|
const result = finalizeTargeting(looped.body, workspaceRoot, workspaceListing, deniedPaths);
|
|
43400
|
-
return { ...result, loop: summary };
|
|
43534
|
+
return { ...result, loop: { ...summary, ...listingView ? { repoView: listingView } : {} } };
|
|
43401
43535
|
} catch (err) {
|
|
43402
43536
|
if (err instanceof DeniedPathError || err instanceof SafetyRefusalError) throw err;
|
|
43403
43537
|
if (err instanceof LoopFailure) {
|
|
@@ -43416,7 +43550,12 @@ async function runTargeting(gateway, design, workspaceRoot, workspaceListing, re
|
|
|
43416
43550
|
reads: summary?.reads ?? [],
|
|
43417
43551
|
stopReason: "fallback",
|
|
43418
43552
|
fellBack: true,
|
|
43419
|
-
fallbackReason: reason
|
|
43553
|
+
fallbackReason: reason,
|
|
43554
|
+
// QUIKTR-1582: what the loop cost and saw before it gave up is kept, so the card still shows it.
|
|
43555
|
+
...summary?.peakRequestTokens ? { peakRequestTokens: summary.peakRequestTokens } : {},
|
|
43556
|
+
...summary?.turnUsage ? { turnUsage: summary.turnUsage } : {},
|
|
43557
|
+
...summary?.turnUsageCut ? { turnUsageCut: true } : {},
|
|
43558
|
+
...listingView ? { repoView: listingView } : {}
|
|
43420
43559
|
};
|
|
43421
43560
|
const log = options.loopDeps?.log ?? ((e) => console.log(JSON.stringify(e)));
|
|
43422
43561
|
log({
|
|
@@ -43536,6 +43675,9 @@ function clampLoop(loop) {
|
|
|
43536
43675
|
...typeof loop.contractVersion === "string" && loop.contractVersion.length > 0 ? { contractVersion: loop.contractVersion.slice(0, 40) } : {},
|
|
43537
43676
|
...clampNotesRecord(loop.notes) ? { notes: clampNotesRecord(loop.notes) } : {},
|
|
43538
43677
|
...clampRepoView(loop.repoView, loop.peakRequestTokens),
|
|
43678
|
+
...clampTurnRows(loop.turnUsage) ? { turnUsage: clampTurnRows(loop.turnUsage) } : {},
|
|
43679
|
+
...loop.turnUsageCut ? { turnUsageCut: true } : {},
|
|
43680
|
+
...clampTotals(loop.usage) ? { usage: clampTotals(loop.usage) } : {},
|
|
43539
43681
|
reads,
|
|
43540
43682
|
...refusedTurns.rows.length > 0 ? { refusedTurns: refusedTurns.rows } : {},
|
|
43541
43683
|
...cut ? { truncated: true } : {}
|
|
@@ -43742,7 +43884,11 @@ async function run(env2) {
|
|
|
43742
43884
|
packet.guardrails.deniedPaths,
|
|
43743
43885
|
discovery.result.value,
|
|
43744
43886
|
outOfScope,
|
|
43745
|
-
|
|
43887
|
+
// QUIKTR-1561 - the early look's findings, filtered to this checkout inside runTargeting. Passed ONLY when there are some, so a run
|
|
43888
|
+
// without a completed look calls it exactly as before.
|
|
43889
|
+
// QUIKTR-1580 - and the scope: in map mode it is how targeting sees the repository; since QUIKTR-1582 it is also handed over in listing
|
|
43890
|
+
// mode, only so the record can say which folder the run could change (listing-mode targeting reads nothing else from it).
|
|
43891
|
+
{ ...packet.findings ? { findings: packet.findings } : {}, scope, ...tools2 ? { tools2 } : {} }
|
|
43746
43892
|
);
|
|
43747
43893
|
targetingResult = targeting;
|
|
43748
43894
|
for (const w of targeting.warnings ?? []) {
|
|
@@ -43832,7 +43978,8 @@ async function run(env2) {
|
|
|
43832
43978
|
gateway: packet.gateway,
|
|
43833
43979
|
targets: targeting.targets,
|
|
43834
43980
|
workspaceListing,
|
|
43835
|
-
|
|
43981
|
+
// In both views (QUIKTR-1582): map mode reads the repository through it; listing mode only records the folder it could change.
|
|
43982
|
+
scope,
|
|
43836
43983
|
...tools2 ? { tools2 } : {},
|
|
43837
43984
|
...writeRoot ? { writeRoot } : {},
|
|
43838
43985
|
requiredTests: packet.requiredTests,
|
|
@@ -44029,6 +44176,11 @@ async function run(env2) {
|
|
|
44029
44176
|
console.warn(`::warning::Could not keep the failed run's files: ${err instanceof Error ? err.message : String(err)}`);
|
|
44030
44177
|
}
|
|
44031
44178
|
}
|
|
44179
|
+
const targetingRecord = targetingResult ? buildTargetingRecord(targetingResult, contextLog) : void 0;
|
|
44180
|
+
const targetingUsage = clampTotals(spendOf("targeting"));
|
|
44181
|
+
if (targetingRecord?.loop && targetingUsage) targetingRecord.loop = { ...targetingRecord.loop, usage: targetingUsage };
|
|
44182
|
+
const codegenUsage = clampTotals(spendOf("codegen"));
|
|
44183
|
+
const codegenRecord = codegenOut.loop && codegenUsage ? { ...codegenOut.loop, usage: codegenUsage } : codegenOut.loop;
|
|
44032
44184
|
await reportBack({
|
|
44033
44185
|
callbackUrl: env2.callbackUrl,
|
|
44034
44186
|
runToken,
|
|
@@ -44036,14 +44188,15 @@ async function run(env2) {
|
|
|
44036
44188
|
branch,
|
|
44037
44189
|
warnings,
|
|
44038
44190
|
// Omitted when targeting itself never produced a result (nothing exists to record).
|
|
44039
|
-
targeting:
|
|
44191
|
+
targeting: targetingRecord,
|
|
44040
44192
|
baselineFindings,
|
|
44041
44193
|
vanishedTests,
|
|
44042
44194
|
unsuppliedInputs,
|
|
44043
44195
|
changesNoTestDependsOn,
|
|
44044
44196
|
testsCorrected,
|
|
44045
|
-
codegenLoop:
|
|
44046
|
-
unresolved: failureReasons.length > 0 ? failureReasons : void 0
|
|
44197
|
+
codegenLoop: codegenRecord,
|
|
44198
|
+
unresolved: failureReasons.length > 0 ? failureReasons : void 0,
|
|
44199
|
+
aiCostUsd: spendSoFar().costUsd
|
|
44047
44200
|
});
|
|
44048
44201
|
return { hardFailure };
|
|
44049
44202
|
}
|
|
@@ -44344,7 +44497,7 @@ async function runInvestigateLoop(args, deps) {
|
|
|
44344
44497
|
const now = deps.now ?? Date.now;
|
|
44345
44498
|
const log = deps.log ?? ((e) => console.log(JSON.stringify(e)));
|
|
44346
44499
|
const turnTimeoutMs = deps.turnTimeoutMs ?? 6e4;
|
|
44347
|
-
const deadlineMs = deps.deadlineMs ??
|
|
44500
|
+
const deadlineMs = deps.deadlineMs ?? 21e4;
|
|
44348
44501
|
const secrets = deps.secrets ?? [];
|
|
44349
44502
|
const env2 = {
|
|
44350
44503
|
listing: new Set(args.listing),
|
|
@@ -44407,7 +44560,10 @@ async function runInvestigateLoop(args, deps) {
|
|
|
44407
44560
|
const turnStarted = now();
|
|
44408
44561
|
let envelope;
|
|
44409
44562
|
try {
|
|
44410
|
-
envelope = await deps.post(
|
|
44563
|
+
envelope = await deps.post(
|
|
44564
|
+
contextData,
|
|
44565
|
+
AbortSignal.timeout(turnTimeoutFor(turn, turnTimeoutMs, deps.turnTimeoutMs !== void 0, INVESTIGATE_FIRST_TURN_TIMEOUT_MS))
|
|
44566
|
+
);
|
|
44411
44567
|
} catch (err) {
|
|
44412
44568
|
throw classifyTransport3(err);
|
|
44413
44569
|
}
|
|
@@ -44540,7 +44696,7 @@ async function postInvestigate(gateway, contextData, signal) {
|
|
|
44540
44696
|
signal
|
|
44541
44697
|
});
|
|
44542
44698
|
if (!res.ok) throw new TargetingHttpError(res.status, res.statusText);
|
|
44543
|
-
return res.json();
|
|
44699
|
+
return noteSpend(await res.json(), "investigate");
|
|
44544
44700
|
}
|
|
44545
44701
|
async function reportInvestigation(callbackUrl, runToken, body) {
|
|
44546
44702
|
const res = await fetch(callbackUrl, {
|