MCPcopy Create free account
hub / github.com/holaboss-ai/holaOS / retrieveWorkspaceMemory

Function retrieveWorkspaceMemory

runtime/api-server/src/workspace-memory.ts:362–476  ·  view source on GitHub ↗
(params: {
  store: RuntimeStateStore;
  workspaceId: string;
  query: string;
  intent?: string | null;
  categories?: WorkspaceMemoryCategory[] | null;
  treeIds?: string[] | null;
  retrievalPolicy?: MemoryRetrievalPolicy | null;
  answerGoal?: string | null;
  selectedModel?: string | null;
  sessionId?: string | null;
  inputId?: string | null;
  executionProfile?: WorkspaceMemoryExecutionProfile | null;
})

Source from the content-addressed store, hash-verified

360}
361
362export async function retrieveWorkspaceMemory(params: {
363 store: RuntimeStateStore;
364 workspaceId: string;
365 query: string;
366 intent?: string | null;
367 categories?: WorkspaceMemoryCategory[] | null;
368 treeIds?: string[] | null;
369 retrievalPolicy?: MemoryRetrievalPolicy | null;
370 answerGoal?: string | null;
371 selectedModel?: string | null;
372 sessionId?: string | null;
373 inputId?: string | null;
374 executionProfile?: WorkspaceMemoryExecutionProfile | null;
375}): Promise<WorkspaceMemoryRetrieveResult> {
376 const useEmbeddings = params.executionProfile?.useEmbeddings !== false;
377 const useLlmRerank = params.executionProfile?.useLlmRerank !== false;
378 const categories = planWorkspaceMemoryCategories({
379 store: params.store,
380 workspaceId: params.workspaceId,
381 requestedCategories: params.categories ?? undefined,
382 treeId: Array.isArray(params.treeIds) && params.treeIds[0] ? params.treeIds[0] : null,
383 });
384 const candidateLimit = Math.max(
385 VECTOR_FIRST_PASS_LIMIT_FLOOR,
386 Math.min((params.retrievalPolicy?.max_evidence ?? 8) * 3, VECTOR_FIRST_PASS_LIMIT_CEILING),
387 );
388 const vectorFirstPass = useEmbeddings
389 ? await buildWorkspaceVectorFirstPassHits({
390 store: params.store,
391 workspaceId: params.workspaceId,
392 query: params.query,
393 categories,
394 treeIds: params.treeIds ?? null,
395 selectedModel: params.selectedModel ?? null,
396 sessionId: params.sessionId ?? null,
397 inputId: params.inputId ?? null,
398 maxCandidates: candidateLimit,
399 })
400 : {
401 modelId: null,
402 interactionHits: [],
403 integrationHits: [],
404 };
405 const lexicalSupportLimit = Math.max(
406 LEXICAL_SUPPORT_LIMIT_FLOOR,
407 Math.min(params.retrievalPolicy?.max_evidence ?? 8, LEXICAL_SUPPORT_LIMIT_CEILING),
408 );
409 const interactionSupportScopes = categories.includes("interaction")
410 ? distinctTreeIds(vectorFirstPass.interactionHits, params.treeIds ?? null, "interaction:")
411 : [];
412 const integrationSupportScopes = categories.includes("integration")
413 ? distinctTreeIds(vectorFirstPass.integrationHits, params.treeIds ?? null, "integration:")
414 : [];
415 const interactionSupportResults = categories.includes("interaction")
416 ? await Promise.all(interactionSupportScopes.map(async (treeId) =>
417 retrieveInteractionMemory({
418 store: params.store,
419 workspaceId: params.workspaceId,

Callers 3

retrieveMemoryMethod · 0.85

Tested by

no test coverage detected