akaaafk commited on
Commit
15259bb
·
verified ·
1 Parent(s): 5695b7a

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +6 -0
  2. benchmark/Cybench/benchmark/bug_bounty/lunary/.dockerignore +15 -0
  3. benchmark/Cybench/benchmark/bug_bounty/lunary/.env.example +19 -0
  4. benchmark/Cybench/benchmark/bug_bounty/lunary/.eslintrc.js +0 -0
  5. benchmark/Cybench/benchmark/bug_bounty/lunary/.prettierrc +3 -0
  6. benchmark/Cybench/benchmark/bug_bounty/lunary/README.md +89 -0
  7. benchmark/Cybench/benchmark/bug_bounty/lunary/package.json +23 -0
  8. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/backend/README.md +15 -0
  9. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/backend/package.json +49 -0
  10. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/backend/tsconfig.json +26 -0
  11. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/db/init.sql +471 -0
  12. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/LICENSE +201 -0
  13. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/README.md +1 -0
  14. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/next-env.d.ts +5 -0
  15. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/next.config.js +56 -0
  16. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/package.json +50 -0
  17. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/_app.tsx +143 -0
  18. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/_document.tsx +16 -0
  19. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/analytics.tsx +235 -0
  20. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/index.tsx +19 -0
  21. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/join.tsx +281 -0
  22. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/login.tsx +141 -0
  23. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/maintenance.tsx +22 -0
  24. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/request-password-reset.tsx +94 -0
  25. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/reset-password.tsx +101 -0
  26. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/settings.tsx +156 -0
  27. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/signup.tsx +500 -0
  28. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/team.tsx +191 -0
  29. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/update-password.tsx +92 -0
  30. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/postcss.config.js +14 -0
  31. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/styles/globals.css +42 -0
  32. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/tsconfig.json +39 -0
  33. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/utils/analytics.ts +107 -0
  34. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/utils/auth.tsx +72 -0
  35. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/utils/colors.ts +69 -0
  36. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/utils/context.ts +11 -0
  37. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/utils/dataHooks.ts +700 -0
  38. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/utils/datatable.tsx +213 -0
  39. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/utils/errors.tsx +47 -0
  40. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/utils/fetcher.ts +112 -0
  41. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/utils/format.ts +82 -0
  42. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/shared/README.md +0 -0
  43. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/shared/filters/index.ts +885 -0
  44. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/shared/filters/params.ts +125 -0
  45. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/shared/filters/serialize.ts +138 -0
  46. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/shared/filters/types.ts +50 -0
  47. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/shared/index.ts +3 -0
  48. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/shared/models.ts +82 -0
  49. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/shared/package.json +10 -0
  50. benchmark/Cybench/benchmark/bug_bounty/lunary/packages/shared/tsconfig.json +19 -0
.gitattributes CHANGED
@@ -687,3 +687,9 @@ benchmark/MIT_Mystery_Hunt/puzzles/by_tsv/2003/2003_www.acme-corp.com_teamGuest_
687
  benchmark/MIT_Mystery_Hunt/puzzles/by_tsv/2003/2003_www.acme-corp.com_teamGuest_R_1_853_index.html/29.mov filter=lfs diff=lfs merge=lfs -text
688
  benchmark/MIT_Mystery_Hunt/puzzles/by_tsv/2003/2003_www.acme-corp.com_teamGuest_R_1_853_index.html/30.mov filter=lfs diff=lfs merge=lfs -text
689
  benchmark/MIT_Mystery_Hunt/puzzles/by_tsv/2003/2003_www.acme-corp.com_teamGuest_R_1_853_index.html/4.mov filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
687
  benchmark/MIT_Mystery_Hunt/puzzles/by_tsv/2003/2003_www.acme-corp.com_teamGuest_R_1_853_index.html/29.mov filter=lfs diff=lfs merge=lfs -text
688
  benchmark/MIT_Mystery_Hunt/puzzles/by_tsv/2003/2003_www.acme-corp.com_teamGuest_R_1_853_index.html/30.mov filter=lfs diff=lfs merge=lfs -text
689
  benchmark/MIT_Mystery_Hunt/puzzles/by_tsv/2003/2003_www.acme-corp.com_teamGuest_R_1_853_index.html/4.mov filter=lfs diff=lfs merge=lfs -text
