"""Install a synthetic completed MCP tool call in the dev replay showcase fixture.
Usage: python3 prepare-replay.py CHECKOUT ATTACHMENT_ID
Production application code is unchanged. The HTML is uploaded by seed-browser.js.
"""
import json, pathlib, sys
root, attachment = pathlib.Path(sys.argv[1]), sys.argv[2]
app = dict(attachmentId=attachment, server='analytics', tool='aggregate_events', resourceUri='ui://apps/dataviz', prefersBorder=True)
def update(value):
    return dict(type='emit_inbound', frame=dict(kind='notification', method='session/update', params=dict(sessionId='dev-replay-session',update=value)))
entries = [
 dict(type='transcript_start', provider='acpRegistry', protocol='acp.ndjson-jsonrpc', version='1',scenario='synthetic_mcp_app'),
 dict(type='expect_outbound',frame=dict(kind='request',method='session/prompt',params='<any>')),
 update(dict(sessionUpdate='tool_call',toolCallId='analytics-call',kind='other',title='analytics.aggregate_events',status='pending',rawInput=dict(server='analytics',tool='aggregate_events',arguments={}),_meta=dict(is_mcp_tool_call=True))),
 update(dict(sessionUpdate='tool_call_update',toolCallId='analytics-call',status='completed',rawOutput=dict(t3McpApp=app))),
 dict(type='emit_inbound',frame=dict(kind='response',method='session/prompt',result=dict(stopReason='end_turn')))
]
(root/'apps/server/scripts/dev-replay/showcase_transcript.ndjson').write_text(''.join(json.dumps(e)+'\n' for e in entries))
