MCPcopy Create free account
hub / github.com/IgorWarzocha/howcode / createRuntimeForNewSession

Function createRuntimeForNewSession

desktop/runtime/runtime-registry.ts:383–408  ·  view source on GitHub ↗
(
  cwd: string,
  sessionDir?: string | undefined | null | undefined,
  options: { chatGroupId?: string | undefined | null | undefined } = {},
)

Source from the content-addressed store, hash-verified

381}
382
383export 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
410export function scheduleRuntimeDisposalForRuntime(runtime: PiRuntime) {
411 const runtimeKey = getPersistedSessionPath(runtime.session.sessionFile)

Callers 1

sendComposerPromptFunction · 0.90

Calls 5

getPersistedSessionPathFunction · 0.90
getRuntimeRecordFunction · 0.90
suspendRuntimeDisposalFunction · 0.90
registerRuntimeFunction · 0.90
createRuntimeFunction · 0.70

Tested by

no test coverage detected