Skip to content

Commit aff7e4d

Browse files
committed
Merge branch 'dev' into swiftyos/optimse-views
# Conflicts: # autogpt_platform/backend/backend/TEST_DATA_README.md # autogpt_platform/backend/backend/check_db.py # autogpt_platform/backend/backend/check_store_data.py # autogpt_platform/backend/backend/test_data_updater.py # autogpt_platform/backend/backend/util/test_data_creator.py
2 parents 5dcc100 + c77cb1f commit aff7e4d

File tree

646 files changed

+48021
-9503
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

646 files changed

+48021
-9503
lines changed

.github/workflows/platform-backend-ci.yml

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,23 @@ jobs:
5050
env:
5151
RABBITMQ_DEFAULT_USER: ${{ env.RABBITMQ_DEFAULT_USER }}
5252
RABBITMQ_DEFAULT_PASS: ${{ env.RABBITMQ_DEFAULT_PASS }}
53+
clamav:
54+
image: clamav/clamav-debian:latest
55+
ports:
56+
- 3310:3310
57+
env:
58+
CLAMAV_NO_FRESHCLAMD: false
59+
CLAMD_CONF_StreamMaxLength: 50M
60+
CLAMD_CONF_MaxFileSize: 100M
61+
CLAMD_CONF_MaxScanSize: 100M
62+
CLAMD_CONF_MaxThreads: 4
63+
CLAMD_CONF_ReadTimeout: 300
64+
options: >-
65+
--health-cmd "clamdscan --version || exit 1"
66+
--health-interval 30s
67+
--health-timeout 10s
68+
--health-retries 5
69+
--health-start-period 180s
5370
5471
steps:
5572
- name: Checkout repository
@@ -131,6 +148,35 @@ jobs:
131148
# outputs:
132149
# DB_URL, API_URL, GRAPHQL_URL, ANON_KEY, SERVICE_ROLE_KEY, JWT_SECRET
133150

151+
- name: Wait for ClamAV to be ready
152+
run: |
153+
echo "Waiting for ClamAV daemon to start..."
154+
max_attempts=60
155+
attempt=0
156+
157+
until nc -z localhost 3310 || [ $attempt -eq $max_attempts ]; do
158+
echo "ClamAV is unavailable - sleeping (attempt $((attempt+1))/$max_attempts)"
159+
sleep 5
160+
attempt=$((attempt+1))
161+
done
162+
163+
if [ $attempt -eq $max_attempts ]; then
164+
echo "ClamAV failed to start after $((max_attempts*5)) seconds"
165+
echo "Checking ClamAV service logs..."
166+
docker logs $(docker ps -q --filter "ancestor=clamav/clamav-debian:latest") 2>&1 | tail -50 || echo "No ClamAV container found"
167+
exit 1
168+
fi
169+
170+
echo "ClamAV is ready!"
171+
172+
# Verify ClamAV is responsive
173+
echo "Testing ClamAV connection..."
174+
timeout 10 bash -c 'echo "PING" | nc localhost 3310' || {
175+
echo "ClamAV is not responding to PING"
176+
docker logs $(docker ps -q --filter "ancestor=clamav/clamav-debian:latest") 2>&1 | tail -50 || echo "No ClamAV container found"
177+
exit 1
178+
}
179+
134180
- name: Run Database Migrations
135181
run: poetry run prisma migrate dev --name updates
136182
env:
@@ -144,9 +190,9 @@ jobs:
144190
- name: Run pytest with coverage
145191
run: |
146192
if [[ "${{ runner.debug }}" == "1" ]]; then
147-
poetry run pytest -s -vv -o log_cli=true -o log_cli_level=DEBUG test
193+
poetry run pytest -s -vv -o log_cli=true -o log_cli_level=DEBUG
148194
else
149-
poetry run pytest -s -vv test
195+
poetry run pytest -s -vv
150196
fi
151197
if: success() || (failure() && steps.lint.outcome == 'failure')
152198
env:
@@ -159,6 +205,7 @@ jobs:
159205
REDIS_HOST: "localhost"
160206
REDIS_PORT: "6379"
161207
REDIS_PASSWORD: "testpassword"
208+
ENCRYPTION_KEY: "dvziYgz0KSK8FENhju0ZYi8-fRTfAdlz6YLhdB_jhNw=" # DO NOT USE IN PRODUCTION!!
162209

163210
env:
164211
CI: true

.github/workflows/platform-frontend-ci.yml

Lines changed: 104 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,45 @@ defaults:
1818
working-directory: autogpt_platform/frontend
1919

