Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/code/src/main/di/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ import {
} from "@posthog/workspace-server/services/archive/identifiers";
import { authProxyModule } from "@posthog/workspace-server/services/auth-proxy/auth-proxy.module";
import { AUTH_PROXY_AUTH } from "@posthog/workspace-server/services/auth-proxy/identifiers";
import { claudeCliSessionsModule } from "@posthog/workspace-server/services/claude-cli-sessions/claude-cli-sessions.module";
import { enrichmentModule } from "@posthog/workspace-server/services/enrichment/enrichment.module";
import {
ENRICHMENT_AUTH,
Expand Down Expand Up @@ -586,6 +587,7 @@ container.bind(MAIN_POSTHOG_PLUGIN_SERVICE).toService(POSTHOG_PLUGIN_SERVICE);
container.load(skillsModule);
container.load(skillsMarketplaceModule);
container.load(onboardingImportModule);
container.load(claudeCliSessionsModule);
container.load(additionalDirectoriesModule);
container.bind(MAIN_SLEEP_SERVICE).to(SleepService);
container.bind(SLEEP_SERVICE).toService(MAIN_SLEEP_SERVICE);
Expand Down
2 changes: 2 additions & 0 deletions apps/code/src/main/trpc/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { authRouter } from "@posthog/host-router/routers/auth.router";
import { canvasDataRouter } from "@posthog/host-router/routers/canvas-data.router";
import { canvasTemplatesRouter } from "@posthog/host-router/routers/canvas-templates.router";
import { channelTasksRouter } from "@posthog/host-router/routers/channel-tasks.router";
import { claudeCliSessionsRouter } from "@posthog/host-router/routers/claude-cli-sessions.router";
import { cloudTaskRouter } from "@posthog/host-router/routers/cloud-task.router";
import { connectivityRouter } from "@posthog/host-router/routers/connectivity.router";
import { contextMenuRouter } from "@posthog/host-router/routers/context-menu.router";
Expand Down Expand Up @@ -55,6 +56,7 @@ export const trpcRouter = router({
canvasData: canvasDataRouter,
canvasTemplates: canvasTemplatesRouter,
channelTasks: channelTasksRouter,
claudeCliSessions: claudeCliSessionsRouter,
dashboards: dashboardsRouter,
cloudTask: cloudTaskRouter,
connectivity: connectivityRouter,
Expand Down
2 changes: 2 additions & 0 deletions packages/host-router/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { authRouter } from "./routers/auth.router";
import { canvasDataRouter } from "./routers/canvas-data.router";
import { canvasTemplatesRouter } from "./routers/canvas-templates.router";
import { channelTasksRouter } from "./routers/channel-tasks.router";
import { claudeCliSessionsRouter } from "./routers/claude-cli-sessions.router";
import { cloudTaskRouter } from "./routers/cloud-task.router";
import { connectivityRouter } from "./routers/connectivity.router";
import { contextMenuRouter } from "./routers/context-menu.router";
Expand Down Expand Up @@ -53,6 +54,7 @@ export const hostRouter = router({
canvasData: canvasDataRouter,
canvasTemplates: canvasTemplatesRouter,
channelTasks: channelTasksRouter,
claudeCliSessions: claudeCliSessionsRouter,
cloudTask: cloudTaskRouter,
connectivity: connectivityRouter,
contextMenu: contextMenuRouter,
Expand Down
58 changes: 58 additions & 0 deletions packages/host-router/src/routers/claude-cli-sessions.router.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { publicProcedure, router } from "@posthog/host-trpc/trpc";
import {
CLAUDE_CLI_SESSIONS_SERVICE,
type ClaudeCliSessionsService,
} from "@posthog/workspace-server/services/claude-cli-sessions/identifiers";
import {
deleteImportedCliSessionInput,
deleteImportRecordInput,
importCliSessionInput,
importCliSessionOutput,
listCliSessionsInput,
listCliSessionsOutput,
recordCliImportInput,
} from "@posthog/workspace-server/services/claude-cli-sessions/schemas";

export const claudeCliSessionsRouter = router({
list: publicProcedure
.input(listCliSessionsInput)
.output(listCliSessionsOutput)
.query(({ ctx, input }) =>
ctx.container
.get<ClaudeCliSessionsService>(CLAUDE_CLI_SESSIONS_SERVICE)
.listForRepo(input),
),

import: publicProcedure
.input(importCliSessionInput)
.output(importCliSessionOutput)
.mutation(({ ctx, input }) =>
ctx.container
.get<ClaudeCliSessionsService>(CLAUDE_CLI_SESSIONS_SERVICE)
.importSession(input),
),

deleteImport: publicProcedure
.input(deleteImportedCliSessionInput)
.mutation(({ ctx, input }) =>
ctx.container
.get<ClaudeCliSessionsService>(CLAUDE_CLI_SESSIONS_SERVICE)
.deleteImportedSession(input),
),

recordImport: publicProcedure
.input(recordCliImportInput)
.mutation(({ ctx, input }) =>
ctx.container
.get<ClaudeCliSessionsService>(CLAUDE_CLI_SESSIONS_SERVICE)
.recordImport(input),
),

deleteImportRecord: publicProcedure
.input(deleteImportRecordInput)
.mutation(({ ctx, input }) =>
ctx.container
.get<ClaudeCliSessionsService>(CLAUDE_CLI_SESSIONS_SERVICE)
.deleteImportRecord(input),
),
});
3 changes: 3 additions & 0 deletions packages/workspace-server/src/db/identifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ export const DEFAULT_ADDITIONAL_DIRECTORY_REPOSITORY = Symbol.for(
export const TASK_METADATA_REPOSITORY = Symbol.for(
"posthog.workspace.taskMetadataRepository",
);
export const CLAUDE_SESSION_IMPORT_REPOSITORY = Symbol.for(
"posthog.workspace.claudeSessionImportRepository",
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CREATE TABLE `claude_session_imports` (
`id` text PRIMARY KEY NOT NULL,
`source_session_id` text NOT NULL,
`imported_session_id` text NOT NULL,
`task_id` text NOT NULL,
`repo_path` text NOT NULL,
`source_mtime_ms` integer NOT NULL,
`source_size_bytes` integer NOT NULL,
`source_last_entry_uuid` text,
`created_at` text DEFAULT (CURRENT_TIMESTAMP) NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `claude_session_imports_importedSessionId_unique` ON `claude_session_imports` (`imported_session_id`);--> statement-breakpoint
CREATE INDEX `claude_session_imports_source_idx` ON `claude_session_imports` (`source_session_id`);--> statement-breakpoint
CREATE INDEX `claude_session_imports_task_idx` ON `claude_session_imports` (`task_id`);
Loading
Loading