(
cwd: string,
sessionDir?: string | undefined | null | undefined,
options: { chatGroupId?: string | undefined | null | undefined } = {},
)
| 381 | } |
| 382 | |
| 383 | export async function createRuntimeForNewSession( |
| 384 | cwd: string, |
| 385 | sessionDir?: string | undefined | null | undefined, |
| 386 | options: { chatGroupId?: string | undefined | null | undefined } = {}, |
| 387 | ) { |
| 388 | const runtime = await createRuntime({ |
| 389 | cwd, |
| 390 | sessionDir, |
| 391 | settingsCwd: sessionDir ?? null, |
| 392 | chatGroupId: options.chatGroupId ?? null, |
| 393 | }) |
| 394 | const runtimeKey = getPersistedSessionPath(runtime.session.sessionFile) |
| 395 | |
| 396 | if (runtimeKey) { |
| 397 | const existingRuntime = getRuntimeRecord(runtimeKey) |
| 398 | if (existingRuntime) { |
| 399 | suspendRuntimeDisposal(runtimeKey) |
| 400 | runtime.session.dispose() |
| 401 | return await existingRuntime.runtimePromise |
| 402 | } |
| 403 | |
| 404 | registerRuntime(runtimeKey, Promise.resolve(runtime), sessionDir ?? null) |
| 405 | } |
| 406 | |
| 407 | return runtime |
| 408 | } |
| 409 | |
| 410 | export function scheduleRuntimeDisposalForRuntime(runtime: PiRuntime) { |
| 411 | const runtimeKey = getPersistedSessionPath(runtime.session.sessionFile) |
no test coverage detected