Skip to content

Commit ac26839

Browse files
authored
Merge branch 'langgenius:main' into main
2 parents c1b2cd9 + ad7fdd1 commit ac26839

1,418 files changed

Lines changed: 84427 additions & 11498 deletions

File tree

Some content is hidden

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

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"nodeGypDependencies": true,
1212
"version": "lts"
1313
},
14-
"ghcr.io/devcontainers-contrib/features/npm-package:1": {
14+
"ghcr.io/devcontainers-extra/features/npm-package:1": {
1515
"package": "typescript",
1616
"version": "latest"
1717
},

.devcontainer/post_create_command.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ cd web && pnpm install
66
pipx install uv
77

88
echo "alias start-api=\"cd $WORKSPACE_ROOT/api && uv run python -m flask run --host 0.0.0.0 --port=5001 --debug\"" >> ~/.bashrc
9-
echo "alias start-worker=\"cd $WORKSPACE_ROOT/api && uv run python -m celery -A app.celery worker -P gevent -c 1 --loglevel INFO -Q dataset,generation,mail,ops_trace,app_deletion,plugin,workflow_storage\"" >> ~/.bashrc
9+
echo "alias start-worker=\"cd $WORKSPACE_ROOT/api && uv run python -m celery -A app.celery worker -P threads -c 1 --loglevel INFO -Q dataset,priority_dataset,priority_pipeline,pipeline,mail,ops_trace,app_deletion,plugin,workflow_storage,conversation,workflow,schedule_poller,schedule_executor,triggered_workflow_dispatcher,trigger_refresh_executor\"" >> ~/.bashrc
1010
echo "alias start-web=\"cd $WORKSPACE_ROOT/web && pnpm dev\"" >> ~/.bashrc
1111
echo "alias start-web-prod=\"cd $WORKSPACE_ROOT/web && pnpm build && pnpm start\"" >> ~/.bashrc
1212
echo "alias start-containers=\"cd $WORKSPACE_ROOT/docker && docker-compose -f docker-compose.middleware.yaml -p dify --env-file middleware.env up -d\"" >> ~/.bashrc
1313
echo "alias stop-containers=\"cd $WORKSPACE_ROOT/docker && docker-compose -f docker-compose.middleware.yaml -p dify --env-file middleware.env down\"" >> ~/.bashrc
1414

1515
source /home/vscode/.bashrc
16-

.github/workflows/autofix.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: autofix.ci
22
on:
33
pull_request:
44
branches: ["main"]
5+
push:
6+
branches: ["main"]
57
permissions:
68
contents: read
79

.github/workflows/style.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ jobs:
103103
run: |
104104
pnpm run lint
105105
106+
- name: Web type check
107+
if: steps.changed-files.outputs.any_changed == 'true'
108+
working-directory: ./web
109+
run: pnpm run type-check
110+
106111
docker-compose-template:
107112
name: Docker Compose Template
108113
runs-on: ubuntu-latest

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ __pycache__/
66
# C extensions
77
*.so
88

9+
# *db files
10+
*.db
11+
912
# Distribution / packaging
1013
.Python
1114
build/
@@ -97,6 +100,7 @@ __pypackages__/
97100

98101
# Celery stuff
99102
celerybeat-schedule
103+
celerybeat-schedule.db
100104
celerybeat.pid
101105

102106
# SageMath parsed files
@@ -234,4 +238,7 @@ scripts/stress-test/reports/
234238

235239
# mcp
236240
.playwright-mcp/
237-
.serena/
241+
.serena/
242+
243+
# settings
244+
*.local.json

.vscode/launch.json.template

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
"module": "flask",
99
"env": {
1010
"FLASK_APP": "app.py",
11-
"FLASK_ENV": "development",
12-
"GEVENT_SUPPORT": "True"
11+
"FLASK_ENV": "development"
1312
},
1413
"args": [
1514
"run",
@@ -28,9 +27,7 @@
2827
"type": "debugpy",
2928
"request": "launch",
3029
"module": "celery",
31-
"env": {
32-
"GEVENT_SUPPORT": "True"
33-
},
30+
"env": {},
3431
"args": [
3532
"-A",
3633
"app.celery",
@@ -40,7 +37,7 @@
4037
"-c",
4138
"1",
4239
"-Q",
43-
"dataset,generation,mail,ops_trace",
40+
"dataset,mail,ops_trace,app_deletion,plugin,workflow_storage,conversation,priority_pipeline,pipeline",
4441
"--loglevel",
4542
"INFO"
4643
],

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Dify is an open-source platform for developing LLM applications. Its intuitive i
6363
> - CPU >= 2 Core
6464
> - RAM >= 4 GiB
6565
66-
</br>
66+
<br/>
6767

6868
The easiest way to start the Dify server is through [Docker Compose](docker/docker-compose.yaml). Before running Dify with the following commands, make sure that [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/) are installed on your machine:
6969

@@ -109,15 +109,15 @@ All of Dify's offerings come with corresponding APIs, so you could effortlessly
109109

110110
## Using Dify
111111

112-
- **Cloud </br>**
112+
- **Cloud <br/>**
113113
We host a [Dify Cloud](https://dify.ai) service for anyone to try with zero setup. It provides all the capabilities of the self-deployed version, and includes 200 free GPT-4 calls in the sandbox plan.
114114

115-
- **Self-hosting Dify Community Edition</br>**
115+
- **Self-hosting Dify Community Edition<br/>**
116116
Quickly get Dify running in your environment with this [starter guide](#quick-start).
117117
Use our [documentation](https://docs.dify.ai) for further references and more in-depth instructions.
118118

119-
- **Dify for enterprise / organizations</br>**
120-
We provide additional enterprise-centric features. [Log your questions for us through this chatbot](https://udify.app/chat/22L1zSxg6yW1cWQg) or [send us an email](mailto:business@dify.ai?subject=%5BGitHub%5DBusiness%20License%20Inquiry) to discuss enterprise needs. </br>
119+
- **Dify for enterprise / organizations<br/>**
120+
We provide additional enterprise-centric features. [Send us an email](mailto:business@dify.ai?subject=%5BGitHub%5DBusiness%20License%20Inquiry) to discuss your enterprise needs. <br/>
121121

122122
> For startups and small businesses using AWS, check out [Dify Premium on AWS Marketplace](https://aws.amazon.com/marketplace/pp/prodview-t22mebxzwjhu6) and deploy it to your own AWS VPC with one click. It's an affordable AMI offering with the option to create apps with custom logo and branding.
123123

api/.env.example

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ FILES_URL=http://localhost:5001
2727
# Example: INTERNAL_FILES_URL=http://api:5001
2828
INTERNAL_FILES_URL=http://127.0.0.1:5001
2929

30+
# TRIGGER URL
31+
TRIGGER_URL=http://localhost:5001
32+
3033
# The time in seconds after the signature is rejected
3134
FILES_ACCESS_TIMEOUT=300
3235

@@ -156,6 +159,9 @@ SUPABASE_URL=your-server-url
156159
# CORS configuration
157160
WEB_API_CORS_ALLOW_ORIGINS=http://localhost:3000,*
158161
CONSOLE_CORS_ALLOW_ORIGINS=http://localhost:3000,*
162+
# Set COOKIE_DOMAIN when the console frontend and API are on different subdomains.
163+
# Provide the registrable domain (e.g. example.com); leading dots are optional.
164+
COOKIE_DOMAIN=
159165

160166
# Vector database configuration
161167
# Supported values are `weaviate`, `qdrant`, `milvus`, `myscale`, `relyt`, `pgvector`, `pgvecto-rs`, `chroma`, `opensearch`, `oracle`, `tencent`, `elasticsearch`, `elasticsearch-ja`, `analyticdb`, `couchbase`, `vikingdb`, `oceanbase`, `opengauss`, `tablestore`,`vastbase`,`tidb`,`tidb_on_qdrant`,`baidu`,`lindorm`,`huawei_cloud`,`upstash`, `matrixone`.
@@ -368,6 +374,12 @@ UPLOAD_IMAGE_FILE_SIZE_LIMIT=10
368374
UPLOAD_VIDEO_FILE_SIZE_LIMIT=100
369375
UPLOAD_AUDIO_FILE_SIZE_LIMIT=50
370376

377+
# Comma-separated list of file extensions blocked from upload for security reasons.
378+
# Extensions should be lowercase without dots (e.g., exe,bat,sh,dll).
379+
# Empty by default to allow all file types.
380+
# Recommended: exe,bat,cmd,com,scr,vbs,ps1,msi,dll
381+
UPLOAD_FILE_EXTENSION_BLACKLIST=
382+
371383
# Model configuration
372384
MULTIMODAL_SEND_FORMAT=base64
373385
PROMPT_GENERATION_MAX_TOKENS=512
@@ -457,6 +469,9 @@ HTTP_REQUEST_NODE_MAX_BINARY_SIZE=10485760
457469
HTTP_REQUEST_NODE_MAX_TEXT_SIZE=1048576
458470
HTTP_REQUEST_NODE_SSL_VERIFY=True
459471

472+
# Webhook request configuration
473+
WEBHOOK_REQUEST_BODY_MAX_SIZE=10485760
474+
460475
# Respect X-* headers to redirect clients
461476
RESPECT_XFORWARD_HEADERS_ENABLED=false
462477

@@ -512,7 +527,7 @@ API_WORKFLOW_NODE_EXECUTION_REPOSITORY=repositories.sqlalchemy_api_workflow_node
512527
API_WORKFLOW_RUN_REPOSITORY=repositories.sqlalchemy_api_workflow_run_repository.DifyAPISQLAlchemyWorkflowRunRepository
513528
# Workflow log cleanup configuration
514529
# Enable automatic cleanup of workflow run logs to manage database size
515-
WORKFLOW_LOG_CLEANUP_ENABLED=true
530+
WORKFLOW_LOG_CLEANUP_ENABLED=false
516531
# Number of days to retain workflow run logs (default: 30 days)
517532
WORKFLOW_LOG_RETENTION_DAYS=30
518533
# Batch size for workflow log cleanup operations (default: 100)
@@ -534,6 +549,12 @@ ENABLE_CLEAN_MESSAGES=false
534549
ENABLE_MAIL_CLEAN_DOCUMENT_NOTIFY_TASK=false
535550
ENABLE_DATASETS_QUEUE_MONITOR=false
536551
ENABLE_CHECK_UPGRADABLE_PLUGIN_TASK=true
552+
ENABLE_WORKFLOW_SCHEDULE_POLLER_TASK=true
553+
# Interval time in minutes for polling scheduled workflows(default: 1 min)
554+
WORKFLOW_SCHEDULE_POLLER_INTERVAL=1
555+
WORKFLOW_SCHEDULE_POLLER_BATCH_SIZE=100
556+
# Maximum number of scheduled workflows to dispatch per tick (0 for unlimited)
557+
WORKFLOW_SCHEDULE_MAX_DISPATCH_PER_TICK=0
537558

538559
# Position configuration
539560
POSITION_TOOL_PINS=
@@ -605,3 +626,9 @@ SWAGGER_UI_PATH=/swagger-ui.html
605626
# Whether to encrypt dataset IDs when exporting DSL files (default: true)
606627
# Set to false to export dataset IDs as plain text for easier cross-environment import
607628
DSL_EXPORT_ENCRYPT_DATASET_ID=true
629+
630+
# Tenant isolated task queue configuration
631+
TENANT_ISOLATED_TASK_CONCURRENCY=1
632+
633+
# Maximum number of segments for dataset segments API (0 for unlimited)
634+
DATASET_MAX_SEGMENTS_PER_REQUEST=0

api/.vscode/launch.json.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"--loglevel",
5555
"DEBUG",
5656
"-Q",
57-
"dataset,generation,mail,ops_trace,app_deletion"
57+
"dataset,priority_pipeline,pipeline,mail,ops_trace,app_deletion,plugin,workflow_storage,conversation,workflow,schedule_poller,schedule_executor,triggered_workflow_dispatcher,trigger_refresh_executor"
5858
]
5959
}
6060
]

api/AGENTS.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Agent Skill Index
2+
3+
Start with the section that best matches your need. Each entry lists the problems it solves plus key files/concepts so you know what to expect before opening it.
4+
5+
______________________________________________________________________
6+
7+
## Platform Foundations
8+
9+
- **[Infrastructure Overview](agent_skills/infra.md)**\
10+
When to read this:
11+
12+
- You need to understand where a feature belongs in the architecture.
13+
- You’re wiring storage, Redis, vector stores, or OTEL.
14+
- You’re about to add CLI commands or async jobs.\
15+
What it covers: configuration stack (`configs/app_config.py`, remote settings), storage entry points (`extensions/ext_storage.py`, `core/file/file_manager.py`), Redis conventions (`extensions/ext_redis.py`), plugin runtime topology, vector-store factory (`core/rag/datasource/vdb/*`), observability hooks, SSRF proxy usage, and core CLI commands.
16+
17+
- **[Coding Style](agent_skills/coding_style.md)**\
18+
When to read this:
19+
20+
- You’re writing or reviewing backend code and need the authoritative checklist.
21+
- You’re unsure about Pydantic validators, SQLAlchemy session usage, or logging patterns.
22+
- You want the exact lint/type/test commands used in PRs.\
23+
Includes: Ruff & BasedPyright commands, no-annotation policy, session examples (`with Session(db.engine, ...)`), `@field_validator` usage, logging expectations, and the rule set for file size, helpers, and package management.
24+
25+
______________________________________________________________________
26+
27+
## Plugin & Extension Development
28+
29+
- **[Plugin Systems](agent_skills/plugin.md)**\
30+
When to read this:
31+
32+
- You’re building or debugging a marketplace plugin.
33+
- You need to know how manifests, providers, daemons, and migrations fit together.\
34+
What it covers: plugin manifests (`core/plugin/entities/plugin.py`), installation/upgrade flows (`services/plugin/plugin_service.py`, CLI commands), runtime adapters (`core/plugin/impl/*` for tool/model/datasource/trigger/endpoint/agent), daemon coordination (`core/plugin/entities/plugin_daemon.py`), and how provider registries surface capabilities to the rest of the platform.
35+
36+
- **[Plugin OAuth](agent_skills/plugin_oauth.md)**\
37+
When to read this:
38+
39+
- You must integrate OAuth for a plugin or datasource.
40+
- You’re handling credential encryption or refresh flows.\
41+
Topics: credential storage, encryption helpers (`core/helper/provider_encryption.py`), OAuth client bootstrap (`services/plugin/oauth_service.py`, `services/plugin/plugin_parameter_service.py`), and how console/API layers expose the flows.
42+
43+
______________________________________________________________________
44+
45+
## Workflow Entry & Execution
46+
47+
- **[Trigger Concepts](agent_skills/trigger.md)**\
48+
When to read this:
49+
- You’re debugging why a workflow didn’t start.
50+
- You’re adding a new trigger type or hook.
51+
- You need to trace async execution, draft debugging, or webhook/schedule pipelines.\
52+
Details: Start-node taxonomy, webhook & schedule internals (`core/workflow/nodes/trigger_*`, `services/trigger/*`), async orchestration (`services/async_workflow_service.py`, Celery queues), debug event bus, and storage/logging interactions.
53+
54+
______________________________________________________________________
55+
56+
## Additional Notes for Agents
57+
58+
- All skill docs assume you follow the coding style guide—run Ruff/BasedPyright/tests listed there before submitting changes.
59+
- When you cannot find an answer in these briefs, search the codebase using the paths referenced (e.g., `core/plugin/impl/tool.py`, `services/dataset_service.py`).
60+
- If you run into cross-cutting concerns (tenancy, configuration, storage), check the infrastructure guide first; it links to most supporting modules.
61+
- Keep multi-tenancy and configuration central: everything flows through `configs.dify_config` and `tenant_id`.
62+
- When touching plugins or triggers, consult both the system overview and the specialised doc to ensure you adjust lifecycle, storage, and observability consistently.

0 commit comments

Comments
 (0)