Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

1.5 KB
Raw Blame
import { vi } from 'vitest'
import type {
  AiVaultSearchHit,
  AiVaultSearchRequest,
  AiVaultSearchResponse
} from './ai-vault-search-types'
import { unavailableSessionSearchStatus } from './ai-vault-search-client'

export function searchHit(): AiVaultSearchHit {
  return {
    agent: 'codex',
    sessionId: 'host-session',
    title: 'Indexed conversation',
    cwd: '/host/folder',
    branch: null,
    updatedAt: null,
    messageCount: 2,
    score: 1,
    source: { presence: 'present', filePath: '/host/transcript.jsonl', codexHome: '/host/codex' },
    evidence: { role: 'user', timestamp: null, snippet: 'a [[needle]]' },
    resumeCommand: 'host-resume-command'
  }
}

export function searchResults(): Extract<AiVaultSearchResponse, { kind: 'results' }> {
  return {
    kind: 'results',
    hits: [searchHit()],
    page: { cursor: null, hasMore: false },
    generation: 7,
    truncated: { candidates: false, snippets: 0, query: false, freshness: false },
    durationMs: 1,
    debug: { route: 'phrase', plannerReport: { route: 'phrase', scope: 'all' } }
  }
}

export function fakeSearchService() {
  return {
    search: vi.fn(
      async (
        _request: AiVaultSearchRequest,
        // Declare the host scope verdict for mock.calls; keep it loose to avoid a host-only type in shared fixtures.
        _hostScope?: unknown
      ): Promise<AiVaultSearchResponse> => searchResults()
    ),
    status: vi.fn(async () => ({
      ...unavailableSessionSearchStatus(),
      enabled: true,
      generation: 7
    })),
    reconcile: vi.fn(async () => {})
  }
}