| 111 | registry: opts.registry, |
| 112 | permissions: opts.permissions, |
| 113 | config, // contract budgets (if any) applied above |
| 114 | cwd: opts.cwd, |
| 115 | }); |
| 116 | |
| 117 | if (!initialMessages) { |
| 118 | initialMessages = await agent.buildInitialMessages( |
| 119 | effectivePrompt, |
| 120 | modeOverride, |
| 121 | explicitModelOverride ?? opts.config.defaults.model, |
| 122 | ); |
| 123 | } |
| 124 | |
| 125 | // Record user turn (the rendered prompt, so resume sees the real instructions) |
| 126 | store.recordTurn(sessionId, [{ role: 'user', content: effectivePrompt }], { input: 0, output: 0, costUsd: 0 }); |
| 127 | |
| 128 | let exitCode = 0; |
| 129 | // ── Contract-run telemetry, gathered regardless of --json ── |