peppa/packages/testkit/src/scenario.ts
Асель 9149c75840 PEP-19/54: project secrets for agents, secrets audit and two-key PEPPA_SECRET rotation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 07:19:57 +05:00

36 lines
2.0 KiB
TypeScript

// Scenario format for the mock agents. A scenario is a list of turns; the initial
// prompt starts turn 0 and every prompt submitted afterwards starts the next turn.
// It is read from <workspace>/.peppa/mock-scenario.json.
export type Action =
| { say: string } // print an assistant message (the last one is the turn's final message)
| { work: number } // animate a spinner for N ms (screen keeps changing)
| { sleep: number }
| { mcp: string; args?: Record<string, unknown> } // call a peppa MCP tool
| { permission: { tool: string; input: Record<string, unknown> } } // claude: PermissionRequest
| { ask: Array<{ question: string; options?: string[] }> } // claude: AskUserQuestion
// usage limit: StopFailure (claude) / banner only (codex); resetInSec → "resets at HH:MM";
// credential → only when the run's login (Claude token, Codex auth.json, OpenCode key) contains it
| { limit: true | { resetInSec?: number; reset?: "unknown"; credential?: string } }
// PEP-5: an assistant message with this token usage in the transcript, then (claude) the
// statusLine command with cost / context / limit windows (pct, reset in N seconds)
| { usage: { input?: number; output?: number; cacheRead?: number; cacheWrite?: number; model?: string; costUsd?: number; context?: { used: number; size: number }; fiveHour?: number; sevenDay?: number; resetInSec?: number } }
| { warn: number } // usage warning banner: "You've used N% of your weekly limit"
| { hang: true } // freeze: no output, no input handling
| { crash: number } // exit with this code
| { clear: true } // claude: /clear (SessionEnd + SessionStart with a new id)
| { exit: true }; // clean exit (code 0)
export interface Scenario {
turns: Action[][];
/** Used instead of `turns` when the CLI is started with a resume target. */
resumeTurns?: Action[][];
/** PEP-54: env variables the mock prints as `NAME=value` at start and logs (secrets tests). */
echoEnv?: string[];
}
export interface MockLogEntry {
ev: string;
[k: string]: unknown;
}