(config: JoinSessionConfig = {})
| 45 | * ``` |
| 46 | */ |
| 47 | export async function joinSession(config: JoinSessionConfig = {}): Promise<CopilotSession> { |
| 48 | const sessionId = process.env.SESSION_ID; |
| 49 | if (!sessionId) { |
| 50 | throw new Error( |
| 51 | "joinSession() is intended for extensions running as child processes of the Copilot CLI." |
| 52 | ); |
| 53 | } |
| 54 | |
| 55 | const client = new CopilotClient({ _internalConnection: { kind: "parent-process" } }); |
| 56 | |
| 57 | // Strip `extensionSdkPath` at runtime even though `JoinSessionConfig` omits it |
| 58 | // at the type level — untyped (JS) callers can still slip it through, and |
| 59 | // honoring it here would be misleading since the extension subprocess has |
| 60 | // already been forked by the host with the SDK the host chose. |
| 61 | const { extensionSdkPath: _stripped, ...rest } = config as JoinSessionConfig & { |
| 62 | extensionSdkPath?: string; |
| 63 | }; |
| 64 | void _stripped; |
| 65 | |
| 66 | return client.resumeSession(sessionId, { |
| 67 | ...rest, |
| 68 | onPermissionRequest: config.onPermissionRequest ?? defaultJoinSessionPermissionHandler, |
| 69 | suppressResumeEvent: config.suppressResumeEvent ?? true, |
| 70 | }); |
| 71 | } |
no test coverage detected
searching dependent graphs…