2020
jobs:
21+
setup:
22+
runs-on: ubuntu-latest
23+
outputs:
24+
cache-key: ${{ steps.cache-key.outputs.key }}
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Set up Node.js
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: "21"
34+
35+
- name: Enable corepack
36+
run: corepack enable
37+
38+
- name: Generate cache key
39+
id: cache-key
40+
run: echo "key=${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}" >> $GITHUB_OUTPUT
41+
42+
- name: Cache dependencies
43+
uses: actions/cache@v4
44+
with:
45+
path: ~/.pnpm-store
46+
key: ${{ steps.cache-key.outputs.key }}
47+
restore-keys: |
48+
${{ runner.os }}-pnpm-
49+
50+
- name: Install dependencies
51+
run: pnpm install --frozen-lockfile
52+
2153
lint:
2254
runs-on: ubuntu-latest
55+
needs: setup
2356

2457
steps:
25-
- uses: actions/checkout@v4
58+
- name: Checkout repository
59+
uses: actions/checkout@v4
2660

2761
- name: Set up Node.js
2862
uses: actions/setup-node@v4
@@ -32,6 +66,14 @@ jobs:
3266
- name: Enable corepack
3367
run: corepack enable
3468

69+
- name: Restore dependencies cache
70+
uses: actions/cache@v4
71+
with:
72+
path: ~/.pnpm-store
73+
key: ${{ needs.setup.outputs.cache-key }}
74+
restore-keys: |
75+
${{ runner.os }}-pnpm-
76+
3577
- name: Install dependencies
3678
run: pnpm install --frozen-lockfile
3779

@@ -40,9 +82,11 @@ jobs:
4082

4183
type-check:
4284
runs-on: ubuntu-latest
85+
needs: setup
4386

4487
steps:
45-
- uses: actions/checkout@v4
88+
- name: Checkout repository
89+
uses: actions/checkout@v4
4690

4791
- name: Set up Node.js
4892
uses: actions/setup-node@v4
@@ -52,14 +96,62 @@ jobs:
5296
- name: Enable corepack
5397
run: corepack enable
5498

99+
- name: Restore dependencies cache
100+
uses: actions/cache@v4
101+
with:
102+
path: ~/.pnpm-store
103+
key: ${{ needs.setup.outputs.cache-key }}
104+
restore-keys: |
105+
${{ runner.os }}-pnpm-
106+
55107
- name: Install dependencies
56108
run: pnpm install --frozen-lockfile
57109

58110
- name: Run tsc check
59111
run: pnpm type-check
60112

113+
chromatic:
114+
runs-on: ubuntu-latest
115+
needs: setup
116+
# Only run on dev branch pushes or PRs targeting dev
117+
if: github.ref == 'refs/heads/dev' || github.base_ref == 'dev'
118+
119+
steps:
120+
- name: Checkout repository
121+
uses: actions/checkout@v4
122+
with:
123+
fetch-depth: 0
124+
125+
- name: Set up Node.js
126+
uses: actions/setup-node@v4
127+
with:
128+
node-version: "21"
129+
130+
- name: Enable corepack
131+
run: corepack enable
132+
133+
- name: Restore dependencies cache
134+
uses: actions/cache@v4
135+
with:
136+
path: ~/.pnpm-store
137+
key: ${{ needs.setup.outputs.cache-key }}
138+
restore-keys: |
139+
${{ runner.os }}-pnpm-
140+
141+
- name: Install dependencies
142+
run: pnpm install --frozen-lockfile
143+
144+
- name: Run Chromatic
145+
uses: chromaui/action@latest
146+
with:
147+
projectToken: chpt_9e7c1a76478c9c8
148+
onlyChanged: true
149+
workingDir: autogpt_platform/frontend
150+
token: ${{ secrets.GITHUB_TOKEN }}
151+
61152
test:
62153
runs-on: ubuntu-latest
154+
needs: setup
63155
strategy:
64156
fail-fast: false
65157
matrix:
@@ -97,6 +189,14 @@ jobs:
97189
run: |
98190
docker compose -f ../docker-compose.yml up -d
99191
192+
- name: Restore dependencies cache
193+
uses: actions/cache@v4
194+
with:
195+
path: ~/.pnpm-store
196+
key: ${{ needs.setup.outputs.cache-key }}
197+
restore-keys: |
198+
${{ runner.os }}-pnpm-
199+
100200
- name: Install dependencies
101201
run: pnpm install --frozen-lockfile
102202

@@ -112,6 +212,8 @@ jobs:
112212

113213
- name: Run Playwright tests
114214
run: pnpm test:no-build --project=${{ matrix.browser }}
215+
env:
216+
BROWSER_TYPE: ${{ matrix.browser }}
115217

