mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
Persist task messages (#44)
This commit is contained in:
parent
ef42763ad9
commit
ab92f7693e
10 changed files with 2379 additions and 2704 deletions
23
.env
23
.env
|
|
@ -2,14 +2,18 @@
|
|||
# for local development and in the "Environment Variables" setting on Vercel
|
||||
# for production (https://vercel.com/roo-code/roo-code-cloud/settings/environment-variables).
|
||||
|
||||
# Deep Links
|
||||
VSCODE_EXTENSION_BASE_URL=vscode://RooVeterinaryInc.roo-cline
|
||||
CURSOR_EXTENSION_BASE_URL=cursor://RooVeterinaryInc.roo-cline
|
||||
# Postgres
|
||||
DATABASE_URL=fake-url
|
||||
|
||||
# ClickHouse
|
||||
CLICKHOUSE_URL=https://fake-url.com
|
||||
CLICKHOUSE_PASSWORD=fake-password
|
||||
|
||||
# Clerk
|
||||
CLERK_SECRET_KEY=your_clerk_secret_key
|
||||
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_ZXBpYy1jaGFtb2lzLTg1LmNsZXJrLmFjY291bnRzLmRldiQ
|
||||
NEXT_PUBLIC_CLERK_FRONTEND_API=https://epic-chamois-85.clerk.accounts.dev
|
||||
CLERK_SECRET_KEY=fake-secret-key
|
||||
|
||||
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_...
|
||||
NEXT_PUBLIC_CLERK_FRONTEND_API=fake-url
|
||||
|
||||
# https://clerk.com/docs/deployments/clerk-environment-variables#sign-in-and-sign-up-redirects
|
||||
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
|
||||
|
|
@ -19,7 +23,6 @@ NEXT_PUBLIC_CLERK_SIGN_UP_FORCE_REDIRECT_URL=/authorized
|
|||
NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL=/authorized
|
||||
NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL=/authorized
|
||||
|
||||
# ClickHouse
|
||||
CLICKHOUSE_URL=https://fake.us-west-2.aws.clickhouse.cloud:1234
|
||||
CLICKHOUSE_USERNAME=default
|
||||
CLICKHOUSE_PASSWORD=fake-your_clickhouse_password
|
||||
# Deep Links
|
||||
VSCODE_EXTENSION_BASE_URL=vscode://RooVeterinaryInc.roo-cline
|
||||
CURSOR_EXTENSION_BASE_URL=cursor://RooVeterinaryInc.roo-cline
|
||||
|
|
|
|||
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -5,7 +5,7 @@
|
|||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# Database
|
||||
# database
|
||||
*.db
|
||||
|
||||
# testing
|
||||
|
|
@ -41,8 +41,9 @@ pnpm-debug.log*
|
|||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# local env files
|
||||
# .env
|
||||
.env*.local
|
||||
.env*.production
|
||||
|
||||
# local folder
|
||||
local
|
||||
|
|
|
|||
|
|
@ -44,7 +44,13 @@ pnpm test
|
|||
|
||||
### Start Development Server
|
||||
|
||||
Copy `.env.local.sample` to `.env.local` and fill in the required secrets.
|
||||
Create an `.env.local` file and fill out the required secrets, including:
|
||||
|
||||
- `CLICKHOUSE_URL`
|
||||
- `CLICKHOUSE_PASSWORD`
|
||||
- `CLERK_SECRET_KEY`
|
||||
- `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY`
|
||||
- `NEXT_PUBLIC_CLERK_FRONTEND_API`
|
||||
|
||||
You can now start the Next.js app and [Spotlight](https://spotlightjs.com/) with:
|
||||
|
||||
|
|
|
|||
128
package.json
128
package.json
|
|
@ -27,31 +27,31 @@
|
|||
"prepare": "husky"
|
||||
},
|
||||
"dependencies": {
|
||||
"@clerk/localizations": "^3.14.2",
|
||||
"@clerk/nextjs": "^6.18.3",
|
||||
"@clerk/themes": "^2.1.36",
|
||||
"@clerk/localizations": "^3.16.2",
|
||||
"@clerk/nextjs": "^6.20.1",
|
||||
"@clerk/themes": "^2.2.47",
|
||||
"@clickhouse/client": "^1.11.1",
|
||||
"@hookform/resolvers": "^5.0.1",
|
||||
"@logtail/pino": "^0.5.2",
|
||||
"@radix-ui/react-accordion": "^1.2.1",
|
||||
"@radix-ui/react-checkbox": "^1.3.1",
|
||||
"@radix-ui/react-dialog": "^1.1.13",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.14",
|
||||
"@logtail/pino": "^0.5.5",
|
||||
"@radix-ui/react-accordion": "^1.2.11",
|
||||
"@radix-ui/react-checkbox": "^1.3.2",
|
||||
"@radix-ui/react-dialog": "^1.1.14",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.15",
|
||||
"@radix-ui/react-icons": "^1.3.2",
|
||||
"@radix-ui/react-label": "^2.1.0",
|
||||
"@radix-ui/react-separator": "^1.1.6",
|
||||
"@radix-ui/react-slider": "^1.3.4",
|
||||
"@radix-ui/react-slot": "^1.2.2",
|
||||
"@radix-ui/react-switch": "^1.2.4",
|
||||
"@radix-ui/react-tabs": "^1.1.11",
|
||||
"@radix-ui/react-toast": "^1.2.13",
|
||||
"@radix-ui/react-tooltip": "^1.1.3",
|
||||
"@roo-code/types": "^1.11.0",
|
||||
"@sentry/nextjs": "^9.17.0",
|
||||
"@t3-oss/env-nextjs": "^0.13.4",
|
||||
"@tailwindcss/postcss": "^4.1.6",
|
||||
"@tanstack/react-query": "^5.76.1",
|
||||
"@tanstack/react-table": "^8.20.5",
|
||||
"@radix-ui/react-label": "^2.1.7",
|
||||
"@radix-ui/react-separator": "^1.1.7",
|
||||
"@radix-ui/react-slider": "^1.3.5",
|
||||
"@radix-ui/react-slot": "^1.2.3",
|
||||
"@radix-ui/react-switch": "^1.2.5",
|
||||
"@radix-ui/react-tabs": "^1.1.12",
|
||||
"@radix-ui/react-toast": "^1.2.14",
|
||||
"@radix-ui/react-tooltip": "^1.2.7",
|
||||
"@roo-code/types": "^1.22.0",
|
||||
"@sentry/nextjs": "^9.23.0",
|
||||
"@t3-oss/env-nextjs": "^0.13.6",
|
||||
"@tailwindcss/postcss": "^4.1.8",
|
||||
"@tanstack/react-query": "^5.77.2",
|
||||
"@tanstack/react-table": "^8.21.3",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"cmdk": "^1.1.1",
|
||||
|
|
@ -63,77 +63,77 @@
|
|||
"next-intl": "^4.1.0",
|
||||
"next-themes": "^0.4.6",
|
||||
"next-typesafe-url": "^5.1.7",
|
||||
"pino": "^9.5.0",
|
||||
"pino": "^9.7.0",
|
||||
"pino-pretty": "^13.0.0",
|
||||
"postgres": "^3.4.5",
|
||||
"postgres": "^3.4.7",
|
||||
"prettier": "^3.5.3",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0",
|
||||
"react-hook-form": "^7.53.0",
|
||||
"react-hook-form": "^7.56.4",
|
||||
"react-use": "^17.6.0",
|
||||
"sonner": "^2.0.3",
|
||||
"stripe": "^18.1.0",
|
||||
"stripe": "^18.1.1",
|
||||
"tailwind-merge": "^3.3.0",
|
||||
"uuid": "^11.1.0",
|
||||
"vaul": "^1.1.2",
|
||||
"zod": "^3.23.8"
|
||||
"zod": "^3.25.32"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@clerk/testing": "^1.3.11",
|
||||
"@dotenvx/dotenvx": "^1.43.0",
|
||||
"@eslint/js": "^9.26.0",
|
||||
"@clerk/testing": "^1.7.4",
|
||||
"@dotenvx/dotenvx": "^1.44.1",
|
||||
"@eslint/js": "^9.27.0",
|
||||
"@next/bundle-analyzer": "^15.3.2",
|
||||
"@next/eslint-plugin-next": "^15.3.2",
|
||||
"@percy/cli": "1.30.10",
|
||||
"@percy/playwright": "^1.0.6",
|
||||
"@playwright/test": "^1.48.1",
|
||||
"@storybook/addon-essentials": "^8.3.5",
|
||||
"@storybook/addon-interactions": "^8.3.5",
|
||||
"@storybook/addon-links": "^8.3.5",
|
||||
"@storybook/addon-onboarding": "^8.3.5",
|
||||
"@storybook/blocks": "^8.3.5",
|
||||
"@storybook/nextjs": "^8.3.5",
|
||||
"@storybook/react": "^8.3.5",
|
||||
"@storybook/test": "^8.3.5",
|
||||
"@percy/playwright": "^1.0.8",
|
||||
"@playwright/test": "^1.52.0",
|
||||
"@storybook/addon-essentials": "^8.6.14",
|
||||
"@storybook/addon-interactions": "^8.6.14",
|
||||
"@storybook/addon-links": "^8.6.14",
|
||||
"@storybook/addon-onboarding": "^8.6.14",
|
||||
"@storybook/blocks": "^8.6.14",
|
||||
"@storybook/nextjs": "^8.6.14",
|
||||
"@storybook/react": "^8.6.14",
|
||||
"@storybook/test": "^8.6.14",
|
||||
"@storybook/test-runner": "^0.22.0",
|
||||
"@testing-library/jest-dom": "^6.6.1",
|
||||
"@testing-library/react": "^16.0.1",
|
||||
"@testing-library/user-event": "^14.5.2",
|
||||
"@types/node": "^22.7.6",
|
||||
"@types/pg": "^8.11.10",
|
||||
"@types/react": "^19.1.3",
|
||||
"@vitejs/plugin-react": "^4.3.2",
|
||||
"@vitest/coverage-v8": "^3.1.3",
|
||||
"@vitest/expect": "^3.1.3",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"@testing-library/jest-dom": "^6.6.3",
|
||||
"@testing-library/react": "^16.3.0",
|
||||
"@testing-library/user-event": "^14.6.1",
|
||||
"@types/node": "^22.15.23",
|
||||
"@types/pg": "^8.15.2",
|
||||
"@types/react": "^19.1.6",
|
||||
"@vitejs/plugin-react": "^4.5.0",
|
||||
"@vitest/coverage-v8": "^3.1.4",
|
||||
"@vitest/expect": "^3.1.4",
|
||||
"autoprefixer": "^10.4.21",
|
||||
"cross-env": "^7.0.3",
|
||||
"drizzle-kit": "^0.31.1",
|
||||
"eslint": "^9.26.0",
|
||||
"eslint": "^9.27.0",
|
||||
"eslint-config-prettier": "^10.1.5",
|
||||
"eslint-plugin-only-warn": "^1.1.0",
|
||||
"eslint-plugin-react": "^7.37.5",
|
||||
"eslint-plugin-react-hooks": "^5.2.0",
|
||||
"eslint-plugin-turbo": "^2.5.3",
|
||||
"globals": "^16.1.0",
|
||||
"globals": "^16.2.0",
|
||||
"http-server": "^14.1.1",
|
||||
"husky": "^9.1.6",
|
||||
"import-in-the-middle": "^1.13.1",
|
||||
"husky": "^9.1.7",
|
||||
"import-in-the-middle": "^1.14.0",
|
||||
"jsdom": "^26.1.0",
|
||||
"lint-staged": "^16.0.0",
|
||||
"lint-staged": "^16.1.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"postcss": "^8.5.3",
|
||||
"require-in-the-middle": "^7.5.2",
|
||||
"rimraf": "^6.0.1",
|
||||
"start-server-and-test": "^2.0.8",
|
||||
"storybook": "^8.3.5",
|
||||
"tailwindcss": "^4.1.6",
|
||||
"start-server-and-test": "^2.0.12",
|
||||
"storybook": "^8.6.14",
|
||||
"tailwindcss": "^4.1.8",
|
||||
"tailwindcss-animate": "^1.0.7",
|
||||
"tsx": "^4.19.1",
|
||||
"tw-animate-css": "^1.2.9",
|
||||
"typescript": "^5.6.3",
|
||||
"typescript-eslint": "^8.32.0",
|
||||
"vite-tsconfig-paths": "^5.0.1",
|
||||
"vitest": "^3.1.3",
|
||||
"tsx": "^4.19.4",
|
||||
"tw-animate-css": "^1.3.0",
|
||||
"typescript": "^5.8.3",
|
||||
"typescript-eslint": "^8.33.0",
|
||||
"vite-tsconfig-paths": "^5.1.4",
|
||||
"vitest": "^3.1.4",
|
||||
"vitest-fail-on-console": "^0.7.1"
|
||||
},
|
||||
"lint-staged": {
|
||||
|
|
|
|||
4831
pnpm-lock.yaml
generated
4831
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
|
|
@ -11,6 +11,8 @@ import type { TimePeriod } from '@/types';
|
|||
import { analytics } from '@/lib/server';
|
||||
import { type User, getUsersById } from '@/db/server';
|
||||
|
||||
type Table = 'events' | 'messages';
|
||||
|
||||
/**
|
||||
* captureEvent
|
||||
*/
|
||||
|
|
@ -23,19 +25,26 @@ type AnalyticsEvent = {
|
|||
event: RooCodeTelemetryEvent;
|
||||
};
|
||||
|
||||
export const captureEvent = async ({
|
||||
event: { properties, ...cloudEvent },
|
||||
...analyticsEvent
|
||||
}: AnalyticsEvent) => {
|
||||
// The destructuring here flattens the `AnalyticsEvent` to match the ClickHouse
|
||||
// schema.
|
||||
const value = { ...analyticsEvent, ...cloudEvent, ...properties };
|
||||
export const captureEvent = async ({ event, ...rest }: AnalyticsEvent) => {
|
||||
let value;
|
||||
let table: Table;
|
||||
|
||||
await analytics.insert({
|
||||
table: 'events',
|
||||
values: [value],
|
||||
format: 'JSONEachRow',
|
||||
});
|
||||
switch (event.type) {
|
||||
case TelemetryEventName.TASK_MESSAGE: {
|
||||
table = 'messages';
|
||||
const { taskId, message } = event.properties;
|
||||
const { ts, type, ask, say, text, reasoning, partial } = message;
|
||||
value = { ...rest, taskId, ts, type, ask, say, text, reasoning, partial };
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
table = 'events';
|
||||
value = { ...rest, type: event.type, ...event.properties };
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
await analytics.insert({ table, values: [value], format: 'JSONEachRow' });
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
34
src/db/clickhouse/events.sql
Normal file
34
src/db/clickhouse/events.sql
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
CREATE TABLE default.events
|
||||
(
|
||||
-- Shared
|
||||
`id` UUID,
|
||||
`orgId` String,
|
||||
`userId` String,
|
||||
`timestamp` Int32,
|
||||
`type` String,
|
||||
|
||||
-- App
|
||||
`appVersion` String,
|
||||
`vscodeVersion` String,
|
||||
`platform` String,
|
||||
`editorName` String,
|
||||
`language` String,
|
||||
`mode` String,
|
||||
|
||||
-- Task
|
||||
`taskId` Nullable(String),
|
||||
`apiProvider` Nullable(String),
|
||||
`modelId` Nullable(String),
|
||||
`diffStrategy` Nullable(String),
|
||||
`isSubtask` Nullable(Bool),
|
||||
|
||||
-- Completion
|
||||
`inputTokens` Nullable(Int32),
|
||||
`outputTokens` Nullable(Int32),
|
||||
`cacheReadTokens` Nullable(Int32),
|
||||
`cacheWriteTokens` Nullable(Int32),
|
||||
`cost` Nullable(Float32)
|
||||
)
|
||||
ENGINE = ReplicatedMergeTree('/clickhouse/tables/{uuid}/{shard}', '{replica}')
|
||||
ORDER BY (id, type, timestamp)
|
||||
SETTINGS index_granularity = 8192;
|
||||
18
src/db/clickhouse/messages.sql
Normal file
18
src/db/clickhouse/messages.sql
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
CREATE TABLE default.messages
|
||||
(
|
||||
`id` UUID,
|
||||
`orgId` String,
|
||||
`userId` String,
|
||||
`taskId` String,
|
||||
`ts` Int32,
|
||||
`type` String, -- "ask" | "say"
|
||||
`ask` Nullable(String),
|
||||
`say` Nullable(String),
|
||||
`text` Nullable(String),
|
||||
`reasoning` Nullable(String),
|
||||
`partial` Nullable(Bool),
|
||||
`timestamp` Int32,
|
||||
)
|
||||
ENGINE = ReplicatedMergeTree('/clickhouse/tables/{uuid}/{shard}', '{replica}')
|
||||
ORDER BY (id, timestamp)
|
||||
SETTINGS index_granularity = 8192;
|
||||
|
|
@ -4,6 +4,5 @@ import { Env } from './env';
|
|||
|
||||
export const analytics = createClient({
|
||||
url: Env.CLICKHOUSE_URL,
|
||||
username: Env.CLICKHOUSE_USERNAME,
|
||||
password: Env.CLICKHOUSE_PASSWORD,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ export const Env = createEnv({
|
|||
VSCODE_EXTENSION_BASE_URL: z.string().min(1),
|
||||
CURSOR_EXTENSION_BASE_URL: z.string().min(1),
|
||||
CLICKHOUSE_URL: z.string().min(1),
|
||||
CLICKHOUSE_USERNAME: z.string().min(1),
|
||||
CLICKHOUSE_PASSWORD: z.string().min(1),
|
||||
},
|
||||
client: {
|
||||
|
|
@ -47,7 +46,6 @@ export const Env = createEnv({
|
|||
process.env.NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL,
|
||||
NODE_ENV: process.env.NODE_ENV,
|
||||
CLICKHOUSE_URL: process.env.CLICKHOUSE_URL,
|
||||
CLICKHOUSE_USERNAME: process.env.CLICKHOUSE_USERNAME,
|
||||
CLICKHOUSE_PASSWORD: process.env.CLICKHOUSE_PASSWORD,
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue