Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

6.8 KB
Raw Blame
// Tier 3 — headless stream + interaction logic and thinking-message helpers. Imports only from
// ../logics/* and ../utils/* (no component or registry imports), so it never pulls the side-effectful
// tool registry or the markdown/virtualization chunks. Pair with ./types for a fully headless lane —
// status badges, automation, or a consumer that drives a run without rendering the prepackaged UI.
//
// Part of the `products/posthog_ai/frontend/api/<module>` public surface — import from here, not from
// deep `../logics/*` paths. See ../README.md for the tier model and ../AGENTS.md for the coupling rule.

// --- Stream logic + status helpers ---
// `runStreamLogic` keys on a generic `streamKey` (conversation id for Max, run/task id for a task
// viewer); read `currentRunStatus` / `isTerminalRunStatus` off it for a status badge with no UI.
export { runStreamLogic, isTerminalRunStatus, INITIAL_PERMISSION_MODE } from '../logics/runStreamLogic'
export { prefetchRunStream } from '../logics/runPrefetch'
export type { RunStreamLogicProps, RunSseStatus, RunStatus } from '../logics/runStreamLogic'

// --- Interaction facade (follow-up / queue) ---
export { runInteractionLogic } from '../logics/runInteractionLogic'
export { messageRatingsLogic } from '../logics/messageRatingsLogic'
export type { MessageRating, MessageRatingOrNull } from '../logics/messageRatingsLogic'
export type { RunInteractionLogicProps, QueuedMessage } from '../logics/runInteractionLogic'

// --- Thinking-message helpers ---
export {
    getThinkingMessageFromResponse,
    getRandomThinkingMessage,
    getWebSearchResultsByToolUseId,
    THINKING_MESSAGES,
} from '../utils/thinkingMessages'
export type { WebSearchResultsByToolUseId } from '../utils/thinkingMessages'

// --- Composer model/effort helpers (pure — no component imports) ---
export { resolveEffortForModel, DEFAULT_COMPOSER_MODEL, DEFAULT_COMPOSER_EFFORT } from '../utils/composerModels'
export { modelCatalogueLogic } from '../logics/modelCatalogueLogic'
// The server-resolved default model/effort for this user in this project (their own preference over
// the project default). A host that launches a run on the user's behalf reads it to tell whether a
// stored default will apply, because a model sent with the run overrides one.
export { taskRunDefaultsLogic } from '../logics/taskRunDefaultsLogic'

export { tasksLogic } from '../logics/tasksLogic'

// --- Chat skin ---
// Here, not in ./primitives, because surfaces that load eagerly (the composer on the AI-first homepage) read it.
export { useThreadSkin, ThreadSkinOverrideContext } from '../hooks/useThreadSkin'
export type { ThreadSkin } from '../components/quill/quillThreadContext'

// --- Attached-context injection hook (headless) ---
// `useAttachedContext` registers a provider in the shell's context store for the lifetime of a mount.
export { useAttachedContext } from '../hooks/useAttachedContext'
export type { UseAttachedContextOptions } from '../hooks/useAttachedContext'
// Contextual welcome headlines: a host registers headlines matching what the user is looking at,
// and the composer's empty state picks from them instead of the generic defaults.
export { welcomeOverrideLogic } from '../logics/welcomeOverrideLogic'
export { useWelcomeOverride } from '../hooks/useWelcomeOverride'
export type { UseWelcomeOverrideOptions } from '../hooks/useWelcomeOverride'
// Contextual composer overrides (suggestions, repo picker), the sibling of the welcome headline override above.
export { composerOverrideLogic } from '../logics/composerOverrideLogic'
export type { ComposerOverride } from '../logics/composerOverrideLogic'
export { useComposerOverride } from '../hooks/useComposerOverride'
export type { UseComposerOverrideOptions } from '../hooks/useComposerOverride'
// The standing "act via tool calls" instruction the sidebar surfaces attach while the user watches a
// run — the prompt-side half of `useMcpToolApplyBack` (hidden from chips, deduped once per task).
export { AGENT_TOOL_APPLY_BACK_CONTEXT_ITEM, wrapWithPosthogContext } from '../utils/posthogContextBlock'

// --- User-picked context (the composer's @-affordance, headless half) ---
// `contextPickerLogic` turns a selection into a pick, and `chatContextLogic` combines picks with the rest of a
// chat's context; the `AttachedContextBar` component (Tier 2 `api/primitives`) is the prepackaged UI.
export { chatContextLogic, chatSendItems } from '../logics/chatContextLogic'
export { contextPickerLogic, taxonomicItemToAttachedContext } from '../logics/contextPickerLogic'
export type { PickableTaxonomicItem } from '../logics/contextPickerLogic'

// --- Tool-stream event bus + subscription hook (headless) ---
// `runStreamLogic` publishes tool-call lifecycle events (resolved names) plus turn-complete and
// run-terminal events; subscribe to react when the agent invokes a specific tool.
// `useToolStreamListener` registers a subscription for a mount's life.
export { toolStreamEventsLogic } from '../logics/toolStreamEventsLogic'
export type { ToolStreamSubscription } from '../logics/toolStreamEventsLogic'
export { useToolStreamListener } from '../hooks/useToolStream'
export type { UseToolStreamListenerOptions } from '../hooks/useToolStream'
export { resolveToolCall } from '../utils/toolResolver'
export { getToolOutputRecord } from '../utils/getToolOutputRecord'

// --- Foreground stream registry + MCP tool apply-back (headless) ---
// `foregroundStreamLogic` marks the single stream rendered in the side panel the user is watching; a
// surface registers via `useForegroundStream`. `useMcpToolApplyBack` reacts to that foreground run's
// MCP tool calls (foreground-gated, replay-excluded) so a scene can apply a generated query back when
// its tool completes or at the end of the turn.
export { foregroundStreamLogic } from '../logics/foregroundStreamLogic'
export { useForegroundStream } from '../hooks/useForegroundStream'
export { useMcpToolApplyBack } from '../hooks/useMcpToolApplyBack'
export type { ApplyOn, McpToolApplyContext, UseMcpToolApplyBackOptions } from '../hooks/useMcpToolApplyBack'

// --- Composer seed hand-off (headless) ---
// A one-shot store that lets a host seed a not-yet-mounted composer with an initial prompt (optionally
// auto-submitting it); the paired `taskTrackerSceneLogic` consumes it on mount or when it arrives.
export { composerSeedLogic } from '../logics/composerSeedLogic'
export { composerAttachmentsLogic } from '../logics/composerAttachmentsLogic'
export { ATTACHMENT_MAX_SIZE_BYTES } from '../utils/attachments'
export type { ComposerSeed, ComposerSeedLogicProps } from '../logics/composerSeedLogic'

// The staff debug-logs preference, for hosts that render their own overflow menu around it.
export { debugLogsLogic } from '../logics/debugLogsLogic'

// One task's record, with its archive (delete) loader, for hosts that act on a task outside the runner scene.
export { taskLogic } from '../logics/taskLogic'