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.9 KB
Raw Blame
import { createQueryKeys } from '@lukemorales/query-key-factory';

export const agentSessionKeys = createQueryKeys('agentSessionMentions', {
  detail: (id: string) => ({ queryKey: [id] }),
  preview: (id: string, graphql: boolean) => ({ queryKey: [id, graphql] }),
});

/**
 * A session's captured changes: the summary (invalidated by the
 * `agent_session_changes` realtime event) and the patch behind one capture,
 * keyed by changeset id so a newer capture never reads an older body.
 */
export const agentSessionChangesKeys = createQueryKeys('agentSessionChanges', {
  summary: (sessionId: string) => ({ queryKey: [sessionId] }),
  patch: (sessionId: string, changesetId: string) => ({
    queryKey: [sessionId, changesetId],
  }),
});

/** Pull request links, looked up from either side. */
export const agentSessionPullRequestKeys = createQueryKeys(
  'agentSessionPullRequests',
  {
    forPullRequest: (url: string) => ({ queryKey: [url] }),
    forSession: (sessionId: string) => ({ queryKey: [sessionId] }),
    /** Everything a batch of pull requests links to, keyed by their URLs. */
    linksForPullRequests: (urls: readonly string[]) => ({
      queryKey: [urls],
    }),
  }
);

/** Speculative, hidden sessions prepared for the signed-in owner. */
export const agentSessionWarmKeys = createQueryKeys('agentSessionWarm', {
  owner: (userId: string | undefined) => ({ queryKey: [userId] }),
});

/** Durable code-mode records, scoped to their owning session. */
export const agentCodeExecutionKeys = createQueryKeys('agentCodeExecution', {
  detail: (sessionId: string, executionId: string) => ({
    queryKey: [sessionId, executionId],
  }),
});

/** A session's auto-archive choices, its owner's defaults, and the archive a trigger made. */
export const agentSessionAutoArchiveKeys = createQueryKeys(
  'agentSessionAutoArchive',
  {
    detail: (sessionId: string) => ({ queryKey: [sessionId] }),
  }
);