690
+ benchmark/MIT_Mystery_Hunt/puzzles/by_tsv/2003/2003_www.acme-corp.com_teamGuest_R_1_853_index.html/5.mov filter=lfs diff=lfs merge=lfs -text
691
+ benchmark/MIT_Mystery_Hunt/puzzles/by_tsv/2003/2003_www.acme-corp.com_teamGuest_R_1_853_index.html/6.mov filter=lfs diff=lfs merge=lfs -text
692
+ benchmark/MIT_Mystery_Hunt/puzzles/by_tsv/2003/2003_www.acme-corp.com_teamGuest_R_1_853_index.html/7.mov filter=lfs diff=lfs merge=lfs -text
693
+ benchmark/MIT_Mystery_Hunt/puzzles/by_tsv/2003/2003_www.acme-corp.com_teamGuest_R_1_853_index.html/8.mov filter=lfs diff=lfs merge=lfs -text
694
+ benchmark/MIT_Mystery_Hunt/puzzles/by_tsv/2003/2003_www.acme-corp.com_teamGuest_R_1_853_index.html/9.mov filter=lfs diff=lfs merge=lfs -text
695
+ benchmark/science_bowl/MS-Sample-Questions/Sample-Set-16/2022-MS-3.pdf filter=lfs diff=lfs merge=lfs -text
benchmark/Cybench/benchmark/bug_bounty/lunary/.dockerignore ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ */node_modules
2
+ *npm-debug.log
3
+ *.Dockerfile
4
+ docker-compose*
5
+ .env
6
+ .dockerignore
7
+ .git
8
+ .gitignore
9
+ *README.md
10
+ *LICENSE
11
+ .vscode
12
+ *.next
13
+ *.swp
14
+ /scripts
15
+ .env
benchmark/Cybench/benchmark/bug_bounty/lunary/.env.example ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Next
2
+ NEXT_PUBLIC_API_URL="http://localhost:3333"
3
+ NEXT_PUBLIC_APP_URL="http://localhost:8080"
4
+
5
+ # Database
6
+ DATABASE_URL=<your_db_uri>
7
+
8
+ # POSTGRES_USER="postgres"
9
+ # POSTGRES_PASSWORD="mysecretpassword"
10
+ # POSTGRES_DB="lunary"
11
+
12
+ # Backend
13
+ SKIP_EMAIL_VERIFY=true # Set to false to enable email verification
14
+ DEFAULT_PLAN=free
15
+
16
+ # Playground & Evals (Optional)
17
+ OPENAI_API_KEY=
18
+ OPENROUTER_API_KEY=
19
+ ANTHROPIC_API_KEY
benchmark/Cybench/benchmark/bug_bounty/lunary/.eslintrc.js ADDED
File without changes
benchmark/Cybench/benchmark/bug_bounty/lunary/.prettierrc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "semi": false
3
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/README.md ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div align="center">
2
+
3
+ # 📈 lunary
4
+
5
+ **Open-source observability & prompt platform for LLMs**
6
+
7
+ [website](https://lunary.ai) - [docs](https://lunary.ai/docs) - [self host](https://lunary.ai/docs/self-host)
8
+
9
+ [![npm version](https://badge.fury.io/js/lunary.svg)](https://badge.fury.io/js/lunary) ![PyPI - Version](https://img.shields.io/pypi/v/llmonitor) ![GitHub last commit (by committer)](https://img.shields.io/github/last-commit/lunary-ai/lunary) ![GitHub commit activity (branch)](https://img.shields.io/github/commit-activity/w/lunary-ai/lunary)
10
+
11
+ </div>
12
+
13
+ ## Features
14
+
15
+ Lunary helps AI devs take their apps in production, with features such as:
16
+
17
+ - 💵 Analytics (cost, token, latency, ..)
18
+ - 🔍 Monitoring (logs, traces, user tracking, ..)
19
+ - ⛩️ Prompt Templates (versioning, team collaboration, ..)
20
+ - 🏷️ Creat fine-tuning datasets
21
+ - 🖲️ Chat & feedback tracking
22
+ - 🧪 Evaluations
23
+
24
+ It also designed to be:
25
+
26
+ - 🤖 Usable with any model, not just OpenAI
27
+ - 📦 Easy to integrate (2 minutes)
28
+ - 🧑‍💻 Simple to self-host
29
+
30
+ ## Demo
31
+
32
+ https://github.com/lunary-ai/lunary/assets/5092466/a2b4ba9b-4afb-46e3-9b6b-faf7ddb4a931
33
+
34
+ ## ⚙️ Integration
35
+
36
+ Modules available for:
37
+
38
+ - [JavaScript](https://github.com/lunary-ai/lunary-js)
39
+ - [Python](https://github.com/lunary-ai/lunary-py)
40
+
41
+ Lunary natively supports:
42
+
43
+ - [LangChain](https://lunary.ai/docs/langchain) (JS & Python)
44
+ - [OpenAI module](https://lunary.ai/docs/js/openai)
45
+ - [LiteLLM](https://docs.litellm.ai/docs/observability/lunary_integration)
46
+
47
+ Additionally you can use it with any framework by wrapping the relevant methods.
48
+
49
+ ## 📚 Documentation
50
+
51
+ Full documentation is available [on the website](https://lunary.ai/docs/intro).
52
+
53
+ ## ☁️ Hosted version
54
+
55
+ We offer [a hosted version](https://lunary.ai) with a free plan of up to 1k requests / days.
56
+
57
+ With the hosted version:
58
+
59
+ - 👷 don't worry about devops or managing updates
60
+ - 🙋 get priority 1:1 support with our team
61
+ - 🇪🇺 your data is stored safely in Europe
62
+
63
+ ## Running locally
64
+
65
+ Lunary is powered by Node.js.
66
+
67
+ To run it locally, you'll need access to a Postgres database to set as the `DATABASE_URL` in your `.env` file.
68
+
69
+ ```bash
70
+ # Clone the repository
71
+ git clone https://github.com/lunary-ai/lunary
72
+
73
+ # Copy env variables
74
+ cp .env.example .env
75
+
76
+ # Install dependencies
77
+ npm install
78
+
79
+ # Run the development server
80
+ npm run dev
81
+ ```
82
+
83
+ ## 🙋 Support
84
+
85
+ Need help or have questions? Chat with us on [the website](https://lunary.ai) or email us: [hello [at] lunary.ai](mailto:hello@lunary.ai). We're here to support you every step of the way.
86
+
87
+ ## License
88
+
89
+ This project is licensed under the Apache 2.0 License.
benchmark/Cybench/benchmark/bug_bounty/lunary/package.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "lunary",
3
+ "version": "1.0.0",
4
+ "private": "true",
5
+ "scripts": {
6
+ "dev": "concurrently \"npm run frontend:dev\" \"npm run backend:dev\"",
7
+ "frontend:start": "npm -w packages/frontend run start",
8
+ "frontend:dev": "npm -w packages/frontend run dev",
9
+ "backend:start": "npm -w packages/backend run start",
10
+ "backend:dev": "npm -w packages/backend run dev",
11
+ "backend:radar": "npm -w packages/backend run radar"
12
+ },
13
+ "workspaces": [
14
+ "packages/*"
15
+ ],
16
+ "devDependencies": {
17
+ "concurrently": "^8.2.2",
18
+ "prettier": "^3.2.4",
19
+ "tsup": "^8.0.1",
20
+ "tsx": "^4.7.0",
21
+ "typescript": "^5.3.3"
22
+ }
23
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/backend/README.md ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # backend
2
+
3
+ To install dependencies:
4
+
5
+ ```bash
6
+ bun install
7
+ ```
8
+
9
+ To run:
10
+
11
+ ```bash
12
+ bun run index.ts
13
+ ```
14
+
15
+ This project was created using `bun init` in bun v1.0.14. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/backend/package.json ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@lunary/backend",
3
+ "main": "index.ts",
4
+ "scripts": {
5
+ "dev": "tsx --env-file=.env --watch src/index.ts",
6
+ "start": "tsx src/index.ts",
7
+ "build": "tsup src/index.ts --format esm",
8
+ "radar": "tsx --env-file=.env src/radar.ts"
9
+ },
10
+ "dependencies": {
11
+ "@json2csv/plainjs": "^7.0.5",
12
+ "@koa/cors": "^5.0.0",
13
+ "@sentry/node": "^7.99.0",
14
+ "@sentry/profiling-node": "^1.3.5",
15
+ "@sentry/utils": "^7.99.0",
16
+ "@xenova/transformers": "^2.14.2",
17
+ "argon2": "^0.31.2",
18
+ "bcrypt": "^5.1.1",
19
+ "jose": "^5.2.0",
20
+ "js-tiktoken": "1.0.7",
21
+ "koa": "^2.15.0",
22
+ "koa-bodyparser": "^4.4.1",
23
+ "koa-logger": "^3.2.1",
24
+ "koa-ratelimit": "^5.1.0",
25
+ "koa-router": "^12.0.1",
26
+ "litellm": "^0.12.0",
27
+ "lunary": "^0.7.2",
28
+ "node-cron": "^3.0.3",
29
+ "openai": "^4.26.0",
30
+ "postgres": "^3.4.3",
31
+ "prexit": "^2.2.0",
32
+ "rouge": "^1.0.3",
33
+ "shared": "*",
34
+ "stripe": "^14.14.0",
35
+ "washyourmouthoutwithsoap": "^1.0.2",
36
+ "zod": "^3.22.4"
37
+ },
38
+ "devDependencies": {
39
+ "@types/bcrypt": "^5.0.2",
40
+ "@types/koa": "^2.14.0",
41
+ "@types/koa__cors": "^5.0.0",
42
+ "@types/koa-bodyparser": "^4.3.12",
43
+ "@types/koa-logger": "^3.1.5",
44
+ "@types/koa-ratelimit": "^5.0.5",
45
+ "@types/koa-router": "^7.4.8",
46
+ "@types/node": "^20.11.11",
47
+ "@types/node-cron": "^3.0.11"
48
+ }
49
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/backend/tsconfig.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "compilerOptions": {
3
+ "lib": ["ESNext"],
4
+ "module": "esnext",
5
+ "target": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "moduleDetection": "force",
8
+ "allowImportingTsExtensions": true,
9
+ "noEmit": true,
10
+ "composite": true,
11
+ "strict": true,
12
+ "downlevelIteration": true,
13
+ "skipLibCheck": true,
14
+ "jsx": "react-jsx",
15
+ "allowSyntheticDefaultImports": true,
16
+ "forceConsistentCasingInFileNames": true,
17
+ "allowJs": true,
18
+ "baseUrl": ".",
19
+ "rootDir": "src",
20
+ "paths": {
21
+ "@/*": ["./*"],
22
+ "@/utils/*": ["src/utils/*"],
23
+ "@/checks/*": ["src/checks/*"],
24
+ },
25
+ },
26
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/db/init.sql ADDED
@@ -0,0 +1,471 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ create extension if not exists pg_trgm;
2
+ create extension if not exists pgroonga;
3
+ create extension if not exists "uuid-ossp";
4
+
5
+
6
+ create type user_role as enum (
7
+ 'member',
8
+ 'admin'
9
+ );
10
+
11
+ create type org_plan as enum (
12
+ 'free',
13
+ 'pro',
14
+ 'unlimited',
15
+ 'custom'
16
+ );
17
+
18
+ create type api_key_type as enum (
19
+ 'public',
20
+ 'private'
21
+ );
22
+
23
+ ----------
24
+ --- TABLES
25
+ ----------
26
+ create table account (
27
+ id uuid default uuid_generate_v4() primary key,
28
+ created_at timestamp with time zone default now() not null,
29
+ email text unique,
30
+ password_hash text,
31
+ recovery_token text,
32
+ name text,
33
+ org_id uuid,
34
+ role user_role,
35
+ verified boolean default false not null
36
+ );
37
+ create index on account(org_id);
38
+
39
+ create table api_key (
40
+ id serial primary key,
41
+ created_at timestamp with time zone default now() not null,
42
+ type api_key_type not null,
43
+ api_key uuid default uuid_generate_v4() not null,
44
+ project_id uuid not null
45
+ );
46
+ create index on api_key(project_id);
47
+
48
+ create table external_user (
49
+ id serial primary key,
50
+ created_at timestamp with time zone default now() not null,
51
+ project_id uuid not null,
52
+ external_id character varying,
53
+ last_seen timestamp with time zone,
54
+ props jsonb
55
+ );
56
+ create unique index on external_user (project_id, external_id);
57
+ create index on external_user using gin (lower((props)::text) gin_trgm_ops);
58
+ create index on external_user using gin (lower(external_id) gin_trgm_ops);
59
+ create index on external_user (project_id, last_seen desc);
60
+
61
+
62
+ create table log (
63
+ id bigint primary key,
64
+ created_at timestamp with time zone default now() not null,
65
+ message text,
66
+ level text,
67
+ extra jsonb,
68
+ project_id uuid not null,
69
+ run_id uuid
70
+ );
71
+
72
+ create table org (
73
+ id uuid default uuid_generate_v4() primary key,
74
+ created_at timestamp with time zone default now() not null,
75
+ name text not null,
76
+ plan org_plan not null,
77
+ play_allowance integer default 3 not null,
78
+ stripe_customer text,
79
+ stripe_subscription text,
80
+ limited boolean default false not null,
81
+ plan_period text default 'monthly'::text not null,
82
+ canceled boolean default false not null
83
+ );
84
+
85
+
86
+ create table project (
87
+ id uuid default uuid_generate_v4() primary key,
88
+ created_at timestamp with time zone default now() not null,
89
+ name text not null,
90
+ org_id uuid not null
91
+ );
92
+ create index on project(org_id);
93
+
94
+
95
+ create table run (
96
+ id uuid default uuid_generate_v4() primary key,
97
+ created_at timestamp with time zone default now() not null,
98
+ ended_at timestamp with time zone,
99
+ duration interval generated always as (ended_at - created_at) stored,
100
+ tags text[],
101
+ project_id uuid not null,
102
+ status text,
103
+ name text,
104
+ error jsonb,
105
+ input jsonb,
106
+ output jsonb,
107
+ params jsonb,
108
+ type text not null,
109
+ parent_run_id uuid,
110
+ prompt_tokens integer,
111
+ completion_tokens integer,
112
+ cost float,
113
+ external_user_id bigint,
114
+ feedback jsonb,
115
+ is_public boolean default false not null,
116
+ sibling_run_id uuid,
117
+ template_version_id integer,
118
+ input_text text generated always as ((input)::text) stored,
119
+ output_text text generated always as ((output)::text) stored,
120
+ error_text text generated always as ((error)::text) stored,
121
+ runtime text
122
+ );
123
+ create index on run (type, parent_run_id);
124
+ create index on run (type);
125
+ create index on run (duration);
126
+ create index on run using gin (lower(name) gin_trgm_ops);
127
+ create index on run using gin (lower(output_text) gin_trgm_ops);
128
+ create index on run using gin (lower(input_text) gin_trgm_ops);
129
+ create index on run using pgroonga (input_text, created_at desc);
130
+ create index on run using pgroonga (input);
131
+ create index on run (ended_at, created_at);
132
+ create index on run (created_at desc);
133
+ create index on run (created_at);
134
+ create index on run (created_at, project_id);
135
+ create index on run (project_id, external_user_id);
136
+ create index on run using pgroonga (project_id, type, output_text);
137
+ create index on run using pgroonga (project_id, type, input_text);
138
+ create index on run (project_id, type);
139
+ create index on run using pgroonga (project_id, type, error_text);
140
+ create index on run (project_id, type, created_at desc);
141
+ create index on run (project_id);
142
+ create index on run (external_user_id);
143
+ create index on run using gin (tags);
144
+ create index on run (parent_run_id);
145
+ create index on run (type, external_user_id);
146
+ create index on run (name);
147
+ create index on run using gin (feedback);
148
+
149
+
150
+ create table template (
151
+ id serial primary key,
152
+ created_at timestamp with time zone default now(),
153
+ owner_id uuid,
154
+ name text,
155
+ "group" text,
156
+ slug text,
157
+ project_id uuid not null,
158
+ mode text
159
+ );
160
+
161
+
162
+ create table template_version (
163
+ id serial primary key,
164
+ created_at timestamp with time zone default now() not null,
165
+ extra jsonb,
166
+ content jsonb,
167
+ template_id integer not null,
168
+ version integer,
169
+ test_values jsonb,
170
+ is_draft boolean
171
+ );
172
+
173
+
174
+ create table radar (
175
+ id serial primary key,
176
+ "description" text,
177
+ project_id uuid,
178
+ owner_id uuid,
179
+ view jsonb,
180
+ checks jsonb
181
+ );
182
+
183
+ create table radar_result (
184
+ id serial primary key,
185
+ radar_id integer,
186
+ run_id uuid,
187
+ created_at timestamp with time zone default now() not null,
188
+ results jsonb[],
189
+ passed boolean,
190
+ details jsonb
191
+ );
192
+
193
+ ----------------------
194
+ --- MATERIALIZED VIEWS
195
+ ----------------------
196
+ create materialized view tag_cache as
197
+ select
198
+ run.project_id,
199
+ unnest(run.tags) as tag,
200
+ now() as refreshed_at
201
+ from
202
+ run
203
+ where
204
+ run.type = 'llm'::text
205
+ group by
206
+ run.project_id,
207
+ (unnest(run.tags));
208
+
209
+ create unique index on tag_cache (project_id, tag);
210
+ create index on tag_cache(project_id);
211
+
212
+
213
+ create materialized view model_name_cache as
214
+ select
215
+ run.project_id,
216
+ run.name,
217
+ now() as refreshed_at
218
+ from
219
+ run
220
+ where
221
+ run.type = 'llm'::text
222
+ and run.name is not null
223
+ group by
224
+ run.project_id,
225
+ run.name;
226
+
227
+ create unique index on model_name_cache (project_id, name);
228
+ create index on model_name_cache(project_id);
229
+
230
+
231
+ ----------------
232
+ --- FOREIGN KEYS
233
+ ----------------
234
+ alter table account add foreign key (org_id) references org(id);
235
+
236
+ alter table api_key add foreign key (project_id) references project(id);
237
+
238
+ -- alter table dataset add foreign key (project_id) references project(id) on delete cascade;
239
+
240
+ alter table external_user add foreign key (project_id) references project(id);
241
+
242
+ alter table log add foreign key (project_id) references project(id);
243
+ alter table log add foreign key (run_id) references run(id) on delete cascade on update cascade;
244
+
245
+ alter table project add foreign key (org_id) references org(id);
246
+
247
+ alter table run add foreign key (project_id) references project(id) on delete cascade;
248
+ alter table run add foreign key (parent_run_id) references run(id) on delete set null on update cascade;
249
+ alter table run add foreign key (external_user_id) references external_user(id) on delete set null on update cascade;
250
+ alter table run add foreign key (sibling_run_id) references run(id) on delete set null on update cascade;
251
+
252
+ alter table template add foreign key (project_id) references project(id) on delete cascade;
253
+ alter table template add foreign key (owner_id) references account(id) on delete set null;
254
+
255
+ alter table template_version add foreign key (template_id) references template(id) on delete cascade;
256
+
257
+ alter table radar add foreign key (project_id) references project(id) on delete cascade;
258
+ alter table radar add foreign key (owner_id) references account(id) on delete set null;
259
+
260
+ alter table radar_result add foreign key (radar_id) references radar(id) on delete cascade;
261
+ alter table radar_result add foreign key (run_id) references run(id) on delete cascade on update cascade;
262
+
263
+ update
264
+ api_key
265
+ set
266
+ api_key = project_id
267
+ where
268
+ type = 'public';
269
+
270
+ alter table api_key
271
+ drop constraint "api_key_project_id_fkey",
272
+ add constraint "api_key_project_id_fkey" foreign key (project_id) references project (id) on delete cascade;
273
+
274
+ alter table external_user
275
+ drop constraint "external_user_project_id_fkey",
276
+ add constraint "external_user_project_id_fkey" foreign key (project_id) references project (id) on delete cascade;
277
+
278
+ alter table account
279
+ drop constraint "account_org_id_fkey",
280
+ add constraint "account_org_id_fkey" foreign key (org_id) references org (id) on delete cascade;
281
+
282
+ alter table project
283
+ drop constraint "project_org_id_fkey",
284
+ add constraint "project_org_id_fkey" foreign key (org_id) references org (id) on delete cascade;
285
+
286
+
287
+ -- convert radar tables to use uuids (no data yet)
288
+
289
+ drop table radar;
290
+ drop table radar_result;
291
+
292
+ create table radar (
293
+ "id" uuid default uuid_generate_v4 (),
294
+ "description" text,
295
+ "project_id" uuid,
296
+ "owner_id" uuid,
297
+ "view" jsonb,
298
+ "checks" jsonb,
299
+ "alerts" jsonb,
300
+ "negative" bool,
301
+ constraint "radar_owner_id_fkey" foreign key ("owner_id") references "public"."account" ("id") on delete set null,
302
+ constraint "radar_project_id_fkey" foreign key ("project_id") references "public"."project" ("id") on delete cascade,
303
+ primary key ("id")
304
+ );
305
+
306
+
307
+ create table radar_result (
308
+ "id" uuid default uuid_generate_v4 (),
309
+ "radar_id" uuid,
310
+ "run_id" uuid,
311
+ "created_at" timestamptz not null default now(),
312
+ "results" _jsonb,
313
+ "passed" bool,
314
+ "details" jsonb,
315
+ constraint "radar_result_radar_id_fkey" foreign key ("radar_id") references "public"."radar" ("id") on delete cascade,
316
+ constraint "radar_result_run_id_fkey" foreign key ("run_id") references "public"."run" ("id") on delete cascade on update cascade,
317
+ primary key ("id")
318
+ );
319
+
320
+
321
+ create table evaluation (
322
+ id uuid default uuid_generate_v4() primary key,
323
+ created_at timestamp with time zone default now() not null,
324
+ name text not null,
325
+ owner_id uuid not null,
326
+ project_id uuid not null,
327
+ models text[],
328
+ checks jsonb,
329
+ constraint fk_evaluation_owner_id foreign key (owner_id) references account(id) on delete cascade,
330
+ constraint fk_evaluation_project_id foreign key (project_id) references project(id) on delete cascade
331
+ );
332
+ create index on evaluation (project_id);
333
+
334
+
335
+ create table prompt (
336
+ id uuid default uuid_generate_v4() primary key,
337
+ created_at timestamp with time zone default now() not null,
338
+ evaluation_id uuid not null,
339
+ content jsonb not null,
340
+ extra jsonb,
341
+ constraint fk_prompt_evaluation_id foreign key (evaluation_id) references evaluation(id) on delete cascade
342
+ );
343
+ create index on prompt (evaluation_id);
344
+
345
+
346
+ create table prompt_variation (
347
+ id uuid default uuid_generate_v4() primary key,
348
+ created_at timestamp with time zone default now() not null,
349
+ variables jsonb not null,
350
+ context text,
351
+ ideal_output text,
352
+ prompt_id uuid not null,
353
+ constraint fk_prompt_variation_prompt_id foreign key (prompt_id) references prompt(id) on delete cascade
354
+ );
355
+ create index on prompt_variation (prompt_id);
356
+
357
+
358
+
359
+ create table evaluation_result (
360
+ id uuid default uuid_generate_v4() primary key,
361
+ evaluation_id uuid not null,
362
+ prompt_id uuid,
363
+ variation_id uuid,
364
+ model text not null,
365
+ output jsonb not null,
366
+ results jsonb not null,
367
+ passed boolean default false,
368
+ completion_tokens integer,
369
+ cost float8,
370
+ duration text,
371
+ created_at timestamp with time zone default now() not null,
372
+ constraint fk_evaluation_result_evaluation_id foreign key (evaluation_id) references evaluation(id) on delete cascade,
373
+ constraint fk_evaluation_result_prompt_id foreign key (prompt_id) references prompt(id) on delete cascade,
374
+ constraint fk_evaluation_result_variation_id foreign key (variation_id) references prompt_variation(id) on delete cascade
375
+ );
376
+ create index on evaluation_result(evaluation_id, prompt_id, variation_id, model);
377
+
378
+
379
+ alter table prompt rename to evaluation_prompt;
380
+ alter table prompt_variation rename to evaluation_prompt_variation;
381
+ alter table prompt rename column content to messages
382
+
383
+ -- 14/02/2024
384
+
385
+ create table checklist (
386
+ id uuid default uuid_generate_v4() primary key,
387
+ slug text not null,
388
+ data jsonb not null,
389
+ type text not null,
390
+ created_at timestamp with time zone default now(),
391
+ updated_at timestamp with time zone default now(),
392
+ owner_id uuid not null,
393
+ project_id uuid not null,
394
+ constraint fk_checklist_owner_id foreign key (owner_id) references account(id) on delete set null,
395
+ constraint fk_checklist_project_id foreign key (project_id) references project(id) on delete cascade
396
+ );
397
+
398
+ create table provider (
399
+ id uuid default uuid_generate_v4() primary key,
400
+ model text not null,
401
+ params jsonb,
402
+ created_at timestamp with time zone default now(),
403
+ updated_at timestamp with time zone default now(),
404
+ owner_id uuid not null,
405
+ project_id uuid not null,
406
+ constraint fk_checklist_owner_id foreign key (owner_id) references account(id) on delete set null,
407
+ constraint fk_checklist_project_id foreign key (project_id) references project(id) on delete cascade
408
+ );
409
+
410
+ alter table evaluation add column checklist_id uuid references checklist(id) on delete set null;
411
+
412
+
413
+
414
+
415
+ create table dataset (
416
+ id uuid not null default uuid_generate_v4() primary key,
417
+ created_at timestamptz not null default now(),
418
+ updated_at timestamptz not null default now(),
419
+ project_id uuid not null,
420
+ owner_id uuid not null,
421
+ slug text not null,
422
+
423
+ foreign key (project_id) references project(id) on delete cascade,
424
+ foreign key (owner_id) references account(id)
425
+
426
+ );
427
+ create index on dataset (project_id, slug);
428
+
429
+
430
+ create table dataset_prompt (
431
+ id uuid not null default uuid_generate_v4() primary key,
432
+ created_at timestamptz not null default now(),
433
+ dataset_id uuid not null,
434
+ messages jsonb not null,
435
+ foreign key (dataset_id) references dataset(id) on delete cascade
436
+ );
437
+ create index on dataset_prompt(dataset_id);
438
+
439
+
440
+ create table dataset_prompt_variation (
441
+ id uuid not null default uuid_generate_v4() primary key,
442
+ created_at timestamptz not null default now(),
443
+ variables jsonb not null,
444
+ context text,
445
+ ideal_output text,
446
+ prompt_id uuid not null,
447
+ foreign key (prompt_id) references dataset_prompt (id) on delete cascade
448
+ );
449
+ create index on dataset_prompt_variation(prompt_id);
450
+
451
+
452
+ create table evaluation (
453
+ id uuid not null default uuid_generate_v4(),
454
+ created_at timestamptz not null default now() primary key,
455
+ name text not null,
456
+ project_id uuid not null,
457
+ owner_id uuid not null,
458
+ dataset_id uuid not null,
459
+ models _text not null,
460
+ checks jsonb not null,
461
+ foreign key (project_id) references project(id) on delete cascade,
462
+ foreign key (owner_id) references account(id),
463
+ foreign key (dataset_id) references dataset(id)
464
+ );
465
+ create index on evaluation(project_id);
466
+
467
+
468
+
469
+ alter table evaluation_result
470
+ drop constraint "fk_evaluation_result_variation_id",
471
+ add constraint "fk_evaluation_result_variation_id" foreign key (prompt_id) references dataset_prompt(id) on delete cascade;
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/README.md ADDED
@@ -0,0 +1 @@
 
 
1
+ ## Next.js
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/next-env.d.ts ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ /// <reference types="next" />
2
+ /// <reference types="next/image-types/global" />
3
+
4
+ // NOTE: This file should not be edited
5
+ // see https://nextjs.org/docs/basic-features/typescript for more information.
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/next.config.js ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /** @type {import('next').NextConfig} */
2
+ const nextConfig = {
3
+ reactStrictMode: true,
4
+ eslint: {
5
+ // Warning: This allows production builds to successfully complete even if
6
+ // your project has ESLint errors.
7
+ ignoreDuringBuilds: true,
8
+ },
9
+ typescript: {
10
+ // !! WARN !!
11
+ // Dangerously allow production builds to successfully complete even if
12
+ // your project has type errors.
13
+ // !! WARN !!
14
+ ignoreBuildErrors: true,
15
+ },
16
+ images: {
17
+ remotePatterns: [
18
+ {
19
+ protocol: "https",
20
+ hostname: "**",
21
+ },
22
+ ],
23
+ },
24
+ async rewrites() {
25
+ return [
26
+ {
27
+ source: "/ingest/:path*",
28
+ destination: "https://app.posthog.com/:path*",
29
+ },
30
+ {
31
+ source: "/api/v1/report",
32
+ destination: process.env.NEXT_PUBLIC_API_URL + "/api/report",
33
+ },
34
+ {
35
+ source: "/api/report",
36
+ destination: process.env.NEXT_PUBLIC_API_URL + "/api/report",
37
+ },
38
+ {
39
+ source: "/api/v1/template",
40
+ destination: process.env.NEXT_PUBLIC_API_URL + "/api/v1/template",
41
+ },
42
+ ]
43
+ },
44
+ webpack: (config, { webpack }) => {
45
+ config.plugins.push(
46
+ new webpack.IgnorePlugin({
47
+ resourceRegExp: /^pg-native$|^cloudflare:sockets$/,
48
+ }),
49
+ )
50
+
51
+ return config
52
+ },
53
+ transpilePackages: ["shared"],
54
+ }
55
+
56
+ module.exports = nextConfig
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/package.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@lunary/frontend",
3
+ "main": "pages/index.ts",
4
+ "scripts": {
5
+ "dev": "next dev -p 8080",
6
+ "build": "next build",
7
+ "start": "next start",
8
+ "lint": "next lint",
9
+ "format": "prettier --write ./**/*.{ts,tsx}"
10
+ },
11
+ "dependencies": {
12
+ "@calcom/embed-react": "^1.3.0",
13
+ "@mantine/core": "^7.5.0",
14
+ "@mantine/form": "^7.5.0",
15
+ "@mantine/hooks": "^7.5.0",
16
+ "@mantine/modals": "^7.5.0",
17
+ "@mantine/notifications": "^7.5.0",
18
+ "@tabler/icons-react": "^2.46.0",
19
+ "@tanstack/react-table": "^8.11.2",
20
+ "@tanstack/react-virtual": "3.0.0-alpha.0",
21
+ "@types/node": "20.10.5",
22
+ "@types/react": "18.2.45",
23
+ "@types/react-dom": "18.2.18",
24
+ "bcrypt": "^5.1.1",
25
+ "crisp-sdk-web": "^1.0.21",
26
+ "date-fns": "^3.3.1",
27
+ "jose": "^5.2.0",
28
+ "jsonrepair": "^3.5.1",
29
+ "next": "^14.1.0",
30
+ "next-plausible": "^3.12.0",
31
+ "next-seo": "^6.4.0",
32
+ "postgres": "^3.4.3",
33
+ "posthog-js": "^1.103.1",
34
+ "random-word-slugs": "^0.1.7",
35
+ "react": "18.2.0",
36
+ "react-confetti": "^6.1.0",
37
+ "react-dom": "18.2.0",
38
+ "react-json-view-lite": "^1.2.1",
39
+ "recharts": "^2.11.0",
40
+ "shared": "*",
41
+ "swr": "^2.2.4"
42
+ },
43
+ "devDependencies": {
44
+ "@types/react": "18.2.45",
45
+ "@types/react-dom": "^18.2.18",
46
+ "postcss": "^8.4.33",
47
+ "postcss-preset-mantine": "^1.12.3",
48
+ "postcss-simple-vars": "^7.0.1"
49
+ }
50
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/_app.tsx ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import "@mantine/core/styles.css"
2
+ import "@mantine/notifications/styles.css"
3
+ import "../styles/globals.css"
4
+
5
+ import { MantineProvider, createTheme } from "@mantine/core"
6
+ import type { AppProps } from "next/app"
7
+ import Head from "next/head"
8
+
9
+ import Layout from "@/components/Layout"
10
+ import AnalyticsWrapper from "@/components/Layout/Analytics"
11
+ import { DefaultSeo } from "next-seo"
12
+ import Link from "next/link"
13
+
14
+ import { fetcher } from "@/utils/fetcher"
15
+ import localFont from "next/font/local"
16
+ import { SWRConfig } from "swr"
17
+ import { AuthProvider } from "@/utils/auth"
18
+
19
+ export const circularPro = localFont({
20
+ display: "swap",
21
+ fallback: [
22
+ "-apple-system",
23
+ "BlinkMacSystemFont",
24
+ "Segoe UI",
25
+ "Roboto",
26
+ "Helvetica",
27
+ "Arial",
28
+ "sans-serif",
29
+ ],
30
+ src: [
31
+ {
32
+ path: "../public/fonts/circular-pro-book.woff2",
33
+ weight: "400",
34
+ style: "normal",
35
+ },
36
+ {
37
+ path: "../public/fonts/circular-pro-medium.woff2",
38
+ weight: "500",
39
+ style: "normal",
40
+ },
41
+ {
42
+ path: "../public/fonts/circular-pro-bold.woff2",
43
+ weight: "700",
44
+ style: "normal",
45
+ },
46
+ // {
47
+ // path: "../public/fonts/circular-pro-black.woff2",
48
+ // weight: "900",
49
+ // style: "normal",
50
+ // },
51
+ ],
52
+ })
53
+
54
+ const theme = createTheme({
55
+ defaultRadius: "md",
56
+ fontFamily: circularPro.style.fontFamily,
57
+ headings: {
58
+ fontWeight: "700",
59
+ },
60
+ components: {
61
+ Anchor: {
62
+ defaultProps: {
63
+ component: Link,
64
+ },
65
+ },
66
+ NavLink: {
67
+ defaultProps: {
68
+ h: 36,
69
+ },
70
+ },
71
+ Select: {
72
+ defaultProps: {
73
+ spellCheck: "false",
74
+ autoCorrect: "off",
75
+ },
76
+ },
77
+ Button: {
78
+ defaultProps: {
79
+ fw: "500",
80
+ },
81
+ },
82
+ Popover: {
83
+ defaultProps: {
84
+ withArrow: true,
85
+ shadow: "sm",
86
+ },
87
+ },
88
+ Combobox: {
89
+ defaultProps: {
90
+ withArrow: true,
91
+ shadow: "sm",
92
+ },
93
+ },
94
+ HoverCard: {
95
+ defaultProps: {
96
+ withArrow: true,
97
+ shadow: "sm",
98
+ },
99
+ },
100
+ Tooltip: {
101
+ defaultProps: {
102
+ withArrow: true,
103
+ shadow: "sm",
104
+ },
105
+ },
106
+ },
107
+ })
108
+
109
+ export default function App({ Component, pageProps }: AppProps) {
110
+ return (
111
+ <>
112
+ <style jsx global>{`
113
+ html {
114
+ font-family: ${circularPro.style.fontFamily};
115
+ }
116
+ `}</style>
117
+ <Head>
118
+ <link href="https://lunary.ai/logo.png" rel="icon" type="image/png" />
119
+ </Head>
120
+ <AuthProvider>
121
+ <SWRConfig
122
+ value={{
123
+ fetcher: fetcher.get,
124
+ dedupingInterval: 10000,
125
+ }}
126
+ >
127
+ <DefaultSeo
128
+ title="Dashboard"
129
+ titleTemplate="%s | Lunary"
130
+ defaultTitle="Dashboard | Lunary"
131
+ />
132
+ <MantineProvider theme={theme} defaultColorScheme="auto">
133
+ <AnalyticsWrapper>
134
+ <Layout>
135
+ <Component {...pageProps} />
136
+ </Layout>
137
+ </AnalyticsWrapper>
138
+ </MantineProvider>
139
+ </SWRConfig>
140
+ </AuthProvider>
141
+ </>
142
+ )
143
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/_document.tsx ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Html, Head, Main, NextScript } from "next/document"
2
+ import { ColorSchemeScript } from "@mantine/core"
3
+
4
+ export default function Document() {
5
+ return (
6
+ <Html lang="en">
7
+ <Head>
8
+ <ColorSchemeScript defaultColorScheme="auto" />
9
+ </Head>
10
+ <body>
11
+ <Main />
12
+ <NextScript />
13
+ </body>
14
+ </Html>
15
+ )
16
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/analytics.tsx ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import AgentSummary from "@/components/Analytics/AgentSummary"
2
+ import AnalyticsCard from "@/components/Analytics/AnalyticsCard"
3
+ import BarList from "@/components/Analytics/BarList"
4
+ import LineChart from "@/components/Analytics/LineChart"
5
+ import UsageSummary from "@/components/Analytics/UsageSummary"
6
+ import { formatAppUser, formatCost } from "@/utils/format"
7
+
8
+ import AppUserAvatar from "@/components/Blocks/AppUserAvatar"
9
+ import Empty from "@/components/Layout/Empty"
10
+ import {
11
+ useAppUsers,
12
+ useOrg,
13
+ useProject,
14
+ useRunsUsage,
15
+ useRunsUsageByDay,
16
+ } from "@/utils/dataHooks"
17
+ import {
18
+ Center,
19
+ Container,
20
+ Group,
21
+ Loader,
22
+ SegmentedControl,
23
+ SimpleGrid,
24
+ Stack,
25
+ Title,
26
+ } from "@mantine/core"
27
+ import { useLocalStorage } from "@mantine/hooks"
28
+ import { IconChartAreaLine } from "@tabler/icons-react"
29
+ import { NextSeo } from "next-seo"
30
+
31
+ const calculateDailyCost = (usage) => {
32
+ // calculate using calcRunCost, reduce by model, and filter by type llm
33
+ // reduce by day
34
+
35
+ const cost = usage.reduce((acc, curr) => {
36
+ const { date, cost } = curr
37
+
38
+ if (!acc[date]) acc[date] = 0
39
+ acc[date] += cost
40
+
41
+ return acc
42
+ }, {})
43
+
44
+ const final = Object.keys(cost).map((date) => ({
45
+ date,
46
+ cost: cost[date],
47
+ }))
48
+
49
+ return final
50
+ }
51
+
52
+ export default function Analytics() {
53
+ const [range, setRange] = useLocalStorage({
54
+ key: "dateRange-analytics",
55
+ defaultValue: 7,
56
+ })
57
+
58
+ const { project } = useProject()
59
+
60
+ const { org } = useOrg()
61
+
62
+ const { usage, loading: usageLoading } = useRunsUsage(range)
63
+
64
+ const { dailyUsage, loading: dailyUsageLoading } = useRunsUsageByDay(range)
65
+ const { users, loading: usersLoading } = useAppUsers(range)
66
+
67
+ const loading = usageLoading || dailyUsageLoading || usersLoading
68
+
69
+ if (loading)
70
+ return (
71
+ <Center h="60vh">
72
+ <Loader />
73
+ </Center>
74
+ )
75
+
76
+ return (
77
+ <Empty
78
+ Icon={IconChartAreaLine}
79
+ title="Waiting for data..."
80
+ description="Analytics will appear here once you have some data."
81
+ showProjectId
82
+ enable={!loading && !project?.activated}
83
+ >
84
+ <Container size="lg" my="lg">
85
+ <NextSeo title="Analytics" />
86
+ <Stack gap="lg">
87
+ <Group justify="space-between">
88
+ <Title order={2}>Analytics</Title>
89
+ <SegmentedControl
90
+ w={300}
91
+ value={range.toString()}
92
+ onChange={(val) => setRange(parseInt(val))}
93
+ data={[
94
+ { label: "24H", value: "1" },
95
+ { label: "7D", value: "7" },
96
+ { label: "30D", value: "30" },
97
+ { label: "90D", value: "90" },
98
+ ]}
99
+ />
100
+ </Group>
101
+
102
+ <SimpleGrid cols={{ base: 1, sm: 3 }} spacing="md">
103
+ {usage && (
104
+ <>
105
+ <UsageSummary usage={usage} />
106
+ <AgentSummary usage={usage} />
107
+ </>
108
+ )}
109
+
110
+ {users && (
111
+ <AnalyticsCard title="Users">
112
+ <BarList
113
+ customMetric={{
114
+ label: "users",
115
+ value: users.length,
116
+ }}
117
+ filterZero={false}
118
+ data={users
119
+ .sort((a, b) => a.cost - b.cost)
120
+ .map((u) => ({
121
+ agentRuns: u.agentRuns,
122
+ cost: u.cost,
123
+ barSections: [
124
+ {
125
+ value: "cost",
126
+ tooltip: "Cost",
127
+ count: u.cost,
128
+ color: "teal.2",
129
+ },
130
+ ],
131
+ ...u,
132
+ }))}
133
+ columns={[
134
+ {
135
+ name: "User",
136
+ render: (u, row) => (
137
+ <Group my={-4} gap="sm">
138
+ <AppUserAvatar size={30} user={row} />
139
+ {formatAppUser(row)}
140
+ </Group>
141
+ ),
142
+ },
143
+ {
144
+ name: "Cost",
145
+ key: "cost",
146
+ render: formatCost,
147
+ main: true,
148
+ },
149
+ ]}
150
+ />
151
+ </AnalyticsCard>
152
+ )}
153
+ </SimpleGrid>
154
+
155
+ {dailyUsage && (
156
+ <>
157
+ <LineChart
158
+ range={range}
159
+ title="Tokens"
160
+ height={230}
161
+ splitBy="name"
162
+ data={dailyUsage
163
+ .filter((u) => u.type === "llm")
164
+ .map((p) => ({
165
+ ...p,
166
+ tokens: p.completionTokens + p.promptTokens,
167
+ }))}
168
+ props={["tokens"]}
169
+ />
170
+
171
+ <LineChart
172
+ title="Cost Usage"
173
+ range={range}
174
+ height={230}
175
+ formatter={formatCost}
176
+ data={calculateDailyCost(dailyUsage)}
177
+ props={["cost"]}
178
+ />
179
+
180
+ <LineChart
181
+ range={range}
182
+ title="Agents"
183
+ height={230}
184
+ splitBy="name"
185
+ data={dailyUsage
186
+ .filter((u) => u.type === "agent")
187
+ .map((p) => ({
188
+ ...p,
189
+ runs: p.success + p.errors,
190
+ }))}
191
+ props={["runs"]}
192
+ />
193
+
194
+ {org?.plan === "free" && (
195
+ <>
196
+ <LineChart
197
+ blocked={true}
198
+ props={["users"]}
199
+ range={range}
200
+ title="Avg User Cost"
201
+ height={230}
202
+ />
203
+
204
+ <LineChart
205
+ blocked={true}
206
+ range={range}
207
+ props={["users"]}
208
+ title="Errors over time"
209
+ height={230}
210
+ />
211
+
212
+ <LineChart
213
+ blocked={true}
214
+ range={range}
215
+ props={["users"]}
216
+ title="Avg latency"
217
+ height={230}
218
+ />
219
+
220
+ <LineChart
221
+ blocked={true}
222
+ range={range}
223
+ props={["users"]}
224
+ title="Positive feedback"
225
+ height={230}
226
+ />
227
+ </>
228
+ )}
229
+ </>
230
+ )}
231
+ </Stack>
232
+ </Container>
233
+ </Empty>
234
+ )
235
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/index.tsx ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useAuth } from "@/utils/auth"
2
+ import { Center, Loader } from "@mantine/core"
3
+ import Router from "next/router"
4
+ import { useEffect } from "react"
5
+
6
+ function IndexPage() {
7
+ const { isSignedIn } = useAuth()
8
+ useEffect(() => {
9
+ Router.replace(isSignedIn ? "/analytics" : "/login")
10
+ }, [])
11
+
12
+ return (
13
+ <Center h="100vh" w="100vw">
14
+ <Loader />
15
+ </Center>
16
+ )
17
+ }
18
+
19
+ export default IndexPage
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/join.tsx ADDED
@@ -0,0 +1,281 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useEffect, useState } from "react"
2
+
3
+ import {
4
+ Anchor,
5
+ Button,
6
+ Container,
7
+ Flex,
8
+ Paper,
9
+ PasswordInput,
10
+ Stack,
11
+ Text,
12
+ TextInput,
13
+ Title,
14
+ } from "@mantine/core"
15
+
16
+ import { useForm } from "@mantine/form"
17
+ import { IconAnalyze, IconAt, IconUser } from "@tabler/icons-react"
18
+
19
+ import analytics from "@/utils/analytics"
20
+ import { useAuth } from "@/utils/auth"
21
+ import errorHandler from "@/utils/errors"
22
+ import { fetcher } from "@/utils/fetcher"
23
+ import { SEAT_ALLOWANCE } from "@/utils/pricing"
24
+ import { NextSeo } from "next-seo"
25
+ import Router, { useRouter } from "next/router"
26
+ import Confetti from "react-confetti"
27
+ import postgres from "postgres"
28
+
29
+ const sql = postgres(process.env.DATABASE_URL!)
30
+
31
+ export async function getServerSideProps(context) {
32
+ const { orgId } = context.query
33
+
34
+ const [org] = await sql`
35
+ SELECT name, plan FROM org WHERE id = ${orgId}
36
+ `
37
+
38
+ const [orgUserCountResult] = await sql`
39
+ SELECT COUNT(*) FROM account WHERE org_id = ${orgId}
40
+ `
41
+ const orgUserCount = orgUserCountResult.count
42
+
43
+ return {
44
+ props: { orgUserCount, orgName: org?.name, orgId, orgPlan: org?.plan },
45
+ }
46
+ }
47
+
48
+ function TeamFull({ orgName }) {
49
+ return (
50
+ <Container py={100} size={600}>
51
+ <NextSeo title="Signup" />
52
+ <Stack align="center" gap={30}>
53
+ <IconAnalyze color={"#206dce"} size={60} />
54
+ <Title order={2} fw={700} size={40} ta="center">
55
+ Sorry, ${orgName} is full
56
+ </Title>
57
+
58
+ <Flex align="center" gap={30}>
59
+ <Button size="md" onClick={() => Router.push("/")}>
60
+ Go back home
61
+ </Button>
62
+ <Anchor
63
+ component="button"
64
+ type="button"
65
+ onClick={() => {
66
+ $crisp.push(["do", "chat:open"])
67
+ }}
68
+ >
69
+ Contact support →
70
+ </Anchor>
71
+ </Flex>
72
+ </Stack>
73
+ </Container>
74
+ )
75
+ }
76
+ export default function Join({ orgUserCount, orgName, orgId, orgPlan }) {
77
+ const auth = useAuth()
78
+ const [loading, setLoading] = useState(false)
79
+ const [step, setStep] = useState(1)
80
+ const router = useRouter()
81
+
82
+ useEffect(() => {
83
+ router.query.step = String(step)
84
+ router.push(router)
85
+ }, [step])
86
+
87
+ const form = useForm({
88
+ initialValues: {
89
+ email: "",
90
+ name: "",
91
+ password: "",
92
+ },
93
+
94
+ validate: {
95
+ email: (val) => (/^\S+@\S+$/.test(val) ? null : "Invalid email"),
96
+ name: (val) => (val.length <= 2 ? "Your name that short :) ?" : null),
97
+ password: (val) =>
98
+ val.length < 6 ? "Password must be at least 6 characters" : null,
99
+ },
100
+ })
101
+
102
+ const handleSignup = async ({
103
+ email,
104
+ password,
105
+ name,
106
+ }: {
107
+ email: string
108
+ password: string
109
+ name: string
110
+ }) => {
111
+ setLoading(true)
112
+
113
+ const body = await errorHandler(
114
+ fetcher.post("/auth/signup", {
115
+ arg: {
116
+ email,
117
+ password,
118
+ name,
119
+ orgId,
120
+ signupMethod: "join",
121
+ },
122
+ }),
123
+ )
124
+
125
+ if (body?.token) {
126
+ // add ?done to the url
127
+ Router.replace("/signup?done")
128
+ auth.setJwt(body.token)
129
+
130
+ analytics.track("Join", { email, name })
131
+ }
132
+
133
+ setLoading(false)
134
+ }
135
+
136
+ const nextStep = () => {
137
+ if (step === 1) {
138
+ if (
139
+ form.validateField("email").hasError ||
140
+ form.validateField("password").hasError
141
+ ) {
142
+ return
143
+ }
144
+ }
145
+
146
+ setStep(step + 1)
147
+ }
148
+
149
+ if (orgUserCount >= SEAT_ALLOWANCE[orgPlan]) {
150
+ return <TeamFull orgName={orgName} />
151
+ }
152
+
153
+ return (
154
+ <Container py={100} size={600}>
155
+ <NextSeo title="Join" />
156
+
157
+ <Stack align="center" gap={50}>
158
+ <Stack align="center">
159
+ <IconAnalyze color={"#206dce"} size={60} />
160
+ <Title order={2} fw={700} size={40} ta="center">
161
+ Join {orgName}
162
+ </Title>
163
+ </Stack>
164
+ <Paper radius="md" p="xl" withBorder miw={350}>
165
+ <form onSubmit={form.onSubmit(handleSignup)}>
166
+ <Stack gap="xl">
167
+ {step === 1 && (
168
+ <>
169
+ <Title order={2} fw={700} ta="center">
170
+ Get Started
171
+ </Title>
172
+ <TextInput
173
+ leftSection={<IconAt size="16" />}
174
+ label="Email"
175
+ type="email"
176
+ autoComplete="email"
177
+ error={form.errors.email && "Invalid email"}
178
+ placeholder="Your email"
179
+ {...form.getInputProps("email")}
180
+ />
181
+
182
+ <PasswordInput
183
+ label="Password"
184
+ autoComplete="new-password"
185
+ onKeyPress={(e) => {
186
+ if (e.key === "Enter") {
187
+ nextStep()
188
+ }
189
+ }}
190
+ error={form.errors.password && "Invalid password"}
191
+ placeholder="Your password"
192
+ {...form.getInputProps("password")}
193
+ />
194
+
195
+ <Button
196
+ size="md"
197
+ mt="md"
198
+ onClick={nextStep}
199
+ fullWidth
200
+ loading={loading}
201
+ >
202
+ {`Continue →`}
203
+ </Button>
204
+ </>
205
+ )}
206
+
207
+ {step === 2 && (
208
+ <>
209
+ <Title order={2} fw={700} ta="center">
210
+ Almost there...
211
+ </Title>
212
+
213
+ <TextInput
214
+ label="Full Name"
215
+ autoComplete="name"
216
+ description="Only used to address you properly."
217
+ leftSection={<IconUser size="16" />}
218
+ placeholder="Your full name"
219
+ error={form.errors.name && "This field is required"}
220
+ {...form.getInputProps("name")}
221
+ />
222
+
223
+ <Stack>
224
+ <Button
225
+ size="md"
226
+ mt="md"
227
+ type="submit"
228
+ fullWidth
229
+ loading={loading}
230
+ >
231
+ {`Create account`}
232
+ </Button>
233
+
234
+ <Button
235
+ size="sm"
236
+ onClick={() => setStep(1)}
237
+ fullWidth
238
+ variant="link"
239
+ color="gray.4"
240
+ >
241
+ {`← Go back`}
242
+ </Button>
243
+ </Stack>
244
+ </>
245
+ )}
246
+
247
+ {step === 3 && (
248
+ <>
249
+ <Confetti
250
+ recycle={false}
251
+ numberOfPieces={500}
252
+ gravity={0.3}
253
+ />
254
+
255
+ <Stack align="center">
256
+ <IconAnalyze color={"#206dce"} size={60} />
257
+ <Title order={2} fw={700} size={40} ta="center">
258
+ You&nbsp;re all set 🎉
259
+ </Title>
260
+
261
+ <Text size="lg" mt="xs" mb="xl" fw={500}>
262
+ Check your emails for the confirmation link.
263
+ </Text>
264
+
265
+ <Button
266
+ onClick={() => router.push("/")}
267
+ variant="outline"
268
+ size="lg"
269
+ >
270
+ Open Dashboard
271
+ </Button>
272
+ </Stack>
273
+ </>
274
+ )}
275
+ </Stack>
276
+ </form>
277
+ </Paper>
278
+ </Stack>
279
+ </Container>
280
+ )
281
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/login.tsx ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {
2
+ Anchor,
3
+ Button,
4
+ Container,
5
+ Paper,
6
+ Stack,
7
+ Text,
8
+ TextInput,
9
+ Title,
10
+ } from "@mantine/core"
11
+
12
+ import { useForm } from "@mantine/form"
13
+ import { IconAnalyze, IconAt } from "@tabler/icons-react"
14
+
15
+ import { useState } from "react"
16
+
17
+ import analytics from "@/utils/analytics"
18
+ import { fetcher } from "@/utils/fetcher"
19
+ import { NextSeo } from "next-seo"
20
+ import { useAuth } from "@/utils/auth"
21
+
22
+ function LoginPage() {
23
+ const [loading, setLoading] = useState(false)
24
+ const auth = useAuth()
25
+
26
+ const form = useForm({
27
+ initialValues: {
28
+ email: "",
29
+ password: "",
30
+ },
31
+
32
+ validate: {
33
+ email: (val) => (/^\S+@\S+$/.test(val) ? null : "Invalid email"),
34
+ password: (val) =>
35
+ val.length < 6 ? "Password must be at least 6 characters" : null,
36
+ },
37
+ })
38
+
39
+ async function handleLoginWithPassword({
40
+ email,
41
+ password,
42
+ }: {
43
+ email: string
44
+ password: string
45
+ }) {
46
+ setLoading(true)
47
+
48
+ try {
49
+ const { token } = await fetcher.post("/auth/login", {
50
+ arg: {
51
+ email,
52
+ password,
53
+ },
54
+ })
55
+
56
+ if (!token) {
57
+ throw new Error("No token received")
58
+ }
59
+
60
+ auth.setJwt(token)
61
+
62
+ analytics.track("Login", { method: "password" })
63
+ } catch (error) {
64
+ console.error(error)
65
+
66
+ // empty local storage
67
+ auth.setJwt(null)
68
+ }
69
+
70
+ setLoading(false)
71
+ }
72
+
73
+ return (
74
+ <Container pt="60" size="600">
75
+ <NextSeo title="Login" />
76
+ <Stack align="center" gap="50">
77
+ <Stack align="center">
78
+ <IconAnalyze color="#206dce" size="60" />
79
+ <Title order={2} fw="700" size="40" ta="center">
80
+ Welcome back
81
+ </Title>
82
+ </Stack>
83
+ <Paper radius="md" p="xl" withBorder miw="350">
84
+ <Text size="lg" mb="xl" fw="500">
85
+ Sign In
86
+ </Text>
87
+
88
+ <form onSubmit={form.onSubmit(handleLoginWithPassword)}>
89
+ <Stack>
90
+ <TextInput
91
+ leftSection={<IconAt size="16" />}
92
+ label="Email"
93
+ type="email"
94
+ autoComplete="email"
95
+ value={form.values.email}
96
+ onChange={(event) =>
97
+ form.setFieldValue("email", event.currentTarget.value)
98
+ }
99
+ error={form.errors.email}
100
+ placeholder="Your email"
101
+ />
102
+
103
+ <div>
104
+ <TextInput
105
+ type="password"
106
+ autoComplete="current-password"
107
+ label="Password"
108
+ value={form.values.password}
109
+ onChange={(event) =>
110
+ form.setFieldValue("password", event.currentTarget.value)
111
+ }
112
+ error={form.errors.password}
113
+ placeholder="Your password"
114
+ />
115
+ <Anchor
116
+ display="block"
117
+ pt="xs"
118
+ size="sm"
119
+ href="/request-password-reset"
120
+ >
121
+ Forgot password?
122
+ </Anchor>
123
+ </div>
124
+
125
+ <Button mt="md" type="submit" fullWidth loading={loading}>
126
+ Login
127
+ </Button>
128
+
129
+ <Text size="sm" style={{ textAlign: "center" }}>
130
+ {`Don't have an account? `}
131
+ <Anchor href="/signup">Sign Up</Anchor>
132
+ </Text>
133
+ </Stack>
134
+ </form>
135
+ </Paper>
136
+ </Stack>
137
+ </Container>
138
+ )
139
+ }
140
+
141
+ export default LoginPage
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/maintenance.tsx ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // pages/maintenance.tsx
2
+ import { useRouter } from "next/router"
3
+ import React, { useEffect } from "react"
4
+
5
+ export default function Maintenance() {
6
+ const router = useRouter()
7
+ useEffect(() => {
8
+ if (process.env.NEXT_PUBLIC_MAINTENANCE_MODE !== "on") {
9
+ router.push("/")
10
+ }
11
+ }, [router])
12
+
13
+ return (
14
+ <div>
15
+ <h1>We&apos;re currently undergoing maintenance</h1>
16
+ <p>
17
+ Rest assured, all your new events are safely stored and will be
18
+ accessible once we&apos;re back.
19
+ </p>
20
+ </div>
21
+ )
22
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/request-password-reset.tsx ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {
2
+ Button,
3
+ Container,
4
+ Paper,
5
+ Stack,
6
+ Text,
7
+ TextInput,
8
+ Title,
9
+ } from "@mantine/core"
10
+ import { useForm } from "@mantine/form"
11
+ import { notifications } from "@mantine/notifications"
12
+ import { IconAnalyze, IconAt, IconCheck } from "@tabler/icons-react"
13
+ import { NextSeo } from "next-seo"
14
+ import { useState } from "react"
15
+ import errorHandler from "../utils/errors"
16
+
17
+ export default function PasswordReset() {
18
+ const [loading, setLoading] = useState(false)
19
+
20
+ const form = useForm({
21
+ initialValues: {
22
+ email: "",
23
+ },
24
+
25
+ validate: {
26
+ email: (val) => (/^\S+@\S+$/.test(val) ? null : "Invalid email"),
27
+ },
28
+ })
29
+
30
+ async function handlePasswordReset({ email }) {
31
+ setLoading(true)
32
+
33
+ const res = await errorHandler(
34
+ fetch(`${process.env.NEXT_PUBLIC_API_URL}/auth/request-password-reset`, {
35
+ method: "POST",
36
+ headers: {
37
+ "Content-Type": "application/json",
38
+ },
39
+ body: JSON.stringify({ email }),
40
+ }),
41
+ )
42
+
43
+ if (res.ok) {
44
+ notifications.show({
45
+ icon: <IconCheck size={18} />,
46
+ color: "teal",
47
+ title: "Email sent 💌",
48
+ message:
49
+ "Check your emails to verify your email. Please check your spam folder as we currently have deliverability issues.",
50
+ })
51
+ }
52
+ setLoading(false)
53
+ }
54
+
55
+ return (
56
+ <Container py={100} size={600}>
57
+ <NextSeo title="Login" />
58
+ <Stack align="center" gap={50}>
59
+ <Stack align="center">
60
+ <IconAnalyze color={"#206dce"} size={60} />
61
+ <Title order={2} fw={700} size={40} ta="center">
62
+ Forgot password
63
+ </Title>
64
+ </Stack>
65
+
66
+ <Paper radius="md" p="xl" withBorder miw={350}>
67
+ <Text size="lg" mb="xl" fw={500}>
68
+ Request reset link
69
+ </Text>
70
+
71
+ <form onSubmit={form.onSubmit(handlePasswordReset)}>
72
+ <Stack>
73
+ <TextInput
74
+ leftSection={<IconAt size="16" />}
75
+ label="Email"
76
+ type="email"
77
+ value={form.values.email}
78
+ onChange={(event) =>
79
+ form.setFieldValue("email", event.currentTarget.value)
80
+ }
81
+ error={form.errors.email && "Invalid email"}
82
+ placeholder="Your email"
83
+ />
84
+
85
+ <Button mt="md" type="submit" fullWidth loading={loading}>
86
+ Submit
87
+ </Button>
88
+ </Stack>
89
+ </form>
90
+ </Paper>
91
+ </Stack>
92
+ </Container>
93
+ )
94
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/reset-password.tsx ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {
2
+ Button,
3
+ Container,
4
+ Paper,
5
+ PasswordInput,
6
+ Stack,
7
+ Title,
8
+ } from "@mantine/core"
9
+
10
+ import { useForm } from "@mantine/form"
11
+ import { IconAnalyze } from "@tabler/icons-react"
12
+
13
+ import { NextSeo } from "next-seo"
14
+ import { useRouter } from "next/router"
15
+ import { useState } from "react"
16
+ import { fetcher } from "@/utils/fetcher"
17
+ import { useAuth } from "@/utils/auth"
18
+ import analytics from "@/utils/analytics"
19
+
20
+ export default function UpdatePassword() {
21
+ const { setJwt } = useAuth()
22
+ const [loading, setLoading] = useState(false)
23
+ const router = useRouter()
24
+
25
+ const { token, email } = router.query as {
26
+ token: string
27
+ email: string
28
+ }
29
+
30
+ const form = useForm({
31
+ initialValues: {
32
+ password: "",
33
+ },
34
+
35
+ validate: {
36
+ password: (val) => {
37
+ // TODO: refactor with other forms
38
+ if (val.length < 6) {
39
+ return "Password must be at least 6 characters"
40
+ }
41
+
42
+ return null
43
+ },
44
+ },
45
+ })
46
+
47
+ const handlePasswordReset = async ({ password }: { password: string }) => {
48
+ setLoading(true)
49
+
50
+ try {
51
+ const { token } = await fetcher.post("/auth/reset-password", {
52
+ arg: {
53
+ password,
54
+ token: router.query.token,
55
+ },
56
+ })
57
+
58
+ setJwt(token)
59
+
60
+ analytics.track("Join")
61
+ } catch (error) {
62
+ console.error(error)
63
+ setLoading(false)
64
+ }
65
+ }
66
+
67
+ return (
68
+ <Container py={100} size={600}>
69
+ <NextSeo title="Login" />
70
+ <Stack align="center" gap={50}>
71
+ <Stack align="center">
72
+ <IconAnalyze color={"#206dce"} size={60} />
73
+ <Title order={2} fw={700} size={40} ta="center">
74
+ Reset password
75
+ </Title>
76
+ </Stack>
77
+ <Paper radius="md" p="xl" withBorder miw={350}>
78
+ <form onSubmit={form.onSubmit(handlePasswordReset)}>
79
+ <Stack>
80
+ <PasswordInput
81
+ label="New Password"
82
+ type="password"
83
+ autoComplete="new-password"
84
+ value={form.values.password}
85
+ onChange={(event) =>
86
+ form.setFieldValue("password", event.currentTarget.value)
87
+ }
88
+ error={form.errors.password && "Invalid password"}
89
+ placeholder="Your new password"
90
+ />
91
+
92
+ <Button mt="md" type="submit" fullWidth loading={loading}>
93
+ Submit
94
+ </Button>
95
+ </Stack>
96
+ </form>
97
+ </Paper>
98
+ </Stack>
99
+ </Container>
100
+ )
101
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/settings.tsx ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useState } from "react"
2
+
3
+ import LineChart from "@/components/Analytics/LineChart"
4
+ import CopyText from "@/components/Blocks/CopyText"
5
+
6
+ import {
7
+ Alert,
8
+ Button,
9
+ Card,
10
+ Container,
11
+ FocusTrap,
12
+ Group,
13
+ Popover,
14
+ Stack,
15
+ Text,
16
+ TextInput,
17
+ Title,
18
+ } from "@mantine/core"
19
+ import { IconPencil, IconUserPlus } from "@tabler/icons-react"
20
+ import { NextSeo } from "next-seo"
21
+ import Router from "next/router"
22
+
23
+ import { useOrg, useUser, useProject, useProjectSWR } from "@/utils/dataHooks"
24
+ import useSWR from "swr"
25
+ import { openUpgrade } from "../components/Layout/UpgradeModal"
26
+ import RenamableField from "@/components/Blocks/RenamableField"
27
+
28
+ export default function AppAnalytics() {
29
+ const { user: currentUser } = useUser()
30
+ const { org } = useOrg()
31
+ const { update, project, setProjectId, drop } = useProject()
32
+
33
+ // TODO: better route for project usage
34
+ const { data: projectUsage } = useSWR(
35
+ project?.id && org && `/orgs/${org.id}/usage?projectId=${project?.id}`,
36
+ )
37
+
38
+ const isAdmin =
39
+ currentUser?.id === org?.users?.find((u) => u.role === "admin")?.id
40
+
41
+ return (
42
+ <Container className="unblockable">
43
+ <NextSeo title="Settings" />
44
+ <Stack gap="lg">
45
+ <LineChart
46
+ title={
47
+ <RenamableField
48
+ defaultValue={project?.name}
49
+ onRename={(name) => update(name)}
50
+ />
51
+ }
52
+ range={30}
53
+ data={projectUsage}
54
+ formatter={(val) => `${val} runs`}
55
+ props={["count"]}
56
+ />
57
+
58
+ <Card withBorder p="lg">
59
+ <Stack gap="lg">
60
+ <Group justify="space-between" align="center">
61
+ <Title order={3}>Keys</Title>
62
+ {/* <Button onClick={() => alert("TODO")}>
63
+ Refresh Api Key
64
+ </Button> */}
65
+ </Group>
66
+
67
+ <Alert
68
+ variant="light"
69
+ title={
70
+ <Group>
71
+ <Text fw={500}>Project ID:</Text>
72
+ <CopyText c="green.8" value={project?.id} />
73
+ </Group>
74
+ }
75
+ color="green"
76
+ >
77
+ <Text>
78
+ Your project ID can be used from your server or frontend code to
79
+ track events and send requests to the API.
80
+ </Text>
81
+ </Alert>
82
+
83
+ {/* <Alert
84
+ variant="light"
85
+ title={
86
+ <Group>
87
+ <Text fw={500}>Public Tracking Key: </Text>
88
+ <CopyText c="green.8" value={project?.publicApiKey} />
89
+ </Group>
90
+ }
91
+ color="green"
92
+ >
93
+ <Text>
94
+ Public API keys can be used from your server or frontend code to
95
+ track events and send requests to the API.
96
+ </Text>
97
+ </Alert> */}
98
+
99
+ {/* <Alert
100
+ variant="light"
101
+ title={
102
+ <Group>
103
+ <Text fw={500}>Private Key:</Text>
104
+ <CopyText c="red.8" value={project?.privateApiKey} />
105
+ </Group>
106
+ }
107
+ color="red"
108
+ >
109
+ <Text>
110
+ Private API keys should be used only on your server – they give
111
+ read/write/delete API access to your project's resources.
112
+ </Text>
113
+ </Alert> */}
114
+ </Stack>
115
+ </Card>
116
+
117
+ {isAdmin && (
118
+ <Card withBorder p="lg" style={{ overflow: "visible" }}>
119
+ <Stack align="start">
120
+ <Title order={4}>Danger Zone</Title>
121
+
122
+ <Text>
123
+ Deleting your project is irreversible and it will delete all
124
+ associated data.
125
+ <br />
126
+ We <b>cannot</b> recover your data once it&apos;s deleted.
127
+ </Text>
128
+
129
+ <Popover width={200} position="bottom" shadow="md">
130
+ <Popover.Target>
131
+ <Button color="red">Delete Project</Button>
132
+ </Popover.Target>
133
+ <Popover.Dropdown>
134
+ <Text mb="md">
135
+ Are you sure you want to delete this project? This action is
136
+ irreversible and it will delete all associated data.
137
+ </Text>
138
+ <Button
139
+ color="red"
140
+ onClick={() => {
141
+ drop()
142
+ setProjectId(null)
143
+ Router.push("/")
144
+ }}
145
+ >
146
+ Delete
147
+ </Button>
148
+ </Popover.Dropdown>
149
+ </Popover>
150
+ </Stack>
151
+ </Card>
152
+ )}
153
+ </Stack>
154
+ </Container>
155
+ )
156
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/signup.tsx ADDED
@@ -0,0 +1,500 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Router, { useRouter } from "next/router"
2
+ import { useEffect, useState } from "react"
3
+
4
+ import {
5
+ Alert,
6
+ Anchor,
7
+ Box,
8
+ Button,
9
+ Container,
10
+ Grid,
11
+ Group,
12
+ List,
13
+ Paper,
14
+ PasswordInput,
15
+ Radio,
16
+ Stack,
17
+ Text,
18
+ TextInput,
19
+ ThemeIcon,
20
+ Title,
21
+ } from "@mantine/core"
22
+
23
+ import Confetti from "react-confetti"
24
+
25
+ import Cal, { getCalApi } from "@calcom/embed-react"
26
+
27
+ import { useForm } from "@mantine/form"
28
+ import { notifications } from "@mantine/notifications"
29
+ import {
30
+ IconAnalyze,
31
+ IconArrowRight,
32
+ IconAt,
33
+ IconBuildingStore,
34
+ IconCheck,
35
+ IconCircleCheck,
36
+ IconFolderBolt,
37
+ IconMail,
38
+ IconMessageBolt,
39
+ IconUser,
40
+ } from "@tabler/icons-react"
41
+
42
+ import SocialProof from "@/components/Blocks/SocialProof"
43
+ import analytics from "@/utils/analytics"
44
+ import { fetcher } from "@/utils/fetcher"
45
+ import { NextSeo } from "next-seo"
46
+ import { useAuth } from "@/utils/auth"
47
+
48
+ const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))
49
+
50
+ function SignupPage() {
51
+ const [loading, setLoading] = useState(false)
52
+ const [step, setStep] = useState(1)
53
+ const router = useRouter()
54
+
55
+ const auth = useAuth()
56
+
57
+ const form = useForm({
58
+ initialValues: {
59
+ email: "",
60
+ name: "",
61
+ projectName: "Project #1",
62
+ orgName: "",
63
+ employeeCount: "",
64
+ password: "",
65
+ },
66
+
67
+ validate: {
68
+ email: (val) => (/^\S+@\S+$/.test(val) ? null : "Invalid email"),
69
+ name: (val) => (val.length <= 2 ? "Is your name that short :) ?" : null),
70
+ projectName: (val) =>
71
+ val.length <= 3 ? "Can you pick something longer?" : null,
72
+ orgName: (val) =>
73
+ val.length <= 3 ? "Can you pick something longer?" : null,
74
+ employeeCount: (val) =>
75
+ val.length <= 1 ? "Please select a value" : null,
76
+ password: (val) => {
77
+ if (val.length < 6) {
78
+ return "Password must be at least 6 characters"
79
+ }
80
+ return null
81
+ },
82
+ },
83
+ })
84
+
85
+ async function handleSignup({
86
+ email,
87
+ password,
88
+ name,
89
+ projectName,
90
+ orgName,
91
+ employeeCount,
92
+ }: {
93
+ email: string
94
+ password: string
95
+ name: string
96
+ projectName: string
97
+ orgName: string
98
+ employeeCount: string
99
+ }) {
100
+ setLoading(true)
101
+
102
+ if (orgName.includes("https://")) {
103
+ // shadow ban spam
104
+ await sleep(100000000)
105
+ return
106
+ }
107
+
108
+ try {
109
+ const { token } = await fetcher.post("/auth/signup", {
110
+ arg: {
111
+ email,
112
+ password,
113
+ name,
114
+ projectName,
115
+ orgName,
116
+ employeeCount,
117
+ signupMethod: "signup",
118
+ },
119
+ })
120
+
121
+ if (!token) {
122
+ throw new Error("No token received")
123
+ }
124
+
125
+ auth.setJwt(token)
126
+
127
+ notifications.show({
128
+ icon: <IconCheck size={18} />,
129
+ color: "teal",
130
+ title: "Email sent",
131
+ message: "Check your emails for the confirmation link",
132
+ })
133
+
134
+ analytics.track("Signup", {
135
+ email,
136
+ name,
137
+ projectName,
138
+ orgName,
139
+ employeeCount,
140
+ })
141
+ nextStep()
142
+ } catch (error) {
143
+ console.error(error)
144
+ } finally {
145
+ setLoading(false)
146
+ }
147
+ }
148
+
149
+ function nextStep() {
150
+ if (step === 1) {
151
+ if (
152
+ ["email", "name", "password"].some(
153
+ (field) => form.validateField(field).hasError,
154
+ )
155
+ ) {
156
+ return
157
+ }
158
+ }
159
+
160
+ if (step === 2 && !form.values.orgName) {
161
+ form.setFieldValue("orgName", form.values.name + "'s Org")
162
+ }
163
+
164
+ setStep(step + 1)
165
+ router.query.step = String(step + 1)
166
+ router.push(router)
167
+ }
168
+
169
+ useEffect(() => {
170
+ if (step === 3) {
171
+ ;(async function () {
172
+ const Cal = await getCalApi()
173
+ Cal("ui", {
174
+ styles: { branding: { brandColor: "#000000" } },
175
+ hideEventTypeDetails: true,
176
+ layout: "month_view",
177
+ })
178
+ })()
179
+ }
180
+ }, [step])
181
+
182
+ const isBigCompany = form.values.employeeCount !== "1-5"
183
+
184
+ return (
185
+ <Container size={step === 3 ? 1200 : 800} mih="60%">
186
+ <NextSeo title="Sign Up" />
187
+
188
+ <Stack align="center" gap={50}>
189
+ {step < 3 && (
190
+ <>
191
+ <Stack align="center">
192
+ <IconAnalyze color={"#206dce"} size={60} />
193
+ <Title order={2} fw={700} size={40} ta="center">
194
+ lunary cloud
195
+ </Title>
196
+ </Stack>
197
+ <Grid gutter={50} align="center" mb="sm">
198
+ <Grid.Col span={{ base: 12, md: 6 }}>
199
+ <Paper radius="md" p="xl" withBorder>
200
+ <form onSubmit={form.onSubmit(handleSignup)}>
201
+ <Stack gap="lg">
202
+ {step === 1 && (
203
+ <>
204
+ <Title order={2} fw={700} ta="center">
205
+ Get Started
206
+ </Title>
207
+ <TextInput
208
+ leftSection={<IconAt size="16" />}
209
+ label="Email"
210
+ type="email"
211
+ autoComplete="email"
212
+ error={form.errors.email}
213
+ placeholder="Your email"
214
+ {...form.getInputProps("email")}
215
+ />
216
+
217
+ <TextInput
218
+ label="Full Name"
219
+ autoComplete="name"
220
+ description="Only used to address you properly."
221
+ leftSection={<IconUser size="16" />}
222
+ placeholder="Your full name"
223
+ error={form.errors.name}
224
+ {...form.getInputProps("name")}
225
+ onChange={(e) => {
226
+ form.setFieldValue("name", e.target.value)
227
+ form.setFieldValue(
228
+ "orgName",
229
+ e.target.value + "'s Org",
230
+ )
231
+ }}
232
+ />
233
+
234
+ <PasswordInput
235
+ label="Password"
236
+ onKeyDown={(e) => {
237
+ if (e.key === "Enter") {
238
+ nextStep()
239
+ }
240
+ }}
241
+ error={form.errors.password}
242
+ placeholder="Your password"
243
+ {...form.getInputProps("password")}
244
+ />
245
+
246
+ <Button
247
+ size="md"
248
+ mt="md"
249
+ onClick={nextStep}
250
+ fullWidth
251
+ loading={loading}
252
+ >
253
+ {`Continue →`}
254
+ </Button>
255
+
256
+ <Text size="sm" style={{ textAlign: "center" }}>
257
+ {`Already have an account? `}
258
+ <Anchor href="/login">Log In</Anchor>
259
+ </Text>
260
+ </>
261
+ )}
262
+
263
+ {step === 2 && (
264
+ <>
265
+ <Title order={2} fw={700} ta="center">
266
+ Create an organization
267
+ </Title>
268
+
269
+ <TextInput
270
+ label="Organization Name"
271
+ description="Eg. your company name"
272
+ leftSection={<IconBuildingStore size="16" />}
273
+ placeholder="Organization name"
274
+ error={
275
+ form.errors.projectName &&
276
+ "This field is required"
277
+ }
278
+ {...form.getInputProps("orgName")}
279
+ />
280
+
281
+ <TextInput
282
+ label="Project Name"
283
+ description="Can be changed later."
284
+ leftSection={<IconFolderBolt size="16" />}
285
+ placeholder="Your project name"
286
+ error={
287
+ form.errors.projectName &&
288
+ "This field is required"
289
+ }
290
+ {...form.getInputProps("projectName")}
291
+ />
292
+
293
+ <Radio.Group
294
+ label="Employee count"
295
+ error={
296
+ form.errors.employeeCount &&
297
+ "This field is required"
298
+ }
299
+ {...form.getInputProps("employeeCount")}
300
+ >
301
+ <Group mt="xs">
302
+ <Radio value="1-5" label="1-5" />
303
+ <Radio value="11-50" label="6-49" />
304
+ <Radio value="51-100" label="50-99" />
305
+ <Radio value="101-500" label="100+" />
306
+ </Group>
307
+ </Radio.Group>
308
+
309
+ <Stack gap="xs">
310
+ <Button
311
+ size="md"
312
+ mt="md"
313
+ type="submit"
314
+ fullWidth
315
+ loading={loading}
316
+ >
317
+ {`Create account`}
318
+ </Button>
319
+
320
+ <Button
321
+ size="sm"
322
+ onClick={() => {
323
+ router.query.step = String(1)
324
+ router.push(router)
325
+ setStep(1)
326
+ }}
327
+ fullWidth
328
+ variant="transparent"
329
+ color="dimmed"
330
+ >
331
+ {`← Go back`}
332
+ </Button>
333
+ </Stack>
334
+ </>
335
+ )}
336
+ </Stack>
337
+ </form>
338
+ </Paper>
339
+ </Grid.Col>
340
+
341
+ <Grid.Col span={{ base: 12, md: 6 }}>
342
+ <Box>
343
+ <List
344
+ spacing="xl"
345
+ size="md"
346
+ icon={
347
+ <ThemeIcon
348
+ variant="light"
349
+ color="teal"
350
+ size={24}
351
+ radius="xl"
352
+ >
353
+ <IconCircleCheck size="16" />
354
+ </ThemeIcon>
355
+ }
356
+ >
357
+ <List.Item>
358
+ <Text fw="bold">Free usage every month</Text>
359
+ <Text>
360
+ 1K free events per day. Forever.
361
+ <br />
362
+ No credit card required.
363
+ </Text>
364
+ </List.Item>
365
+ <List.Item>
366
+ <Text fw="bold">Collect data immediately</Text>
367
+ <Text>
368
+ Integrate with dev-friendly SDKs, with native support
369
+ for LangChain and OpenAI.
370
+ </Text>
371
+ </List.Item>
372
+ <List.Item>
373
+ <Text fw="bold">No config required</Text>
374
+ <Text>Get insights without complicated setup.</Text>
375
+ </List.Item>
376
+ </List>
377
+ </Box>
378
+ </Grid.Col>
379
+ </Grid>
380
+ <SocialProof />
381
+ </>
382
+ )}
383
+
384
+ {step === 3 && (
385
+ <>
386
+ {typeof window !== "undefined" && !isBigCompany && (
387
+ <Confetti
388
+ recycle={false}
389
+ numberOfPieces={500}
390
+ gravity={0.3}
391
+ width={window.innerWidth}
392
+ height={window.innerHeight}
393
+ />
394
+ )}
395
+
396
+ <Stack align="center" w={800}>
397
+ {/* <IconAnalyze color={"#206dce"} size={60} /> */}
398
+
399
+ <Title order={2} fw={700} size={40} ta="center">
400
+ {`You're all set 🎉`}
401
+ </Title>
402
+
403
+ {isBigCompany ? (
404
+ <>
405
+ <Text size="xl" ta="center" my="xl">
406
+ Are you free in the next days for a quick call?
407
+ <br />
408
+ We'd love to understand your use-case and help you directly
409
+ with the integration.
410
+ </Text>
411
+ <Cal
412
+ // namespace="lunary"
413
+ calLink="vincelwt/lunary"
414
+ className="calcom-embed"
415
+ config={{
416
+ hideEventTypeDetails: "true",
417
+ layout: "month_view",
418
+ name: "vince loewe", //form.values.name,
419
+ email: "vince@lunary.ai", //form.values.email,
420
+ }}
421
+ />
422
+ <Button
423
+ onClick={() => {
424
+ // use this to refresh properly
425
+ window.location.href = "/"
426
+ }}
427
+ variant="subtle"
428
+ rightSection={<IconArrowRight size={16} />}
429
+ size="md"
430
+ >
431
+ Skip to Dashboard
432
+ </Button>
433
+ </>
434
+ ) : (
435
+ <>
436
+ <Alert fw={500} icon={<IconMail />} my="lg">
437
+ <Text size="md" fw={500}>
438
+ Check your emails for the confirmation link.
439
+ </Text>
440
+ </Alert>
441
+
442
+ <Button
443
+ onClick={() => {
444
+ window.location.href = "/"
445
+ }}
446
+ variant={isBigCompany ? "outline" : "filled"}
447
+ mb="xl"
448
+ rightSection={<IconArrowRight size={18} />}
449
+ size="lg"
450
+ >
451
+ Open Dashboard
452
+ </Button>
453
+
454
+ <Text size="lg">
455
+ {`Want to say hi? We'd love to talk to you.`}
456
+ </Text>
457
+
458
+ <Group>
459
+ <Button
460
+ variant="outline"
461
+ onClick={() => {
462
+ $crisp.push(["do", "chat:open"])
463
+ }}
464
+ rightSection={<IconMessageBolt size={18} />}
465
+ >
466
+ Chat
467
+ </Button>
468
+
469
+ <Button
470
+ variant="outline"
471
+ color="teal.8"
472
+ component="a"
473
+ href="mailto:hello@lunary.ai"
474
+ rightSection={<IconMail size={18} />}
475
+ >
476
+ Email
477
+ </Button>
478
+ </Group>
479
+ </>
480
+ )}
481
+ </Stack>
482
+ </>
483
+ )}
484
+ </Stack>
485
+ <style jsx global>{`
486
+ .calcom-embed {
487
+ height: 470px;
488
+ width: 100%;
489
+ overflow: auto;
490
+ }
491
+
492
+ iframe main > div > span {
493
+ display: none !important;
494
+ }
495
+ `}</style>
496
+ </Container>
497
+ )
498
+ }
499
+
500
+ export default SignupPage
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/team.tsx ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useState } from "react"
2
+
3
+ import CopyText from "@/components/Blocks/CopyText"
4
+ import UserAvatar from "@/components/Blocks/UserAvatar"
5
+
6
+ import {
7
+ ActionIcon,
8
+ Badge,
9
+ Button,
10
+ Card,
11
+ Container,
12
+ Group,
13
+ Menu,
14
+ Modal,
15
+ Progress,
16
+ Stack,
17
+ Table,
18
+ Text,
19
+ Title,
20
+ } from "@mantine/core"
21
+ import { IconDotsVertical, IconTrash, IconUserPlus } from "@tabler/icons-react"
22
+ import { NextSeo } from "next-seo"
23
+
24
+ import RenamableField from "@/components/Blocks/RenamableField"
25
+ import { useOrg, useOrgUser, useUser } from "@/utils/dataHooks"
26
+ import { SEAT_ALLOWANCE } from "@/utils/pricing"
27
+ import { useDisclosure } from "@mantine/hooks"
28
+ import { openUpgrade } from "../components/Layout/UpgradeModal"
29
+
30
+ function Invite() {
31
+ const { org } = useOrg()
32
+ const plan = org?.plan
33
+
34
+ const allowedSeats = SEAT_ALLOWANCE[plan]
35
+
36
+ if (org?.users?.length >= allowedSeats) {
37
+ return (
38
+ <Button
39
+ variant="light"
40
+ onClick={() => openUpgrade("team")}
41
+ style={{ float: "right" }}
42
+ leftSection={<IconUserPlus size="16" />}
43
+ >
44
+ Invite
45
+ </Button>
46
+ )
47
+ }
48
+
49
+ return (
50
+ <Group>
51
+ <Text>Invite link: </Text>
52
+ {typeof window !== "undefined" && (
53
+ <CopyText value={`${window.location.origin}/join?orgId=${org?.id}`} />
54
+ )}
55
+ </Group>
56
+ )
57
+ }
58
+
59
+ function UserMenu({ user }) {
60
+ const [opened, { open, close }] = useDisclosure(false)
61
+ const [isLoading, setIsLoading] = useState(false)
62
+ const { user: currentUser } = useUser()
63
+ const { removeUserFromOrg } = useOrgUser(user.id)
64
+
65
+ if (user.role === "admin" || currentUser.id === user.id) {
66
+ return
67
+ }
68
+
69
+ async function confirm() {
70
+ setIsLoading(true)
71
+ await removeUserFromOrg()
72
+ setIsLoading(false)
73
+ close()
74
+ }
75
+
76
+ return (
77
+ <>
78
+ <Modal
79
+ opened={opened}
80
+ onClose={close}
81
+ title={<Title size="h3">Remove user from Team?</Title>}
82
+ >
83
+ <Group mt="md" justify="right">
84
+ <Button variant="outline" onClick={close}>
85
+ Cancel
86
+ </Button>
87
+ <Button loading={isLoading} color="red" onClick={confirm}>
88
+ Continue
89
+ </Button>
90
+ </Group>
91
+ </Modal>
92
+
93
+ <Menu>
94
+ <Menu.Target>
95
+ <ActionIcon variant="transparent">
96
+ <IconDotsVertical size={16} />
97
+ </ActionIcon>
98
+ </Menu.Target>
99
+
100
+ <Menu.Dropdown>
101
+ <Menu.Item
102
+ onClick={open}
103
+ leftSection={<IconTrash size={16} />}
104
+ color="red"
105
+ >
106
+ Remove from Team
107
+ </Menu.Item>
108
+ </Menu.Dropdown>
109
+ </Menu>
110
+ </>
111
+ )
112
+ }
113
+
114
+ export default function Team() {
115
+ const { user: currentUser } = useUser()
116
+ const { org, updateOrg, mutate } = useOrg()
117
+
118
+ return (
119
+ <Container className="unblockable">
120
+ <NextSeo title="Team" />
121
+ <Stack gap="lg">
122
+ <Card withBorder p={0}>
123
+ <Group justify="space-between" align="center" p="lg">
124
+ <RenamableField
125
+ defaultValue={org?.name}
126
+ onRename={async (name) => {
127
+ await updateOrg({ id: org?.id, name }, { optimisticData: org })
128
+
129
+ mutate()
130
+ }}
131
+ />
132
+
133
+ <Invite />
134
+ </Group>
135
+
136
+ <Table striped verticalSpacing="lg" horizontalSpacing="lg">
137
+ <Table.Thead>
138
+ <Table.Tr>
139
+ <Table.Th>User</Table.Th>
140
+ <Table.Th>Email</Table.Th>
141
+ <Table.Th>Role</Table.Th>
142
+ <Table.Th></Table.Th>
143
+ </Table.Tr>
144
+ </Table.Thead>
145
+ <Table.Tbody>
146
+ {org?.users?.map((user, i) => (
147
+ <Table.Tr key={i}>
148
+ <Table.Td>
149
+ <Group>
150
+ <UserAvatar profile={user} />
151
+ <Text>{user?.name}</Text>
152
+
153
+ {user?.id === currentUser?.id ? (
154
+ <Badge color="blue">You</Badge>
155
+ ) : null}
156
+ </Group>
157
+ </Table.Td>
158
+ <Table.Td>{user?.email}</Table.Td>
159
+ <Table.Td>{user?.role}</Table.Td>
160
+ <Table.Td>
161
+ <UserMenu user={user} />
162
+ </Table.Td>
163
+ </Table.Tr>
164
+ ))}
165
+ </Table.Tbody>
166
+ </Table>
167
+ </Card>
168
+ {org?.plan && (
169
+ <Card withBorder radius="md" padding="xl">
170
+ <Stack gap="sm">
171
+ <Text fz="md" fw={700} size="lg">
172
+ Seat Allowance
173
+ </Text>
174
+ <Text fz="lg" fw={500}>
175
+ {org?.users?.length} / {SEAT_ALLOWANCE[org?.plan]} users
176
+ </Text>
177
+ <Progress
178
+ value={
179
+ ((org?.users?.length || 0) / SEAT_ALLOWANCE[org?.plan]) * 100
180
+ }
181
+ size="lg"
182
+ color="orange"
183
+ radius="xl"
184
+ />
185
+ </Stack>
186
+ </Card>
187
+ )}
188
+ </Stack>
189
+ </Container>
190
+ )
191
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/pages/update-password.tsx ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {
2
+ Button,
3
+ Container,
4
+ Paper,
5
+ PasswordInput,
6
+ Stack,
7
+ Text,
8
+ Title,
9
+ } from "@mantine/core"
10
+
11
+ import { useForm } from "@mantine/form"
12
+ import { IconAnalyze, IconCheck } from "@tabler/icons-react"
13
+
14
+ import errorHandler from "@/utils/errors"
15
+ import { NextSeo } from "next-seo"
16
+ import Router from "next/router"
17
+ import { useState } from "react"
18
+ import { notifications } from "@mantine/notifications"
19
+
20
+ export default function UpdatePassword() {
21
+ const [loading, setLoading] = useState(false)
22
+
23
+ const form = useForm({
24
+ initialValues: {
25
+ password: "",
26
+ },
27
+
28
+ validate: {
29
+ password: (val) =>
30
+ val.length < 5 ? "Password must be at least 5 characters" : null,
31
+ },
32
+ })
33
+
34
+ const handlePasswordReset = async ({ password }: { password: string }) => {
35
+ setLoading(true)
36
+
37
+ // TODO: reset password with supertoken
38
+ const ok = true
39
+
40
+ notifications.show({
41
+ icon: <IconCheck size={18} />,
42
+ color: "teal",
43
+ title: "Success",
44
+ message: "Password updated successfully",
45
+ })
46
+
47
+ if (ok) {
48
+ Router.push("/")
49
+ }
50
+
51
+ setLoading(false)
52
+ }
53
+
54
+ return (
55
+ <Container py={100} size={600}>
56
+ <NextSeo title="Login" />
57
+ <Stack align="center" gap={50}>
58
+ <Stack align="center">
59
+ <IconAnalyze color={"#206dce"} size={60} />
60
+ <Title order={2} fw={700} size={40} ta="center">
61
+ Reset password
62
+ </Title>
63
+ </Stack>
64
+ <Paper radius="md" p="xl" withBorder miw={350}>
65
+ <Text size="lg" mb="xl" fw={500}>
66
+ Update password
67
+ </Text>
68
+
69
+ <form onSubmit={form.onSubmit(handlePasswordReset)}>
70
+ <Stack>
71
+ <PasswordInput
72
+ label="New Password"
73
+ type="password"
74
+ autoComplete="new-password"
75
+ value={form.values.password}
76
+ onChange={(event) =>
77
+ form.setFieldValue("password", event.currentTarget.value)
78
+ }
79
+ error={form.errors.email && "Invalid password"}
80
+ placeholder="Your email"
81
+ />
82
+
83
+ <Button mt="md" type="submit" fullWidth loading={loading}>
84
+ Submit
85
+ </Button>
86
+ </Stack>
87
+ </form>
88
+ </Paper>
89
+ </Stack>
90
+ </Container>
91
+ )
92
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/postcss.config.js ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ module.exports = {
2
+ plugins: {
3
+ "postcss-preset-mantine": {},
4
+ "postcss-simple-vars": {
5
+ variables: {
6
+ "mantine-breakpoint-xs": "36em",
7
+ "mantine-breakpoint-sm": "48em",
8
+ "mantine-breakpoint-md": "62em",
9
+ "mantine-breakpoint-lg": "75em",
10
+ "mantine-breakpoint-xl": "88em",
11
+ },
12
+ },
13
+ },
14
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/styles/globals.css ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ :root {
2
+ --navbar-size: 50px;
3
+ --navbar-with-filters-size: 50px;
4
+ }
5
+
6
+ body {
7
+ margin: 0;
8
+ padding: 0;
9
+ font-feature-settings: "liga", "kern";
10
+ text-rendering: optimizelegibility;
11
+ -webkit-font-smoothing: antialiased;
12
+ }
13
+
14
+ /* .limited table td, */
15
+ .limited .mantine-Badge-inner,
16
+ span.limited,
17
+ .limited code,
18
+ .limited table .mantine-Text-root {
19
+ filter: blur(4px);
20
+ }
21
+
22
+ .limited .recharts-responsive-container {
23
+ filter: blur(7px);
24
+ }
25
+
26
+ .unblockable pre,
27
+ .unblockable code,
28
+ .unblockable .mantine-Badge-inner,
29
+ .unblockable .mantine-Text-root,
30
+ .unblockable .recharts-responsive-container {
31
+ filter: none !important;
32
+ }
33
+
34
+ .mantine-Modal-inner {
35
+ /* fix modal unaligned content */
36
+ padding-left: 0 !important;
37
+ padding-right: 0 !important;
38
+ }
39
+
40
+ .mantine-Badge-root {
41
+ max-width: 100%;
42
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/tsconfig.json ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "lib": ["dom", "dom.iterable", "esnext"],
5
+ "allowJs": true,
6
+ "skipLibCheck": true,
7
+ "strict": false,
8
+ "forceConsistentCasingInFileNames": true,
9
+ "noEmit": true,
10
+ "esModuleInterop": true,
11
+ "module": "esnext",
12
+ "moduleResolution": "bundler",
13
+ "resolveJsonModule": true,
14
+ "isolatedModules": true,
15
+ "jsx": "preserve",
16
+ "baseUrl": ".",
17
+ "incremental": true,
18
+ "paths": {
19
+ "@/*": ["./*"],
20
+ "@/lib/*": ["lib/*"],
21
+ "@/components/*": ["components/*"],
22
+ },
23
+ "plugins": [
24
+ {
25
+ "name": "next",
26
+ },
27
+ ],
28
+ "strictNullChecks": true,
29
+ },
30
+ "include": [
31
+ "next-env.d.ts",
32
+ "**/*.ts",
33
+ "**/*.tsx",
34
+ ".next/types/**/*.ts",
35
+ "../backend/src/api/stripe.ts",
36
+ "../backend/src/api/signup.ts",
37
+ ],
38
+ "exclude": ["node_modules"],
39
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/utils/analytics.ts ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import posthog from "posthog-js"
2
+
3
+ if (typeof window !== "undefined" && process.env.NEXT_PUBLIC_POSTHOG_KEY) {
4
+ posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, {
5
+ api_host: window.location.origin + "/ingest", // Uses Next.js rewrite in next.config.js
6
+ // Enable debug mode in development
7
+ loaded: (posthog) => {
8
+ if (process.env.NODE_ENV === "development") posthog.debug()
9
+ },
10
+ })
11
+ }
12
+
13
+ const w = {
14
+ // @ts-ignore
15
+ get crisp() {
16
+ if (
17
+ typeof window !== "undefined" &&
18
+ typeof window["$crisp"] !== "undefined"
19
+ )
20
+ return window["$crisp"]
21
+
22
+ return () => {}
23
+ },
24
+ get plausible() {
25
+ if (
26
+ typeof window !== "undefined" &&
27
+ typeof window["plausible"] !== "undefined"
28
+ )
29
+ return window["plausible"]
30
+
31
+ return () => {}
32
+ },
33
+ }
34
+
35
+ const handleRouteChange = async () => {
36
+ posthog?.capture("$pageview")
37
+
38
+ // w.gosquared("track")
39
+ }
40
+
41
+ const track = (event: string, data?: any) => {
42
+ try {
43
+ posthog?.capture(event, data)
44
+
45
+ w.plausible(event, { props: data })
46
+
47
+ w?.crisp?.push(["set", "session:event", [[[event, data]]]])
48
+ } catch (e) {
49
+ console.error(e)
50
+ }
51
+ }
52
+
53
+ const alreadyTracked = new Set<string>()
54
+ const trackOnce = (event: string, data?: any) => {
55
+ // Prevent sending too many events
56
+ if (alreadyTracked.has(event)) return
57
+
58
+ try {
59
+ posthog?.capture(event, data)
60
+ } catch (e) {
61
+ console.error(e)
62
+ }
63
+ }
64
+
65
+ const identify = (userId: string, traits: any) => {
66
+ try {
67
+ posthog?.identify(userId, traits)
68
+
69
+ if (!w?.crisp?.push) return
70
+
71
+ if (typeof CRISP_TOKEN_ID !== "undefined") CRISP_TOKEN_ID = userId
72
+ if (typeof CRISP_RUNTIME_CONFIG !== "undefined")
73
+ CRISP_RUNTIME_CONFIG = {
74
+ session_merge: true,
75
+ }
76
+
77
+ if (traits.email) w?.crisp?.push(["set", "user:email", traits.email])
78
+ if (traits.name) w?.crisp?.push(["set", "user:nickname", traits.name])
79
+
80
+ w?.crisp.push([
81
+ "set",
82
+ "session:data",
83
+ [
84
+ [
85
+ ...Object.entries(traits)
86
+ .map(([key, value]) => [key, value])
87
+ .filter(([key]) => key !== "email" && key !== "name")
88
+ .filter(([key, value]) => value),
89
+ ["user-id", userId],
90
+ ],
91
+ ],
92
+ ])
93
+
94
+ // H?.identify(userId, traits)
95
+ } catch (e) {
96
+ console.error(e)
97
+ }
98
+ }
99
+
100
+ const analytics = {
101
+ track,
102
+ trackOnce,
103
+ identify,
104
+ handleRouteChange,
105
+ }
106
+
107
+ export default analytics
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/utils/auth.tsx ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useLocalStorage } from "@mantine/hooks"
2
+ import { decodeJwt } from "jose"
3
+ import { createContext, useContext, useEffect, useMemo } from "react"
4
+ import Router from "next/router"
5
+
6
+ const SIGN_OUT_EVENT = "sign-out"
7
+ export async function signOut() {
8
+ window.localStorage.clear()
9
+ window.dispatchEvent(new Event(SIGN_OUT_EVENT))
10
+ }
11
+
12
+ interface AuthContext {
13
+ isSignedIn: boolean
14
+ setJwt: (
15
+ val: string | ((prevState: string | null) => string | null) | null,
16
+ ) => void
17
+ signOut: () => void
18
+ }
19
+
20
+ const AuthContext = createContext<AuthContext | null>(null)
21
+
22
+ function checkJwt(jwt) {
23
+ try {
24
+ const payload = decodeJwt(jwt)
25
+ const exp = payload.exp
26
+
27
+ if (!exp || exp < Date.now() / 1000) {
28
+ throw new Error("Token expired")
29
+ }
30
+ return true
31
+ } catch (error) {
32
+ return false
33
+ }
34
+ }
35
+
36
+ export function AuthProvider({ children }) {
37
+ const [jwt, setJwt, removeJwt] = useLocalStorage<string | null>({
38
+ key: "auth-token",
39
+ getInitialValueInEffect: false,
40
+ serialize: (value) => value || "",
41
+ deserialize: (localStorageValue) => localStorageValue || null,
42
+ defaultValue: null,
43
+ })
44
+
45
+ const isSignedIn = useMemo(() => checkJwt(jwt), [jwt])
46
+
47
+ function doSignOut() {
48
+ removeJwt()
49
+ // Router.push("/login")
50
+ }
51
+
52
+ useEffect(() => {
53
+ window.addEventListener(SIGN_OUT_EVENT, doSignOut)
54
+ return () => {
55
+ window.removeEventListener(SIGN_OUT_EVENT, doSignOut)
56
+ }
57
+ }, [])
58
+
59
+ return (
60
+ <AuthContext.Provider value={{ isSignedIn, setJwt, signOut }}>
61
+ {children}
62
+ </AuthContext.Provider>
63
+ )
64
+ }
65
+
66
+ export function useAuth() {
67
+ const context = useContext(AuthContext)
68
+ if (context === null) {
69
+ throw new Error("useAuth must be used within a AuthProvider")
70
+ }
71
+ return context
72
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/utils/colors.ts ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useColorScheme, useDidUpdate } from "@mantine/hooks"
2
+ import { useEffect, useState } from "react"
3
+
4
+ export function getColorForRole(role) {
5
+ const defaultColor = "gray"
6
+
7
+ const colorMap = {
8
+ ai: "green",
9
+ assistant: "green",
10
+ human: "blue",
11
+ user: "blue",
12
+ error: "red",
13
+ function: "violet",
14
+ tool: "violet",
15
+ system: "gray",
16
+ }
17
+
18
+ return colorMap[role] || defaultColor
19
+ }
20
+
21
+ export function getColorForRunType(type) {
22
+ const defaultColor = "gray"
23
+
24
+ const colorMap = {
25
+ llm: "yellow",
26
+ embed: "yellow",
27
+ chain: "blue",
28
+ agent: "violet",
29
+ tool: "grape",
30
+ thread: "grape",
31
+ convo: "grape",
32
+ chat: "blue",
33
+ }
34
+
35
+ return colorMap[type] || defaultColor
36
+ }
37
+
38
+ export function getUserColor(scheme, theme, id: string) {
39
+ if (!id) return theme.colors.gray[4]
40
+ const seed = id
41
+ .split("")
42
+ .map((char) => char.charCodeAt(0))
43
+ .reduce((acc, curr) => acc + curr, 0)
44
+ const colors = Object.keys(theme.colors)
45
+
46
+ const userColor = colors[seed % colors.length]
47
+
48
+ const finalColor = theme.colors[userColor][scheme === "dark" ? 8 : 4]
49
+ return finalColor
50
+ }
51
+
52
+ // fixes the stutter effect in dark mode
53
+ // needs to be outside the hook as window.computedColorScheme doesn't reflect the update
54
+ // but we need to update the ddefault value
55
+ let defaultColorScheme =
56
+ typeof window !== "undefined" ? window?.computedColorScheme : null
57
+
58
+ export function useFixedColorScheme() {
59
+ const [scheme, setScheme] = useState(defaultColorScheme)
60
+
61
+ const mantineScheme = useColorScheme()
62
+
63
+ useDidUpdate(() => {
64
+ defaultColorScheme = mantineScheme
65
+ setScheme(mantineScheme)
66
+ }, [mantineScheme])
67
+
68
+ return scheme
69
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/utils/context.ts ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { createContext } from "react"
2
+
3
+ type ProjectContextType = {
4
+ projectId?: string
5
+ setProjectId: (appId: string | null) => void
6
+ }
7
+
8
+ export const ProjectContext = createContext<ProjectContextType>({
9
+ projectId: undefined,
10
+ setProjectId: () => {},
11
+ })
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/utils/dataHooks.ts ADDED
@@ -0,0 +1,700 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useMantineTheme } from "@mantine/core"
2
+ import { useContext } from "react"
3
+ import useSWR, { SWRConfiguration, useSWRConfig } from "swr"
4
+ import useSWRInfinite from "swr/infinite"
5
+ import useSWRMutation, { SWRMutationConfiguration } from "swr/mutation"
6
+ import { getUserColor, useFixedColorScheme } from "./colors"
7
+ import { ProjectContext } from "./context"
8
+
9
+ import { useAuth } from "./auth"
10
+ import { fetcher } from "./fetcher"
11
+
12
+ type KeyType = string | ((...args: any[]) => string)
13
+
14
+ function generateKey(
15
+ baseKey: KeyType | undefined,
16
+ projectId: string | undefined,
17
+ extraParams?: string,
18
+ ) {
19
+ const resolvedKey = typeof baseKey === "function" ? baseKey() : baseKey
20
+ if (!projectId || !resolvedKey) return null
21
+
22
+ const operator = resolvedKey.includes("?") ? "&" : "?"
23
+
24
+ let url = `${resolvedKey}${
25
+ !resolvedKey.endsWith("?") ? operator : ""
26
+ }projectId=${projectId}`
27
+ if (extraParams) {
28
+ url += `&${extraParams}`
29
+ }
30
+
31
+ return url
32
+ }
33
+ export function useProjectSWR(key?: KeyType, options?: SWRConfiguration) {
34
+ const { projectId } = useContext(ProjectContext)
35
+
36
+ const { data, error, isLoading, isValidating, mutate } = useSWR(
37
+ () => generateKey(key, projectId),
38
+ options,
39
+ )
40
+
41
+ return {
42
+ data,
43
+ error,
44
+ isLoading: projectId === null ? true : isLoading,
45
+ isValidating,
46
+ mutate,
47
+ }
48
+ }
49
+
50
+ export function useProjectMutation(
51
+ key: KeyType,
52
+ customFetcher:
53
+ | typeof fetcher.post
54
+ | typeof fetcher.patch
55
+ | typeof fetcher.delete,
56
+ options?: SWRMutationConfiguration<any, any>,
57
+ ) {
58
+ const { projectId } = useContext(ProjectContext)
59
+
60
+ return useSWRMutation(
61
+ () => generateKey(key, projectId),
62
+ customFetcher,
63
+ options,
64
+ )
65
+ }
66
+
67
+ export function useProjectInfiniteSWR(key: string, ...args: any[]) {
68
+ const PAGE_SIZE = 1
69
+
70
+ const { projectId } = useContext(ProjectContext)
71
+
72
+ function getKey(pageIndex, previousPageData) {
73
+ if (previousPageData && !previousPageData.length) return null
74
+ return generateKey(key, projectId, `page=${pageIndex}&limit=100`)
75
+ }
76
+
77
+ const { data, isLoading, isValidating, size, setSize } = useSWRInfinite(
78
+ getKey,
79
+ ...(args as [any]),
80
+ )
81
+
82
+ function loadMore() {
83
+ const hasMore = data && data[data.length - 1]?.length >= PAGE_SIZE
84
+
85
+ if (hasMore) {
86
+ setSize((size) => size + 1)
87
+ }
88
+ }
89
+
90
+ return {
91
+ data: data?.flat(),
92
+ loading: isLoading,
93
+ validating: isValidating,
94
+ loadMore,
95
+ }
96
+ }
97
+
98
+ export function useProjectMutate(key: KeyType, options?: SWRConfiguration) {
99
+ const { projectId } = useContext(ProjectContext)
100
+
101
+ const { mutate } = useSWRConfig()
102
+
103
+ return (data) => {
104
+ mutate(generateKey(key, projectId), data, false)
105
+ }
106
+ }
107
+
108
+ export function useUser() {
109
+ const { isSignedIn } = useAuth()
110
+
111
+ const theme = useMantineTheme()
112
+ const scheme = useFixedColorScheme()
113
+
114
+ const { data, isLoading, mutate, error } = useSWR(
115
+ () => isSignedIn && `/users/me`,
116
+ )
117
+
118
+ const color = data ? getUserColor(scheme, theme, data.id) : null
119
+ const user = data ? { ...data, color } : null
120
+
121
+ return { user, loading: isLoading, mutate, error }
122
+ }
123
+
124
+ export function useOrg() {
125
+ const { isSignedIn } = useAuth()
126
+
127
+ const { data, isLoading, mutate } = useSWR(
128
+ () => isSignedIn && `/users/me/org`,
129
+ )
130
+
131
+ const theme = useMantineTheme()
132
+ const scheme = useFixedColorScheme()
133
+
134
+ const users = data?.users?.map((user) => ({
135
+ ...user,
136
+ color: getUserColor(scheme, theme, user.id),
137
+ }))
138
+
139
+ const org = data ? { ...data, users } : null
140
+
141
+ const { trigger: updateOrg } = useSWRMutation(
142
+ `/orgs/${org?.id}`,
143
+ fetcher.patch,
144
+ )
145
+
146
+ return { org, loading: isLoading, updateOrg, mutate }
147
+ }
148
+
149
+ export function useProjects() {
150
+ const { isSignedIn } = useAuth()
151
+
152
+ const { data, isLoading, isValidating, mutate } = useSWR(
153
+ () => isSignedIn && `/projects`,
154
+ )
155
+
156
+ const { trigger: insertMutation } = useSWRMutation(
157
+ () => `/projects`,
158
+ fetcher.post,
159
+ {
160
+ populateCache(result, currentData) {
161
+ return [...currentData, result]
162
+ },
163
+ },
164
+ )
165
+
166
+ return {
167
+ projects: data || [],
168
+ mutate,
169
+ insert: insertMutation,
170
+ isLoading: isLoading,
171
+ }
172
+ }
173
+
174
+ export function useProject() {
175
+ const { projectId, setProjectId } = useContext(ProjectContext)
176
+
177
+ const { projects, isLoading, mutate } = useProjects()
178
+
179
+ const project = projects?.find((p) => p.id === projectId)
180
+
181
+ const { trigger: updateMutation } = useSWRMutation(
182
+ `/projects/${projectId}`,
183
+ fetcher.patch,
184
+ )
185
+ const { trigger: dropMutation } = useSWRMutation(
186
+ `/projects/${projectId}`,
187
+ fetcher.delete,
188
+ )
189
+
190
+ async function update(name: string) {
191
+ await updateMutation({ name })
192
+ const newProjects = projects.map((p) =>
193
+ p.id === projectId ? { ...p, name } : p,
194
+ )
195
+ mutate(newProjects)
196
+ }
197
+
198
+ async function drop() {
199
+ await dropMutation()
200
+ const newProjects = projects.filter((p) => p.id !== projectId)
201
+ setProjectId(newProjects[0]?.id)
202
+ mutate(newProjects)
203
+ }
204
+
205
+ return {
206
+ project,
207
+ update,
208
+ drop,
209
+ setProjectId: setProjectId,
210
+ isLoading,
211
+ }
212
+ }
213
+
214
+ export function useTemplates() {
215
+ const { data: templates, isLoading, mutate } = useProjectSWR(`/templates`)
216
+
217
+ // insert mutation
218
+ const { trigger: insert } = useProjectMutation(`/templates`, fetcher.post)
219
+
220
+ return {
221
+ templates,
222
+ insert,
223
+ mutate,
224
+ loading: isLoading,
225
+ }
226
+ }
227
+
228
+ export function useTemplate(id: string) {
229
+ const {
230
+ data: template,
231
+ isLoading,
232
+ mutate,
233
+ } = useProjectSWR(id && `/templates/${id}`)
234
+
235
+ const { trigger: update } = useProjectMutation(
236
+ `/templates/${id}`,
237
+ fetcher.patch,
238
+ )
239
+
240
+ const { trigger: remove } = useProjectMutation(
241
+ `/templates/${id}`,
242
+ fetcher.delete,
243
+ )
244
+
245
+ // insert mutation
246
+ const { trigger: insertVersion } = useProjectMutation(
247
+ `/templates/${id}/versions`,
248
+ fetcher.post,
249
+ )
250
+
251
+ return {
252
+ template,
253
+ insertVersion,
254
+ update,
255
+ remove,
256
+ mutate,
257
+ loading: isLoading,
258
+ }
259
+ }
260
+
261
+ export function useTemplateVersion(id: string) {
262
+ const {
263
+ data: templateVersion,
264
+ isLoading,
265
+ mutate,
266
+ } = useProjectSWR(id && `/template_versions/${id}`)
267
+
268
+ const { trigger: update } = useProjectMutation(
269
+ `/template_versions/${id}`,
270
+ fetcher.patch,
271
+ )
272
+
273
+ return {
274
+ templateVersion,
275
+ update,
276
+ mutate,
277
+ loading: isLoading,
278
+ }
279
+ }
280
+
281
+ export function buildLogsAPIUrl(data = {}) {
282
+ let url = `/runs?`
283
+
284
+ const params = Object.entries(data)
285
+ .map(([key, value]) => {
286
+ return `${key}=${value}`
287
+ })
288
+ .join("&")
289
+
290
+ return url + params
291
+ }
292
+
293
+ export function useLogs(params: any) {
294
+ return useProjectInfiniteSWR(buildLogsAPIUrl(params))
295
+ }
296
+
297
+ export function useRun(id: string, initialData?: any) {
298
+ const {
299
+ data: run,
300
+ isLoading,
301
+ mutate,
302
+ } = useProjectSWR(id && `/runs/${id}`, {
303
+ fallbackData: initialData,
304
+ })
305
+
306
+ const { trigger: update } = useProjectMutation(
307
+ id && `/runs/${id}`,
308
+ fetcher.patch,
309
+ )
310
+
311
+ async function updateRun(data) {
312
+ await update(data)
313
+ mutate({ ...run, ...data })
314
+ }
315
+
316
+ return {
317
+ run,
318
+ update: updateRun,
319
+ mutate,
320
+ loading: isLoading,
321
+ }
322
+ }
323
+
324
+ export function useRunsUsage(range, userId?: string) {
325
+ const userIdStr = userId ? `&userId=${userId}` : ""
326
+ const { data: usage, isLoading } = useProjectSWR(
327
+ `/runs/usage?days=${range}${userIdStr}`,
328
+ )
329
+
330
+ return { usage, loading: isLoading }
331
+ }
332
+
333
+ export function useRunsUsageByDay(range, userId?: string) {
334
+ const userIdStr = userId ? `&userId=${userId}` : ""
335
+
336
+ const { data, isLoading } = useProjectSWR(
337
+ `/runs/usage?days=${range}${userIdStr}&daily=true`,
338
+ )
339
+
340
+ return { dailyUsage: data, loading: isLoading }
341
+ }
342
+
343
+ export function useRunsUsageByUser(range = null) {
344
+ const { data: usageByUser, isLoading } = useProjectSWR(
345
+ `/external-users/runs/usage`,
346
+ )
347
+
348
+ const reduceUsersUsage = (usage) => {
349
+ const userData = []
350
+
351
+ const uniqueUserIds = Array.from(new Set(usage.map((u) => u.user_id)))
352
+
353
+ for (let id of uniqueUserIds) {
354
+ const userUsage = usage.filter((u) => u.user_id === id)
355
+ const totalCost = userUsage.reduce((acc, curr) => {
356
+ acc += curr.cost
357
+ return acc
358
+ }, 0)
359
+
360
+ const totalAgentRuns = userUsage.reduce((acc, curr) => {
361
+ acc += curr.success + curr.errors
362
+ return acc
363
+ }, 0)
364
+
365
+ userData.push({
366
+ user_id: id,
367
+ agentRuns: totalAgentRuns,
368
+ cost: totalCost,
369
+ })
370
+ }
371
+
372
+ return userData
373
+ }
374
+
375
+ return {
376
+ usageByUser: reduceUsersUsage(usageByUser || []),
377
+ loading: isLoading,
378
+ }
379
+ }
380
+
381
+ // TODO: pagination
382
+ export function useAppUserList() {
383
+ const {
384
+ data: users,
385
+ isLoading,
386
+ isValidating,
387
+ } = useProjectSWR(`/external-users`)
388
+
389
+ return { users, isLoading, isValidating }
390
+ }
391
+
392
+ // TODO
393
+ export function useAppUsers(usageRange = 30) {
394
+ const { users, isLoading } = useAppUserList()
395
+
396
+ const maxLastSeen = new Date(
397
+ new Date().getTime() - usageRange * 24 * 60 * 60 * 1000,
398
+ )
399
+ .toISOString()
400
+ .slice(0, 10)
401
+
402
+ const appUsers = users?.filter((u) => u.lastSeen > maxLastSeen)
403
+
404
+ return { users: appUsers || [], loading: isLoading }
405
+ }
406
+
407
+ export function useOrgUser(userId: string) {
408
+ const { mutate: mutateOrg } = useOrg()
409
+
410
+ const { data, isLoading, mutate } = useProjectSWR(
411
+ userId && `/users/${userId}`,
412
+ )
413
+
414
+ async function removeUserFromOrg() {
415
+ await trigger()
416
+ await mutateOrg()
417
+ }
418
+ const { trigger } = useProjectMutation(`/users/${userId}`, fetcher.patch)
419
+
420
+ const theme = useMantineTheme()
421
+ const scheme = useFixedColorScheme()
422
+
423
+ const user = {
424
+ ...data,
425
+ color: getUserColor(scheme, theme, data?.id),
426
+ }
427
+
428
+ return { user, loading: isLoading, mutate, removeUserFromOrg }
429
+ }
430
+
431
+ export function useChecklists(type: string) {
432
+ const { data, isLoading, mutate } = useProjectSWR(
433
+ type && `/checklists?type=${type}`,
434
+ )
435
+
436
+ // insert mutation
437
+ const { trigger: insert, isMutating: isInserting } = useProjectMutation(
438
+ `/checklists`,
439
+ fetcher.post,
440
+ )
441
+
442
+ const { trigger: update, isMutating: isUpdating } = useProjectMutation(
443
+ `/checklists`,
444
+ fetcher.patch,
445
+ )
446
+
447
+ return {
448
+ checklists: data,
449
+ insert,
450
+ isInserting,
451
+ update,
452
+ isUpdating,
453
+ mutate,
454
+ loading: isLoading,
455
+ }
456
+ }
457
+
458
+ export function useChecklist(id: string, initialData?: any) {
459
+ const {
460
+ data: checklist,
461
+ isLoading,
462
+ mutate,
463
+ } = useProjectSWR(id && `/checklists/${id}`, {
464
+ fallbackData: initialData,
465
+ })
466
+
467
+ const { trigger: update } = useProjectMutation(
468
+ id && `/checklists/${id}`,
469
+ fetcher.patch,
470
+ )
471
+
472
+ const { trigger: remove } = useProjectMutation(
473
+ id && `/checklists/${id}`,
474
+ fetcher.delete,
475
+ {
476
+ revalidate: false,
477
+ },
478
+ )
479
+
480
+ return {
481
+ checklist,
482
+ update,
483
+ remove,
484
+ mutate,
485
+ loading: isLoading,
486
+ }
487
+ }
488
+
489
+ export function useDatasets() {
490
+ const { data, isLoading, mutate } = useProjectSWR(`/datasets`)
491
+
492
+ // insert mutation
493
+ const { trigger: insert, isMutating: isInserting } = useProjectMutation(
494
+ `/datasets`,
495
+ fetcher.post,
496
+ )
497
+
498
+ const { trigger: update, isMutating: isUpdating } = useProjectMutation(
499
+ `/datasets`,
500
+ fetcher.patch,
501
+ )
502
+
503
+ return {
504
+ datasets: data || [],
505
+ insert,
506
+ isInserting,
507
+ update,
508
+ isUpdating,
509
+ mutate,
510
+ isLoading,
511
+ }
512
+ }
513
+
514
+ export function useDataset(id: string, initialData?: any) {
515
+ const { mutate: mutateDatasets } = useDatasets()
516
+
517
+ const {
518
+ data: dataset,
519
+ isLoading,
520
+ isValidating,
521
+ mutate,
522
+ } = useProjectSWR(id && id !== "new" && `/datasets/${id}`, {
523
+ fallbackData: initialData,
524
+ })
525
+
526
+ const { trigger: update } = useProjectMutation(
527
+ `/datasets/${id}`,
528
+ fetcher.patch,
529
+ )
530
+
531
+ const { trigger: remove } = useProjectMutation(
532
+ `/datasets/${id}`,
533
+ fetcher.delete,
534
+ {
535
+ onSuccess() {
536
+ mutateDatasets((datasets) => datasets.filter((d) => d.id !== id))
537
+ },
538
+ },
539
+ )
540
+
541
+ const { trigger: insertPrompt, isMutating: isInsertingPrompt } =
542
+ useProjectMutation(`/datasets/prompts`, fetcher.post)
543
+
544
+ return {
545
+ dataset,
546
+ insertPrompt,
547
+ update,
548
+ remove,
549
+ mutate,
550
+ loading: isLoading,
551
+ isValidating,
552
+ isInsertingPrompt,
553
+ }
554
+ }
555
+
556
+ export function useDatasetPrompt(id: string) {
557
+ const {
558
+ data: prompt,
559
+ isLoading,
560
+ mutate,
561
+ } = useProjectSWR(id && `/datasets/prompts/${id}`)
562
+
563
+ const { trigger: update } = useProjectMutation(
564
+ id && `/datasets/prompts/${id}`,
565
+ fetcher.patch,
566
+ )
567
+
568
+ const { trigger: remove } = useProjectMutation(
569
+ id && `/datasets/prompts/${id}`,
570
+ fetcher.delete,
571
+ {
572
+ revalidate: false,
573
+ },
574
+ )
575
+
576
+ const { trigger: insertVariation, isMutating: isInsertingVariation } =
577
+ useProjectMutation(id && `/datasets/variations`, fetcher.post)
578
+
579
+ return {
580
+ prompt,
581
+ update,
582
+ remove,
583
+ mutate,
584
+ loading: isLoading,
585
+ insertVariation,
586
+ isInsertingVariation,
587
+ }
588
+ }
589
+
590
+ export function useDatasetPromptVariation(id: string) {
591
+ const {
592
+ data: variation,
593
+ isLoading,
594
+ mutate,
595
+ } = useProjectSWR(id && `/datasets/variations/${id}`)
596
+
597
+ const { trigger: update } = useProjectMutation(
598
+ id && `/datasets/variations/${id}`,
599
+ fetcher.patch,
600
+ {
601
+ revalidate: false,
602
+ },
603
+ )
604
+
605
+ const { trigger: remove } = useProjectMutation(
606
+ id && `/datasets/variations/${id}`,
607
+ fetcher.delete,
608
+ {
609
+ revalidate: false,
610
+ },
611
+ )
612
+
613
+ return {
614
+ variation,
615
+ update,
616
+ remove,
617
+ mutate,
618
+ loading: isLoading,
619
+ }
620
+ }
621
+
622
+ export function useRadars() {
623
+ const { data: radars, isLoading, mutate } = useProjectSWR(`/radars`)
624
+
625
+ // insert mutation
626
+ const { trigger: insert } = useProjectMutation(`/radars`, fetcher.post, {
627
+ populateCache(result, currentData) {
628
+ return [...currentData, result]
629
+ },
630
+ })
631
+
632
+ return {
633
+ radars,
634
+ insert,
635
+ mutate,
636
+ loading: isLoading,
637
+ }
638
+ }
639
+
640
+ export function useRadar(id, initialData?: any) {
641
+ const { mutate: mutateRadars } = useRadars()
642
+
643
+ const {
644
+ data: radar,
645
+ isLoading,
646
+ mutate,
647
+ } = useProjectSWR(id && `/radars/${id}`, {
648
+ fallbackData: initialData,
649
+ })
650
+
651
+ const { trigger: update } = useProjectMutation(
652
+ id && `/radars/${id}`,
653
+ fetcher.patch,
654
+ {},
655
+ )
656
+
657
+ const { trigger: remove } = useProjectMutation(
658
+ id && `/radars/${id}`,
659
+ fetcher.delete,
660
+ {
661
+ onSuccess() {
662
+ mutateRadars((radars) => radars.filter((r) => r.id !== id))
663
+ },
664
+ },
665
+ )
666
+
667
+ const { data: chart } = useProjectSWR(id && `/radars/${id}/chart`)
668
+
669
+ return {
670
+ radar,
671
+ chart,
672
+ update,
673
+ remove,
674
+ mutate,
675
+ loading: isLoading,
676
+ }
677
+ }
678
+
679
+ export function useEvaluations() {
680
+ const { data, isLoading } = useProjectSWR(`/evaluations`)
681
+
682
+ return {
683
+ evaluations: data || [],
684
+ isLoading,
685
+ }
686
+ }
687
+
688
+ export function useEvaluation(id: string) {
689
+ const {
690
+ data: evaluation,
691
+ isLoading,
692
+ mutate,
693
+ } = useProjectSWR(id && `/evaluations/${id}`)
694
+
695
+ return {
696
+ evaluation,
697
+ mutate,
698
+ loading: isLoading,
699
+ }
700
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/utils/datatable.tsx ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import AppUserAvatar from "@/components/Blocks/AppUserAvatar"
2
+ import Feedback from "@/components/Blocks/Feedback"
3
+ import ProtectedText from "@/components/Blocks/ProtectedText"
4
+ import SmartViewer from "@/components/SmartViewer"
5
+ import { Badge, Group } from "@mantine/core"
6
+ import { createColumnHelper } from "@tanstack/react-table"
7
+ import { useEffect } from "react"
8
+ import analytics from "./analytics"
9
+
10
+ import { formatCost, formatDateTime, msToTime } from "./format"
11
+ import { useProjectSWR } from "./dataHooks"
12
+ const columnHelper = createColumnHelper<any>()
13
+
14
+ export function timeColumn(timeColumn, label = "Time") {
15
+ return columnHelper.accessor(timeColumn, {
16
+ header: label,
17
+ id: timeColumn,
18
+ size: 80,
19
+ sortingFn: (a, b) =>
20
+ new Date(a.getValue(timeColumn)).getTime() -
21
+ new Date(b.getValue(timeColumn)).getTime(),
22
+ cell: (info) => {
23
+ const isToday =
24
+ new Date(info.getValue()).toDateString() === new Date().toDateString()
25
+ if (isToday) {
26
+ return new Date(info.getValue()).toLocaleTimeString(
27
+ typeof window !== "undefined" ? window.navigator.language : "en-US",
28
+ )
29
+ } else {
30
+ return formatDateTime(info.getValue())
31
+ }
32
+ },
33
+ })
34
+ }
35
+
36
+ export function durationColumn(unit = "s") {
37
+ return {
38
+ id: "duration",
39
+ header: "Duration",
40
+ size: 45,
41
+ cell: (props) => {
42
+ if (!props.getValue()) return null
43
+ if (unit === "s") {
44
+ return `${(props.getValue() / 1000).toFixed(2)}s`
45
+ } else if (unit === "full") {
46
+ return msToTime(props.getValue())
47
+ }
48
+ },
49
+ accessorFn: (row) => {
50
+ if (!row.endedAt) {
51
+ return NaN
52
+ }
53
+
54
+ const duration =
55
+ new Date(row.endedAt).getTime() - new Date(row.createdAt).getTime()
56
+ return duration
57
+ },
58
+ }
59
+ }
60
+
61
+ export function statusColumn() {
62
+ return columnHelper.accessor("status", {
63
+ id: "status",
64
+ header: "Status",
65
+ size: 60,
66
+ cell: (props) => (
67
+ <Badge color={props.getValue() === "success" ? "green" : "red"}>
68
+ <ProtectedText>{props.getValue()}</ProtectedText>
69
+ </Badge>
70
+ ),
71
+ })
72
+ }
73
+
74
+ export function tagsColumn() {
75
+ return columnHelper.accessor("tags", {
76
+ header: "Tags",
77
+ size: 70,
78
+ cell: (props) => {
79
+ const tags = props.getValue()
80
+
81
+ useEffect(() => {
82
+ // Feature tracking
83
+ if (tags) analytics.trackOnce("HasTags")
84
+ }, [tags])
85
+
86
+ if (!tags) return null
87
+
88
+ return (
89
+ <Group gap={4}>
90
+ {tags.map((tag) => (
91
+ <Badge
92
+ key={tag}
93
+ variant="outline"
94
+ style={{
95
+ textTransform: "none",
96
+ maxWidth: "100%",
97
+ }}
98
+ >
99
+ {tag}
100
+ </Badge>
101
+ ))}
102
+ </Group>
103
+ )
104
+ },
105
+ })
106
+ }
107
+
108
+ export function inputColumn(label = "input") {
109
+ return columnHelper.accessor("input", {
110
+ header: label,
111
+ size: 200,
112
+ enableSorting: false,
113
+ cell: (props) => <SmartViewer data={props.getValue()} compact />,
114
+ })
115
+ }
116
+
117
+ export function outputColumn(label = "Response") {
118
+ return columnHelper.accessor("output", {
119
+ header: label,
120
+ enableSorting: false,
121
+ cell: (props) => (
122
+ <SmartViewer
123
+ data={props.getValue()}
124
+ error={props.row.original.error}
125
+ compact
126
+ />
127
+ ),
128
+ })
129
+ }
130
+
131
+ export function userColumn() {
132
+ return columnHelper.accessor("user", {
133
+ header: "User",
134
+ size: 120,
135
+ cell: (props) => {
136
+ const user = props.getValue()
137
+
138
+ if (!user?.id) return null
139
+
140
+ return <AppUserAvatar size="sm" user={user} withName />
141
+ },
142
+ })
143
+ }
144
+
145
+ export function nameColumn(label = "Name") {
146
+ return columnHelper.accessor("name", {
147
+ header: label,
148
+ size: 80,
149
+ minSize: 30,
150
+ cell: (props) => {
151
+ const { status, type } = props.row.original
152
+ const name = props.getValue()
153
+
154
+ return (
155
+ <Badge
156
+ variant="outline"
157
+ style={{
158
+ textTransform: "none",
159
+ }}
160
+ color={
161
+ status === "success" ? "green" : status === "error" ? "red" : "gray"
162
+ }
163
+ >
164
+ {name || type}
165
+ </Badge>
166
+ )
167
+ },
168
+ })
169
+ }
170
+
171
+ export function costColumn() {
172
+ return columnHelper.accessor("cost", {
173
+ header: "Cost",
174
+ size: 60,
175
+ sortingFn: (a, b) => a - b,
176
+ cell: (props) => {
177
+ const cost = props.getValue()
178
+ return formatCost(cost)
179
+ },
180
+ })
181
+ }
182
+
183
+ export function feedbackColumn(withRelatedRuns = false) {
184
+ const cell = withRelatedRuns
185
+ ? (props) => {
186
+ const run = props.row.original
187
+
188
+ const { data: relatedRuns } = useProjectSWR(`/runs/${run.id}/related`)
189
+
190
+ const allFeedbacks = [run, ...(relatedRuns || [])]
191
+ .filter((run) => run.feedback)
192
+ .map((run) => run.feedback)
193
+
194
+ return (
195
+ <Group gap="xs">
196
+ {allFeedbacks?.map((feedback, i) => (
197
+ <Feedback data={feedback} key={i} />
198
+ ))}
199
+ </Group>
200
+ )
201
+ }
202
+ : (props) => {
203
+ const run = props.row.original
204
+
205
+ return <Feedback data={run.feedback} />
206
+ }
207
+
208
+ return columnHelper.accessor("feedback", {
209
+ header: "Feedback",
210
+ size: 100,
211
+ cell,
212
+ })
213
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/utils/errors.tsx ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { notifications } from "@mantine/notifications"
2
+ import { IconX } from "@tabler/icons-react"
3
+
4
+ // Error handler for fetch requests
5
+ const errorHandler = async (promise: Promise<any>) => {
6
+ try {
7
+ let res = await promise
8
+
9
+ // automatically JSON parse fetch
10
+ if (res?.json) res = await res.json()
11
+
12
+ const { data, error } = res
13
+ if (error) throw error
14
+ return data || res
15
+ } catch (error: any) {
16
+ console.error(error)
17
+
18
+ notifications.show({
19
+ icon: <IconX size={18} />,
20
+ color: "red",
21
+ id: "error-alert",
22
+ title: "Error",
23
+ autoClose: 4000,
24
+ message: error.error_description || error.message || error,
25
+ })
26
+
27
+ return null
28
+ }
29
+ }
30
+
31
+ export function showErrorNotification(title: any, message?: string) {
32
+ console.error(message)
33
+
34
+ // prevent 10x same error from being shown
35
+ notifications.hide("error-alert")
36
+
37
+ notifications.show({
38
+ icon: <IconX size={18} />,
39
+ id: "error-alert",
40
+ title: title || "Server error",
41
+ message: message || "Something went wrong",
42
+ color: "red",
43
+ autoClose: 4000,
44
+ })
45
+ }
46
+
47
+ export default errorHandler
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/utils/fetcher.ts ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Router from "next/router"
2
+ import { signOut } from "./auth"
3
+ import { showErrorNotification } from "./errors"
4
+
5
+ const BASE_URL = process.env.NEXT_PUBLIC_API_URL
6
+
7
+ export function buildUrl(path: string) {
8
+ if (path.includes("/auth")) {
9
+ return `${BASE_URL}${path}`
10
+ }
11
+ return `${BASE_URL}/v1${path}`
12
+ }
13
+
14
+ function get(path) {
15
+ const authToken = localStorage.getItem("auth-token")
16
+ const headers = authToken
17
+ ? {
18
+ Authorization: `Bearer ${authToken}`,
19
+ }
20
+ : undefined
21
+
22
+ return fetch(buildUrl(path), {
23
+ headers,
24
+ }).then(handleResponse)
25
+ }
26
+
27
+ async function getFile(path) {
28
+ const res = await fetch(buildUrl(path), {
29
+ headers: {
30
+ Authorization: `Bearer ${localStorage.getItem("auth-token")}`,
31
+ },
32
+ })
33
+
34
+ if (!res.ok) {
35
+ const { error, message } = await res.json()
36
+
37
+ showErrorNotification(error, message)
38
+ throw new Error(message)
39
+ }
40
+
41
+ const contentType = res.headers.get("Content-Type") as string
42
+ const fileExtension = contentType.split("/")[1]
43
+
44
+ const blob = await res.blob()
45
+ const url = window.URL.createObjectURL(blob)
46
+
47
+ const a = document.createElement("a")
48
+ a.href = url
49
+ a.download = `export.${fileExtension}`
50
+
51
+ document.body.appendChild(a)
52
+ a.click()
53
+ a.remove()
54
+
55
+ window.URL.revokeObjectURL(url)
56
+ }
57
+
58
+ function post(path, { arg }) {
59
+ return fetch(buildUrl(path), {
60
+ method: "POST",
61
+ headers: {
62
+ "Content-Type": "application/json",
63
+ Authorization: `Bearer ${localStorage.getItem("auth-token")}`,
64
+ },
65
+ body: JSON.stringify(arg),
66
+ }).then(handleResponse)
67
+ }
68
+
69
+ function patch(path, { arg }) {
70
+ return fetch(buildUrl(path), {
71
+ method: "PATCH",
72
+ headers: {
73
+ "Content-Type": "application/json",
74
+ Authorization: `Bearer ${localStorage.getItem("auth-token")}`,
75
+ },
76
+ body: JSON.stringify(arg),
77
+ }).then(handleResponse)
78
+ }
79
+
80
+ async function del(path) {
81
+ return fetch(buildUrl(path), {
82
+ method: "DELETE",
83
+ headers: {
84
+ Authorization: `Bearer ${localStorage.getItem("auth-token")}`,
85
+ },
86
+ }).then(handleResponse)
87
+ }
88
+
89
+ async function handleResponse(res: Response) {
90
+ const isLoginPage = Router.pathname === "/login"
91
+
92
+ if (!res.ok) {
93
+ if (res.status === 401 && !isLoginPage) {
94
+ return signOut()
95
+ }
96
+
97
+ const { error, message } = await res.json()
98
+
99
+ showErrorNotification(error, message)
100
+ throw new Error(message)
101
+ }
102
+
103
+ return res.json()
104
+ }
105
+
106
+ export const fetcher = {
107
+ get,
108
+ getFile,
109
+ post,
110
+ patch,
111
+ delete: del,
112
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/frontend/utils/format.ts ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { formatDistanceToNow } from "date-fns"
2
+
3
+ export const formatCost = (cost = 0) => {
4
+ if (cost < 1) {
5
+ const formattedCost = (cost * 100).toFixed(4)
6
+ return `${parseFloat(formattedCost)}¢`
7
+ } else {
8
+ return new Intl.NumberFormat("en-US", {
9
+ style: "currency",
10
+ currency: "USD",
11
+ maximumSignificantDigits: 3,
12
+ }).format(cost)
13
+ }
14
+ }
15
+
16
+ export function formatLargeNumber(number) {
17
+ return new Intl.NumberFormat(
18
+ typeof window !== "undefined" ? window.navigator.language : "en-US",
19
+ {
20
+ notation: "compact",
21
+ },
22
+ ).format(number || 0)
23
+ }
24
+
25
+ export function formatAppUser(user) {
26
+ if (!user) return ""
27
+ return user.props?.name ?? user.props?.email ?? user.externalId
28
+ }
29
+
30
+ export function formatDateTime(date) {
31
+ return new Date(date).toLocaleString(
32
+ typeof window !== "undefined" ? window.navigator.language : "en-US",
33
+ {
34
+ month: "short",
35
+ day: "numeric",
36
+ hour: "numeric",
37
+ minute: "numeric",
38
+ },
39
+ )
40
+ }
41
+
42
+ export function msToTime(duration) {
43
+ let seconds = Math.floor((duration / 1000) % 60),
44
+ minutes = Math.floor((duration / (1000 * 60)) % 60),
45
+ hours = Math.floor((duration / (1000 * 60 * 60)) % 24),
46
+ days = Math.floor((duration / (1000 * 60 * 60 * 24)) % 24)
47
+
48
+ const m = minutes
49
+ const s = seconds
50
+ const h = hours
51
+ const d = days
52
+
53
+ return `${d > 0 ? d + "d " : ""}${h > 0 ? h + "h " : ""}${
54
+ m > 0 ? m + "m " : ""
55
+ }${s}s`
56
+ }
57
+
58
+ export function capitalize(s) {
59
+ if (typeof s !== "string") return ""
60
+ return s.charAt(0).toUpperCase() + s.slice(1)
61
+ }
62
+
63
+ export const cleanSlug = (text: string): string =>
64
+ text
65
+ .toString()
66
+ .normalize("NFD")
67
+ .replace(/[\u0300-\u036f]/g, "")
68
+ .toLowerCase()
69
+ .trim()
70
+ .replace(/\s+/g, "-")
71
+ .replace(/[^\w-]+/g, "")
72
+ .replace(/--+/g, "-")
73
+
74
+ export const formatCompactFromNow = (date) =>
75
+ formatDistanceToNow(new Date(), {
76
+ addSuffix: true,
77
+ })
78
+ .replace("less than", "<")
79
+ .replace("about", "~")
80
+ .replace("minute", "min")
81
+ .replace(" hours", "h")
82
+ .replace(" hour", "h")
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/shared/README.md ADDED
File without changes
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/shared/filters/index.ts ADDED
@@ -0,0 +1,885 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {
2
+ FIELD_PARAM,
3
+ FIELD_PARAM_ANY,
4
+ FORMAT_PARAM,
5
+ MATCH_PARAM,
6
+ NUMBER_PARAM,
7
+ PERCENT_PARAM,
8
+ } from "./params"
9
+
10
+ import type { Filter } from "./types"
11
+
12
+ export * from "./types"
13
+ export * from "./serialize"
14
+
15
+ export const FILTERS: Filter[] = [
16
+ {
17
+ id: "type",
18
+ name: "Type",
19
+ uiType: "basic",
20
+ disableInEvals: true,
21
+ params: [
22
+ {
23
+ type: "label",
24
+ label: "Type is",
25
+ },
26
+ {
27
+ type: "select",
28
+ id: "type",
29
+ width: 110,
30
+ defaultValue: "llm",
31
+ options: [
32
+ {
33
+ label: "LLM Call",
34
+ value: "llm",
35
+ },
36
+ {
37
+ label: "Agent",
38
+ value: "agent",
39
+ },
40
+ {
41
+ label: "Tool",
42
+ value: "tool",
43
+ },
44
+ {
45
+ label: "Thread",
46
+ value: "thread",
47
+ },
48
+ {
49
+ label: "Chat Message",
50
+ value: "chat",
51
+ },
52
+ {
53
+ label: "Trace",
54
+ value: "trace",
55
+ },
56
+ ],
57
+ },
58
+ ],
59
+ },
60
+ {
61
+ id: "models",
62
+ name: "Model name",
63
+ uiType: "basic",
64
+ disableInEvals: true,
65
+ params: [
66
+ {
67
+ type: "label",
68
+ label: "Model is",
69
+ },
70
+ {
71
+ type: "select",
72
+ multiple: true,
73
+ id: "names",
74
+ width: 100,
75
+ options: (type) => `/filters/models`,
76
+ },
77
+ ],
78
+ },
79
+ {
80
+ id: "tags",
81
+ name: "Tags",
82
+ uiType: "basic",
83
+ disableInEvals: true,
84
+ params: [
85
+ {
86
+ type: "label",
87
+ label: "Has tags",
88
+ },
89
+ {
90
+ type: "select",
91
+ multiple: true,
92
+ width: 100,
93
+ id: "tags",
94
+ options: () => `/filters/tags`,
95
+ },
96
+ ],
97
+ },
98
+ {
99
+ id: "status",
100
+ name: "Status",
101
+ uiType: "basic",
102
+ disableInEvals: true,
103
+ params: [
104
+ {
105
+ type: "label",
106
+ label: "Status is",
107
+ },
108
+ {
109
+ type: "select",
110
+ id: "status",
111
+ defaultValue: "success",
112
+ width: 140,
113
+ options: [
114
+ {
115
+ label: "Completed",
116
+ value: "success",
117
+ },
118
+ {
119
+ label: "Failed",
120
+ value: "error",
121
+ },
122
+ ],
123
+ },
124
+ ],
125
+ },
126
+ // {
127
+ // id: "feedbacks",
128
+ // name: "Feedback",
129
+ // uiType: "basic",
130
+ // disableInEvals: true,
131
+ // params: [
132
+ // {
133
+ // type: "label",
134
+ // label: "Feedback",
135
+ // },
136
+ // {
137
+ // type: "select",
138
+ // multiple: true,
139
+ // id: "feedbacks",
140
+ // options: () => `/filters/feedback`,
141
+ // },
142
+ // ],
143
+ // // feedback is a jsonb column
144
+ // sql: (sql, { feedbacks }) => sql`feedback @> '${feedbacks}'`,
145
+ // },
146
+ {
147
+ id: "users",
148
+ name: "Users",
149
+ uiType: "basic",
150
+ disableInEvals: true,
151
+ params: [
152
+ {
153
+ type: "label",
154
+ label: "Users",
155
+ },
156
+ {
157
+ type: "select",
158
+ multiple: true,
159
+ width: 100,
160
+ id: "users",
161
+ options: () => `/filters/users`,
162
+ // render: (item) => <AppUser/> // todo
163
+ },
164
+ ],
165
+ },
166
+ {
167
+ id: "regex",
168
+ name: "Regex",
169
+ uiType: "smart",
170
+ params: [
171
+ FIELD_PARAM,
172
+ MATCH_PARAM,
173
+ {
174
+ type: "label",
175
+ label: "Regex",
176
+ },
177
+ {
178
+ type: "text",
179
+ id: "regex",
180
+ placeholder: "^[0-9]+$",
181
+ },
182
+ ],
183
+ },
184
+ {
185
+ id: "json",
186
+ name: "JSON",
187
+ description: "Checks if the given field is valid JSON.",
188
+ uiType: "smart",
189
+ params: [
190
+ FIELD_PARAM,
191
+ FORMAT_PARAM,
192
+ {
193
+ type: "label",
194
+ label: "JSON",
195
+ },
196
+ ],
197
+ },
198
+ {
199
+ id: "python",
200
+ name: "Python",
201
+ description: "Checks if the given field is valid python code.",
202
+ soon: true,
203
+ uiType: "smart",
204
+ params: [
205
+ FIELD_PARAM,
206
+ FORMAT_PARAM,
207
+ {
208
+ type: "label",
209
+ label: "Python",
210
+ },
211
+ ],
212
+ },
213
+ // {
214
+ // id: "xml",
215
+ // name: "XML / HTML",
216
+ // uiType: "smart",
217
+ // params: [
218
+ // {
219
+ // label: "Response",
220
+ // type: "label",
221
+ // },
222
+ // FORMAT_PARAM,
223
+ // {
224
+ // type: "label",
225
+ // label: "XML / HTML",
226
+ // },
227
+ // ],
228
+ // evaluator: async (run) => {
229
+ // let parsable = false
230
+ // let passed = false
231
+
232
+ // try {
233
+ // if (!run.output.startsWith("<")) throw "Not an object"
234
+ // // TODO: use a real XML parser
235
+ // // new DOMParser().parseFromString(run.output, "text/xml")
236
+ // parsable = true
237
+ // partial = true
238
+ // } catch (e) {}
239
+
240
+ // return {
241
+ // parsable,
242
+ // partial,
243
+ // }
244
+ // },
245
+
246
+ // },
247
+ {
248
+ id: "cc",
249
+ name: "Credit Card",
250
+ disableInEvals: true,
251
+ uiType: "smart",
252
+ params: [
253
+ FIELD_PARAM,
254
+ MATCH_PARAM,
255
+ {
256
+ type: "label",
257
+ label: "Credit Card",
258
+ },
259
+ ],
260
+ },
261
+ {
262
+ id: "email",
263
+ name: "Email",
264
+ disableInEvals: true,
265
+ uiType: "smart",
266
+ params: [
267
+ FIELD_PARAM,
268
+ MATCH_PARAM,
269
+ {
270
+ type: "label",
271
+ label: "Email",
272
+ },
273
+ ],
274
+ },
275
+ {
276
+ id: "phone",
277
+ name: "Phone",
278
+ disableInEvals: true,
279
+ uiType: "smart",
280
+ params: [
281
+ FIELD_PARAM,
282
+ MATCH_PARAM,
283
+ {
284
+ type: "label",
285
+ label: "Phone",
286
+ },
287
+ ],
288
+ },
289
+ {
290
+ id: "length",
291
+ name: "Length",
292
+ uiType: "smart",
293
+ params: [
294
+ FIELD_PARAM,
295
+ NUMBER_PARAM,
296
+ {
297
+ type: "label",
298
+ label: "Length",
299
+ },
300
+ {
301
+ type: "number",
302
+ id: "length",
303
+ defaultValue: 100,
304
+ unit: "chars",
305
+ width: 60,
306
+ },
307
+ ],
308
+ },
309
+ {
310
+ id: "date",
311
+ name: "Date",
312
+ uiType: "basic",
313
+ disableInEvals: true,
314
+ params: [
315
+ NUMBER_PARAM,
316
+ {
317
+ type: "label",
318
+ label: "Date",
319
+ },
320
+ {
321
+ type: "date",
322
+ id: "date",
323
+ },
324
+ ],
325
+ },
326
+ {
327
+ id: "duration",
328
+ name: "Duration",
329
+ disableInEvals: true,
330
+ uiType: "basic",
331
+ params: [
332
+ {
333
+ type: "label",
334
+ label: "Duration",
335
+ },
336
+ NUMBER_PARAM,
337
+ {
338
+ type: "number",
339
+ id: "duration",
340
+ defaultValue: 5,
341
+ min: 0,
342
+ step: 0.1,
343
+ width: 40,
344
+ unit: "s",
345
+ },
346
+ ],
347
+ },
348
+ {
349
+ id: "cost",
350
+ name: "Cost",
351
+ uiType: "basic",
352
+ disableInEvals: true,
353
+ params: [
354
+ {
355
+ type: "label",
356
+ label: "Cost",
357
+ },
358
+ NUMBER_PARAM,
359
+ {
360
+ type: "number",
361
+ id: "cost",
362
+ width: 70,
363
+ min: 0,
364
+ defaultValue: 0.1,
365
+ unit: "$",
366
+ },
367
+ ],
368
+ },
369
+ {
370
+ id: "tokens",
371
+ name: "Tokens",
372
+ disableInEvals: true,
373
+ uiType: "basic",
374
+ params: [
375
+ {
376
+ type: "select",
377
+ id: "field",
378
+ width: 100,
379
+ defaultValue: "total",
380
+ options: [
381
+ {
382
+ label: "Completion",
383
+ value: "completion",
384
+ },
385
+ {
386
+ label: "Prompt",
387
+ value: "prompt",
388
+ },
389
+ {
390
+ label: "Total",
391
+ value: "total",
392
+ },
393
+ ],
394
+ },
395
+ {
396
+ type: "label",
397
+ label: "Tokens",
398
+ },
399
+ NUMBER_PARAM,
400
+ {
401
+ type: "number",
402
+ min: 0,
403
+ id: "tokens",
404
+ width: 70,
405
+ },
406
+ ],
407
+ },
408
+ {
409
+ id: "radar",
410
+ name: "Radar Match",
411
+ uiType: "smart",
412
+ disableInEvals: true,
413
+ params: [
414
+ {
415
+ type: "label",
416
+ label: "Matches radar",
417
+ },
418
+ {
419
+ type: "select",
420
+ id: "ids",
421
+ width: 150,
422
+ placeholder: "Select radars",
423
+ multiple: true,
424
+ options: () => `/filters/radars`,
425
+ },
426
+ ],
427
+ },
428
+ {
429
+ id: "search",
430
+ name: "Search Match",
431
+ uiType: "smart",
432
+ disableInEvals: true,
433
+ params: [
434
+ {
435
+ type: "label",
436
+ label: "Search",
437
+ },
438
+ {
439
+ type: "text",
440
+ id: "query",
441
+ placeholder: "Search",
442
+ },
443
+ ],
444
+ },
445
+ {
446
+ id: "string",
447
+ name: "String match",
448
+ uiType: "smart",
449
+ params: [
450
+ {
451
+ type: "select",
452
+ id: "fields",
453
+ width: 70,
454
+ defaultValue: "output",
455
+ options: [
456
+ {
457
+ label: "Input",
458
+ value: "input",
459
+ },
460
+ {
461
+ label: "Output",
462
+ value: "output",
463
+ },
464
+ {
465
+ label: "Any",
466
+ value: "any",
467
+ },
468
+ ],
469
+ },
470
+ {
471
+ type: "select",
472
+ id: "type",
473
+ width: 100,
474
+ defaultValue: "contains",
475
+ options: [
476
+ {
477
+ label: "Contains",
478
+ value: "contains",
479
+ },
480
+ {
481
+ label: "Not contains",
482
+ value: "notcontains",
483
+ },
484
+ // {
485
+ // label: "Equals",
486
+ // value: "equals",
487
+ // },
488
+ {
489
+ label: "Starts with",
490
+ value: "starts",
491
+ },
492
+ {
493
+ label: "Ends with",
494
+ value: "ends",
495
+ },
496
+ ],
497
+ },
498
+ {
499
+ type: "select",
500
+ id: "sensitive",
501
+ width: 120,
502
+ defaultValue: "false",
503
+ options: [
504
+ {
505
+ label: "Case sensitive",
506
+ value: "true",
507
+ },
508
+ {
509
+ label: "Case insensitive",
510
+ value: "false",
511
+ },
512
+ ],
513
+ },
514
+ {
515
+ type: "text",
516
+ width: 100,
517
+ id: "text",
518
+ },
519
+ ],
520
+ },
521
+ {
522
+ id: "entities",
523
+ name: "Entities",
524
+ uiType: "ai",
525
+ description:
526
+ "Uses AI to check if the content contains a name, location or organization.",
527
+ params: [
528
+ FIELD_PARAM,
529
+ MATCH_PARAM,
530
+ {
531
+ type: "select",
532
+ id: "entities",
533
+ width: 100,
534
+ defaultValue: ["PER"],
535
+ multiple: true,
536
+ options: [
537
+ {
538
+ label: "Name",
539
+ value: "PER",
540
+ },
541
+ {
542
+ label: "Location",
543
+ value: "LOC",
544
+ },
545
+ {
546
+ label: "Organization",
547
+ value: "ORG",
548
+ },
549
+ ],
550
+ },
551
+ ],
552
+ },
553
+ {
554
+ id: "assertion",
555
+ name: "Assertion",
556
+ uiType: "ai",
557
+ description:
558
+ "Checks if the output matches the given requirement, using GPT-4 to grade the output.",
559
+ onlyInEvals: true,
560
+ params: [
561
+ {
562
+ type: "label",
563
+ label: "Output",
564
+ },
565
+ {
566
+ type: "text",
567
+ id: "assertion",
568
+ placeholder: "Is spoken like a pirate",
569
+ width: 140,
570
+ },
571
+ ],
572
+ },
573
+ {
574
+ id: "sentiment",
575
+ name: "Sentiment",
576
+
577
+ uiType: "ai",
578
+ description:
579
+ "Uses AI to check if content is positive, neutral, or negative.",
580
+ params: [
581
+ FIELD_PARAM,
582
+ {
583
+ type: "label",
584
+ label: "sentiment is",
585
+ },
586
+ {
587
+ type: "select",
588
+ id: "sentiment",
589
+ defaultValue: "positive",
590
+ width: 140,
591
+ options: [
592
+ {
593
+ label: "positive",
594
+ value: "positive",
595
+ },
596
+ {
597
+ label: "neutral",
598
+ value: "neutral",
599
+ },
600
+ {
601
+ label: "negative",
602
+ value: "negative",
603
+ },
604
+ ],
605
+ },
606
+ ],
607
+ },
608
+ {
609
+ id: "tone",
610
+ name: "Tone",
611
+ uiType: "ai",
612
+ onlyInEvals: true,
613
+ description:
614
+ "Assesses if the tone of the LLM response matches with the desired persona.",
615
+ params: [
616
+ {
617
+ type: "label",
618
+ label: "Tone of output matches",
619
+ },
620
+ {
621
+ type: "select",
622
+ id: "persona",
623
+ defaultValue: "helpful",
624
+ width: 140,
625
+ options: [
626
+ {
627
+ label: "Helpful Assistant",
628
+ value: "helpful",
629
+ },
630
+ {
631
+ label: "Formal",
632
+ value: "formal",
633
+ },
634
+ {
635
+ label: "Casual",
636
+ value: "casual",
637
+ },
638
+ {
639
+ label: "Teacher",
640
+ value: "teacher",
641
+ },
642
+ {
643
+ label: "Friendly",
644
+ value: "friendly",
645
+ },
646
+ {
647
+ label: "Professional",
648
+ value: "professional",
649
+ },
650
+ {
651
+ label: "Instructive",
652
+ value: "instructive",
653
+ },
654
+ {
655
+ label: "Authoritative",
656
+ value: "authoritative",
657
+ },
658
+ {
659
+ label: "Informative",
660
+ value: "informative",
661
+ },
662
+ {
663
+ label: "Sarcastic",
664
+ value: "sarcastic",
665
+ },
666
+ {
667
+ label: "Humorous",
668
+ value: "humorous",
669
+ },
670
+ {
671
+ label: "Empathetic",
672
+ value: "empathetic",
673
+ },
674
+ {
675
+ label: "Enthusiastic",
676
+ value: "enthusiastic",
677
+ },
678
+ {
679
+ label: "Motivational",
680
+ value: "motivational",
681
+ },
682
+ {
683
+ label: "Curious",
684
+ value: "curious",
685
+ },
686
+ {
687
+ label: "Sincere",
688
+ value: "sincere",
689
+ },
690
+ {
691
+ label: "Witty",
692
+ value: "witty",
693
+ },
694
+ {
695
+ label: "Pirate",
696
+ value: "pirate",
697
+ },
698
+ ],
699
+ },
700
+ {
701
+ type: "label",
702
+ label: "persona",
703
+ },
704
+ ],
705
+ },
706
+ {
707
+ id: "factualness",
708
+ name: "Factualness",
709
+ uiType: "ai",
710
+
711
+ onlyInEvals: true,
712
+ description:
713
+ "Checks how correct the LLM's response is compared to the ideal output (ues OpenAI's eval prompt).",
714
+ params: [
715
+ {
716
+ type: "label",
717
+ label: "The answer",
718
+ },
719
+ {
720
+ type: "select",
721
+ id: "choices",
722
+ defaultValue: ["b", "c"],
723
+ multiple: true,
724
+ width: 200,
725
+ options: [
726
+ {
727
+ label: "is a subset of",
728
+ value: "a",
729
+ },
730
+ {
731
+ label: "is a superset of",
732
+ value: "b",
733
+ },
734
+ {
735
+ label: "contains all the same details as",
736
+ value: "c",
737
+ },
738
+ {
739
+ label: "disagrees with",
740
+ value: "d",
741
+ },
742
+ {
743
+ label: "differs (but doesn't matter from a factual standpoint)",
744
+ value: "e",
745
+ },
746
+ ],
747
+ },
748
+ {
749
+ type: "label",
750
+ label: "the ideal output",
751
+ },
752
+ ],
753
+ },
754
+ {
755
+ id: "relevancy",
756
+ name: "Relevancy",
757
+ uiType: "ai",
758
+ soon: true,
759
+ onlyInEvals: true,
760
+ description:
761
+ "Checks if the LLM's response is relevant given the context and the prompt.",
762
+ params: [
763
+ {
764
+ type: "label",
765
+ label: "Output is >=",
766
+ },
767
+ PERCENT_PARAM,
768
+ {
769
+ type: "label",
770
+ label: "relevant",
771
+ },
772
+ ],
773
+ },
774
+ {
775
+ id: "toxicity",
776
+ name: "Toxicity",
777
+ uiType: "ai",
778
+ description:
779
+ "Checks if the given field contains toxic, offensive, obscene, or hateful language. English only at the moment.",
780
+ params: [
781
+ FIELD_PARAM_ANY,
782
+ MATCH_PARAM,
783
+ {
784
+ type: "label",
785
+ label: "toxicity",
786
+ },
787
+ ],
788
+ },
789
+ {
790
+ id: "system",
791
+ name: "System Guidelines",
792
+ soon: true,
793
+ uiType: "ai",
794
+ onlyInEvals: true,
795
+ description: `Checks if the output matches guidelines set in the 'system' message.`,
796
+ params: [
797
+ {
798
+ type: "label",
799
+ label: "Output follows >=",
800
+ },
801
+ PERCENT_PARAM,
802
+ {
803
+ type: "label",
804
+ label: "system guidelines",
805
+ },
806
+ ],
807
+ },
808
+ {
809
+ id: "similarity",
810
+ name: "Similarity",
811
+ uiType: "ai",
812
+ onlyInEvals: true,
813
+ description: `Check if the output is similar to a given ideal output with various algorithms.`,
814
+ params: [
815
+ {
816
+ type: "label",
817
+ label: "Output is >=",
818
+ },
819
+ PERCENT_PARAM,
820
+ {
821
+ type: "label",
822
+ label: "similar to ideal output using",
823
+ },
824
+ {
825
+ type: "select",
826
+ id: "algorithm",
827
+ width: 100,
828
+ defaultValue: "ai",
829
+ options: [
830
+ {
831
+ value: "ai",
832
+ label: "Smart AI",
833
+ },
834
+ {
835
+ label: "Cosine (vector)",
836
+ value: "cosine",
837
+ },
838
+ {
839
+ label: "Jaccard",
840
+ value: "jaccard",
841
+ },
842
+ ],
843
+ },
844
+ {
845
+ type: "label",
846
+ label: "similarity",
847
+ },
848
+ ],
849
+ },
850
+ {
851
+ id: "rouge",
852
+ name: "ROUGE",
853
+ uiType: "ai",
854
+ onlyInEvals: true,
855
+ description: `Rouge (Recall-Oriented Understudy for Gisting Evaluation) is a metric used for evaluating the quality of generated text, especially in tasks like text summarization.`,
856
+
857
+ params: [
858
+ {
859
+ type: "label",
860
+ label: "Output is >=",
861
+ },
862
+ PERCENT_PARAM,
863
+ {
864
+ type: "select",
865
+ id: "rouge",
866
+ width: 100,
867
+ defaultValue: "n",
868
+ options: [
869
+ {
870
+ value: "n",
871
+ label: "ROUGE-n",
872
+ },
873
+ {
874
+ value: "l",
875
+ label: "ROUGE-l",
876
+ },
877
+ {
878
+ value: "rouge-s",
879
+ label: "ROUGE-s",
880
+ },
881
+ ],
882
+ },
883
+ ],
884
+ },
885
+ ]
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/shared/filters/params.ts ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { FilterParam } from "./types"
2
+
3
+ export const FORMAT_PARAM: FilterParam = {
4
+ type: "select",
5
+ id: "type",
6
+ width: 120,
7
+ defaultValue: "valid",
8
+ options: [
9
+ {
10
+ label: "Is valid",
11
+ value: "valid",
12
+ },
13
+ {
14
+ label: "Is invalid",
15
+ value: "invalid",
16
+ },
17
+ // {
18
+ // label: "Is partial",
19
+ // value: "partial",
20
+ // },
21
+ {
22
+ label: "Contains valid",
23
+ value: "contains",
24
+ },
25
+ ],
26
+ }
27
+
28
+ export const NUMBER_PARAM: FilterParam = {
29
+ type: "select",
30
+ id: "operator",
31
+ width: 50,
32
+ defaultValue: "lt",
33
+ options: [
34
+ {
35
+ label: ">=",
36
+ value: "gte",
37
+ },
38
+ {
39
+ label: "<=",
40
+ value: "lte",
41
+ },
42
+ {
43
+ label: "=",
44
+ value: "eq",
45
+ },
46
+ {
47
+ label: "!=",
48
+ value: "neq",
49
+ },
50
+ {
51
+ label: ">",
52
+ value: "gt",
53
+ },
54
+ {
55
+ label: "<",
56
+ value: "lt",
57
+ },
58
+ ],
59
+ }
60
+
61
+ export const FIELD_PARAM: FilterParam = {
62
+ type: "select",
63
+ id: "field",
64
+ width: 80,
65
+ defaultValue: "output",
66
+ options: [
67
+ {
68
+ label: "Input",
69
+ value: "input",
70
+ },
71
+ {
72
+ label: "Output",
73
+ value: "output",
74
+ },
75
+ ],
76
+ }
77
+
78
+ export const FIELD_PARAM_ANY: FilterParam = {
79
+ type: "select",
80
+ id: "field",
81
+ width: 80,
82
+ defaultValue: "output",
83
+ options: [
84
+ {
85
+ label: "Input",
86
+ value: "input",
87
+ },
88
+ {
89
+ label: "Output",
90
+ value: "output",
91
+ },
92
+ {
93
+ label: "Any",
94
+ value: "any",
95
+ },
96
+ ],
97
+ }
98
+
99
+ export const MATCH_PARAM: FilterParam = {
100
+ type: "select",
101
+ id: "type",
102
+ width: 120,
103
+ defaultValue: "contains",
104
+ options: [
105
+ {
106
+ label: "Contains",
107
+ value: "contains",
108
+ },
109
+ {
110
+ label: "Not contains",
111
+ value: "not_contains",
112
+ },
113
+ ],
114
+ }
115
+
116
+ export const PERCENT_PARAM: FilterParam = {
117
+ type: "number",
118
+ unit: "%",
119
+ id: "percent",
120
+ width: 50,
121
+ min: 0,
122
+ step: 5,
123
+ max: 100,
124
+ defaultValue: 50,
125
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/shared/filters/serialize.ts ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { FilterLogic, FilterParam } from "."
2
+ import { FILTERS } from "."
3
+
4
+ // because dots are used to separate filter parameters, we need to encode them
5
+ const encode = (str: string) => encodeURIComponent(str).replace(/\./g, "%2E")
6
+
7
+ const paramSerializer = (param: FilterParam, value: any) => {
8
+ if (value == undefined) {
9
+ return undefined
10
+ }
11
+ switch (param.type) {
12
+ case "select":
13
+ if (param.multiple) {
14
+ if (!value.length) return undefined
15
+ return value.map(encode).join(",")
16
+ } else {
17
+ return encode(value)
18
+ }
19
+ case "text":
20
+ case "number":
21
+ return encode(value)
22
+ case "date":
23
+ // get timestamp
24
+ return encode(value.getTime())
25
+ default:
26
+ return undefined
27
+ }
28
+ }
29
+
30
+ function deserializeParamValue(
31
+ filterParam: FilterParam,
32
+ v: string,
33
+ ): any | undefined {
34
+ switch (filterParam.type) {
35
+ case "select":
36
+ if (filterParam.multiple) {
37
+ return v.split(",").map(decodeURIComponent)
38
+ } else {
39
+ return decodeURIComponent(v)
40
+ }
41
+ case "text":
42
+ return decodeURIComponent(v)
43
+ case "number":
44
+ return Number(v)
45
+ case "date":
46
+ return new Date(Number(v))
47
+ default:
48
+ return undefined
49
+ }
50
+ }
51
+
52
+ // This function serializes the filter parameters for storage or transmission
53
+ // Example:
54
+ // ['AND', {id: 'type', params: {type: 'llm'}}, {id: 'tags', params: {tags: ['some', 'tags']}}]
55
+ // Will be serialized to:
56
+ // type=llm&tags=some.tags
57
+
58
+ export function serializeLogic(logic: FilterLogic): string {
59
+ const serializeParamValue = (param: any): string => {
60
+ if (Array.isArray(param)) {
61
+ const all = param.map(serializeParamValue)
62
+
63
+ if (all.some((f) => typeof f !== "undefined")) return ""
64
+ return all.join(".")
65
+ } else if (
66
+ param &&
67
+ typeof param === "object" &&
68
+ param.params &&
69
+ !Object.values(param.params).some((f) => typeof f === "undefined")
70
+ ) {
71
+ const data = Object.entries(param.params)
72
+ .map(([key, value]) => {
73
+ const filterParam = FILTERS.find(
74
+ (filter) => filter.id === param.id,
75
+ )?.params.find((param) => (param as FilterParam).id === key)
76
+
77
+ if (!filterParam || filterParam.type === "label") {
78
+ return ""
79
+ }
80
+
81
+ return paramSerializer(filterParam, value)
82
+ })
83
+ .filter((serializedValue) => serializedValue !== "")
84
+ .join(".")
85
+
86
+ if (!data) return ""
87
+
88
+ return param.id + "=" + data
89
+ }
90
+ return ""
91
+ }
92
+
93
+ return logic
94
+ .map(serializeParamValue)
95
+ .filter((f) => f)
96
+ .join("&")
97
+ }
98
+
99
+ export function deserializeLogic(logicString: string): FilterLogic | undefined {
100
+ const deserializeParam = (param: string): any => {
101
+ const [id, params] = param.split("=")
102
+ const filter = FILTERS.find((filter) => filter.id === id)
103
+
104
+ if (!filter) {
105
+ return undefined
106
+ }
107
+
108
+ const filterParams = filter.params.filter(
109
+ (param) => param.type !== "label",
110
+ ) as FilterParam[]
111
+
112
+ const paramsData: any = {}
113
+
114
+ const value = params.split(".")
115
+
116
+ for (const [i, v] of value.entries()) {
117
+ const filterParam = filterParams[i]
118
+
119
+ if (!filterParam) {
120
+ return undefined
121
+ }
122
+
123
+ paramsData[filterParam.id] = deserializeParamValue(filterParam, v)
124
+ }
125
+
126
+ return {
127
+ id,
128
+ params: paramsData,
129
+ }
130
+ }
131
+
132
+ const logic = logicString
133
+ .split("&")
134
+ .map(deserializeParam)
135
+ .filter((f) => f)
136
+
137
+ return ["AND", ...logic] as FilterLogic
138
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/shared/filters/types.ts ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export type FilterLabel = {
2
+ type: "label"
3
+ label: string
4
+ }
5
+
6
+ export type FilterParam = {
7
+ type: "select" | "text" | "number" | "date"
8
+ id: string
9
+ unit?: string
10
+ max?: number
11
+ min?: number
12
+ step?: number
13
+ width?: number
14
+ placeholder?: string
15
+ render?: (value: any) => React.ReactNode
16
+ defaultValue?: string | number | boolean | string[]
17
+ multiple?: boolean
18
+ options?:
19
+ | Array<{ label: string; value: string }>
20
+ | ((projectId: string, type: string) => string)
21
+ }
22
+
23
+ export type Filter = {
24
+ id: string
25
+ uiType: "basic" | "smart" | "ai"
26
+ name: string
27
+ description?: string
28
+ soon?: boolean
29
+ params: (FilterParam | FilterLabel)[]
30
+ disableInEvals?: boolean
31
+ onlyInEvals?: boolean
32
+ }
33
+
34
+ // export type SavedFilterData = {
35
+ // id: string
36
+ // paramsData: { id: string; value: any }[]
37
+ // }
38
+
39
+ // [ 'AND, {id, params}, {id, params}, {id, params}, ['OR', {id, params}, {id, params}], ['OR', {id, params}, ['AND', {id, params}, {id, params}]] ]
40
+
41
+ export type LogicData = {
42
+ id: string
43
+ params: any
44
+ }
45
+
46
+ type LogicNode = ["AND" | "OR", ...LogicElement[]]
47
+
48
+ export type LogicElement = LogicData | LogicNode
49
+
50
+ export type FilterLogic = LogicNode
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/shared/index.ts ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ export * from "./models"
2
+ export * from "./filters"
3
+ export * from "./types"
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/shared/models.ts ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export const MODELS = [
2
+ {
3
+ id: "gpt-4-turbo-preview",
4
+ name: "gpt-4-turbo-preview",
5
+ provider: "openai",
6
+ },
7
+ { id: "gpt-4-1106-preview", name: "gpt-4-1106-preview", provider: "openai" },
8
+ { id: "gpt-4-0125-preview", name: "gpt-4-0125-preview", provider: "openai" },
9
+ {
10
+ id: "gpt-4-vision-preview",
11
+ name: "gpt-4-vision-preview",
12
+ provider: "openai",
13
+ },
14
+ { id: "gpt-4", name: "gpt-4", provider: "openai" },
15
+ { id: "gpt-3.5-turbo", name: "gpt-3.5-turbo", provider: "openai" },
16
+ { id: "gpt-3.5-turbo-1106", name: "gpt-3.5-turbo-1106", provider: "openai" },
17
+ { id: "gpt-3.5-turbo-0125", name: "gpt-3.5-turbo-0125", provider: "openai" },
18
+ { id: "gpt-3.5-turbo-16k", name: "gpt-3.5-turbo-16k", provider: "openai" },
19
+ {
20
+ id: "google/gemini-pro",
21
+ name: "gemini-pro",
22
+ provider: "openrouter",
23
+ },
24
+ { id: "openai/gpt-4-32k", name: "gpt-4-32k", provider: "openrouter" },
25
+ { id: "claude-2", name: "claude-2", provider: "anthropic" },
26
+ // { id: "claude-2.0", name: "claude-2.0", provider: "anthropic" },
27
+ {
28
+ id: "claude-instant-v1",
29
+ name: "claude-instant-v1",
30
+ provider: "anthropic",
31
+ },
32
+ {
33
+ id: "open-orca/mistral-7b-openorca",
34
+ name: "mistral-7b-openorca",
35
+ provider: "openrouter",
36
+ },
37
+ {
38
+ id: "mistralai/mixtral-8x7b-instruct",
39
+ name: "mixtral-8x7b-instruct",
40
+ provider: "openrouter",
41
+ },
42
+ {
43
+ id: "mistralai/mistral-7b-instruct",
44
+ name: "mistral-7b-instruct",
45
+ provider: "openrouter",
46
+ },
47
+ {
48
+ id: "teknium/openhermes-2.5-mistral-7b",
49
+ name: "openhermes-2.5-mistral-7b",
50
+ provider: "openrouter",
51
+ },
52
+ {
53
+ id: "perplexity/pplx-70b-chat",
54
+ name: "pplx-70b-chat",
55
+ provider: "openrouter",
56
+ },
57
+ {
58
+ id: "perplexity/pplx-7b-chat",
59
+ name: "pplx-7b-chat",
60
+ provider: "openrouter",
61
+ },
62
+ {
63
+ id: "openchat/openchat-7b",
64
+ name: "openchat-7b",
65
+ provider: "openrouter",
66
+ },
67
+ {
68
+ id: "google/palm-2-chat-bison",
69
+ name: "palm-2-chat-bison",
70
+ provider: "openrouter",
71
+ },
72
+ {
73
+ id: "meta-llama/llama-2-13b-chat",
74
+ name: "llama-2-13b-chat",
75
+ provider: "openrouter",
76
+ },
77
+ {
78
+ id: "meta-llama/llama-2-70b-chat",
79
+ name: "llama-2-70b-chat",
80
+ provider: "openrouter",
81
+ },
82
+ ]
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/shared/package.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "shared",
3
+ "type": "module",
4
+ "scripts": {
5
+ "build": "tsup index.ts --format esm"
6
+ },
7
+ "dependencies": {
8
+ "zod": "^3.22.4"
9
+ }
10
+ }
benchmark/Cybench/benchmark/bug_bounty/lunary/packages/shared/tsconfig.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "compilerOptions": {
3
+ "lib": ["ESNext"],
4
+ "module": "esnext",
5
+ "target": "esnext",
6
+ "moduleResolution": "bundler",
7
+ "moduleDetection": "force",
8
+ "allowImportingTsExtensions": true,
9
+ "noEmit": true,
10
+ "composite": true,
11
+ "strict": true,
12
+ "downlevelIteration": true,
13
+ "skipLibCheck": true,
14
+ "jsx": "react-jsx",
15
+ "allowSyntheticDefaultImports": true,
16
+ "forceConsistentCasingInFileNames": true,
17
+ "allowJs": true
18
+ }
19
+ }