@promptdriven/runtime-client 1.1.1 → 1.1.3
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 +1 -1
- package/src/runtime/adaptive-concurrency.mjs +53 -0
- package/src/runtime/agent-guide.mjs +3 -0
- package/src/runtime/agent-judge.mjs +73 -2
- package/src/runtime/contract-refs.mjs +4 -0
- package/src/runtime/index.mjs +37 -0
- package/src/runtime/product-composition.mjs +6 -4
- package/src/runtime/prompt-clauses.mjs +290 -0
- package/src/runtime/run-program.mjs +13 -8
- package/src/runtime/runtime-binding-plan.mjs +116 -15
- package/src/runtime/runtime-bindings.mjs +11 -8
- package/src/runtime/runtime-check-plan.mjs +47 -17
- package/src/runtime/runtime-client.mjs +2033 -282
- package/src/runtime/runtime-markdown.mjs +95 -41
- package/src/runtime/runtime-outcome.mjs +156 -5
- package/src/runtime/runtime-output.mjs +115 -13
- package/src/runtime/runtime-preflight.mjs +1186 -41
- package/src/runtime/try-doors.mjs +105 -23
- package/src/runtime/try-http.mjs +232 -10
- package/src/runtime/try-mcp.mjs +15 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Generated from prompts/cli/runtime-output.prompt.md (sha256: 6e4117a1364be9328834407e8b6dd8feb5dbacee947193f1a32476c4bb894457).
|
|
2
2
|
import { bindingRefusals } from './runtime-binding-plan.mjs';
|
|
3
3
|
import { describeCompatibility } from './lint-compatibility-display.mjs';
|
|
4
|
+
import { indexClauseTable, validateStepClauses } from './prompt-clauses.mjs';
|
|
4
5
|
import { failedCheckCount, hasProgress, outcomeFor, outcomeText, progressText, providerText, resultOutcome, PROVIDER_TEXT } from './runtime-outcome.mjs';
|
|
5
6
|
export const OPEN_STATES = new Set(['queued', 'running', 'sent']);
|
|
6
7
|
|
|
@@ -160,9 +161,10 @@ function predecessorErrors(refusal, report, steps, secrets) {
|
|
|
160
161
|
}
|
|
161
162
|
|
|
162
163
|
// The parts of a server answer that pdd shows.
|
|
163
|
-
export function projectAnswer(answer, { origin, secrets = [], steps: authoredSteps = [], criterionTexts = {}, test, sourceFiles, capacityUncertain = false, sampleEvidence = 'full' } = {}) {
|
|
164
|
+
export function projectAnswer(answer, { origin, secrets = [], steps: authoredSteps = [], criterionTexts = {}, test, sourceFiles, capacityUncertain = false, sampleEvidence = 'full', clauseTable = null } = {}) {
|
|
164
165
|
const result = answer?.result ?? null, report = result?.report ?? null, time_limit = stepTimeLimit(answer, { steps: authoredSteps, secrets });
|
|
165
166
|
const outcome = outcomeFor(answer, { test, steps: authoredSteps, timeLimit: !!time_limit, sourceFiles, capacityUncertain, sampleEvidence });
|
|
167
|
+
const clauseIndex = indexClauseTable(clauseTable);
|
|
166
168
|
const safeEvidence = value => typeof value === 'string' ? cleanEvidenceString(value, secrets)
|
|
167
169
|
: Array.isArray(value) ? value.map(safeEvidence)
|
|
168
170
|
: isObjectLike(value) ? Object.fromEntries(Object.entries(value).map(([key, item]) => [cleanEvidenceString(key, secrets), safeEvidence(item)])) : value;
|
|
@@ -187,6 +189,16 @@ export function projectAnswer(answer, { origin, secrets = [], steps: authoredSte
|
|
|
187
189
|
: [...(compatibility.reported?.operations ?? []), ...(compatibility.reported?.edges ?? [])].find(row => row.verdict === compatibility.state)?.reason_code)) : null;
|
|
188
190
|
const sampleSteps = (Array.isArray(report?.samples) ? report.samples : [])
|
|
189
191
|
.flatMap(sample => (Array.isArray(sample?.steps) ? sample.steps : []).map((step, index) => ({ step, index })));
|
|
192
|
+
const flatSteps = !sampleSteps.length && Array.isArray(report?.steps) ? report.steps.filter(isObjectLike) : [];
|
|
193
|
+
const flatStepById = new Map(flatSteps.filter(step => typeof step.step_id === 'string' && step.step_id).map(step => [step.step_id, step]));
|
|
194
|
+
const stepClauseResults = new WeakMap();
|
|
195
|
+
let droppedClauseCount = 0;
|
|
196
|
+
for (const step of [...sampleSteps.map(entry => entry.step), ...flatSteps].filter(isObjectLike)) {
|
|
197
|
+
if (stepClauseResults.has(step)) continue;
|
|
198
|
+
const validated = validateStepClauses(step.clauses, clauseIndex);
|
|
199
|
+
stepClauseResults.set(step, validated);
|
|
200
|
+
droppedClauseCount += validated.dropped;
|
|
201
|
+
}
|
|
190
202
|
const nonNegativeInt = value => Number.isSafeInteger(value) && value >= 0 ? value : undefined;
|
|
191
203
|
const rerunStep = item => ({
|
|
192
204
|
step_id: cleanField(item.step_id, secrets) || null,
|
|
@@ -231,7 +243,40 @@ export function projectAnswer(answer, { origin, secrets = [], steps: authoredSte
|
|
|
231
243
|
const ref_target = typeof check?.ref_target === 'string' && check.ref_target ? cleanField(check.ref_target, secrets) : undefined;
|
|
232
244
|
const ref_path = typeof check?.ref_path === 'string' ? cleanField(check.ref_path, secrets) : undefined;
|
|
233
245
|
const ref_json_path = typeof check?.ref_json_path === 'string' ? cleanField(check.ref_json_path, secrets) : undefined;
|
|
246
|
+
const diff_summary = isObjectLike(check?.diff_summary) ? (() => {
|
|
247
|
+
const ds = check.diff_summary;
|
|
248
|
+
const expected_len = nonNegativeInt(ds.expected_len), actual_len = nonNegativeInt(ds.actual_len);
|
|
249
|
+
if (expected_len === undefined || actual_len === undefined) return undefined;
|
|
250
|
+
const out = { expected_len, actual_len };
|
|
251
|
+
if (ds.kind === 'array' || ds.kind === 'string') out.kind = ds.kind;
|
|
252
|
+
if (typeof ds.path === 'string' && ds.path) out.path = cleanField(ds.path, secrets);
|
|
253
|
+
const first_diff_index = nonNegativeInt(ds.first_diff_index);
|
|
254
|
+
const first_diff_offset = nonNegativeInt(ds.first_diff_offset);
|
|
255
|
+
if (first_diff_index !== undefined) {
|
|
256
|
+
out.first_diff_index = first_diff_index;
|
|
257
|
+
const window_start = nonNegativeInt(ds.window_start);
|
|
258
|
+
if (window_start !== undefined) out.window_start = window_start;
|
|
259
|
+
if (Array.isArray(ds.expected_window)) out.expected_window = cleanValues(ds.expected_window.slice(0, 32), secrets);
|
|
260
|
+
if (Array.isArray(ds.actual_window)) out.actual_window = cleanValues(ds.actual_window.slice(0, 32), secrets);
|
|
261
|
+
return out;
|
|
262
|
+
}
|
|
263
|
+
if (first_diff_offset !== undefined) {
|
|
264
|
+
out.first_diff_offset = first_diff_offset;
|
|
265
|
+
const excerpt_start = nonNegativeInt(ds.excerpt_start);
|
|
266
|
+
if (excerpt_start !== undefined) out.excerpt_start = excerpt_start;
|
|
267
|
+
if (typeof ds.expected_excerpt === 'string') out.expected_excerpt = cleanValues(ds.expected_excerpt.slice(0, 512), secrets);
|
|
268
|
+
if (typeof ds.actual_excerpt === 'string') out.actual_excerpt = cleanValues(ds.actual_excerpt.slice(0, 512), secrets);
|
|
269
|
+
return out;
|
|
270
|
+
}
|
|
271
|
+
return undefined;
|
|
272
|
+
})() : undefined;
|
|
234
273
|
const stepIndex = Number.isInteger(index) && index >= 0 ? index : Number.isInteger(check?.step_number) && check.step_number >= 1 ? check.step_number - 1 : undefined;
|
|
274
|
+
const effectiveStep = step ?? (typeof check?.step_id === 'string' ? flatStepById.get(check.step_id) : null) ?? null;
|
|
275
|
+
let stepClauses = effectiveStep && stepClauseResults.has(effectiveStep) ? stepClauseResults.get(effectiveStep) : { present: false, valid: [], dropped: 0 };
|
|
276
|
+
if (!stepClauses.present && Array.isArray(check?.clauses)) {
|
|
277
|
+
stepClauses = validateStepClauses(check.clauses, clauseIndex);
|
|
278
|
+
droppedClauseCount += stepClauses.dropped;
|
|
279
|
+
}
|
|
235
280
|
return { criterion_id,
|
|
236
281
|
step_id: cleanField(step?.step_id ?? check?.step_id, secrets) || (stepIndex !== undefined ? cleanField(authoredSteps[stepIndex]?.step_id, secrets) : '') || null,
|
|
237
282
|
criterion_text: typeof criterionTexts[criterion_id] === 'string' && criterionTexts[criterion_id].length <= 160 ? cleanField(criterionTexts[criterion_id], secrets) : null,
|
|
@@ -241,7 +286,10 @@ export function projectAnswer(answer, { origin, secrets = [], steps: authoredSte
|
|
|
241
286
|
...(ref_target !== undefined ? { op: cleanField(check?.op, secrets), ref_target, ...(ref_path !== undefined ? { ref_path } : {}), ...(ref_json_path !== undefined ? { ref_json_path } : {}) } : {}),
|
|
242
287
|
expected: cleanValues(check?.expected, secrets),
|
|
243
288
|
actual: cleanValues(check?.actual, secrets), passed: check?.passed === true,
|
|
244
|
-
normal_result: step ? Object.prototype.hasOwnProperty.call(step, 'result') && !step.error : false,
|
|
289
|
+
normal_result: step ? Object.prototype.hasOwnProperty.call(step, 'result') && !step.error : false,
|
|
290
|
+
...(stepClauses.present ? { clauses: stepClauses.valid } : {}),
|
|
291
|
+
...(diff_summary ? { diff_summary } : {}),
|
|
292
|
+
...(diagnosis ? { diagnosis } : {}) };
|
|
245
293
|
};
|
|
246
294
|
const primarySteps = Array.isArray(report?.samples?.[0]?.steps)
|
|
247
295
|
? report.samples[0].steps
|
|
@@ -325,6 +373,9 @@ export function projectAnswer(answer, { origin, secrets = [], steps: authoredSte
|
|
|
325
373
|
const busyRefusal = outcome.state === 'not_run' && outcome.retryable === true && answer?.command === 'check'
|
|
326
374
|
? rawRefusals.find(item => item?.retryable === true || item?.details?.retryable === true) : null;
|
|
327
375
|
const tokens = tokenUsageOf(answer, { incomplete });
|
|
376
|
+
const clause_warnings = droppedClauseCount > 0
|
|
377
|
+
? [`Warning: dropped ${droppedClauseCount} unknown clause ${droppedClauseCount === 1 ? 'citation' : 'citations'} from the interpreter.`]
|
|
378
|
+
: [];
|
|
328
379
|
return {
|
|
329
380
|
...(compatibility ? { compatibility, client_advice } : {}),
|
|
330
381
|
...(Object.hasOwn(outcome, 'field_agreement') ? { field_agreement: safeEvidence(outcome.field_agreement) } : {}),
|
|
@@ -337,6 +388,7 @@ export function projectAnswer(answer, { origin, secrets = [], steps: authoredSte
|
|
|
337
388
|
time_limit, checks,
|
|
338
389
|
criteria: results.length ? { passed: results.filter(item => item?.status === 'passed').length, total: results.length } : null,
|
|
339
390
|
all_checks: all, failed_checks, refusals,
|
|
391
|
+
...(droppedClauseCount > 0 ? { dropped_clause_citations: droppedClauseCount, clause_warnings } : {}),
|
|
340
392
|
...(step_details.length && sampleEvidence !== 'flat' && (outcome.state === 'failed' || failed_checks.length > 0 || primarySteps.some(step => typeof step?.verdict === 'string' || Array.isArray(step?.checks))) ? { step_details } : {}),
|
|
341
393
|
...(draft_interfaces.length ? { draft_interfaces } : {}),
|
|
342
394
|
calls: !incomplete ? usageCalls : 'unknown',
|
|
@@ -375,7 +427,14 @@ export function tokenUsageOf(answer, { incomplete = false } = {}) {
|
|
|
375
427
|
const topReport = isObjectLike(answer?.report) ? answer.report : null;
|
|
376
428
|
const surfaces = [answer, usage, result, report, topReport].filter(isObjectLike);
|
|
377
429
|
if (incomplete || surfaces.some(s => Object.hasOwn(s, 'accounting_complete') && s.accounting_complete !== true)) return unknownTokens();
|
|
378
|
-
|
|
430
|
+
const hasPreDispatch = surfaces.some(s => s.dispatch === 'pre-dispatch' || s.dispatch_state === 'pre-dispatch');
|
|
431
|
+
const hasCompleteZeroNotStarted = !hasPreDispatch
|
|
432
|
+
&& surfaces.some(s => s.dispatch === 'not_started')
|
|
433
|
+
&& surfaces.some(s => s.accounting_complete === true)
|
|
434
|
+
&& usage.calls === 0
|
|
435
|
+
&& (usage.unknown_calls === undefined || usage.unknown_calls === 0)
|
|
436
|
+
&& ['passed', 'failed', 'refused'].includes(answer?.state);
|
|
437
|
+
if (hasPreDispatch || (surfaces.some(s => s.dispatch === 'not_started') && !hasCompleteZeroNotStarted)) return unknownTokens();
|
|
379
438
|
if (['input_tokens', 'cached_input_tokens', 'output_tokens'].some(key => malformedToken(usage[key]))) return unknownTokens();
|
|
380
439
|
const uIn = tokenInt(usage.input_tokens), uCached = tokenInt(usage.cached_input_tokens), uOut = tokenInt(usage.output_tokens);
|
|
381
440
|
if (uIn !== undefined && uCached !== undefined && uCached > uIn) return unknownTokens();
|
|
@@ -432,7 +491,7 @@ export function tokenUsageOf(answer, { incomplete = false } = {}) {
|
|
|
432
491
|
muOut = tOut ?? (tIn === 0 && usage.calls === 0 ? 0 : undefined);
|
|
433
492
|
} else return unknownTokens();
|
|
434
493
|
} else if (['passed', 'failed', 'refused'].includes(answer?.state) && usage.calls === 0
|
|
435
|
-
&& uIn === undefined && uCached === undefined && uOut === undefined) {
|
|
494
|
+
&& (uIn === undefined || uIn === 0) && (uCached === undefined || uCached === 0) && (uOut === undefined || uOut === 0)) {
|
|
436
495
|
return { input_tokens: 0, cached_input_tokens: 0, output_tokens: 0, cached_input_share: null };
|
|
437
496
|
}
|
|
438
497
|
const input_tokens = muIn ?? uIn ?? 'unknown';
|
|
@@ -460,7 +519,11 @@ function criterionCoverage(row) {
|
|
|
460
519
|
|
|
461
520
|
export function jsonRow(row) {
|
|
462
521
|
const publicChecks = checks => (checks ?? []).map(({ normal_result, ...check }) => check);
|
|
463
|
-
const
|
|
522
|
+
const unsentZeroTokens = !sentRow(row)
|
|
523
|
+
&& row.input_tokens === undefined && row.cached_input_tokens === undefined && row.output_tokens === undefined
|
|
524
|
+
&& row.accounting_complete !== false && row.state !== 'unknown'
|
|
525
|
+
&& (row.calls === undefined || row.calls === 0);
|
|
526
|
+
const rowTokens = row.cached || unsentZeroTokens
|
|
464
527
|
? { input_tokens: 0, cached_input_tokens: 0, output_tokens: 0, cached_input_share: null }
|
|
465
528
|
: (() => {
|
|
466
529
|
const input_tokens = tokenInt(row.input_tokens) ?? 'unknown';
|
|
@@ -508,8 +571,15 @@ export function renderJson({ batch = null, repo, sourceSha256 = null, coverage,
|
|
|
508
571
|
summary_line: perStory.get(row.story) ?? null,
|
|
509
572
|
}));
|
|
510
573
|
const diagnostic = rows.filter(row=>row.diagnostic_subset === true);
|
|
574
|
+
const mergedWarnings = [...warnings];
|
|
575
|
+
for (const row of rows) {
|
|
576
|
+
for (const text of row.clause_warnings ?? []) {
|
|
577
|
+
const prefixed = row.test ? `${row.test}: ${text}` : text;
|
|
578
|
+
if (!mergedWarnings.includes(text) && !mergedWarnings.includes(prefixed)) mergedWarnings.push(prefixed);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
511
581
|
return { batch, repo, ...(diagnostic.length ? {diagnostic_subset:true,selected_steps:[...new Set(diagnostic.flatMap(row=>row.selected_steps ?? []))]} : {}), ...(coverage ? { coverage } : {}), source_sha256: sourceSha256, exit_code: exitCode, summary_line: line, draft: rows.some(row => row.draft),
|
|
512
|
-
token_usage: batchTokenUsage(publicRows), rows: publicRows, warnings };
|
|
582
|
+
token_usage: batchTokenUsage(publicRows), rows: publicRows, warnings: mergedWarnings };
|
|
513
583
|
}
|
|
514
584
|
|
|
515
585
|
const count = (number, word) => `${number} ${word}${number === 1 ? '' : 's'}`;
|
|
@@ -644,6 +714,31 @@ function stepContextLines(step, secrets, { indent = ' ', includeVerdict = false
|
|
|
644
714
|
return [`${indent}Step ${label}${verdict}:`, ...body];
|
|
645
715
|
}
|
|
646
716
|
|
|
717
|
+
function diffSummaryLines(summary, secrets) {
|
|
718
|
+
if (!isObjectLike(summary)) return [];
|
|
719
|
+
const expLen = summary.expected_len, actLen = summary.actual_len;
|
|
720
|
+
if (!Number.isSafeInteger(expLen) || !Number.isSafeInteger(actLen) || expLen < 0 || actLen < 0) return [];
|
|
721
|
+
const at = typeof summary.path === 'string' && summary.path ? ` at ${cleanField(summary.path, secrets)}` : '';
|
|
722
|
+
if (Number.isSafeInteger(summary.first_diff_index) && summary.first_diff_index >= 0) {
|
|
723
|
+
const lines = [` Diff${at}: array len expected ${expLen}, got ${actLen}; first difference at index ${summary.first_diff_index}`];
|
|
724
|
+
if (Array.isArray(summary.expected_window) && Array.isArray(summary.actual_window)) {
|
|
725
|
+
const start = Number.isSafeInteger(summary.window_start) && summary.window_start >= 0 ? summary.window_start : null;
|
|
726
|
+
const maxWin = Math.max(summary.expected_window.length, summary.actual_window.length);
|
|
727
|
+
const span = start !== null && maxWin > 0 ? ` [${start}..${start + maxWin - 1}]` : '';
|
|
728
|
+
lines.push(` Expected${span}: ${shown(summary.expected_window, secrets)}`);
|
|
729
|
+
lines.push(` Got${span}: ${shown(summary.actual_window, secrets)}`);
|
|
730
|
+
}
|
|
731
|
+
return lines;
|
|
732
|
+
}
|
|
733
|
+
if (Number.isSafeInteger(summary.first_diff_offset) && summary.first_diff_offset >= 0) {
|
|
734
|
+
const lines = [` Diff${at}: string len expected ${expLen}, got ${actLen}; first difference at offset ${summary.first_diff_offset}`];
|
|
735
|
+
if (typeof summary.expected_excerpt === 'string') lines.push(` Expected excerpt: ${shown(summary.expected_excerpt, secrets)}`);
|
|
736
|
+
if (typeof summary.actual_excerpt === 'string') lines.push(` Got excerpt: ${shown(summary.actual_excerpt, secrets)}`);
|
|
737
|
+
return lines;
|
|
738
|
+
}
|
|
739
|
+
return [];
|
|
740
|
+
}
|
|
741
|
+
|
|
647
742
|
// The check line: one line when both values fit, else the check and a block for each value, never cut inside a line.
|
|
648
743
|
function checkLines(check, secrets) {
|
|
649
744
|
const jsonPath = typeof check.json_path === 'string' ? ` (${check.json_path || '/'})` : '';
|
|
@@ -654,10 +749,15 @@ function checkLines(check, secrets) {
|
|
|
654
749
|
&& (check.normal_result === true || ['no-error', 'needs-tool'].includes(check.diagnosis?.kind));
|
|
655
750
|
const actualValue = noError ? 'no error (a normal result)' : check.actual, actualDisplay = noError ? actualValue : shown(actualValue, secrets);
|
|
656
751
|
const criterion = check.criterion_text ? [` Criterion: ${plainLine(check.criterion_text, secrets)}`] : [];
|
|
752
|
+
const clauseLines = !check.passed && Array.isArray(check.clauses)
|
|
753
|
+
? check.clauses.filter(clause => isObjectLike(clause) && typeof clause.path === 'string' && Number.isSafeInteger(clause.line) && typeof clause.text === 'string')
|
|
754
|
+
.map(clause => ` Prompt (cited by the interpreter): ${cleanField(clause.path, secrets)}:${clause.line} ${plainLine(clause.text, secrets)}`)
|
|
755
|
+
: [];
|
|
756
|
+
const diffLines = diffSummaryLines(check.diff_summary, secrets);
|
|
657
757
|
const refLabel = check.ref_target && check.ref_path !== undefined
|
|
658
758
|
? `${check.op ? `${check.op} ` : ''}${check.ref_target} ${check.ref_path || '/'}${check.ref_json_path ? ` (${check.ref_json_path})` : ''}` : null;
|
|
659
759
|
const fits = [check.expected, check.actual].every(value => oneLine(value) && shown(value, secrets).length <= 80);
|
|
660
|
-
if (fits) return [`${head} expected ${refLabel ? `${refLabel} (${shown(check.expected, secrets)})` : shown(check.expected, secrets)}, got ${actualDisplay}`, ...criterion];
|
|
760
|
+
if (fits) return [`${head} expected ${refLabel ? `${refLabel} (${shown(check.expected, secrets)})` : shown(check.expected, secrets)}, got ${actualDisplay}`, ...criterion, ...clauseLines, ...diffLines];
|
|
661
761
|
const expected = valueLines(check.expected), actual = valueLines(actualValue);
|
|
662
762
|
// Start 2 lines before the first line where two strings differ, when it is past the first 20.
|
|
663
763
|
const differ = typeof check.expected === 'string' && typeof check.actual === 'string' ? expected.findIndex((text, index) => text !== actual[index]) : -1;
|
|
@@ -666,7 +766,7 @@ function checkLines(check, secrets) {
|
|
|
666
766
|
...lines.slice(from, from + VALUE_LINES).map(text => ` ${plainLine(text, secrets)}`),
|
|
667
767
|
...(lines.length > from + VALUE_LINES ? [` … ${lines.length - from - VALUE_LINES} more lines in the report`] : []),
|
|
668
768
|
...(typeof value === 'string' && value.endsWith('\n') ? [' (ends with a line break)'] : [])];
|
|
669
|
-
return [head, ...criterion, ...block(refLabel ? `expected (${refLabel})` : 'expected', check.expected, expected), ...block('got', check.actual, actual)];
|
|
769
|
+
return [head, ...criterion, ...clauseLines, ...diffLines, ...block(refLabel ? `expected (${refLabel})` : 'expected', check.expected, expected), ...block('got', check.actual, actual)];
|
|
670
770
|
}
|
|
671
771
|
// With a plain reason (#379): the reason, where and the fix; an AI service failure is not a problem in the test.
|
|
672
772
|
function refusalLines(item, serverNext = false) {
|
|
@@ -731,7 +831,7 @@ function localRefusals(rows, secrets) {
|
|
|
731
831
|
}
|
|
732
832
|
|
|
733
833
|
// The terminal result of a batch (stdout).
|
|
734
|
-
export function renderText({ batch, rows, coverage, warnings = [], details = false, timeoutMin = null, interrupted = false, reading = false, exitCode, secrets = [], recovery, now = Date.now(), noFailed = false }, ports = {}) {
|
|
834
|
+
export function renderText({ batch, rows, coverage, warnings = [], details = false, timeoutMin = null, batchTimeoutMin = null, interrupted = false, reading = false, exitCode, secrets = [], recovery, now = Date.now(), noFailed = false }, ports = {}) {
|
|
735
835
|
const out = [];
|
|
736
836
|
rows = [...rows.filter(row=>row.unsent),...rows.filter(row=>!row.unsent)];
|
|
737
837
|
out.push(...localRefusals(rows.filter(row=>row.unsent),secrets));
|
|
@@ -772,7 +872,7 @@ export function renderText({ batch, rows, coverage, warnings = [], details = fal
|
|
|
772
872
|
}
|
|
773
873
|
}
|
|
774
874
|
if (reruns.some(item => item.key === null)) lines.push(reruns.find(item => item.key === null).line);
|
|
775
|
-
if (fullFailure) lines.push(...(row.warnings ?? []).map(text => ` ${text}`));
|
|
875
|
+
if (fullFailure) lines.push(...[...new Set([...(row.warnings ?? []), ...(row.clause_warnings ?? [])])].map(text => ` ${text}`));
|
|
776
876
|
const diagnosed = failed.some(check => check.diagnosis?.why || check.diagnosis?.next_step);
|
|
777
877
|
if (!diagnosed && fullFailure && row.next_step && row.why) lines.push(` Why: ${row.why}`);
|
|
778
878
|
if (!diagnosed && fullFailure && row.next_step) lines.push(` Next: ${row.next_step}`);
|
|
@@ -797,8 +897,10 @@ export function renderText({ batch, rows, coverage, warnings = [], details = fal
|
|
|
797
897
|
out.push(`NOT RUN ${row.title} (${row.test})${explanation ? `: ${explanation}` : ''}${note?.code ? ` (${note.code})` : ''}`, ...serverAdvice(row, secrets));
|
|
798
898
|
}
|
|
799
899
|
for (const row of rows.filter(row => OPEN_STATES.has(row.state))) {
|
|
800
|
-
const
|
|
801
|
-
|
|
900
|
+
const noteText = row.note?.message ?? row.reason?.message ?? '';
|
|
901
|
+
const effectiveMin = /--batch-timeout/.test(noteText) && batchTimeoutMin != null ? batchTimeoutMin : timeoutMin ?? batchTimeoutMin;
|
|
902
|
+
const limit = effectiveMin == null ? '' : Number.isInteger(effectiveMin) ? `${effectiveMin} min` : `${Math.round(effectiveMin * 60)} s`;
|
|
903
|
+
out.push(`STILL RUNNING${reading || (!interrupted && effectiveMin == null) ? '' : interrupted ? ' when pdd stopped reading' : ` after ${limit}`}: ${row.title}. Do not send it again.${row.note?.code === 'timeout-flag' || row.reason?.code === 'timeout-flag' ? ` ${row.note?.message ?? row.reason.message}` : ''}`);
|
|
802
904
|
}
|
|
803
905
|
for (const row of rows.filter(row => ['unknown', 'partial'].includes(row.state) && !row.provider && !row.time_limit)) {
|
|
804
906
|
out.push(`UNKNOWN ${row.title}: the run may have executed. Its result is unknown.`, ...((row.lost || row.final) && row.why ? [` ${row.why}`, ...(row.next_step ? [` Next: ${cleanText(row.next_step, secrets)}`] : [])] : serverAdvice(row, secrets)));
|
|
@@ -868,7 +970,7 @@ export function renderText({ batch, rows, coverage, warnings = [], details = fal
|
|
|
868
970
|
const width = Math.max(...linked.map(row => row.story.length));
|
|
869
971
|
out.push('Reports (anyone with a link can open it):', ...linked.map(row => ` ${row.story.padEnd(width)} ${row.report_url}${row.draft ? ' (DRAFT)' : ''}`));
|
|
870
972
|
}
|
|
871
|
-
const rest = [...warnings, ...rows.filter(row => row.state !== 'failed').flatMap(row => (row.warnings ?? []).map(text => `${text} (${row.test})`))];
|
|
973
|
+
const rest = [...warnings, ...rows.filter(row => row.state !== 'failed').flatMap(row => [...new Set([...(row.warnings ?? []), ...(row.clause_warnings ?? [])])].map(text => `${text} (${row.test})`))];
|
|
872
974
|
out.push(...rest);
|
|
873
975
|
return `${out.join('\n')}\n`;
|
|
874
976
|
}
|