startedSession

tcmts.cli.test.e2e.mcp.startedSession · #wz32sv5q · term · runs on the server

uses node:assert/strict

A session's server as an agent's client starts it (tcm mcp, from cwd, with env and argv), its handshake made: what its instructions say, and its branch.

import { tcmBin } from "#codebase/tcmts/cli/test/e2e/harness";
import { hello, sessionOf } from "#codebase/tcmts/cli/test/e2e/mcp";
import assert from "node:assert/strict";
import type { ChildProcess } from "node:child_process";

export async function startedSession(
  cwd: string,
  keep: <C extends ChildProcess>(c: C) => C,
  env: Record<string, string> = {},
  argv: string[] = [tcmBin(), "mcp"],
) {
  const s = sessionOf(cwd, keep, argv, env);
  const instructions = String((await s.request("initialize", hello)).result!.instructions);
  const branch = /a session on its own branch, (\S+?):/.exec(instructions)?.[1];
  assert.ok(branch, instructions);
  return { ...s, instructions, branch };
}

uses

used by