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

Function buildComposerState

desktop/runtime/composer-state.ts:283–306  ·  view source on GitHub ↗
(
  runtime: PiRuntime,
  options: BuildComposerStateOptions = {},
)

Source from the content-addressed store, hash-verified

281}
282
283export async function buildComposerState(
284 runtime: PiRuntime,
285 options: BuildComposerStateOptions = {},
286): Promise<ComposerState> {
287 const availableModels = (await runtime.session.modelRegistry.getAvailable()).map((model) => ({
288 provider: model.provider,
289 id: model.id,
290 name: model.name ?? model.id,
291 reasoning: Boolean(model.reasoning),
292 input: (model.input ?? ['text']) as Array<'text' | 'image'>,
293 }))
294
295 return {
296 currentModel: mapComposerModel(runtime.session.model),
297 availableModels,
298 currentThinkingLevel: runtime.session.thinkingLevel as ComposerThinkingLevel,
299 availableThinkingLevels: mapThinkingLevels(runtime.session.getAvailableThinkingLevels()),
300 queuedPrompts: buildSessionQueuedPrompts(runtime.session),
301 nativeAskQuestionsRequest: getNativeAskQuestionsRequest(runtime),
302 contextUsage: getContextUsageForComposerState(runtime.session, options),
303 isCompacting: runtime.session.isCompacting,
304 isExtensionCommandRunning: isHeadlessExtensionCommandRunning(runtime.session),
305 }
306}

Callers 13

emitComposerUpdateFunction · 0.90
getComposerStateFunction · 0.90
openThreadRuntimeFunction · 0.90
publishThreadUpdateFunction · 0.90
emitComposerUpdateFunction · 0.90
getComposerStateFunction · 0.90
openThreadRuntimeFunction · 0.90
publishThreadUpdateFunction · 0.90
createRuntimeFunction · 0.90

Calls 6

mapComposerModelFunction · 0.85
mapThinkingLevelsFunction · 0.85

Tested by

no test coverage detected