import { readFile, writeFile } from "node:fs/promises";
import { randomUUID } from "node:crypto";
import { join } from "node:path";
import { CommandId, ThreadId } from "@t3tools/contracts";
import { expect } from "e2e";
import * as Effect from "effect/Effect";
import { APP_DIR, MOBILE, MOBILE_T3_HOME } from "../e2e.config.ts";
import { makeState, rpcClient, runPromise } from "./t3.ts";

  const fixture = join(APP_DIR, "apps/server/src/orchestration-v2/testkit/fixtures/acp_elicitation/registry_transcript.ndjson");
  const original = await readFile(fixture, "utf8");
  const records = original.trim().split("\n").map((line) => JSON.parse(line));
  const request = records.find((r) => r.frame?.method === "elicitation/create" && r.type === "emit_inbound");
  request.frame.params._meta = { "cognition.ai/allowOther": true };
  request.frame.params.message = "Choose how to build the demo application.";
  request.frame.params.requestedSchema = {
    type: "object", title: "Demo application choices",
    properties: Object.fromEntries(["Architecture", "Storage", "Interface", "Deployment"].map((title, i) => [`question${i}`, {
      type: "string", title,
      description: `Which ${title.toLowerCase()} approach should we use for the demo application? Choose an option or write your own answer.`,
      enum: ["Simple: a minimal implementation that is easy to understand and maintain", "Flexible: support several workflows and keep the implementation extensible", "Scalable: prepare for larger workloads with clear boundaries and monitoring", "Custom: adapt the design to the requirements of the project and its users"],
    }])), required: ["question0", "question1", "question2", "question3"],
  };
  await writeFile(fixture, records.map((r) => JSON.stringify(r)).join("\n") + "\n");

