Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

1.0 KB
Raw Blame
import { throwOnErr } from '@core/util/result';
import { agentHarnessServiceClient } from '@service-agent-harness/client';
import { useQuery } from '@tanstack/solid-query';
import { agentRepositoryKeys } from './keys';

function fetchAgentRepositories() {
  return throwOnErr(() => agentHarnessServiceClient.listRepositories());
}

/**
 * The GitHub repositories the signed-in user can hand a coding session: every
 * repository under an installation of Macro's GitHub App they or their teams
 * made. The same list the create-session API authorizes an explicit
 * repository against, so what a picker offers is exactly what a session may
 * select.
 *
 * Kept fresh for a while: the harness caches the listing for ten minutes
 * itself, and installing the App somewhere new is rare and deliberate.
 */
export function useAgentRepositoriesQuery(enabled: () => boolean = () => true) {
  return useQuery(() => ({
    queryKey: agentRepositoryKeys.list.queryKey,
    queryFn: fetchAgentRepositories,
    enabled: enabled(),
    staleTime: 5 * 60 * 1000,
  }));
}