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.

chore(phai): home sandbox renderer in products/posthog_ai/frontend (#65435)

Georgiy Tarasov44ed873df817
diff --git a/.oxlintrc.json b/.oxlintrc.json
index 8e78304941af..d969d1e06e6d 100644
--- a/.oxlintrc.json
+++ b/.oxlintrc.json
@@ -291,6 +291,57 @@
}
]
}
+ },
+ {
+ "files": ["products/posthog_ai/frontend/sandbox/**/*.{ts,tsx}"],
+ "rules": {
+ "no-restricted-imports": [
+ "error",
+ {
+ "patterns": [
+ {
+ "group": ["**/ee/api/conversation", "**/ee/api/conversation/**"],
+ "message": "Sandbox renderer must not import the conversation API. Use products/tasks/frontend/generated/api for task data."
+ },
+ {
+ "group": ["**/api.conversations*"],
+ "message": "Sandbox renderer must not import api.conversations. Use api.tasks.* and products/tasks/frontend/generated/api."
+ }
+ ],
+ "paths": [
+ {
+ "name": "scenes/max/maxThreadLogic",
+ "message": "Sandbox module must not import maxThreadLogic (conversation orchestration). Forbidden by design boundary."
+ },
+ {
+ "name": "scenes/max/maxContextLogic",
+ "message": "Sandbox module must not import maxContextLogic. Forbidden by design boundary."
+ },
+ {
+ "name": "scenes/max/maxLogic",
+ "message": "Sandbox module must not import maxLogic. Forbidden by design boundary."
+ },
+ {
+ "name": "scenes/max/maxGlobalLogic",
+ "message": "Sandbox module must not import maxGlobalLogic. Forbidden by design boundary."
+ },
+ {
+ "name": "scenes/max/maxTypes",
+ "message": "Avoid importing maxTypes from the sandbox module. Extract needed types (e.g. SandboxToolCallMessage) into products/posthog_ai/frontend/sandbox/types/ instead.",
+ "allowTypeImports": true
+ },
+ {
+ "name": "dayjs",
+ "message": "Do not directly import dayjs. Only import the dayjs exported from 'lib/dayjs'."
+ },
+ {
+ "name": "~/queries/schema",
+ "message": "Import from 'queries/schema/schema-foo' to avoid Webpack/Sucrase enum export issues."
+ }
+ ]
+ }
+ ]
+ }
}
]
}
diff --git a/frontend/package.json b/frontend/package.json
index 133c2ee1a02b..6f18a413d0e2 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -108,6 +108,7 @@
"@posthog/products-notebooks": "workspace:*",
"@posthog/products-persons": "workspace:*",
"@posthog/products-platform-features": "workspace:*",
+ "@posthog/products-posthog-ai": "workspace:*",
"@posthog/products-product-analytics": "workspace:*",
"@posthog/products-replay": "workspace:*",
"@posthog/products-replay-vision": "workspace:*",
diff --git a/frontend/src/scenes/inbox/components/detail/AgentRunDetail.tsx b/frontend/src/scenes/inbox/components/detail/AgentRunDetail.tsx
index d23df59c1e91..7f707b9d3e06 100644
--- a/frontend/src/scenes/inbox/components/detail/AgentRunDetail.tsx
+++ b/frontend/src/scenes/inbox/components/detail/AgentRunDetail.tsx
@@ -18,10 +18,9 @@ import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'
import { SignalNode } from 'scenes/debug/signals/types'
import { maxGlobalLogic } from 'scenes/max/maxGlobalLogic'
import { SANDBOX_BIND_TASK_PARAM } from 'scenes/max/maxLogic'
-import { SandboxRunViewer } from 'scenes/max/sandbox/components/SandboxRunViewer'
-import { isTerminalRunStatus } from 'scenes/max/sandboxStreamLogic'
import { urls } from 'scenes/urls'
+import { isTerminalRunStatus, SandboxRunViewer } from 'products/posthog_ai/frontend/sandbox'
import { Task, TaskRunStatus } from 'products/tasks/frontend/types'
import { inboxReportDetailLogic } from '../../logics/inboxReportDetailLogic'
diff --git a/frontend/src/scenes/inbox/components/detail/ArtefactTaskRun.tsx b/frontend/src/scenes/inbox/components/detail/ArtefactTaskRun.tsx
index 793dcfcfb556..ebb3bd9a3325 100644
--- a/frontend/src/scenes/inbox/components/detail/ArtefactTaskRun.tsx
+++ b/frontend/src/scenes/inbox/components/detail/ArtefactTaskRun.tsx
@@ -5,9 +5,8 @@ import { LemonTag } from '@posthog/lemon-ui'
import api from 'lib/api'
import { identifierToHuman } from 'lib/utils/strings'
-import { SandboxRunViewer } from 'scenes/max/sandbox/components/SandboxRunViewer'
-import { isTerminalRunStatus } from 'scenes/max/sandboxStreamLogic'
+import { isTerminalRunStatus, SandboxRunViewer } from 'products/posthog_ai/frontend/sandbox'
import { Task, TaskRunStatus } from 'products/tasks/frontend/types'
import { isCustomAgentTaskRun, taskRunTypeLabel, TaskRunArtefactContent } from './artefactTypes'
diff --git a/frontend/src/scenes/max/FeedbackPrompt.tsx b/frontend/src/scenes/max/FeedbackPrompt.tsx
index 38787a36c566..be6e02274ab5 100644
--- a/frontend/src/scenes/max/FeedbackPrompt.tsx
+++ b/frontend/src/scenes/max/FeedbackPrompt.tsx
@@ -8,8 +8,9 @@ import { LemonButton, LemonInput, LemonModal } from '@posthog/lemon-ui'
import { SupportForm } from 'lib/components/Support/SupportForm'
import { supportLogic } from 'lib/components/Support/supportLogic'
+import { MessageTemplate } from 'products/posthog_ai/frontend/sandbox/messages/MessageTemplate'
+
import { feedbackPromptLogic } from './feedbackPromptLogic'
-import { MessageTemplate } from './messages/MessageTemplate'
import { captureFeedback } from './utils'
interface FeedbackPromptProps {
diff --git a/frontend/src/scenes/max/Thread.tsx b/frontend/src/scenes/max/Thread.tsx
index 7e3291066629..19f635b83e91 100644
--- a/frontend/src/scenes/max/Thread.tsx
+++ b/frontend/src/scenes/max/Thread.tsx
@@ -64,32 +64,33 @@ import { DataVisualizationNode, InsightVizNode } from '~/queries/schema/schema-g
import { isDataVisualizationNode, isHogQLQuery } from '~/queries/utils'
import { PendingApproval, Region } from '~/types'
+import { SandboxContextUsage } from 'products/posthog_ai/frontend/sandbox/components/SandboxContextUsage'
+import { SandboxResourcesBar } from 'products/posthog_ai/frontend/sandbox/components/SandboxResourcesBar'
+import { SandboxThreadView } from 'products/posthog_ai/frontend/sandbox/components/SandboxThreadView'
+import { MarkdownMessage } from 'products/posthog_ai/frontend/sandbox/MarkdownMessage'
+import { AssistantFailureMessage } from 'products/posthog_ai/frontend/sandbox/messages/AssistantFailureMessage'
+import { MessageTemplate } from 'products/posthog_ai/frontend/sandbox/messages/MessageTemplate'
+import { ReasoningAnswer } from 'products/posthog_ai/frontend/sandbox/messages/ReasoningAnswer'
+import { sandboxStreamLogic } from 'products/posthog_ai/frontend/sandbox/sandboxStreamLogic'
+import { getThinkingMessageFromResponse } from 'products/posthog_ai/frontend/sandbox/utils/thinkingMessages'
import { LogEntry } from 'products/tasks/frontend/lib/parse-logs'
import { LangGraphActivity, ShimmeringContent } from './components/Activity'
import { FeedbackDisplay } from './components/FeedbackDisplay'
import { MaxWebAnalyticsNudge } from './components/MaxWebAnalyticsNudge'
-import { SandboxContextUsage } from './components/SandboxContextUsage'
-import { SandboxResourcesBar } from './components/SandboxResourcesBar'
import { ContextSummary } from './Context'
import { DangerousOperationApprovalCard } from './DangerousOperationApprovalCard'
import { FeedbackPrompt } from './FeedbackPrompt'
import { maxMessageRatingsLogic } from './logics/maxMessageRatingsLogic'
-import { MarkdownMessage } from './MarkdownMessage'
import { EnhancedToolCall, ToolRegistration, getToolDefinitionFromToolCall } from './max-constants'
import { maxGlobalLogic } from './maxGlobalLogic'
import { ThreadMessage, maxLogic } from './maxLogic'
import { maxThreadLogic } from './maxThreadLogic'
-import { AssistantFailureMessage } from './messages/AssistantFailureMessage'
-import { MessageTemplate } from './messages/MessageTemplate'
import { MultiQuestionFormRecap } from './messages/MultiQuestionForm'
import { NotebookArtifactAnswer } from './messages/NotebookArtifactAnswer'
-import { ReasoningAnswer } from './messages/ReasoningAnswer'
import { SessionSummarizationProgress } from './messages/SessionSummarizationProgress'
import { RecordingsWidget, isRenderableUIPayloadTool } from './messages/UIPayloadAnswer'
import { VisualizationArtifact } from './messages/VisualizationArtifact'
-import { SandboxThreadView } from './sandbox/components/SandboxThreadView'
-import { sandboxStreamLogic } from './sandboxStreamLogic'
import { MAX_SLASH_COMMANDS, SlashCommandName } from './slash-commands'
import { TicketPrompt } from './TicketPrompt'
import { getTicketPromptData, getTicketSummaryData, isTicketConfirmationMessage } from './ticketUtils'
@@ -108,7 +109,6 @@ import {
isVisualizationArtifactContent,
visualizationTypeToQuery,
} from './utils'
-import { getThinkingMessageFromResponse } from './utils/thinkingMessages'
// Helper function to check if a message is an error or failure
function isErrorMessage(message: ThreadMessage): boolean {
diff --git a/frontend/src/scenes/max/components/Activity/LangGraphActivity.tsx b/frontend/src/scenes/max/components/Activity/LangGraphActivity.tsx
index 130c53e1f3dc..ae0e69f48dd5 100644
--- a/frontend/src/scenes/max/components/Activity/LangGraphActivity.tsx
+++ b/frontend/src/scenes/max/components/Activity/LangGraphActivity.tsx
@@ -4,10 +4,11 @@ import { CodeSnippet, Language } from 'lib/components/CodeSnippet/CodeSnippet'
import { TaskExecutionStatus as ExecutionStatus } from '~/queries/schema/schema-assistant-messages'
-import { MarkdownMessage } from '../../MarkdownMessage'
+import { Activity, ActivityToggleSection } from 'products/posthog_ai/frontend/sandbox/ActivityPrimitives'
+import { MarkdownMessage } from 'products/posthog_ai/frontend/sandbox/MarkdownMessage'
+
import type { EnhancedToolCall } from '../../max-constants'
import { SummarizeSessionsWidget, UIPayloadAnswer, isRenderableUIPayloadTool } from '../../messages/UIPayloadAnswer'
-import { Activity, ActivityToggleSection } from './ActivityPrimitives'
export function LangGraphActivity({
id,
diff --git a/frontend/src/scenes/max/components/Activity/index.ts b/frontend/src/scenes/max/components/Activity/index.ts
index 1781e41e3505..f06b613e99dc 100644
--- a/frontend/src/scenes/max/components/Activity/index.ts
+++ b/frontend/src/scenes/max/components/Activity/index.ts
@@ -6,7 +6,7 @@ export {
ActivitySubsteps,
ActivityToggleSection,
ShimmeringContent,
-} from './ActivityPrimitives'
-export type { ActivityStatus } from './ActivityPrimitives'
+} from 'products/posthog_ai/frontend/sandbox/ActivityPrimitives'
+export type { ActivityStatus } from 'products/posthog_ai/frontend/sandbox/ActivityPrimitives'
export { LangGraphActivity } from './LangGraphActivity'
-export { SandboxActivity } from './SandboxActivity'
+export { SandboxActivity } from 'products/posthog_ai/frontend/sandbox/SandboxActivity'
diff --git a/frontend/src/scenes/max/components/InputFormArea.tsx b/frontend/src/scenes/max/components/InputFormArea.tsx
index 4748ac207c2b..f669f50df373 100644
--- a/frontend/src/scenes/max/components/InputFormArea.tsx
+++ b/frontend/src/scenes/max/components/InputFormArea.tsx
@@ -11,12 +11,17 @@ import {
MultiQuestionFormQuestion,
} from '~/queries/schema/schema-assistant-messages'
-import { MarkdownMessage } from '../MarkdownMessage'
+import {
+ MultiFieldQuestion,
+ QuestionField,
+ isFieldValid,
+} from 'products/posthog_ai/frontend/sandbox/components/QuestionField'
+import { SandboxPermissionInput } from 'products/posthog_ai/frontend/sandbox/components/SandboxPermissionInput'
+import { SandboxQuestionInput } from 'products/posthog_ai/frontend/sandbox/components/SandboxQuestionInput'
+import { MarkdownMessage } from 'products/posthog_ai/frontend/sandbox/MarkdownMessage'
+
import { maxThreadLogic } from '../maxThreadLogic'
import { Option, OptionSelector } from './OptionSelector'
-import { MultiFieldQuestion, QuestionField, isFieldValid } from './QuestionField'
-import { SandboxPermissionInput } from './SandboxPermissionInput'
-import { SandboxQuestionInput } from './SandboxQuestionInput'
function isQuestionComplete(
q: MultiQuestionFormQuestion,
diff --git a/frontend/src/scenes/max/components/MaxWebAnalyticsNudge.tsx b/frontend/src/scenes/max/components/MaxWebAnalyticsNudge.tsx
index d2ebc1940a68..42ea44f7a7ca 100644
--- a/frontend/src/scenes/max/components/MaxWebAnalyticsNudge.tsx
+++ b/frontend/src/scenes/max/components/MaxWebAnalyticsNudge.tsx
@@ -4,10 +4,11 @@ import { LemonButton } from '@posthog/lemon-ui'
import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'
+import { MessageTemplate } from 'products/posthog_ai/frontend/sandbox/messages/MessageTemplate'
+
import { maxWebAnalyticsNudgeLogic } from '../logics/maxWebAnalyticsNudgeLogic'
import { maxLogic, ThreadMessage } from '../maxLogic'
import { maxThreadLogic } from '../maxThreadLogic'
-import { MessageTemplate } from '../messages/MessageTemplate'
export interface MaxWebAnalyticsNudgeProps {
message: ThreadMessage
diff --git a/frontend/src/scenes/max/maxThreadLogic.test.ts b/frontend/src/scenes/max/maxThreadLogic.test.ts
index bddbeb2a1f86..af085bfd84d0 100644
--- a/frontend/src/scenes/max/maxThreadLogic.test.ts
+++ b/frontend/src/scenes/max/maxThreadLogic.test.ts
@@ -30,13 +30,14 @@ import {
import { initKeaTests } from '~/test/init'
import { Conversation, ConversationDetail, ConversationStatus, ConversationType } from '~/types'
+import { sandboxStreamLogic } from 'products/posthog_ai/frontend/sandbox/sandboxStreamLogic'
+
import { EnhancedToolCall, TOOL_DEFINITIONS } from './max-constants'
import { maxContextLogic } from './maxContextLogic'
import { maxGlobalLogic } from './maxGlobalLogic'
import { maxLogic } from './maxLogic'
import { MAX_DASHBOARD_CONTEXT_WAIT_MS, maxThreadLogic } from './maxThreadLogic'
import { MaxContextType } from './maxTypes'
-import { sandboxStreamLogic } from './sandboxStreamLogic'
import {
MOCK_CONVERSATION,
MOCK_CONVERSATION_ID,
diff --git a/frontend/src/scenes/max/maxThreadLogic.tsx b/frontend/src/scenes/max/maxThreadLogic.tsx
index f095e0ef7aec..8ad80e6bf390 100644
--- a/frontend/src/scenes/max/maxThreadLogic.tsx
+++ b/frontend/src/scenes/max/maxThreadLogic.tsx
@@ -64,6 +64,12 @@ import {
SidePanelTab,
} from '~/types'
+import {
+ SANDBOX_INITIAL_PERMISSION_MODE,
+ isTerminalRunStatus,
+ sandboxStreamLogic,
+} from 'products/posthog_ai/frontend/sandbox/sandboxStreamLogic'
+import { getRandomThinkingMessage } from 'products/posthog_ai/frontend/sandbox/utils/thinkingMessages'
import { LogEntry, parseLogEvent } from 'products/tasks/frontend/lib/parse-logs'
import { handsFreeLogic } from './handsFreeLogic'
@@ -82,7 +88,6 @@ import { SCENE_PANEL_ID, SIDE_PANEL_PANEL_ID, maxLogic } from './maxLogic'
import type { maxThreadLogicType } from './maxThreadLogicType'
import { AttachedContext, MaxUIContext } from './maxTypes'
import { posthogAiContextLogic } from './posthogAiContextLogic'
-import { SANDBOX_INITIAL_PERMISSION_MODE, isTerminalRunStatus, sandboxStreamLogic } from './sandboxStreamLogic'
import { MAX_SLASH_COMMANDS, SlashCommand } from './slash-commands'
import { getToolCallDescriptionAndWidgetDef } from './toolCallDisplay'
import {
@@ -94,7 +99,6 @@ import {
isSubagentUpdateEvent,
threadEndsWithMultiQuestionForm,
} from './utils'
-import { getRandomThinkingMessage } from './utils/thinkingMessages'
// On a dashboard, the first message can fire before the dashboard has loaded, when
// dashboardLogic.maxContext still returns []. askMax waits (bounded) for the load so the
diff --git a/frontend/src/scenes/max/maxTypes.ts b/frontend/src/scenes/max/maxTypes.ts
index 2602e88ea203..716cedcac2e6 100644
--- a/frontend/src/scenes/max/maxTypes.ts
+++ b/frontend/src/scenes/max/maxTypes.ts
@@ -243,34 +243,9 @@ export function isAgentMode(mode: unknown): mode is AgentMode {
return typeof mode === 'string' && Object.values(AgentMode).includes(mode as AgentMode)
}
-/**
- * The shape `sandboxToolRegistry` renderers receive — raw `ToolInvocation` stream state plus
- * renderer-facing fields resolved at render time.
- */
-export interface SandboxToolCallMessage {
- /** Stable id — the tool call id. */
- id: string
- /** Registry lookup key — the inner tool name for single-exec calls, otherwise the wire tool name. */
- resolvedKey: string
- rawServerName: string
- rawToolName: string
- innerToolName?: string
- /** Stable SDK tool name from `_meta.claudeCode.toolName` — set for Claude built-ins. */
- claudeToolName?: string
- /** rawInput at `tool_call` (for `exec`, includes the wrapper `{ command }`). */
- rawInput: Record<string, unknown>
- /** JSON-parsed inner args when `innerToolName` is set. */
- innerInput?: Record<string, unknown>
- rawOutput?: unknown
- /** Accumulated ACP `content[]`. */
- content: unknown[]
- status: 'pending' | 'in_progress' | 'completed' | 'failed'
- title?: string
- kind?: string
- /** ACP `toolCall.locations` — file paths (with optional line) the tool touched. */
- locations?: { path: string; line?: number }[]
- error?: { message?: string } | null
-}
+// `SandboxToolCallMessage` now lives with the relocated sandbox renderer. Re-exported here so
+// the frozen LangGraph path and any in-flight branches keep resolving it from `maxTypes`.
+export type { SandboxToolCallMessage } from 'products/posthog_ai/frontend/sandbox/types/sandboxToolTypes'
/**
* Flat context attachment sent to the sandbox agent runtime (`agent_runtime === 'sandbox'`).
diff --git a/frontend/src/scenes/max/messages/MultiQuestionForm.tsx b/frontend/src/scenes/max/messages/MultiQuestionForm.tsx
index 484fa7a68f3a..f940ba511699 100644
--- a/frontend/src/scenes/max/messages/MultiQuestionForm.tsx
+++ b/frontend/src/scenes/max/messages/MultiQuestionForm.tsx
@@ -2,7 +2,7 @@ import { IconCheck, IconX } from '@posthog/icons'
import { MultiQuestionForm as MultiQuestionFormType } from '~/queries/schema/schema-assistant-messages'
-import { MessageTemplate } from './MessageTemplate'
+import { MessageTemplate } from 'products/posthog_ai/frontend/sandbox/messages/MessageTemplate'
interface MultiQuestionFormRecapProps {
form: MultiQuestionFormType
diff --git a/frontend/src/scenes/max/messages/NotebookArtifactAnswer.tsx b/frontend/src/scenes/max/messages/NotebookArtifactAnswer.tsx
index 96c6e9744f12..9648c6c8fad0 100644
--- a/frontend/src/scenes/max/messages/NotebookArtifactAnswer.tsx
+++ b/frontend/src/scenes/max/messages/NotebookArtifactAnswer.tsx
@@ -35,11 +35,12 @@ import { NotebookArtifactContent } from '~/queries/schema/schema-assistant-messa
import { DataVisualizationNode, InsightVizNode, NodeKind } from '~/queries/schema/schema-general'
import { isFunnelsQuery, isHogQLQuery, isInsightVizNode } from '~/queries/utils'
-import { MarkdownMessage } from '../MarkdownMessage'
+import { MarkdownMessage } from 'products/posthog_ai/frontend/sandbox/MarkdownMessage'
+import { MessageTemplate } from 'products/posthog_ai/frontend/sandbox/messages/MessageTemplate'
+
import { MessageStatus } from '../maxLogic'
import { castAssistantQuery, visualizationTypeToQuery } from '../utils'
import { markdownToTiptap } from '../utils/markdownToTiptap'
-import { MessageTemplate } from './MessageTemplate'
interface NotebookArtifactAnswerProps {
content: NotebookArtifactContent
diff --git a/frontend/src/scenes/max/messages/UIPayloadAnswer.tsx b/frontend/src/scenes/max/messages/UIPayloadAnswer.tsx
index ae33580bde2b..fc138b7d0164 100644
--- a/frontend/src/scenes/max/messages/UIPayloadAnswer.tsx
+++ b/frontend/src/scenes/max/messages/UIPayloadAnswer.tsx
@@ -31,6 +31,7 @@ import {
issueQueryOptionsLogic,
} from 'products/error_tracking/frontend/components/IssueQueryOptions/issueQueryOptionsLogic'
import { ERROR_TRACKING_SCENE_LOGIC_KEY } from 'products/error_tracking/frontend/scenes/ErrorTrackingScene/errorTrackingSceneLogic'
+import { MessageTemplate } from 'products/posthog_ai/frontend/sandbox/messages/MessageTemplate'
import { isDangerousOperationResponse, normalizeDangerousOperationResponse } from '../approvalOperationUtils'
import { DangerousOperationApprovalCard } from '../DangerousOperationApprovalCard'
@@ -38,7 +39,6 @@ import { maxLogic } from '../maxLogic'
import { ErrorTrackingFiltersSummary } from './ErrorTrackingFiltersSummary'
import { ErrorTrackingIssueCard } from './ErrorTrackingIssueCard'
import { MaxErrorTrackingWidgetLogicProps, maxErrorTrackingWidgetLogic } from './maxErrorTrackingWidgetLogic'
-import { MessageTemplate } from './MessageTemplate'
import { RecordingsFiltersSummary } from './RecordingsFiltersSummary'
export const RENDERABLE_UI_PAYLOAD_TOOLS: AssistantTool[] = [
diff --git a/frontend/src/scenes/max/messages/VisualizationWidget.tsx b/frontend/src/scenes/max/messages/VisualizationWidget.tsx
index 490403654738..fb3f142fd8af 100644
--- a/frontend/src/scenes/max/messages/VisualizationWidget.tsx
+++ b/frontend/src/scenes/max/messages/VisualizationWidget.tsx
@@ -24,8 +24,9 @@ import { QueryContext } from '~/queries/types'
import { isFunnelsQuery, isHogQLQuery, isInsightVizNode } from '~/queries/utils'
import { InsightShortId } from '~/types'
+import { MessageTemplate } from 'products/posthog_ai/frontend/sandbox/messages/MessageTemplate'
+
import { visualizationTypeToQuery } from '../utils'
-import { MessageTemplate } from './MessageTemplate'
const QUERY_CONTEXT_POSTHOG_AI: QueryContext = { limitContext: 'posthog_ai' } as const
diff --git a/frontend/src/scenes/max/messages/adapters/CreateInsightWidget.tsx b/frontend/src/scenes/max/messages/adapters/CreateInsightWidget.tsx
index 704209b75b01..3827814f0794 100644
--- a/frontend/src/scenes/max/messages/adapters/CreateInsightWidget.tsx
+++ b/frontend/src/scenes/max/messages/adapters/CreateInsightWidget.tsx
@@ -1,6 +1,7 @@
-import { GenericMcpToolRenderer } from '../../sandbox/components/tool/GenericMcpToolRenderer'
-import { SandboxDataToolRow } from '../../sandbox/components/tool/SandboxDataToolRow'
-import type { SandboxToolRendererProps } from '../../sandbox/sandboxToolRegistry'
+import { GenericMcpToolRenderer } from 'products/posthog_ai/frontend/sandbox/components/tool/GenericMcpToolRenderer'
+import { SandboxDataToolRow } from 'products/posthog_ai/frontend/sandbox/components/tool/SandboxDataToolRow'
+import type { SandboxToolRendererProps } from 'products/posthog_ai/frontend/sandbox/sandboxToolRegistry'
+
import { VisualizationWidget, getArtifactOpenTarget } from '../VisualizationWidget'
import { extractVisualizationArtifact } from './extractors'
diff --git a/frontend/src/scenes/max/messages/adapters/CreateNotebookWidget.test.tsx b/frontend/src/scenes/max/messages/adapters/CreateNotebookWidget.test.tsx
index b087c8130fc3..f03e4b38ac67 100644
--- a/frontend/src/scenes/max/messages/adapters/CreateNotebookWidget.test.tsx
+++ b/frontend/src/scenes/max/messages/adapters/CreateNotebookWidget.test.tsx
@@ -1,5 +1,9 @@
+import {
+ lookupSandboxToolRenderer,
+ sandboxToolRegistry,
+} from 'products/posthog_ai/frontend/sandbox/sandboxToolRegistry'
+
import type { SandboxToolCallMessage } from '../../maxTypes'
-import { lookupSandboxToolRenderer, sandboxToolRegistry } from '../../sandbox/sandboxToolRegistry'
import { extractNotebook } from './CreateNotebookWidget'
function toolMessage(rawOutput: unknown, innerInput?: Record<string, unknown>): SandboxToolCallMessage {
diff --git a/frontend/src/scenes/max/messages/adapters/CreateNotebookWidget.tsx b/frontend/src/scenes/max/messages/adapters/CreateNotebookWidget.tsx
index c1b3b6a5a7af..b74fb078fbb0 100644
--- a/frontend/src/scenes/max/messages/adapters/CreateNotebookWidget.tsx
+++ b/frontend/src/scenes/max/messages/adapters/CreateNotebookWidget.tsx
@@ -4,9 +4,9 @@ import { LemonButton } from '@posthog/lemon-ui'
import { IconOpenInNew } from 'lib/lemon-ui/icons'
import { urls } from 'scenes/urls'
-import { GenericMcpToolRenderer } from '../../sandbox/components/tool/GenericMcpToolRenderer'
-import { SandboxDataToolRow } from '../../sandbox/components/tool/SandboxDataToolRow'
-import type { SandboxToolRendererProps } from '../../sandbox/sandboxToolRegistry'
+import { GenericMcpToolRenderer } from 'products/posthog_ai/frontend/sandbox/components/tool/GenericMcpToolRenderer'
+import { SandboxDataToolRow } from 'products/posthog_ai/frontend/sandbox/components/tool/SandboxDataToolRow'
+import type { SandboxToolRendererProps } from 'products/posthog_ai/frontend/sandbox/sandboxToolRegistry'
/** The notebook fields the widget renders, pulled from the REST payload. */
export interface NotebookExtraction {
diff --git a/frontend/src/scenes/max/messages/adapters/EditDiffRenderer.tsx b/frontend/src/scenes/max/messages/adapters/EditDiffRenderer.tsx
index 91442d0dd7db..fbdfd0d83296 100644
--- a/frontend/src/scenes/max/messages/adapters/EditDiffRenderer.tsx
+++ b/frontend/src/scenes/max/messages/adapters/EditDiffRenderer.tsx
@@ -8,11 +8,16 @@ import MonacoDiffEditor from 'lib/components/MonacoDiffEditor'
import { themeLogic } from '~/layout/navigation-3000/themeLogic'
-import { GenericMcpToolRenderer } from '../../sandbox/components/tool/GenericMcpToolRenderer'
-import { SandboxFilePath } from '../../sandbox/components/tool/SandboxFilePath'
-import { SandboxToolActivity } from '../../sandbox/components/tool/SandboxToolActivity'
-import type { SandboxToolRendererProps } from '../../sandbox/sandboxToolRegistry'
-import { findAllDiffContent, getDiffStats, languageFromPath, type ToolCallDiffContent } from '../../toolDiffContent'
+import { GenericMcpToolRenderer } from 'products/posthog_ai/frontend/sandbox/components/tool/GenericMcpToolRenderer'
+import { SandboxFilePath } from 'products/posthog_ai/frontend/sandbox/components/tool/SandboxFilePath'
+import { SandboxToolActivity } from 'products/posthog_ai/frontend/sandbox/components/tool/SandboxToolActivity'
+import type { SandboxToolRendererProps } from 'products/posthog_ai/frontend/sandbox/sandboxToolRegistry'
+import {
+ findAllDiffContent,
+ getDiffStats,
+ languageFromPath,
+ type ToolCallDiffContent,
+} from 'products/posthog_ai/frontend/sandbox/toolDiffContent'
// A stripped-down, unified diff that reads cleanly embedded in a chat card — mirrors the look of the
// sandbox agent's own diff UI (unified style, soft-wrapped, compact font, no editor chrome). Module-level
diff --git a/frontend/src/scenes/max/messages/adapters/ErrorTrackingWidget.tsx b/frontend/src/scenes/max/messages/adapters/ErrorTrackingWidget.tsx
index ada433bb8fb4..0116288ef9c6 100644
--- a/frontend/src/scenes/max/messages/adapters/ErrorTrackingWidget.tsx
+++ b/frontend/src/scenes/max/messages/adapters/ErrorTrackingWidget.tsx
@@ -1,6 +1,7 @@
-import { GenericMcpToolRenderer } from '../../sandbox/components/tool/GenericMcpToolRenderer'
-import { SandboxDataToolRow } from '../../sandbox/components/tool/SandboxDataToolRow'
-import type { SandboxToolRendererProps } from '../../sandbox/sandboxToolRegistry'
+import { GenericMcpToolRenderer } from 'products/posthog_ai/frontend/sandbox/components/tool/GenericMcpToolRenderer'
+import { SandboxDataToolRow } from 'products/posthog_ai/frontend/sandbox/components/tool/SandboxDataToolRow'
+import type { SandboxToolRendererProps } from 'products/posthog_ai/frontend/sandbox/sandboxToolRegistry'
+
import { ErrorTrackingFiltersWidget } from '../UIPayloadAnswer'
import { extractErrorTrackingResponse } from './extractors'
diff --git a/frontend/src/scenes/max/messages/adapters/QueryWidget.tsx b/frontend/src/scenes/max/messages/adapters/QueryWidget.tsx
index a286af0aaa9b..8565b6f32976 100644
--- a/frontend/src/scenes/max/messages/adapters/QueryWidget.tsx
+++ b/frontend/src/scenes/max/messages/adapters/QueryWidget.tsx
@@ -1,6 +1,7 @@
-import { GenericMcpToolRenderer } from '../../sandbox/components/tool/GenericMcpToolRenderer'
-import { SandboxDataToolRow } from '../../sandbox/components/tool/SandboxDataToolRow'
-import type { SandboxToolRendererProps } from '../../sandbox/sandboxToolRegistry'
+import { GenericMcpToolRenderer } from 'products/posthog_ai/frontend/sandbox/components/tool/GenericMcpToolRenderer'
+import { SandboxDataToolRow } from 'products/posthog_ai/frontend/sandbox/components/tool/SandboxDataToolRow'
+import type { SandboxToolRendererProps } from 'products/posthog_ai/frontend/sandbox/sandboxToolRegistry'
+
import { VisualizationWidget } from '../VisualizationWidget'
import { extractQueryResult } from './extractors'
diff --git a/frontend/src/scenes/max/messages/adapters/SearchSessionRecordingsWidget.tsx b/frontend/src/scenes/max/messages/adapters/SearchSessionRecordingsWidget.tsx
index 9a00e9686d13..5970cd539d3b 100644
--- a/frontend/src/scenes/max/messages/adapters/SearchSessionRecordingsWidget.tsx
+++ b/frontend/src/scenes/max/messages/adapters/SearchSessionRecordingsWidget.tsx
@@ -1,6 +1,7 @@
-import { GenericMcpToolRenderer } from '../../sandbox/components/tool/GenericMcpToolRenderer'
-import { SandboxDataToolRow } from '../../sandbox/components/tool/SandboxDataToolRow'
-import type { SandboxToolRendererProps } from '../../sandbox/sandboxToolRegistry'
+import { GenericMcpToolRenderer } from 'products/posthog_ai/frontend/sandbox/components/tool/GenericMcpToolRenderer'
+import { SandboxDataToolRow } from 'products/posthog_ai/frontend/sandbox/components/tool/SandboxDataToolRow'
+import type { SandboxToolRendererProps } from 'products/posthog_ai/frontend/sandbox/sandboxToolRegistry'
+
import { RecordingsWidget } from '../UIPayloadAnswer'
import { extractRecordingFilters } from './extractors'
diff --git a/frontend/src/scenes/max/messages/adapters/UpsertDashboardWidget.tsx b/frontend/src/scenes/max/messages/adapters/UpsertDashboardWidget.tsx
index 18eb99b447ca..6a6743df6a12 100644
--- a/frontend/src/scenes/max/messages/adapters/UpsertDashboardWidget.tsx
+++ b/frontend/src/scenes/max/messages/adapters/UpsertDashboardWidget.tsx
@@ -4,9 +4,10 @@ import { LemonButton } from '@posthog/lemon-ui'
import { IconOpenInNew } from 'lib/lemon-ui/icons'
import { urls } from 'scenes/urls'
-import { GenericMcpToolRenderer } from '../../sandbox/components/tool/GenericMcpToolRenderer'
-import { SandboxDataToolRow } from '../../sandbox/components/tool/SandboxDataToolRow'
-import type { SandboxToolRendererProps } from '../../sandbox/sandboxToolRegistry'
+import { GenericMcpToolRenderer } from 'products/posthog_ai/frontend/sandbox/components/tool/GenericMcpToolRenderer'
+import { SandboxDataToolRow } from 'products/posthog_ai/frontend/sandbox/components/tool/SandboxDataToolRow'
+import type { SandboxToolRendererProps } from 'products/posthog_ai/frontend/sandbox/sandboxToolRegistry'
+
import { extractDashboard } from './extractors'
/**
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 834b3be0a03b..a7dedd9e0c0d 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -720,6 +720,9 @@ importers:
'@posthog/products-platform-features':
specifier: workspace:*
version: link:../products/platform_features
+ '@posthog/products-posthog-ai':
+ specifier: workspace:*
+ version: link:../products/posthog_ai
'@posthog/products-product-analytics':
specifier: workspace:*
version: link:../products/product_analytics
@@ -3755,7 +3758,63 @@ importers:
products/platform_features: {}
- products/posthog_ai: {}
+ products/posthog_ai:
+ dependencies:
+ '@posthog/icons':
+ specifier: '*'
+ '@storybook/react':
+ specifier: 'catalog:'
+ '@types/react':
+ specifier: 18.3.27
+ version: 18.3.27
+ '@types/react-dom':
+ specifier: 18.3.7
+ version: 18.3.7(@types/[email protected])
+ clsx:
+ specifier: '*'
+ version: 2.1.1
+ eventsource-parser:
+ specifier: '*'
+ version: 3.0.6
+ kea:
+ specifier: 'catalog:'
+ version: 4.0.0-pre.5([email protected])
+ kea-forms:
+ specifier: 'catalog:'
+ kea-loaders:
+ specifier: 'catalog:'
+ kea-router:
+ specifier: 'catalog:'
+ kea-subscriptions:
+ specifier: 'catalog:'
+ marked:
+ specifier: '*'
+ version: 17.0.4
+ posthog-js:
+ specifier: '*'
+ version: 1.392.0
+ react:
+ specifier: 18.3.1
+ version: 18.3.1
+ react-dom:
+ specifier: 18.3.1
+ version: 18.3.1([email protected])
+ tailwind-merge:
+ specifier: '*'
+ version: 2.2.2
+ devDependencies:
+ '@testing-library/react':
+ specifier: '*'
+ kea-test-utils:
+ specifier: 'catalog:'
products/product_analytics:
dependencies:
@@ -22272,8 +22331,8 @@ packages:
resolution: {integrity: sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==}
engines: {node: '>= 10.0.0'}
- resolution: {integrity: sha512-QW9wRDW1ejd+wpJpX0uebs1y6xp45j8FLCVusA/mGCh0arjqevlfY0op/g96ShaDrGVJp1ROklk+UmE5lDezBA==}
+ resolution: {integrity: sha512-3irjQmcrnZ9qgBixI7ofa4RdO3I0BR5cS7ujUClze3gaxRloGhfdKbg626QTObdcxT/4NZhaD4pbGlftffVrKA==}
resolution: {integrity: sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==}
@@ -43502,7 +43561,7 @@ snapshots:
dependencies:
react: 18.3.1
- unlayer-types: 1.428.0
+ unlayer-types: 1.433.0
dependencies:
@@ -45812,7 +45871,7 @@ snapshots:
diff --git a/products/ai_observability/frontend/ConversationDisplay/TranscriptBubbleStream.tsx b/products/ai_observability/frontend/ConversationDisplay/TranscriptBubbleStream.tsx
index 1f013ecef19e..9455f36d0a25 100644
--- a/products/ai_observability/frontend/ConversationDisplay/TranscriptBubbleStream.tsx
+++ b/products/ai_observability/frontend/ConversationDisplay/TranscriptBubbleStream.tsx
@@ -4,7 +4,8 @@ import { useEffect, useMemo, useRef, useState } from 'react'
import { IconChevronRight } from '@posthog/icons'
import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'
-import { MessageTemplate } from 'scenes/max/messages/MessageTemplate'
+
+import { MessageTemplate } from 'products/posthog_ai/frontend/sandbox/messages/MessageTemplate'
import { CompatMessage } from '../types'
import {
diff --git a/products/posthog_ai/backend/wire_types.py b/products/posthog_ai/backend/wire_types.py
index c9f4f40eb194..bce50f37cf1d 100644
--- a/products/posthog_ai/backend/wire_types.py
+++ b/products/posthog_ai/backend/wire_types.py
@@ -3,7 +3,7 @@
The backend only ever reads persisted log entries (S3 NDJSON replayed via the products/tasks
``logs/`` path) — today to walk prior ``_posthog/user_message`` notifications for context
dedup on follow-ups. Live SSE frames are consumed exclusively by the frontend, where the full
-contract is typed at ``frontend/src/scenes/max/types/sandboxWireTypes.ts``; keep that copy in
+contract is typed at ``products/posthog_ai/frontend/sandbox/types/sandboxWireTypes.ts``; keep that copy in
mind when extending this one.
The envelope is validated with tolerant pydantic models (we co-own its shape with
diff --git a/frontend/src/scenes/max/components/Activity/ActivityPrimitives.test.tsx b/products/posthog_ai/frontend/sandbox/ActivityPrimitives.test.tsx
similarity index 100%
rename from frontend/src/scenes/max/components/Activity/ActivityPrimitives.test.tsx
rename to products/posthog_ai/frontend/sandbox/ActivityPrimitives.test.tsx
diff --git a/frontend/src/scenes/max/components/Activity/ActivityPrimitives.tsx b/products/posthog_ai/frontend/sandbox/ActivityPrimitives.tsx
similarity index 99%
rename from frontend/src/scenes/max/components/Activity/ActivityPrimitives.tsx
rename to products/posthog_ai/frontend/sandbox/ActivityPrimitives.tsx
index f0e424756d47..5ab60f4e24be 100644
--- a/frontend/src/scenes/max/components/Activity/ActivityPrimitives.tsx
+++ b/products/posthog_ai/frontend/sandbox/ActivityPrimitives.tsx
@@ -4,7 +4,7 @@ import React, { useLayoutEffect, useState } from 'react'
import { IconCheck, IconChevronRight, IconX } from '@posthog/icons'
import { LemonButton, Spinner } from '@posthog/lemon-ui'
-import { MarkdownMessage } from '../../MarkdownMessage'
+import { MarkdownMessage } from './MarkdownMessage'
export type ActivityStatus = 'pending' | 'in_progress' | 'completed' | 'failed'
diff --git a/frontend/src/scenes/max/MarkdownMessage.tsx b/products/posthog_ai/frontend/sandbox/MarkdownMessage.tsx
similarity index 100%
rename from frontend/src/scenes/max/MarkdownMessage.tsx
rename to products/posthog_ai/frontend/sandbox/MarkdownMessage.tsx
diff --git a/frontend/src/scenes/max/components/Activity/SandboxActivity.tsx b/products/posthog_ai/frontend/sandbox/SandboxActivity.tsx
similarity index 100%
rename from frontend/src/scenes/max/components/Activity/SandboxActivity.tsx
rename to products/posthog_ai/frontend/sandbox/SandboxActivity.tsx
diff --git a/frontend/src/scenes/max/sandbox/SandboxGitArtifacts.test.tsx b/products/posthog_ai/frontend/sandbox/SandboxGitArtifacts.test.tsx
similarity index 100%
rename from frontend/src/scenes/max/sandbox/SandboxGitArtifacts.test.tsx
rename to products/posthog_ai/frontend/sandbox/SandboxGitArtifacts.test.tsx
diff --git a/frontend/src/scenes/max/sandbox/SandboxPullRequestCard.tsx b/products/posthog_ai/frontend/sandbox/SandboxPullRequestCard.tsx
similarity index 100%
rename from frontend/src/scenes/max/sandbox/SandboxPullRequestCard.tsx
rename to products/posthog_ai/frontend/sandbox/SandboxPullRequestCard.tsx
diff --git a/frontend/src/scenes/max/sandbox/SandboxQuestionRenderer.test.tsx b/products/posthog_ai/frontend/sandbox/SandboxQuestionRenderer.test.tsx
similarity index 97%
rename from frontend/src/scenes/max/sandbox/SandboxQuestionRenderer.test.tsx
rename to products/posthog_ai/frontend/sandbox/SandboxQuestionRenderer.test.tsx
index b2d05a89f2e9..da338cefa431 100644
--- a/frontend/src/scenes/max/sandbox/SandboxQuestionRenderer.test.tsx
+++ b/products/posthog_ai/frontend/sandbox/SandboxQuestionRenderer.test.tsx
@@ -2,7 +2,8 @@ import '@testing-library/jest-dom'
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
-import type { SandboxToolCallMessage } from '../maxTypes'
+import type { SandboxToolCallMessage } from 'products/posthog_ai/frontend/sandbox/types/sandboxToolTypes'
+
import { SandboxQuestionRenderer } from './SandboxQuestionRenderer'
function makeMessage(overrides: Partial<SandboxToolCallMessage> = {}): SandboxToolCallMessage {
diff --git a/frontend/src/scenes/max/sandbox/SandboxQuestionRenderer.tsx b/products/posthog_ai/frontend/sandbox/SandboxQuestionRenderer.tsx
similarity index 98%
rename from frontend/src/scenes/max/sandbox/SandboxQuestionRenderer.tsx
rename to products/posthog_ai/frontend/sandbox/SandboxQuestionRenderer.tsx
index 3a4d34cfa494..ca9db1c5d0bd 100644
--- a/frontend/src/scenes/max/sandbox/SandboxQuestionRenderer.tsx
+++ b/products/posthog_ai/frontend/sandbox/SandboxQuestionRenderer.tsx
@@ -1,13 +1,13 @@
import { IconAI } from '@posthog/icons'
+import { GenericMcpToolRenderer } from './components/tool/GenericMcpToolRenderer'
+import { SandboxToolActivity } from './components/tool/SandboxToolActivity'
+import { truncateText } from './components/tool/toolContentUtils'
import {
extractSandboxQuestionAnswer,
parseSandboxQuestionAnswers,
parseSandboxQuestions,
-} from '../sandboxQuestionUtils'
-import { GenericMcpToolRenderer } from './components/tool/GenericMcpToolRenderer'
-import { SandboxToolActivity } from './components/tool/SandboxToolActivity'
-import { truncateText } from './components/tool/toolContentUtils'
+} from './sandboxQuestionUtils'
import type { SandboxToolRendererProps } from './sandboxToolRegistry'
/**
diff --git a/frontend/src/scenes/max/sandbox/SandboxRunContext.tsx b/products/posthog_ai/frontend/sandbox/SandboxRunContext.tsx
similarity index 100%
rename from frontend/src/scenes/max/sandbox/SandboxRunContext.tsx
rename to products/posthog_ai/frontend/sandbox/SandboxRunContext.tsx
diff --git a/frontend/src/scenes/max/sandbox/SandboxThreadItems.tsx b/products/posthog_ai/frontend/sandbox/SandboxThreadItems.tsx
similarity index 97%
rename from frontend/src/scenes/max/sandbox/SandboxThreadItems.tsx
rename to products/posthog_ai/frontend/sandbox/SandboxThreadItems.tsx
index 2b9af7a07c95..821c7b09c00a 100644
--- a/frontend/src/scenes/max/sandbox/SandboxThreadItems.tsx
+++ b/products/posthog_ai/frontend/sandbox/SandboxThreadItems.tsx
@@ -4,7 +4,7 @@ import { Spinner } from '@posthog/lemon-ui'
import { cn } from 'lib/utils/css-classes'
import { humanFriendlyNumber } from 'lib/utils/numbers'
-import type { ThreadItem } from '../types/sandboxStreamTypes'
+import type { ThreadItem } from './types/sandboxStreamTypes'
/** Inline `_posthog/status` item — a spinner while compacting, a generic status line otherwise. */
export function SandboxStatusItem({ item }: { item: ThreadItem }): JSX.Element {
diff --git a/frontend/src/scenes/max/components/QuestionField.test.tsx b/products/posthog_ai/frontend/sandbox/components/QuestionField.test.tsx
similarity index 100%
rename from frontend/src/scenes/max/components/QuestionField.test.tsx
rename to products/posthog_ai/frontend/sandbox/components/QuestionField.test.tsx
diff --git a/frontend/src/scenes/max/components/QuestionField.tsx b/products/posthog_ai/frontend/sandbox/components/QuestionField.tsx
similarity index 99%
rename from frontend/src/scenes/max/components/QuestionField.tsx
rename to products/posthog_ai/frontend/sandbox/components/QuestionField.tsx
index 83483d649ff7..3882d39ff1e8 100644
--- a/frontend/src/scenes/max/components/QuestionField.tsx
+++ b/products/posthog_ai/frontend/sandbox/components/QuestionField.tsx
@@ -4,11 +4,10 @@ import { IconPlus } from '@posthog/icons'
import { LemonButton, LemonCheckbox, LemonInput, LemonSelect, LemonSwitch } from '@posthog/lemon-ui'
import { LemonSlider } from 'lib/lemon-ui/LemonSlider/LemonSlider'
+import { OptionSelector, type Option } from 'scenes/max/components/OptionSelector'
import type { MultiQuestionFormField, MultiQuestionFormQuestion } from '~/queries/schema/schema-assistant-messages'
-import { OptionSelector, type Option } from './OptionSelector'
-
interface QuestionFieldProps {
question: MultiQuestionFormQuestion
value: string | string[] | undefined
diff --git a/frontend/src/scenes/max/components/SandboxApproval.test.tsx b/products/posthog_ai/frontend/sandbox/components/SandboxApproval.test.tsx
similarity index 98%
rename from frontend/src/scenes/max/components/SandboxApproval.test.tsx
rename to products/posthog_ai/frontend/sandbox/components/SandboxApproval.test.tsx
index d9d6854510e1..4b9c6559c79f 100644
--- a/frontend/src/scenes/max/components/SandboxApproval.test.tsx
+++ b/products/posthog_ai/frontend/sandbox/components/SandboxApproval.test.tsx
@@ -3,8 +3,9 @@ import '@testing-library/jest-dom'
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
import { useActions, useValues } from 'kea'
+import { SandboxModeBadge } from 'scenes/max/components/InputFormArea'
+
import type { PermissionRequestRecord, ToolInvocation } from '../types/sandboxStreamTypes'
-import { SandboxModeBadge } from './InputFormArea'
import { SandboxPermissionInput } from './SandboxPermissionInput'
jest.mock('kea', () => ({
@@ -18,7 +19,7 @@ jest.mock('use-resize-observer', () => () => ({
ref: { current: null },
}))
-jest.mock('../maxThreadLogic', () => ({
+jest.mock('scenes/max/maxThreadLogic', () => ({
maxThreadLogic: { __mock: 'maxThreadLogic' },
}))
diff --git a/frontend/src/scenes/max/components/SandboxContextUsage.tsx b/products/posthog_ai/frontend/sandbox/components/SandboxContextUsage.tsx
similarity index 100%
rename from frontend/src/scenes/max/components/SandboxContextUsage.tsx
rename to products/posthog_ai/frontend/sandbox/components/SandboxContextUsage.tsx
diff --git a/frontend/src/scenes/max/components/SandboxPermissionInput.tsx b/products/posthog_ai/frontend/sandbox/components/SandboxPermissionInput.tsx
similarity index 100%
rename from frontend/src/scenes/max/components/SandboxPermissionInput.tsx
rename to products/posthog_ai/frontend/sandbox/components/SandboxPermissionInput.tsx
diff --git a/frontend/src/scenes/max/components/SandboxQuestionInput.test.tsx b/products/posthog_ai/frontend/sandbox/components/SandboxQuestionInput.test.tsx
similarity index 100%
rename from frontend/src/scenes/max/components/SandboxQuestionInput.test.tsx
rename to products/posthog_ai/frontend/sandbox/components/SandboxQuestionInput.test.tsx
diff --git a/frontend/src/scenes/max/components/SandboxQuestionInput.tsx b/products/posthog_ai/frontend/sandbox/components/SandboxQuestionInput.tsx
similarity index 100%
rename from frontend/src/scenes/max/components/SandboxQuestionInput.tsx
rename to products/posthog_ai/frontend/sandbox/components/SandboxQuestionInput.tsx
diff --git a/frontend/src/scenes/max/components/SandboxResourcesBar.tsx b/products/posthog_ai/frontend/sandbox/components/SandboxResourcesBar.tsx
similarity index 100%
rename from frontend/src/scenes/max/components/SandboxResourcesBar.tsx
rename to products/posthog_ai/frontend/sandbox/components/SandboxResourcesBar.tsx
diff --git a/frontend/src/scenes/max/sandbox/components/SandboxRunViewer.tsx b/products/posthog_ai/frontend/sandbox/components/SandboxRunViewer.tsx
similarity index 98%
rename from frontend/src/scenes/max/sandbox/components/SandboxRunViewer.tsx
rename to products/posthog_ai/frontend/sandbox/components/SandboxRunViewer.tsx
index 04d9dfcf8ec5..14bb8b1279a4 100644
--- a/frontend/src/scenes/max/sandbox/components/SandboxRunViewer.tsx
+++ b/products/posthog_ai/frontend/sandbox/components/SandboxRunViewer.tsx
@@ -5,7 +5,7 @@ import { Spinner } from '@posthog/lemon-ui'
import { cn } from 'lib/utils/css-classes'
-import { sandboxStreamLogic } from '../../sandboxStreamLogic'
+import { sandboxStreamLogic } from '../sandboxStreamLogic'
import { SandboxThreadView } from './SandboxThreadView'
export interface SandboxRunViewerProps {
diff --git a/frontend/src/scenes/max/sandbox/components/SandboxThreadView.tsx b/products/posthog_ai/frontend/sandbox/components/SandboxThreadView.tsx
similarity index 93%
rename from frontend/src/scenes/max/sandbox/components/SandboxThreadView.tsx
rename to products/posthog_ai/frontend/sandbox/components/SandboxThreadView.tsx
index 44e225079dec..f0f8506b1022 100644
--- a/frontend/src/scenes/max/sandbox/components/SandboxThreadView.tsx
+++ b/products/posthog_ai/frontend/sandbox/components/SandboxThreadView.tsx
@@ -5,19 +5,20 @@ import { IconWrench } from '@posthog/icons'
import { TaskExecutionStatus as ExecutionStatus } from '~/queries/schema/schema-assistant-messages'
-import { SandboxActivity } from '../../components/Activity'
-import { MarkdownMessage } from '../../MarkdownMessage'
-import type { SandboxToolCallMessage } from '../../maxTypes'
-import { AssistantFailureMessage } from '../../messages/AssistantFailureMessage'
-import { MessageTemplate } from '../../messages/MessageTemplate'
-import { ReasoningAnswer } from '../../messages/ReasoningAnswer'
-import { sandboxStreamLogic } from '../../sandboxStreamLogic'
-import type { SandboxProgressStep, ThreadItem as SandboxThreadItem } from '../../types/sandboxStreamTypes'
-import { getRandomThinkingMessage } from '../../utils/thinkingMessages'
+import type { SandboxToolCallMessage } from 'products/posthog_ai/frontend/sandbox/types/sandboxToolTypes'
+
+import { MarkdownMessage } from '../MarkdownMessage'
+import { AssistantFailureMessage } from '../messages/AssistantFailureMessage'
+import { MessageTemplate } from '../messages/MessageTemplate'
+import { ReasoningAnswer } from '../messages/ReasoningAnswer'
+import { SandboxActivity } from '../SandboxActivity'
import { SandboxPullRequestCard } from '../SandboxPullRequestCard'
import { SandboxRunContext } from '../SandboxRunContext'
+import { sandboxStreamLogic } from '../sandboxStreamLogic'
import { SandboxCompactBoundaryItem, SandboxStatusItem, SandboxTaskNotificationItem } from '../SandboxThreadItems'
import { resolveToolCall } from '../sandboxToolResolver'
+import type { SandboxProgressStep, ThreadItem as SandboxThreadItem } from '../types/sandboxStreamTypes'
+import { getRandomThinkingMessage } from '../utils/thinkingMessages'
import { SandboxToolCall } from './tool/SandboxToolCall'
/** Maps a raw merged `ToolInvocation` into the flat `SandboxToolCallMessage` the registry renderers read. */
diff --git a/frontend/src/scenes/max/sandbox/components/tool/GenericMcpToolRenderer.tsx b/products/posthog_ai/frontend/sandbox/components/tool/GenericMcpToolRenderer.tsx
similarity index 100%
rename from frontend/src/scenes/max/sandbox/components/tool/GenericMcpToolRenderer.tsx
rename to products/posthog_ai/frontend/sandbox/components/tool/GenericMcpToolRenderer.tsx
diff --git a/frontend/src/scenes/max/sandbox/components/tool/SandboxDataToolRow.tsx b/products/posthog_ai/frontend/sandbox/components/tool/SandboxDataToolRow.tsx
similarity index 100%
rename from frontend/src/scenes/max/sandbox/components/tool/SandboxDataToolRow.tsx
rename to products/posthog_ai/frontend/sandbox/components/tool/SandboxDataToolRow.tsx
diff --git a/frontend/src/scenes/max/sandbox/components/tool/SandboxFilePath.tsx b/products/posthog_ai/frontend/sandbox/components/tool/SandboxFilePath.tsx
similarity index 100%
rename from frontend/src/scenes/max/sandbox/components/tool/SandboxFilePath.tsx
rename to products/posthog_ai/frontend/sandbox/components/tool/SandboxFilePath.tsx
diff --git a/frontend/src/scenes/max/sandbox/components/tool/SandboxToolActivity.test.tsx b/products/posthog_ai/frontend/sandbox/components/tool/SandboxToolActivity.test.tsx
similarity index 95%
rename from frontend/src/scenes/max/sandbox/components/tool/SandboxToolActivity.test.tsx
rename to products/posthog_ai/frontend/sandbox/components/tool/SandboxToolActivity.test.tsx
index b062fa789569..7b22cf3b12d0 100644
--- a/frontend/src/scenes/max/sandbox/components/tool/SandboxToolActivity.test.tsx
+++ b/products/posthog_ai/frontend/sandbox/components/tool/SandboxToolActivity.test.tsx
@@ -2,7 +2,8 @@ import '@testing-library/jest-dom'
import { fireEvent, render, screen } from '@testing-library/react'
-import type { SandboxToolCallMessage } from '../../../maxTypes'
+import type { SandboxToolCallMessage } from 'products/posthog_ai/frontend/sandbox/types/sandboxToolTypes'
+
import { SandboxToolActivity } from './SandboxToolActivity'
function makeMessage(overrides: Partial<SandboxToolCallMessage> = {}): SandboxToolCallMessage {
diff --git a/frontend/src/scenes/max/sandbox/components/tool/SandboxToolActivity.tsx b/products/posthog_ai/frontend/sandbox/components/tool/SandboxToolActivity.tsx
similarity index 93%
rename from frontend/src/scenes/max/sandbox/components/tool/SandboxToolActivity.tsx
rename to products/posthog_ai/frontend/sandbox/components/tool/SandboxToolActivity.tsx
index 74d57b9fdd47..76cbe5a43531 100644
--- a/frontend/src/scenes/max/sandbox/components/tool/SandboxToolActivity.tsx
+++ b/products/posthog_ai/frontend/sandbox/components/tool/SandboxToolActivity.tsx
@@ -2,9 +2,10 @@ import { type ReactNode } from 'react'
import { IconWarning, IconWrench } from '@posthog/icons'
-import { Activity } from '../../../components/Activity'
-import type { ActivityStatus } from '../../../components/Activity'
-import type { SandboxToolCallMessage } from '../../../maxTypes'
+import type { SandboxToolCallMessage } from 'products/posthog_ai/frontend/sandbox/types/sandboxToolTypes'
+
+import { Activity } from '../../ActivityPrimitives'
+import type { ActivityStatus } from '../../ActivityPrimitives'
import { resolveToolCallStatus } from './toolContentUtils'
export interface SandboxToolActivityProps {
diff --git a/frontend/src/scenes/max/sandbox/components/tool/SandboxToolCall.tsx b/products/posthog_ai/frontend/sandbox/components/tool/SandboxToolCall.tsx
similarity index 92%
rename from frontend/src/scenes/max/sandbox/components/tool/SandboxToolCall.tsx
rename to products/posthog_ai/frontend/sandbox/components/tool/SandboxToolCall.tsx
index 31f4a8add0c2..16fd5cab4404 100644
--- a/frontend/src/scenes/max/sandbox/components/tool/SandboxToolCall.tsx
+++ b/products/posthog_ai/frontend/sandbox/components/tool/SandboxToolCall.tsx
@@ -1,6 +1,7 @@
import { Suspense, memo } from 'react'
-import type { SandboxToolCallMessage } from '../../../maxTypes'
+import type { SandboxToolCallMessage } from 'products/posthog_ai/frontend/sandbox/types/sandboxToolTypes'
+
import { lookupSandboxToolRenderer } from '../../sandboxToolRegistry'
import { ToolCardSkeleton } from './ToolCardSkeleton'
diff --git a/frontend/src/scenes/max/sandbox/components/tool/ToolCardSkeleton.tsx b/products/posthog_ai/frontend/sandbox/components/tool/ToolCardSkeleton.tsx
similarity index 100%
rename from frontend/src/scenes/max/sandbox/components/tool/ToolCardSkeleton.tsx
rename to products/posthog_ai/frontend/sandbox/components/tool/ToolCardSkeleton.tsx
diff --git a/frontend/src/scenes/max/sandbox/components/tool/ToolOutput.tsx b/products/posthog_ai/frontend/sandbox/components/tool/ToolOutput.tsx
similarity index 100%
rename from frontend/src/scenes/max/sandbox/components/tool/ToolOutput.tsx
rename to products/posthog_ai/frontend/sandbox/components/tool/ToolOutput.tsx
diff --git a/frontend/src/scenes/max/sandbox/components/tool/builtinToolRenderers.test.tsx b/products/posthog_ai/frontend/sandbox/components/tool/builtinToolRenderers.test.tsx
similarity index 98%
rename from frontend/src/scenes/max/sandbox/components/tool/builtinToolRenderers.test.tsx
rename to products/posthog_ai/frontend/sandbox/components/tool/builtinToolRenderers.test.tsx
index 51f82410f3d2..85cffdbd8989 100644
--- a/frontend/src/scenes/max/sandbox/components/tool/builtinToolRenderers.test.tsx
+++ b/products/posthog_ai/frontend/sandbox/components/tool/builtinToolRenderers.test.tsx
@@ -2,7 +2,8 @@ import '@testing-library/jest-dom'
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
-import type { SandboxToolCallMessage } from '../../../maxTypes'
+import type { SandboxToolCallMessage } from 'products/posthog_ai/frontend/sandbox/types/sandboxToolTypes'
+
import { BuiltinToolRenderer } from './builtinToolRenderers'
import { GenericMcpToolRenderer } from './GenericMcpToolRenderer'
diff --git a/frontend/src/scenes/max/sandbox/components/tool/builtinToolRenderers.tsx b/products/posthog_ai/frontend/sandbox/components/tool/builtinToolRenderers.tsx
similarity index 99%
rename from frontend/src/scenes/max/sandbox/components/tool/builtinToolRenderers.tsx
rename to products/posthog_ai/frontend/sandbox/components/tool/builtinToolRenderers.tsx
index b793e311b435..13e784f8bbc8 100644
--- a/frontend/src/scenes/max/sandbox/components/tool/builtinToolRenderers.tsx
+++ b/products/posthog_ai/frontend/sandbox/components/tool/builtinToolRenderers.tsx
@@ -7,9 +7,9 @@ import { CodeSnippet } from 'lib/components/CodeSnippet/CodeSnippet'
// IconRobot is not exported from @posthog/icons — it lives only in the legacy lib icon set.
import { IconRobot } from 'lib/lemon-ui/icons'
-import { languageFromPath } from '../../../toolDiffContent'
import { getPostHogExecDisplay } from '../../posthogExecDisplay'
import type { SandboxToolRendererProps } from '../../sandboxToolRegistry'
+import { languageFromPath } from '../../toolDiffContent'
import { GenericMcpToolRenderer } from './GenericMcpToolRenderer'
import { SandboxFilePath } from './SandboxFilePath'
import { SandboxToolActivity } from './SandboxToolActivity'
diff --git a/frontend/src/scenes/max/sandbox/components/tool/toolContentUtils.test.ts b/products/posthog_ai/frontend/sandbox/components/tool/toolContentUtils.test.ts
similarity index 100%
rename from frontend/src/scenes/max/sandbox/components/tool/toolContentUtils.test.ts
rename to products/posthog_ai/frontend/sandbox/components/tool/toolContentUtils.test.ts
diff --git a/frontend/src/scenes/max/sandbox/components/tool/toolContentUtils.ts b/products/posthog_ai/frontend/sandbox/components/tool/toolContentUtils.ts
similarity index 98%
rename from frontend/src/scenes/max/sandbox/components/tool/toolContentUtils.ts
rename to products/posthog_ai/frontend/sandbox/components/tool/toolContentUtils.ts
index 459a7709560d..a2826e790bf0 100644
--- a/frontend/src/scenes/max/sandbox/components/tool/toolContentUtils.ts
+++ b/products/posthog_ai/frontend/sandbox/components/tool/toolContentUtils.ts
@@ -1,4 +1,4 @@
-import type { SandboxToolCallMessage } from '../../../maxTypes'
+import type { SandboxToolCallMessage } from 'products/posthog_ai/frontend/sandbox/types/sandboxToolTypes'
/** Compact single-line preview length for a generic MCP tool's input JSON. */
export const INPUT_PREVIEW_MAX_LENGTH = 60
diff --git a/products/posthog_ai/frontend/sandbox/index.ts b/products/posthog_ai/frontend/sandbox/index.ts
new file mode 100644
index 000000000000..0f717523e3ae
--- /dev/null
+++ b/products/posthog_ai/frontend/sandbox/index.ts
@@ -0,0 +1,26 @@
+// Public surface of the sandbox renderer — the conversation-agnostic PostHog AI agent-run UI.
+// PostHog AI (scenes/max), tasks, and the signals inbox consume this barrel, never deep paths.
+// This module talks to tasks only via `api.tasks.*` / `products/tasks/frontend/generated/api`
+// and must never import the conversations API or Max conversation orchestration.
+
+export { SandboxRunViewer } from './components/SandboxRunViewer'
+export type { SandboxRunViewerProps } from './components/SandboxRunViewer'
+export { SandboxThreadView } from './components/SandboxThreadView'
+
+export { sandboxStreamLogic, isTerminalRunStatus, SANDBOX_INITIAL_PERMISSION_MODE } from './sandboxStreamLogic'
+export type { SandboxStreamLogicProps, SandboxSseStatus, SandboxRunStatus } from './sandboxStreamLogic'
+
+export { SandboxPermissionInput } from './components/SandboxPermissionInput'
+export { SandboxQuestionInput } from './components/SandboxQuestionInput'
+export { SandboxResourcesBar } from './components/SandboxResourcesBar'
+export { SandboxContextUsage } from './components/SandboxContextUsage'
+
+export type {
+ ThreadItem,
+ ToolInvocation,
+ PermissionRequestRecord,
+ ContextUsage,
+ RunArtifacts,
+ SandboxProgressStep,
+} from './types/sandboxStreamTypes'
+export type { SandboxToolCallMessage } from './types/sandboxToolTypes'
diff --git a/frontend/src/scenes/max/messages/AssistantFailureMessage.test.tsx b/products/posthog_ai/frontend/sandbox/messages/AssistantFailureMessage.test.tsx
similarity index 100%
rename from frontend/src/scenes/max/messages/AssistantFailureMessage.test.tsx
rename to products/posthog_ai/frontend/sandbox/messages/AssistantFailureMessage.test.tsx
diff --git a/frontend/src/scenes/max/messages/AssistantFailureMessage.tsx b/products/posthog_ai/frontend/sandbox/messages/AssistantFailureMessage.tsx
similarity index 100%
rename from frontend/src/scenes/max/messages/AssistantFailureMessage.tsx
rename to products/posthog_ai/frontend/sandbox/messages/AssistantFailureMessage.tsx
diff --git a/frontend/src/scenes/max/messages/MessageTemplate.tsx b/products/posthog_ai/frontend/sandbox/messages/MessageTemplate.tsx
similarity index 100%
rename from frontend/src/scenes/max/messages/MessageTemplate.tsx
rename to products/posthog_ai/frontend/sandbox/messages/MessageTemplate.tsx
diff --git a/frontend/src/scenes/max/messages/ReasoningAnswer.tsx b/products/posthog_ai/frontend/sandbox/messages/ReasoningAnswer.tsx
similarity index 93%
rename from frontend/src/scenes/max/messages/ReasoningAnswer.tsx
rename to products/posthog_ai/frontend/sandbox/messages/ReasoningAnswer.tsx
index 325cefe5e3c1..821b0f6ba682 100644
--- a/frontend/src/scenes/max/messages/ReasoningAnswer.tsx
+++ b/products/posthog_ai/frontend/sandbox/messages/ReasoningAnswer.tsx
@@ -1,11 +1,10 @@
import { IconBrain } from '@posthog/icons'
import { inStorybookTestRunner } from 'lib/utils/dom'
+import { LangGraphActivity } from 'scenes/max/components/Activity'
import { TaskExecutionStatus as ExecutionStatus } from '~/queries/schema/schema-assistant-messages'
-import { LangGraphActivity } from '../components/Activity'
-
export interface ReasoningAnswerProps {
content: string
completed: boolean
diff --git a/frontend/src/scenes/max/messages/posthogProducts.ts b/products/posthog_ai/frontend/sandbox/messages/posthogProducts.ts
similarity index 100%
rename from frontend/src/scenes/max/messages/posthogProducts.ts
rename to products/posthog_ai/frontend/sandbox/messages/posthogProducts.ts
diff --git a/frontend/src/scenes/max/sandbox/posthogExecDisplay.ts b/products/posthog_ai/frontend/sandbox/posthogExecDisplay.ts
similarity index 100%
rename from frontend/src/scenes/max/sandbox/posthogExecDisplay.ts
rename to products/posthog_ai/frontend/sandbox/posthogExecDisplay.ts
diff --git a/frontend/src/scenes/max/sandboxPermissionDisplayUtils.test.ts b/products/posthog_ai/frontend/sandbox/sandboxPermissionDisplayUtils.test.ts
similarity index 100%
rename from frontend/src/scenes/max/sandboxPermissionDisplayUtils.test.ts
rename to products/posthog_ai/frontend/sandbox/sandboxPermissionDisplayUtils.test.ts
diff --git a/frontend/src/scenes/max/sandboxPermissionDisplayUtils.ts b/products/posthog_ai/frontend/sandbox/sandboxPermissionDisplayUtils.ts
similarity index 92%
rename from frontend/src/scenes/max/sandboxPermissionDisplayUtils.ts
rename to products/posthog_ai/frontend/sandbox/sandboxPermissionDisplayUtils.ts
index 2569d9c381ea..cf15f8ffb6db 100644
--- a/frontend/src/scenes/max/sandboxPermissionDisplayUtils.ts
+++ b/products/posthog_ai/frontend/sandbox/sandboxPermissionDisplayUtils.ts
@@ -1,9 +1,9 @@
-import { POSTHOG_EXEC_TOOL_RE, formatPostHogExecBody, getPostHogExecDisplay } from './sandbox/posthogExecDisplay'
-import { resolveToolCall } from './sandbox/sandboxToolResolver'
+import { POSTHOG_EXEC_TOOL_RE, formatPostHogExecBody, getPostHogExecDisplay } from './posthogExecDisplay'
+import { resolveToolCall } from './sandboxToolResolver'
import type { PermissionRequestRecord } from './types/sandboxStreamTypes'
// Re-exported so existing importers (and tests) keep resolving the exec display from here.
-export { getPostHogExecDisplay } from './sandbox/posthogExecDisplay'
+export { getPostHogExecDisplay } from './posthogExecDisplay'
export interface SandboxPermissionDisplay {
title?: string
diff --git a/frontend/src/scenes/max/sandboxPermissionUtils.test.ts b/products/posthog_ai/frontend/sandbox/sandboxPermissionUtils.test.ts
similarity index 100%
rename from frontend/src/scenes/max/sandboxPermissionUtils.test.ts
rename to products/posthog_ai/frontend/sandbox/sandboxPermissionUtils.test.ts
diff --git a/frontend/src/scenes/max/sandboxPermissionUtils.ts b/products/posthog_ai/frontend/sandbox/sandboxPermissionUtils.ts
similarity index 100%
rename from frontend/src/scenes/max/sandboxPermissionUtils.ts
rename to products/posthog_ai/frontend/sandbox/sandboxPermissionUtils.ts
diff --git a/frontend/src/scenes/max/sandboxQuestionUtils.test.ts b/products/posthog_ai/frontend/sandbox/sandboxQuestionUtils.test.ts
similarity index 100%
rename from frontend/src/scenes/max/sandboxQuestionUtils.test.ts
rename to products/posthog_ai/frontend/sandbox/sandboxQuestionUtils.test.ts
diff --git a/frontend/src/scenes/max/sandboxQuestionUtils.ts b/products/posthog_ai/frontend/sandbox/sandboxQuestionUtils.ts
similarity index 100%
rename from frontend/src/scenes/max/sandboxQuestionUtils.ts
rename to products/posthog_ai/frontend/sandbox/sandboxQuestionUtils.ts
diff --git a/frontend/src/scenes/max/sandboxStreamLogic.test.ts b/products/posthog_ai/frontend/sandbox/sandboxStreamLogic.test.ts
similarity index 100%
rename from frontend/src/scenes/max/sandboxStreamLogic.test.ts
rename to products/posthog_ai/frontend/sandbox/sandboxStreamLogic.test.ts
diff --git a/frontend/src/scenes/max/sandboxStreamLogic.ts b/products/posthog_ai/frontend/sandbox/sandboxStreamLogic.ts
similarity index 99%
rename from frontend/src/scenes/max/sandboxStreamLogic.ts
rename to products/posthog_ai/frontend/sandbox/sandboxStreamLogic.ts
index cbc476fc94f4..585dc798b5a7 100644
--- a/frontend/src/scenes/max/sandboxStreamLogic.ts
+++ b/products/posthog_ai/frontend/sandbox/sandboxStreamLogic.ts
@@ -9,10 +9,10 @@ import { projectLogic } from 'scenes/projectLogic'
import { tasksRunsCommandCreate } from 'products/tasks/frontend/generated/api'
import type { TaskRunBootstrapCreateRequestInitialPermissionModeEnumApi } from 'products/tasks/frontend/generated/api.schemas'
-import { getClaudeCodeMeta, resolveToolCall } from './sandbox/sandboxToolResolver'
import { parseSandboxQuestions } from './sandboxQuestionUtils'
import type { sandboxStreamLogicType } from './sandboxStreamLogicType'
import { defaultPermissionDecision, findAllowOptionId } from './sandboxToolPolicy'
+import { getClaudeCodeMeta, resolveToolCall } from './sandboxToolResolver'
import type {
ContextUsage,
PermissionRequestRecord,
@@ -961,7 +961,7 @@ export const sandboxStreamLogic = kea<sandboxStreamLogicType>([
// A read-only viewer keys under a `replay:` namespace so it never shares an instance with a live
// stream of the same run — streaming can't bleed into a read-only thread.
key((props) => (props.replayOnly ? `replay:${props.streamKey}` : props.streamKey)),
- path((key) => ['scenes', 'max', 'sandboxStreamLogic', key]),
+ path((key) => ['products', 'posthog_ai', 'sandbox', 'sandboxStreamLogic', key]),
connect(() => ({
values: [projectLogic, ['currentProjectId']],
})),
diff --git a/frontend/src/scenes/max/sandboxToolPolicy.test.ts b/products/posthog_ai/frontend/sandbox/sandboxToolPolicy.test.ts
similarity index 100%
rename from frontend/src/scenes/max/sandboxToolPolicy.test.ts
rename to products/posthog_ai/frontend/sandbox/sandboxToolPolicy.test.ts
diff --git a/frontend/src/scenes/max/sandboxToolPolicy.ts b/products/posthog_ai/frontend/sandbox/sandboxToolPolicy.ts
similarity index 95%
rename from frontend/src/scenes/max/sandboxToolPolicy.ts
rename to products/posthog_ai/frontend/sandbox/sandboxToolPolicy.ts
index 45c2ab079c3a..3cf2632a4acd 100644
--- a/frontend/src/scenes/max/sandboxToolPolicy.ts
+++ b/products/posthog_ai/frontend/sandbox/sandboxToolPolicy.ts
@@ -1,9 +1,9 @@
-import { isPostHogExecTool } from './sandbox/posthogExecDisplay'
-import { resolveToolCall } from './sandbox/sandboxToolResolver'
+import { isPostHogExecTool } from './posthogExecDisplay'
+import { resolveToolCall } from './sandboxToolResolver'
import type { PermissionRequestRecord } from './types/sandboxStreamTypes'
// Re-exported so existing importers (and tests) keep resolving the exec-tool check from here.
-export { isPostHogExecTool } from './sandbox/posthogExecDisplay'
+export { isPostHogExecTool } from './posthogExecDisplay'
/**
* Default sandbox tool-permission policy, ported from Twig
diff --git a/frontend/src/scenes/max/sandbox/sandboxToolRegistry.test.tsx b/products/posthog_ai/frontend/sandbox/sandboxToolRegistry.test.tsx
similarity index 98%
rename from frontend/src/scenes/max/sandbox/sandboxToolRegistry.test.tsx
rename to products/posthog_ai/frontend/sandbox/sandboxToolRegistry.test.tsx
index f68bd55eb398..2a4bbcd1d086 100644
--- a/frontend/src/scenes/max/sandbox/sandboxToolRegistry.test.tsx
+++ b/products/posthog_ai/frontend/sandbox/sandboxToolRegistry.test.tsx
@@ -2,7 +2,8 @@ import '@testing-library/jest-dom'
import { render, screen } from '@testing-library/react'
-import type { SandboxToolCallMessage } from '../maxTypes'
+import type { SandboxToolCallMessage } from 'products/posthog_ai/frontend/sandbox/types/sandboxToolTypes'
+
import { SandboxToolCall } from './components/tool/SandboxToolCall'
import { lookupSandboxToolRenderer, sandboxToolRegistry } from './sandboxToolRegistry'
diff --git a/frontend/src/scenes/max/sandbox/sandboxToolRegistry.tsx b/products/posthog_ai/frontend/sandbox/sandboxToolRegistry.tsx
similarity index 92%
rename from frontend/src/scenes/max/sandbox/sandboxToolRegistry.tsx
rename to products/posthog_ai/frontend/sandbox/sandboxToolRegistry.tsx
index aaa718fe2ed1..14febd3951a6 100644
--- a/frontend/src/scenes/max/sandbox/sandboxToolRegistry.tsx
+++ b/products/posthog_ai/frontend/sandbox/sandboxToolRegistry.tsx
@@ -29,7 +29,7 @@ import {
// IconRobot is not exported from @posthog/icons — it lives only in the legacy lib icon set.
import { IconRobot } from 'lib/lemon-ui/icons'
-import type { SandboxToolCallMessage } from '../maxTypes'
+import type { SandboxToolCallMessage } from 'products/posthog_ai/frontend/sandbox/types/sandboxToolTypes'
export interface SandboxToolRendererProps {
message: SandboxToolCallMessage
@@ -91,26 +91,28 @@ const BuiltinToolRenderer = lazy(() =>
import('./components/tool/builtinToolRenderers').then((m) => ({ default: m.BuiltinToolRenderer }))
)
const EditToolRenderer = lazy(() =>
- import('../messages/adapters/EditDiffRenderer').then((m) => ({ default: m.EditDiffRenderer }))
+ import('scenes/max/messages/adapters/EditDiffRenderer').then((m) => ({ default: m.EditDiffRenderer }))
)
const InsightRenderer = lazy(() =>
- import('../messages/adapters/CreateInsightWidget').then((m) => ({ default: m.CreateInsightWidget }))
+ import('scenes/max/messages/adapters/CreateInsightWidget').then((m) => ({ default: m.CreateInsightWidget }))
)
const DashboardRenderer = lazy(() =>
- import('../messages/adapters/UpsertDashboardWidget').then((m) => ({ default: m.UpsertDashboardWidget }))
+ import('scenes/max/messages/adapters/UpsertDashboardWidget').then((m) => ({ default: m.UpsertDashboardWidget }))
)
const SessionRecordingsRenderer = lazy(() =>
- import('../messages/adapters/SearchSessionRecordingsWidget').then((m) => ({
+ import('scenes/max/messages/adapters/SearchSessionRecordingsWidget').then((m) => ({
default: m.SearchSessionRecordingsWidget,
}))
)
const ErrorTrackingRenderer = lazy(() =>
- import('../messages/adapters/ErrorTrackingWidget').then((m) => ({ default: m.ErrorTrackingWidget }))
+ import('scenes/max/messages/adapters/ErrorTrackingWidget').then((m) => ({ default: m.ErrorTrackingWidget }))
)
const NotebookRenderer = lazy(() =>
- import('../messages/adapters/CreateNotebookWidget').then((m) => ({ default: m.CreateNotebookWidget }))
+ import('scenes/max/messages/adapters/CreateNotebookWidget').then((m) => ({ default: m.CreateNotebookWidget }))
+)
+const QueryRenderer = lazy(() =>
+ import('scenes/max/messages/adapters/QueryWidget').then((m) => ({ default: m.QueryWidget }))
)
-const QueryRenderer = lazy(() => import('../messages/adapters/QueryWidget').then((m) => ({ default: m.QueryWidget })))
const QuestionRenderer = lazy(() =>
import('./SandboxQuestionRenderer').then((m) => ({ default: m.SandboxQuestionRenderer }))
)
diff --git a/frontend/src/scenes/max/sandbox/sandboxToolResolver.test.ts b/products/posthog_ai/frontend/sandbox/sandboxToolResolver.test.ts
similarity index 100%
rename from frontend/src/scenes/max/sandbox/sandboxToolResolver.test.ts
rename to products/posthog_ai/frontend/sandbox/sandboxToolResolver.test.ts
diff --git a/frontend/src/scenes/max/sandbox/sandboxToolResolver.ts b/products/posthog_ai/frontend/sandbox/sandboxToolResolver.ts
similarity index 100%
rename from frontend/src/scenes/max/sandbox/sandboxToolResolver.ts
rename to products/posthog_ai/frontend/sandbox/sandboxToolResolver.ts
diff --git a/frontend/src/scenes/max/toolDiffContent.test.ts b/products/posthog_ai/frontend/sandbox/toolDiffContent.test.ts
similarity index 100%
rename from frontend/src/scenes/max/toolDiffContent.test.ts
rename to products/posthog_ai/frontend/sandbox/toolDiffContent.test.ts
diff --git a/frontend/src/scenes/max/toolDiffContent.ts b/products/posthog_ai/frontend/sandbox/toolDiffContent.ts
similarity index 100%
rename from frontend/src/scenes/max/toolDiffContent.ts
rename to products/posthog_ai/frontend/sandbox/toolDiffContent.ts
diff --git a/frontend/src/scenes/max/types/sandboxStreamTypes.ts b/products/posthog_ai/frontend/sandbox/types/sandboxStreamTypes.ts
similarity index 100%
rename from frontend/src/scenes/max/types/sandboxStreamTypes.ts
rename to products/posthog_ai/frontend/sandbox/types/sandboxStreamTypes.ts
diff --git a/products/posthog_ai/frontend/sandbox/types/sandboxToolTypes.ts b/products/posthog_ai/frontend/sandbox/types/sandboxToolTypes.ts
new file mode 100644
index 000000000000..1d30f3bd524e
--- /dev/null
+++ b/products/posthog_ai/frontend/sandbox/types/sandboxToolTypes.ts
@@ -0,0 +1,28 @@
+/**
+ * The shape `sandboxToolRegistry` renderers receive — raw `ToolInvocation` stream state plus
+ * renderer-facing fields resolved at render time.
+ */
+export interface SandboxToolCallMessage {
+ /** Stable id — the tool call id. */
+ id: string
+ /** Registry lookup key — the inner tool name for single-exec calls, otherwise the wire tool name. */
+ resolvedKey: string
+ rawServerName: string
+ rawToolName: string
+ innerToolName?: string
+ /** Stable SDK tool name from `_meta.claudeCode.toolName` — set for Claude built-ins. */
+ claudeToolName?: string
+ /** rawInput at `tool_call` (for `exec`, includes the wrapper `{ command }`). */
+ rawInput: Record<string, unknown>
+ /** JSON-parsed inner args when `innerToolName` is set. */
+ innerInput?: Record<string, unknown>
+ rawOutput?: unknown
+ /** Accumulated ACP `content[]`. */
+ content: unknown[]
+ status: 'pending' | 'in_progress' | 'completed' | 'failed'
+ title?: string
+ kind?: string
+ /** ACP `toolCall.locations` — file paths (with optional line) the tool touched. */
+ locations?: { path: string; line?: number }[]
+ error?: { message?: string } | null
+}
diff --git a/frontend/src/scenes/max/types/sandboxWireTypes.test.ts b/products/posthog_ai/frontend/sandbox/types/sandboxWireTypes.test.ts
similarity index 100%
rename from frontend/src/scenes/max/types/sandboxWireTypes.test.ts
rename to products/posthog_ai/frontend/sandbox/types/sandboxWireTypes.test.ts
diff --git a/frontend/src/scenes/max/types/sandboxWireTypes.ts b/products/posthog_ai/frontend/sandbox/types/sandboxWireTypes.ts
similarity index 100%
rename from frontend/src/scenes/max/types/sandboxWireTypes.ts
rename to products/posthog_ai/frontend/sandbox/types/sandboxWireTypes.ts
diff --git a/frontend/src/scenes/max/utils/thinkingMessages.ts b/products/posthog_ai/frontend/sandbox/utils/thinkingMessages.ts
similarity index 100%
rename from frontend/src/scenes/max/utils/thinkingMessages.ts
rename to products/posthog_ai/frontend/sandbox/utils/thinkingMessages.ts
diff --git a/products/posthog_ai/package.json b/products/posthog_ai/package.json
index effb57322c95..141402eb2de6 100644
--- a/products/posthog_ai/package.json
+++ b/products/posthog_ai/package.json
@@ -2,5 +2,29 @@
"name": "@posthog/products-posthog-ai",
"scripts": {
"backend:test": "pytest -c ../../pytest.ini --rootdir ../.. backend/ scripts/ -v --tb=short"
+ },
+ "dependencies": {
+ "eventsource-parser": "*",
+ "kea-subscriptions": "catalog:",
+ "marked": "*",
+ "posthog-js": "*",
+ "tailwind-merge": "*"
+ },
+ "devDependencies": {
+ "@testing-library/react": "*",
+ "kea-test-utils": "catalog:"
+ },
+ "peerDependencies": {
+ "@posthog/icons": "*",
+ "@storybook/react": "catalog:",
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "clsx": "*",
+ "kea": "catalog:",
+ "kea-forms": "catalog:",
+ "kea-loaders": "catalog:",
+ "kea-router": "catalog:",
+ "react": "*",
+ "react-dom": "*"
}
}
diff --git a/products/posthog_ai/tsconfig.json b/products/posthog_ai/tsconfig.json
new file mode 100644
index 000000000000..fe425d6fcba8
--- /dev/null
+++ b/products/posthog_ai/tsconfig.json
@@ -0,0 +1,6 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "composite": true
+ }
+}