import { CopilotClient } from "./client.js";
import {
  defaultJoinSessionPermissionHandler
} from "./types.js";
import {
  Canvas,
  CanvasError,
  createCanvas
} from "./canvas.js";
async function joinSession(config = {}) {
  const sessionId = process.env.SESSION_ID;
  if (!sessionId) {
    throw new Error(
      "joinSession() is intended for extensions running as child processes of the Copilot CLI."
    );
  }
  const client = new CopilotClient({ _internalConnection: { kind: "parent-process" } });
  return client.resumeSession(sessionId, {
    ...config,
    onPermissionRequest: config.onPermissionRequest ?? defaultJoinSessionPermissionHandler,
    suppressResumeEvent: config.suppressResumeEvent ?? true
  });
}
export {
  Canvas,
  CanvasError,
  createCanvas,
  joinSession
};