116218
- name: Print Final Docker Compose logs
117219
if: always()

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ package-lock.json
165165

166166
# Allow for locally private items
167167
# private
168-
pri*
168+
pri*
169169
# ignore
170170
ig*
171171
.github_access_token

autogpt_platform/CLAUDE.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ cd backend && poetry install
1919
# Run database migrations
2020
poetry run prisma migrate dev
2121

22-
# Start all services (database, redis, rabbitmq)
22+
# Start all services (database, redis, rabbitmq, clamav)
2323
docker compose up -d
2424

2525
# Run the backend server
@@ -32,6 +32,7 @@ poetry run test
3232
poetry run pytest path/to/test_file.py::test_function_name
3333

3434
# Lint and format
35+
# prefer format if you want to just "fix" it and only get the errors that can't be autofixed
3536
poetry run format # Black + isort
3637
poetry run lint # ruff
3738
```
@@ -77,6 +78,7 @@ npm run type-check
7778
- **Queue System**: RabbitMQ for async task processing
7879
- **Execution Engine**: Separate executor service processes agent workflows
7980
- **Authentication**: JWT-based with Supabase integration
81+
- **Security**: Cache protection middleware prevents sensitive data caching in browsers/proxies
8082

8183
### Frontend Architecture
8284
- **Framework**: Next.js App Router with React Server Components
@@ -90,6 +92,7 @@ npm run type-check
9092
2. **Blocks**: Reusable components in `/backend/blocks/` that perform specific tasks
9193
3. **Integrations**: OAuth and API connections stored per user
9294
4. **Store**: Marketplace for sharing agent templates
95+
5. **Virus Scanning**: ClamAV integration for file upload security
9396

9497
### Testing Approach
9598
- Backend uses pytest with snapshot testing for API responses
@@ -118,6 +121,7 @@ Key models (defined in `/backend/schema.prisma`):
118121
3. Define input/output schemas
119122
4. Implement `run` method
120123
5. Register in block registry
124+
6. Generate the block uuid using `uuid.uuid4()`
121125

122126
**Modifying the API:**
123127
1. Update route in `/backend/backend/server/routers/`
@@ -129,4 +133,15 @@ Key models (defined in `/backend/schema.prisma`):
129133
1. Components go in `/frontend/src/components/`
130134
2. Use existing UI components from `/frontend/src/components/ui/`
131135
3. Add Storybook stories for new components
132-
4. Test with Playwright if user-facing
136+
4. Test with Playwright if user-facing
137+
138+
### Security Implementation
139+
140+
**Cache Protection Middleware:**
141+
- Located in `/backend/backend/server/middleware/security.py`
142+
- Default behavior: Disables caching for ALL endpoints with `Cache-Control: no-store, no-cache, must-revalidate, private`
143+
- Uses an allow list approach - only explicitly permitted paths can be cached
144+
- Cacheable paths include: static assets (`/static/*`, `/_next/static/*`), health checks, public store pages, documentation
145+
- Prevents sensitive data (auth tokens, API keys, user data) from being cached by browsers/proxies
146+
- To allow caching for a new endpoint, add it to `CACHEABLE_PATHS` in the middleware
147+
- Applied to both main API server and external API applications

autogpt_platform/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ To run the AutoGPT Platform, follow these steps:
6262
pnpm i
6363
```
6464

65+
Generate the API client (this step is required before running the frontend):
66+
67+
```
68+
pnpm generate:api-client
69+
```
70+
6571
Then start the frontend application in development mode:
6672

6773
```
@@ -164,3 +170,27 @@ To persist data for PostgreSQL and Redis, you can modify the `docker-compose.yml
164170
3. Save the file and run `docker compose up -d` to apply the changes.
165171

166172
This configuration will create named volumes for PostgreSQL and Redis, ensuring that your data persists across container restarts.
173+
174+
### API Client Generation
175+
176+
The platform includes scripts for generating and managing the API client:
177+
178+
- `pnpm fetch:openapi`: Fetches the OpenAPI specification from the backend service (requires backend to be running on port 8006)
179+
- `pnpm generate:api-client`: Generates the TypeScript API client from the OpenAPI specification using Orval
180+
- `pnpm generate:api-all`: Runs both fetch and generate commands in sequence
181+
182+
#### Manual API Client Updates
183+
184+
If you need to update the API client after making changes to the backend API:
185+
186+
1. Ensure the backend services are running:
187+
```
188+
docker compose up -d
189+
```
190+
191+
2. Generate the updated API client:
192+
```
193+
pnpm generate:api-all
194+
```
195+
196+
This will fetch the latest OpenAPI specification and regenerate the TypeScript client code.

0 commit comments

Comments
 (0)