ravensight-playtest 0.13.1 → 0.13.2
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 +40 -2
- package/package.json +1 -1
- package/src/commands/run.js +35 -6
- package/src/run/aggregate.js +2 -1
- package/src/run/anygame/shared-hashes.json +2 -2
- package/src/run/claimGate.js +9 -0
- package/src/run/drivers/mobile/target.js +22 -3
- package/src/run/drivers/web.js +27 -1
- package/src/run/eventclaims.js +6 -3
- package/src/run/events.js +33 -7
- package/src/run/intent.js +604 -0
- package/src/run/personaLoop.js +119 -9
- package/src/run/thinRun.js +35 -11
- package/src/run/tools.js +52 -14
package/src/run/personaLoop.js
CHANGED
|
@@ -33,7 +33,10 @@ import { recordingMetadata, saveRecording } from './drivers/recording.js';
|
|
|
33
33
|
import { createTranscript } from './transcript.js';
|
|
34
34
|
import { createUsageLedger, writeUsageFile } from './usage.js';
|
|
35
35
|
import { fillPlaceholders, fillReportPlaceholders } from './placeholders.js';
|
|
36
|
-
import { sweepTurnedAway } from './claimGate.js';
|
|
36
|
+
import { repeatsTurnedAway, sweepTurnedAway } from './claimGate.js';
|
|
37
|
+
// The intent check (./intent.js): each input held against the screen after it, a repeated miss not sent again, what the run
|
|
38
|
+
// played, and the in-character section held to the record.
|
|
39
|
+
import { annotateActionLog, createIntentWatch, goalsOf, holdInCharacter, intentReportLines, movementInput, playedScope, withPlayedLine } from './intent.js';
|
|
37
40
|
// The claim judge and the hosted runner's own claim words, check questions and event rules.
|
|
38
41
|
import { claimShape, judgeIssue, legacyIssue, impressionOf } from './judge.js';
|
|
39
42
|
import { EVENTS_RULE, eventsBlock, eventsReportLines, eventsUsage, withEventEvidence } from './events.js';
|
|
@@ -214,6 +217,7 @@ export const PLAY_NOTES = [
|
|
|
214
217
|
'- Every action answers with the screen that followed, so do not call snapshot after an action; call it only to look again after a wait.',
|
|
215
218
|
'- Each turn spends the run\'s model budget, and the budget, not the action count, usually ends a run. Do not spend turns looking twice. When the next two or three inputs are plain (close a dialog, then press Start; end three turns in a row), send them as separate tool calls in ONE turn.',
|
|
216
219
|
'- Say what you expect an action to do (expect). When the brief tells you to pick an option (a faction, a character, a class, a mode, a difficulty), read the options on the screen first, make exactly that choice, and check on the next screen that it is the one in effect. If it is not, say so in a note at once.',
|
|
220
|
+
'- On your next tool call after an input with expect, say whether the screen shows it: intent_check "met", or "missed" with instead (what the screen shows, copied as drawn). Trust the screen over what you believe: a key that brings up something else did not do what you meant, however often the screen changes. An input that missed the same result twice in a row is not sent a third time: reach the target another way first (walk to it with the arrow keys or W A S D, click it, or read what the screen says each key does).',
|
|
217
221
|
'- Keep playing in scope beyond a first win or partial goal. When the brief gives explicit success criteria, complete all of them and their requested verification, then use the completion statement below to stop while preserving the requested end state. Without a completed brief, explore until your actions or budget run out or a persona stop condition fires.',
|
|
218
222
|
'- When you do stop, use the brief completion statement if applicable, otherwise one short sentence, and no tool call. Never write the report here: a separate step writes it from your notes.',
|
|
219
223
|
'- The screen text or the scene outline can be cut short, and a picture is only sent when the text is not enough. When you need to see the screen, call screenshot: its result shows you the picture. What this runner could not show you, could not click or does not offer is a limit of the runner: mention it in a note of kind reaction if you must, never as a bug, a confusing or a suggestion note.'
|
|
@@ -247,8 +251,11 @@ export function personaQuitDetail(text) {
|
|
|
247
251
|
return `${space > 40 ? cut.slice(0, space) : cut}...`;
|
|
248
252
|
}
|
|
249
253
|
|
|
250
|
-
/**
|
|
251
|
-
|
|
254
|
+
/**
|
|
255
|
+
* The stop detail when play ends to keep the report's budget. A run that got here played to its budget: it is never said to
|
|
256
|
+
* have stopped early (the paid local run of 2026-11-20 played 39 of its 40 actions and its report said "stopped early").
|
|
257
|
+
*/
|
|
258
|
+
export const RESERVE_STOP_DETAIL = 'played to its budget: play stopped so the rest of the model budget pays for the report';
|
|
252
259
|
|
|
253
260
|
/**
|
|
254
261
|
* @typedef {Object} PersonaRunOutcome
|
|
@@ -351,6 +358,8 @@ export async function runPersona(args) {
|
|
|
351
358
|
videoPath: null,
|
|
352
359
|
usage: null,
|
|
353
360
|
runDirectory,
|
|
361
|
+
// The run's action limit: what "played to its budget" is said against (./intent.js).
|
|
362
|
+
maxActions,
|
|
354
363
|
// The last state the SERVER accepted, which is not the same thing as the
|
|
355
364
|
// outcome: the caller has to know whether this run ever reached
|
|
356
365
|
// `reporting`, because the server's table only allows `uploading` from
|
|
@@ -398,6 +407,8 @@ export async function runPersona(args) {
|
|
|
398
407
|
});
|
|
399
408
|
imageBudget = play.imageBudget;
|
|
400
409
|
outcome = { ...outcome, ...play };
|
|
410
|
+
// The intent check's record for usage.json (./intent.js); what the run played is added once the report has it.
|
|
411
|
+
outcome.intent = honesty.intent ? honesty.intent.summary() : null;
|
|
401
412
|
|
|
402
413
|
const endedAt = new Date().toISOString();
|
|
403
414
|
// When the recording began, read before the driver is stopped: a finding's
|
|
@@ -423,6 +434,7 @@ export async function runPersona(args) {
|
|
|
423
434
|
// No positive remaining budget was established by the refusal.
|
|
424
435
|
// Preserve the notes without authorizing another model call.
|
|
425
436
|
await writeSomeReport({ outcome, runDirectory, persona, driverName, target, notes, screenshots, actionRecords, play, skill, ledger, runId, jobId, startedAt, endedAt, log, honesty, observations });
|
|
437
|
+
outcome.scope = scopeForUsage(honesty.scope);
|
|
426
438
|
return finish(outcome, ledger, runDirectory, transcript, heartbeat);
|
|
427
439
|
}
|
|
428
440
|
|
|
@@ -499,6 +511,8 @@ export async function runPersona(args) {
|
|
|
499
511
|
}
|
|
500
512
|
|
|
501
513
|
outcome.report = written.report;
|
|
514
|
+
// What the run played, as report.md says it, for usage.json (the hosted runner's `scope`; the server's evidence report reads its line).
|
|
515
|
+
outcome.scope = scopeForUsage(honesty.scope);
|
|
502
516
|
// What the runner met and could not do, for the complete call (./thinRun.js capabilityNotesBody).
|
|
503
517
|
outcome.capabilityNotes = honesty.capability.list();
|
|
504
518
|
outcome.reportMarkdown = written.markdown;
|
|
@@ -576,6 +590,9 @@ export async function runPersona(args) {
|
|
|
576
590
|
}
|
|
577
591
|
// Sent to the server as the run's reason, so it is as safe as the report.
|
|
578
592
|
outcome.quitDetail = safeErrorDetail(error, localBrief);
|
|
593
|
+
// The intent check's record and what the run played, kept in usage.json for a run that did not finish its report too.
|
|
594
|
+
if (honesty.intent) outcome.intent = honesty.intent.summary();
|
|
595
|
+
if (honesty.scope) outcome.scope = scopeForUsage(honesty.scope);
|
|
579
596
|
transcript.write({ kind: 'error', message: outcome.quitDetail });
|
|
580
597
|
await finish(outcome, ledger, runDirectory, transcript, heartbeat);
|
|
581
598
|
throw Object.assign(error, { outcome });
|
|
@@ -898,6 +915,9 @@ async function playLoop({
|
|
|
898
915
|
const briefFields = brief && brief.fields && typeof brief.fields === 'object' ? brief.fields : brief || {};
|
|
899
916
|
const anyGame = honesty.anygame || (honesty.anygame = createLocalAnyGame({ briefText: briefForPrompt(brief), controls: briefFields.build_notes && typeof briefFields.build_notes.controls === 'string' ? briefFields.build_notes.controls : null, touch: Boolean(driver && driver.touch), continuousTime: driver?.inputProfile === 'native-mobile' && driver.frozenBetweenActions === false, driverName: typeof driver.soundSelfTest === 'function' ? '' : driverName }));
|
|
900
917
|
system.push({ type: 'text', text: anyGame.systemText() });
|
|
918
|
+
// The intent check (./intent.js): one watch a run, on the honesty record so the report step reads the same one. Every answer,
|
|
919
|
+
// miss and refused repeat is a line of the step log.
|
|
920
|
+
const intentWatch = honesty.intent || (honesty.intent = createIntentWatch({ goals: goalsOf(brief), onEvent: line => transcript.write(line) }));
|
|
901
921
|
// What earlier playtests of this game learned (./gameMemory.js): the same block every request carries, so it is cached.
|
|
902
922
|
const earlier = earlierMemory && earlierMemory.save !== false ? memoryBlock(earlierMemory) : '';
|
|
903
923
|
if (earlier) {
|
|
@@ -1114,9 +1134,9 @@ async function playLoop({
|
|
|
1114
1134
|
reserveStopped = true;
|
|
1115
1135
|
quitReason = 'budget_exhausted';
|
|
1116
1136
|
quitDetail = reserve.figures.stop_reason === 'act_projection'
|
|
1117
|
-
? '
|
|
1137
|
+
? 'played to its budget: the next action\'s reservation would not fit in the model budget left'
|
|
1118
1138
|
: reserve.figures.stop_reason === 'act_projection_and_report_reserve'
|
|
1119
|
-
? '
|
|
1139
|
+
? 'played to its budget: the next action\'s reservation and the report reserve would not fit in the model budget left'
|
|
1120
1140
|
: RESERVE_STOP_DETAIL;
|
|
1121
1141
|
transcript.write({ kind: 'budget_reserve_stop', ...reserve.figures });
|
|
1122
1142
|
log(`stopping play after ${actions} action(s): ${quitDetail} (spent about $${reserve.figures.usd_spent} of $${reserve.figures.usd_max}; next action projection $${reserve.figures.act_projected_usd}; report reserve $${reserve.figures.report_reserve_usd}; reason ${reserve.figures.stop_reason}).`);
|
|
@@ -1402,6 +1422,8 @@ async function playLoop({
|
|
|
1402
1422
|
// Every ref in this turn was read off the screen before it. Once one of
|
|
1403
1423
|
// its actions changes the screen, a later ref may name something else.
|
|
1404
1424
|
let screenChangedThisTurn = false;
|
|
1425
|
+
// The playtester's answer about its last input is read from this turn's calls until one of them plays an input (./intent.js).
|
|
1426
|
+
let answerOpen = true;
|
|
1405
1427
|
for (const toolUse of answer.toolUses) {
|
|
1406
1428
|
if (argsSignal?.aborted || heartbeat?.canceled) { canceled = true; quitReason = 'error'; quitDetail = 'the job was cancelled'; break; }
|
|
1407
1429
|
if (selection && toolUse.id !== selection.toolId) { results.push({ type: 'tool_result', tool_use_id: toolUse.id, content: 'Alternative not selected. No action executed.' }); continue; }
|
|
@@ -1422,6 +1444,19 @@ async function playLoop({
|
|
|
1422
1444
|
transcript.write({ kind: 'action_not_played', tool: toolUse.name, reason: 'tool_not_allowed_by_server' });
|
|
1423
1445
|
continue;
|
|
1424
1446
|
}
|
|
1447
|
+
// The intent check (./intent.js): the playtester's own answer about its last input, then an input that has missed the
|
|
1448
|
+
// same result twice in a row is not sent again; it is told what the screen showed instead and asked for another way.
|
|
1449
|
+
const checkedInput = toolUse.malformed ? null : redactToolInput(toolUse, secrets);
|
|
1450
|
+
if (answerOpen && checkedInput) intentWatch.answer(checkedInput, { first: true });
|
|
1451
|
+
if (checkedInput && ACTION_TOOLS.includes(toolUse.name)) {
|
|
1452
|
+
const repeated = intentWatch.refusal(toolUse.name, checkedInput, { turn: turns });
|
|
1453
|
+
if (repeated) {
|
|
1454
|
+
results.push(toolResult(toolUse.id, repeated));
|
|
1455
|
+
recentActions.push(`${toolUse.name}: not sent, it repeated a miss`);
|
|
1456
|
+
if (recentActions.length > 10) recentActions.shift();
|
|
1457
|
+
continue;
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1425
1460
|
const notesBefore = notes.length;
|
|
1426
1461
|
const screenBefore = latestObservation;
|
|
1427
1462
|
// A note about something wrong is about the screen as it is now, before
|
|
@@ -1499,6 +1534,13 @@ async function playLoop({
|
|
|
1499
1534
|
};
|
|
1500
1535
|
transcript.write(actionLine);
|
|
1501
1536
|
actionRecords.push(actionLine);
|
|
1537
|
+
// The intent check: an input that reached the game is held against the screen after it (./intent.js).
|
|
1538
|
+
if (checkedInput && ACTION_TOOLS.includes(toolUse.name)) {
|
|
1539
|
+
const reached = !executed.error && !executed.refused;
|
|
1540
|
+
if (reached) answerOpen = false;
|
|
1541
|
+
intentWatch.played({ tool: toolUse.name, input: checkedInput, action: actions, turn: turns, ok: reached, changed: Boolean(executed.changed),
|
|
1542
|
+
pageText: executed.observation && !executed.observation.unchanged ? String(executed.observation.text || '') : '', thought: actionLine.thought || '' });
|
|
1543
|
+
}
|
|
1502
1544
|
if (honesty.traceSteps && Number.isInteger(actionLine.trace_steps)) honesty.traceSteps.set(actions, actionLine.trace_steps);
|
|
1503
1545
|
if (honesty.tester) honesty.tester.acted(actionLine); // [tester hook]
|
|
1504
1546
|
if (executed.unsupported && honesty.capability.add(executed.unsupported)) {
|
|
@@ -1671,6 +1713,9 @@ async function playLoop({
|
|
|
1671
1713
|
asides.push(stuckHint(unchanged, failedInputsOn(failedInputs, latestObservation)));
|
|
1672
1714
|
}
|
|
1673
1715
|
|
|
1716
|
+
// The intent check: a miss the runner or the record found, and a part of the game to leave, said once (./intent.js).
|
|
1717
|
+
for (const notice of intentWatch.notices()) asides.push(notice);
|
|
1718
|
+
|
|
1674
1719
|
// any-game hook: the play style once, and the notebook when screens have dropped out of context.
|
|
1675
1720
|
const anyAside = anyGame.aside({ actions, dropped: staleObservationCount(observations.length, keepObservations) });
|
|
1676
1721
|
if (anyAside) { asides.push(anyAside); transcript.write({ kind: 'any_game_aside', chars: anyAside.length }); }
|
|
@@ -1894,7 +1939,9 @@ async function playLoop({
|
|
|
1894
1939
|
canceled,
|
|
1895
1940
|
imageBudget,
|
|
1896
1941
|
finalScreenshot: final ? final.relativePath : null,
|
|
1897
|
-
|
|
1942
|
+
maxActions,
|
|
1943
|
+
// Each checked input's result rides on its entry of the action log (./intent.js).
|
|
1944
|
+
actionLog: annotateActionLog(actionLogFrom(actionRecords), intentWatch.checks())
|
|
1898
1945
|
};
|
|
1899
1946
|
}
|
|
1900
1947
|
|
|
@@ -2320,6 +2367,23 @@ async function reportPhase({
|
|
|
2320
2367
|
const generatedAt = new Date().toISOString();
|
|
2321
2368
|
const facts = reportFacts({ persona, driverName, target, play });
|
|
2322
2369
|
markdown = stampGeneratedAt(markdown, generatedAt, facts);
|
|
2370
|
+
// What the run played (./intent.js), in the hosted report's words, under the stamp: a run that played to its budget is said
|
|
2371
|
+
// so, with how far it got and the result it aimed at and never reached.
|
|
2372
|
+
const scope = playScopeOf(play, honesty);
|
|
2373
|
+
if (scope) {
|
|
2374
|
+
markdown = withPlayedLine(markdown, scope.line);
|
|
2375
|
+
honesty.scope = scope;
|
|
2376
|
+
transcript.write({ kind: 'played_scope', line: scope.line });
|
|
2377
|
+
log(`what was played: ${scope.line}`);
|
|
2378
|
+
}
|
|
2379
|
+
// The in-character section held to the record: a sentence the record or the frames show otherwise is left out, and the
|
|
2380
|
+
// record's own fact said instead.
|
|
2381
|
+
const heldBack = holdInCharacter(markdown, { families: honesty && honesty.intent ? honesty.intent.families() : [], movedAtAll: couldMove(play.records), turnedAway, repeats: repeatsTurnedAway });
|
|
2382
|
+
if (heldBack.held.length > 0) {
|
|
2383
|
+
markdown = heldBack.markdown;
|
|
2384
|
+
transcript.write({ kind: 'in_character_held', sentences: heldBack.held.map(entry => ({ sentence: String(entry.sentence).slice(0, 300), fact: entry.fact })) });
|
|
2385
|
+
log(`held the in-character section to the run's record: ${heldBack.held.length} sentence(s) it shows otherwise left out.`);
|
|
2386
|
+
}
|
|
2323
2387
|
// The same slots in the prose the dashboard shows from report.json.
|
|
2324
2388
|
report = fillReportPlaceholders(report, { generatedAt, ...facts });
|
|
2325
2389
|
// A finding the server would drop for want of an uploaded file it can
|
|
@@ -2376,6 +2440,41 @@ export function watchedFor(report, watched) {
|
|
|
2376
2440
|
/** The heading of the report's section on the game's own events, the hosted runner's own. */
|
|
2377
2441
|
export const EVENTS_HEADING = '## Measured from the game\'s own events';
|
|
2378
2442
|
|
|
2443
|
+
/**
|
|
2444
|
+
* What the run played (./intent.js playedScope), from the play loop's result and the runner's record: the intent watch and the
|
|
2445
|
+
* game's own event names. Null with nothing to say.
|
|
2446
|
+
*/
|
|
2447
|
+
export function playScopeOf(play, honesty) {
|
|
2448
|
+
if (!play || !honesty) return null;
|
|
2449
|
+
const run = gameEventsRun(honesty);
|
|
2450
|
+
const events = run && run.gameEvents && Array.isArray(run.gameEvents.events) ? run.gameEvents.events : [];
|
|
2451
|
+
// Event names are the build's own strings: only plain ones are repeated.
|
|
2452
|
+
const names = events.map(event => event && event.name).filter(name => typeof name === 'string' && /^[A-Za-z0-9_.:-]{1,40}$/.test(name));
|
|
2453
|
+
return playedScope({ watch: honesty.intent || null, actionsTaken: play.actionsTaken, maxActions: play.maxActions, quitReason: play.quitReason,
|
|
2454
|
+
reserveStopped: Boolean(play.reserveStopped), eventNames: names, eventTotal: run && run.gameEvents ? run.gameEvents.total : 0 });
|
|
2455
|
+
}
|
|
2456
|
+
|
|
2457
|
+
/** What the run played, in the shape usage.json carries it (`line` first: the server's evidence report reads it). */
|
|
2458
|
+
export function scopeForUsage(scope) {
|
|
2459
|
+
if (!scope || !scope.line) return null;
|
|
2460
|
+
return {
|
|
2461
|
+
line: scope.line,
|
|
2462
|
+
budget: Boolean(scope.budget),
|
|
2463
|
+
reached: scope.reached || null,
|
|
2464
|
+
not_reached: (scope.families || []).map(f => ({ expected: f.expected, input: f.input, misses: f.misses, refused: f.refused || 0, actions: f.actions, saw: f.saw })),
|
|
2465
|
+
parts: scope.parts || []
|
|
2466
|
+
};
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2469
|
+
/**
|
|
2470
|
+
* Whether anything the run sent could have moved something across the game: a movement key, a held key, a drag, a stick, or
|
|
2471
|
+
* any pointer input (a click can walk a character in a point and click game). The in-character section is held to it.
|
|
2472
|
+
*/
|
|
2473
|
+
export function couldMove(records) {
|
|
2474
|
+
return (Array.isArray(records) ? records : []).some(record => record && record.kind === 'action' && record.ok
|
|
2475
|
+
&& (movementInput(record.tool, record.input || {}) || ['click', 'hover', 'drag', 'swipe', 'gamepad', 'pinch'].includes(record.tool)));
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2379
2478
|
/**
|
|
2380
2479
|
* What the claim judge and the report read the game's own events from: one
|
|
2381
2480
|
* object per run (the verdicts are kept against it), or null when the driver
|
|
@@ -2805,6 +2904,8 @@ export function buildReportRequest({ skill, schemas = [], persona, brief, localB
|
|
|
2805
2904
|
'What the screens read after the actions you stated an expectation for, and at the end (their visible text, which the observation list above leaves out):',
|
|
2806
2905
|
screenTextLines(play.records),
|
|
2807
2906
|
'',
|
|
2907
|
+
// The intent check (./intent.js): what missed, what was not sent for repeating a miss, and what the run played.
|
|
2908
|
+
...(honesty && honesty.intent ? (text => (text ? [text, ''] : []))(intentReportLines(honesty.intent, playScopeOf(play, honesty))) : []),
|
|
2808
2909
|
CHOICE_CHECK_INSTRUCTION,
|
|
2809
2910
|
...(choiceCheck ? [choiceCheckLine(choiceCheck)] : []),
|
|
2810
2911
|
...(play.declined ? ['', declinedPrompt(play.declined, Boolean(play.declinedEnded))] : []),
|
|
@@ -3303,7 +3404,7 @@ async function finish(outcome, ledger, runDirectory, transcript, heartbeat) {
|
|
|
3303
3404
|
}
|
|
3304
3405
|
outcome.usage = ledger.toReportUsage();
|
|
3305
3406
|
outcome.duration = ledger.duration();
|
|
3306
|
-
await writeUsageFile(runDirectory, ledger, { gameEvents: outcome.gameEvents || null, gameMemory: outcome.gameMemory || null });
|
|
3407
|
+
await writeUsageFile(runDirectory, ledger, { gameEvents: outcome.gameEvents || null, gameMemory: outcome.gameMemory || null, intent: outcome.intent || null, scope: outcome.scope || null });
|
|
3307
3408
|
transcript.write({ kind: 'end', state: outcome.state, quit_reason: outcome.quitReason, actions: outcome.actionsTaken });
|
|
3308
3409
|
await transcript.close();
|
|
3309
3410
|
return outcome;
|
|
@@ -3591,7 +3692,9 @@ async function writePartialReport({ outcome, runDirectory, persona, driverName,
|
|
|
3591
3692
|
// What the runner saw happen is kept even in a report nobody reviewed: a
|
|
3592
3693
|
// crash it watched is true whatever became of the report step.
|
|
3593
3694
|
const honest = writeHonesty({ report, markdown, honesty, driverName, notes, screenshots, observations });
|
|
3594
|
-
const
|
|
3695
|
+
const scope = playScopeOf(play.maxActions ? play : { ...play, maxActions: outcome.maxActions }, honesty);
|
|
3696
|
+
const stamped = withPlayedLine(stampGeneratedAt(honest.markdown, new Date().toISOString(), reportFacts({ persona, driverName, target, play })), scope ? scope.line : null);
|
|
3697
|
+
if (scope && honesty) honesty.scope = scope;
|
|
3595
3698
|
await writeReportFiles({ runDirectory, markdown: stamped, report: honest.report });
|
|
3596
3699
|
outcome.report = honest.report;
|
|
3597
3700
|
outcome.reportMarkdown = stamped;
|
|
@@ -4032,11 +4135,18 @@ export function introducesError(before, after) {
|
|
|
4032
4135
|
export function actionLogLines(log) {
|
|
4033
4136
|
if (!Array.isArray(log) || log.length === 0) return '(none)';
|
|
4034
4137
|
const shown = log.slice(-MAX_ACTIONS_IN_REPORT);
|
|
4035
|
-
const lines = shown.map(entry => `${entry.action}. ${entry.kind} ${entry.target}: ${entry.changed ? 'screen changed' : 'no change'}${entry.expect ? ` (you expected: ${entry.expect}${Number.isInteger(entry.observationAfter) ? `; observation ${entry.observationAfter} is what followed` : ''})` : ''}`);
|
|
4138
|
+
const lines = shown.map(entry => `${entry.action}. ${entry.kind} ${entry.target}: ${entry.changed ? 'screen changed' : 'no change'}${entry.expect ? ` (you expected: ${entry.expect}${Number.isInteger(entry.observationAfter) ? `; observation ${entry.observationAfter} is what followed` : ''}${intentWords(entry.intent)})` : ''}`);
|
|
4036
4139
|
if (shown.length < log.length) lines.unshift(`(the first ${log.length - shown.length} are left out)`);
|
|
4037
4140
|
return lines.join('\n');
|
|
4038
4141
|
}
|
|
4039
4142
|
|
|
4143
|
+
/** What the intent check found of one action, as the action list says it (./intent.js annotateActionLog). */
|
|
4144
|
+
function intentWords(intent) {
|
|
4145
|
+
if (!intent || !intent.result) return '';
|
|
4146
|
+
if (intent.result === 'met') return '; you confirmed it';
|
|
4147
|
+
return `; it MISSED${intent.saw ? `: the screen showed ${JSON.stringify(intent.saw)} instead` : ''}`;
|
|
4148
|
+
}
|
|
4149
|
+
|
|
4040
4150
|
/**
|
|
4041
4151
|
* The failed requests the runner recorded, one line each, for the report
|
|
4042
4152
|
* prompt's network notes.
|
package/src/run/thinRun.js
CHANGED
|
@@ -15,6 +15,24 @@ import path from 'node:path';
|
|
|
15
15
|
/** The heading the explanation is written under in report.md. */
|
|
16
16
|
export const THIN_RUN_HEADING = '## Why this run was short';
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* The heading for a run that played to its budget and was still billed as a thin run: it was not short, and report.md does not
|
|
20
|
+
* say it was (the paid local run of 2026-11-20 played 39 of its 40 actions and was written up as "stopped early").
|
|
21
|
+
*/
|
|
22
|
+
export const PLAYED_HEADING = '## How this run was billed';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The server's sentence for a run that played to its budget, without "stopped early": the one thing the CLI knows better than
|
|
26
|
+
* the server's words is how its own play ended (its action and model budget, with the report reserve). Everything else, the
|
|
27
|
+
* money above all, is the server's, word for word.
|
|
28
|
+
*
|
|
29
|
+
* @param {string} why
|
|
30
|
+
* @returns {string}
|
|
31
|
+
*/
|
|
32
|
+
export function playedWhy(why) {
|
|
33
|
+
return String(why || '').replace(/\bstopped early after (\d+ actions?)\b/g, 'played to its budget ($1)').replace(/\bstopped early\b/g, 'played to its budget');
|
|
34
|
+
}
|
|
35
|
+
|
|
18
36
|
/**
|
|
19
37
|
* The capability notes a `complete` may carry: what the playtester could not
|
|
20
38
|
* read or press, as `{ input, reason }`. The server bounds them again and only
|
|
@@ -35,12 +53,13 @@ export function capabilityNotesBody(outcome) {
|
|
|
35
53
|
* The server's thin run record, when the answer carries one with words in it.
|
|
36
54
|
*
|
|
37
55
|
* @param {any} record `run.thin_run`, or one entry of `thin_runs`
|
|
56
|
+
* @param {{played?: boolean}} [options] played: this run played to its budget (./intent.js playedToBudget)
|
|
38
57
|
* @returns {{why: string, next: string, money: string|null, limited: boolean}|null}
|
|
39
58
|
*/
|
|
40
|
-
export function thinRunOf(record) {
|
|
59
|
+
export function thinRunOf(record, { played = false } = {}) {
|
|
41
60
|
if (!record || typeof record.why !== 'string' || !record.why) return null;
|
|
42
61
|
return {
|
|
43
|
-
why: record.why,
|
|
62
|
+
why: played ? playedWhy(record.why) : record.why,
|
|
44
63
|
next: typeof record.next === 'string' ? record.next : '',
|
|
45
64
|
money: typeof record.money === 'string' && record.money ? record.money : null,
|
|
46
65
|
limited: record.limited === true
|
|
@@ -51,24 +70,27 @@ export function thinRunOf(record) {
|
|
|
51
70
|
* The lines a thin run prints: why, what to try, then the money.
|
|
52
71
|
*
|
|
53
72
|
* @param {any} record
|
|
73
|
+
* @param {{played?: boolean}} [options]
|
|
54
74
|
* @returns {Array<string>} empty when the run is not a thin run
|
|
55
75
|
*/
|
|
56
|
-
export function thinRunLines(record) {
|
|
57
|
-
const thin = thinRunOf(record);
|
|
76
|
+
export function thinRunLines(record, options = {}) {
|
|
77
|
+
const thin = thinRunOf(record, options);
|
|
58
78
|
if (!thin) return [];
|
|
59
79
|
return [thin.why, thin.next, thin.money].filter(Boolean);
|
|
60
80
|
}
|
|
61
81
|
|
|
62
82
|
/**
|
|
63
|
-
* The section report.md gets, so the report itself says why it is short
|
|
83
|
+
* The section report.md gets, so the report itself says why it is short, or, for a run that played to its budget, how it
|
|
84
|
+
* was billed.
|
|
64
85
|
*
|
|
65
86
|
* @param {any} record
|
|
87
|
+
* @param {{played?: boolean}} [options]
|
|
66
88
|
* @returns {string} '' when the run is not a thin run
|
|
67
89
|
*/
|
|
68
|
-
export function thinRunSection(record) {
|
|
69
|
-
const lines = thinRunLines(record);
|
|
90
|
+
export function thinRunSection(record, options = {}) {
|
|
91
|
+
const lines = thinRunLines(record, options);
|
|
70
92
|
if (lines.length === 0) return '';
|
|
71
|
-
return `${THIN_RUN_HEADING}\n\n${lines.join('\n\n')}\n`;
|
|
93
|
+
return `${options.played ? PLAYED_HEADING : THIN_RUN_HEADING}\n\n${lines.join('\n\n')}\n`;
|
|
72
94
|
}
|
|
73
95
|
|
|
74
96
|
/**
|
|
@@ -79,10 +101,11 @@ export function thinRunSection(record) {
|
|
|
79
101
|
*
|
|
80
102
|
* @param {string} directory the run directory
|
|
81
103
|
* @param {any} record
|
|
104
|
+
* @param {{played?: boolean}} [options]
|
|
82
105
|
* @returns {Promise<boolean>} whether the section was written
|
|
83
106
|
*/
|
|
84
|
-
export async function writeThinRunSection(directory, record) {
|
|
85
|
-
const section = thinRunSection(record);
|
|
107
|
+
export async function writeThinRunSection(directory, record, options = {}) {
|
|
108
|
+
const section = thinRunSection(record, options);
|
|
86
109
|
if (!section || !directory) return false;
|
|
87
110
|
const file = path.join(directory, 'report.md');
|
|
88
111
|
try {
|
|
@@ -92,7 +115,8 @@ export async function writeThinRunSection(directory, record) {
|
|
|
92
115
|
} catch (error) {
|
|
93
116
|
if (!error || error.code !== 'ENOENT') throw error;
|
|
94
117
|
}
|
|
95
|
-
const
|
|
118
|
+
const found = [THIN_RUN_HEADING, PLAYED_HEADING].map(heading => text.indexOf(heading)).filter(index => index !== -1);
|
|
119
|
+
const at = found.length > 0 ? Math.min(...found) : -1;
|
|
96
120
|
const kept = (at === -1 ? text : text.slice(0, at)).replace(/\s+$/, '');
|
|
97
121
|
await fs.writeFile(file, `${kept}${kept ? '\n\n' : ''}${section}`);
|
|
98
122
|
return true;
|
package/src/run/tools.js
CHANGED
|
@@ -102,6 +102,22 @@ const thought = {
|
|
|
102
102
|
description: 'One to three sentences in the persona voice, first person. Never break character here.'
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
+
/**
|
|
106
|
+
* The playtester's own answer about its last input, carried on its next tool call (./intent.js): whether the screen it led to
|
|
107
|
+
* shows what it expected, and what it shows instead. The runner holds every input with an expectation to it, and an input that
|
|
108
|
+
* misses the same result twice in a row is not sent a third time.
|
|
109
|
+
*/
|
|
110
|
+
const intentCheck = {
|
|
111
|
+
type: 'string',
|
|
112
|
+
enum: ['met', 'missed'],
|
|
113
|
+
description: 'Your LAST input, held against the screen it led to: "met" when this screen shows what you expected of it, "missed" when it does not. Give it on your first tool call after an input you gave expect for.'
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const instead = {
|
|
117
|
+
type: 'string',
|
|
118
|
+
description: 'When intent_check is missed: what the screen shows instead, copied as drawn, at most 12 words.'
|
|
119
|
+
};
|
|
120
|
+
|
|
105
121
|
const note = {
|
|
106
122
|
type: 'object',
|
|
107
123
|
description: 'Optional: something worth recording at this step. Engineer voice, not persona voice. Use it for anything surprising, frustrating, delightful, broken or confusing.',
|
|
@@ -143,7 +159,7 @@ export function dragTool(name = 'drag') {
|
|
|
143
159
|
return {
|
|
144
160
|
name,
|
|
145
161
|
description: DRAG_DESCRIPTION,
|
|
146
|
-
input_schema: { type: 'object', additionalProperties: false, properties: { ...dragProperties, expect, mood, thought_in_character: thought, note } }
|
|
162
|
+
input_schema: { type: 'object', additionalProperties: false, properties: { ...dragProperties, expect, mood, thought_in_character: thought, note, intent_check: intentCheck, instead } }
|
|
147
163
|
};
|
|
148
164
|
}
|
|
149
165
|
|
|
@@ -161,7 +177,9 @@ export const HOVER_TOOL = {
|
|
|
161
177
|
expect,
|
|
162
178
|
mood,
|
|
163
179
|
thought_in_character: thought,
|
|
164
|
-
note
|
|
180
|
+
note,
|
|
181
|
+
intent_check: intentCheck,
|
|
182
|
+
instead
|
|
165
183
|
}
|
|
166
184
|
}
|
|
167
185
|
};
|
|
@@ -183,7 +201,9 @@ export const SCROLL_TOOL = {
|
|
|
183
201
|
expect,
|
|
184
202
|
mood,
|
|
185
203
|
thought_in_character: thought,
|
|
186
|
-
note
|
|
204
|
+
note,
|
|
205
|
+
intent_check: intentCheck,
|
|
206
|
+
instead
|
|
187
207
|
}
|
|
188
208
|
}
|
|
189
209
|
};
|
|
@@ -202,7 +222,9 @@ export const SELECT_TOOL = {
|
|
|
202
222
|
expect,
|
|
203
223
|
mood,
|
|
204
224
|
thought_in_character: thought,
|
|
205
|
-
note
|
|
225
|
+
note,
|
|
226
|
+
intent_check: intentCheck,
|
|
227
|
+
instead
|
|
206
228
|
}
|
|
207
229
|
}
|
|
208
230
|
};
|
|
@@ -224,7 +246,9 @@ export const PINCH_TOOL = {
|
|
|
224
246
|
expect,
|
|
225
247
|
mood,
|
|
226
248
|
thought_in_character: thought,
|
|
227
|
-
note
|
|
249
|
+
note,
|
|
250
|
+
intent_check: intentCheck,
|
|
251
|
+
instead
|
|
228
252
|
}
|
|
229
253
|
}
|
|
230
254
|
};
|
|
@@ -243,7 +267,9 @@ export const GAMEPAD_TOOL = {
|
|
|
243
267
|
expect,
|
|
244
268
|
mood,
|
|
245
269
|
thought_in_character: thought,
|
|
246
|
-
note
|
|
270
|
+
note,
|
|
271
|
+
intent_check: intentCheck,
|
|
272
|
+
instead
|
|
247
273
|
}
|
|
248
274
|
}
|
|
249
275
|
};
|
|
@@ -313,7 +339,7 @@ export const PLAY_TOOLS = Object.freeze([
|
|
|
313
339
|
input_schema: {
|
|
314
340
|
type: 'object',
|
|
315
341
|
additionalProperties: false,
|
|
316
|
-
properties: { thought_in_character: thought, note }
|
|
342
|
+
properties: { thought_in_character: thought, note, intent_check: intentCheck, instead }
|
|
317
343
|
}
|
|
318
344
|
},
|
|
319
345
|
{
|
|
@@ -333,7 +359,9 @@ export const PLAY_TOOLS = Object.freeze([
|
|
|
333
359
|
expect,
|
|
334
360
|
mood,
|
|
335
361
|
thought_in_character: thought,
|
|
336
|
-
note
|
|
362
|
+
note,
|
|
363
|
+
intent_check: intentCheck,
|
|
364
|
+
instead
|
|
337
365
|
}
|
|
338
366
|
}
|
|
339
367
|
},
|
|
@@ -353,7 +381,9 @@ export const PLAY_TOOLS = Object.freeze([
|
|
|
353
381
|
expect,
|
|
354
382
|
mood,
|
|
355
383
|
thought_in_character: thought,
|
|
356
|
-
note
|
|
384
|
+
note,
|
|
385
|
+
intent_check: intentCheck,
|
|
386
|
+
instead
|
|
357
387
|
}
|
|
358
388
|
}
|
|
359
389
|
},
|
|
@@ -388,7 +418,9 @@ export const PLAY_TOOLS = Object.freeze([
|
|
|
388
418
|
expect,
|
|
389
419
|
mood,
|
|
390
420
|
thought_in_character: thought,
|
|
391
|
-
note
|
|
421
|
+
note,
|
|
422
|
+
intent_check: intentCheck,
|
|
423
|
+
instead
|
|
392
424
|
}
|
|
393
425
|
}
|
|
394
426
|
},
|
|
@@ -402,7 +434,9 @@ export const PLAY_TOOLS = Object.freeze([
|
|
|
402
434
|
properties: {
|
|
403
435
|
url: { type: 'string' },
|
|
404
436
|
thought_in_character: thought,
|
|
405
|
-
note
|
|
437
|
+
note,
|
|
438
|
+
intent_check: intentCheck,
|
|
439
|
+
instead
|
|
406
440
|
}
|
|
407
441
|
}
|
|
408
442
|
},
|
|
@@ -416,7 +450,9 @@ export const PLAY_TOOLS = Object.freeze([
|
|
|
416
450
|
properties: {
|
|
417
451
|
ms: { type: 'integer', minimum: 0 },
|
|
418
452
|
thought_in_character: thought,
|
|
419
|
-
note
|
|
453
|
+
note,
|
|
454
|
+
intent_check: intentCheck,
|
|
455
|
+
instead
|
|
420
456
|
}
|
|
421
457
|
}
|
|
422
458
|
},
|
|
@@ -431,7 +467,9 @@ export const PLAY_TOOLS = Object.freeze([
|
|
|
431
467
|
name: { type: 'string', description: 'a short slug, such as title-screen or level-2-softlock' },
|
|
432
468
|
reason: { type: 'string' },
|
|
433
469
|
thought_in_character: thought,
|
|
434
|
-
note
|
|
470
|
+
note,
|
|
471
|
+
intent_check: intentCheck,
|
|
472
|
+
instead
|
|
435
473
|
}
|
|
436
474
|
}
|
|
437
475
|
}
|
|
@@ -784,7 +822,7 @@ export async function executeTool({ driver, toolUse, onNote, onScreenshot, stale
|
|
|
784
822
|
const prefix = (outcome.ok
|
|
785
823
|
? `${outcome.detail ? `${outcome.detail}\n` : ''}${outcome.changed ? '' : 'That did not change the screen.\n'}`
|
|
786
824
|
: `That did not work: ${outcome.error}\n`)
|
|
787
|
-
+ (expected && outcome.ok ? `You expected: ${expected}. Check the screen below against that
|
|
825
|
+
+ (expected && outcome.ok ? `You expected: ${expected}. Check the screen below against that, and say on your next tool call whether it shows it: intent_check "met", or "missed" with instead: what it shows, copied as drawn.\n` : '');
|
|
788
826
|
return {
|
|
789
827
|
result: observationResult(toolUse.id, observation, prefix, !outcome.ok),
|
|
790
828
|
observation,
|