Compare commits
1541 Commits
codex/inte
...
test/real-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
070cd79c39 | ||
|
|
1d912fee41 | ||
|
|
e92ffbdf50 | ||
|
|
519ef8b8c2 | ||
|
|
0cd3824608 | ||
|
|
869c1dbf07 | ||
|
|
2738bad1fe | ||
|
|
a4cefbe669 | ||
|
|
1f5afb5a48 | ||
|
|
9d285e38eb | ||
|
|
9ce90a4075 | ||
|
|
a5eea69efc | ||
|
|
8260acf04b | ||
|
|
5ea0b59bdd | ||
|
|
0753e6480b | ||
|
|
1aeba1c6bc | ||
|
|
642bfe40eb | ||
|
|
10c5da16f3 | ||
|
|
3b093f881f | ||
|
|
a212b1b0b1 | ||
|
|
8023189566 | ||
|
|
d73c93d2cf | ||
|
|
63d2af7d27 | ||
|
|
81f627cfa1 | ||
|
|
e160419159 | ||
|
|
22cce965f3 | ||
|
|
ea9a3dbb4b | ||
|
|
fd99ce64c9 | ||
|
|
64f028564e | ||
|
|
4214abf28f | ||
|
|
f4027ad6ef | ||
|
|
9d01361c91 | ||
|
|
7d13952e24 | ||
|
|
54486a14c1 | ||
|
|
3be01cbb7a | ||
|
|
de09a17ba9 | ||
|
|
cf957564d8 | ||
|
|
5c0c9dfff0 | ||
|
|
e92d13220f | ||
|
|
70ef9cbd5d | ||
|
|
f0266537cb | ||
|
|
16bbfc50bd | ||
|
|
1cbb6dc385 | ||
|
|
09e372b237 | ||
|
|
c687d0dc6f | ||
|
|
8222397ea9 | ||
|
|
01f632d059 | ||
|
|
98c9a6a23a | ||
|
|
c12c01b8be | ||
|
|
7f4e357418 | ||
|
|
43af5082d3 | ||
|
|
f2755a79c7 | ||
|
|
e6e4cd9406 | ||
|
|
b7bf3f8a29 | ||
|
|
0f611811c2 | ||
|
|
efcf73b4da | ||
|
|
daadf78c02 | ||
|
|
baf6888007 | ||
|
|
4b89972f55 | ||
|
|
a2427050e1 | ||
|
|
f3074ced5b | ||
|
|
1dbf027277 | ||
|
|
9f0e3a4c17 | ||
|
|
a54589a672 | ||
|
|
ba28e3ad82 | ||
|
|
49a4a13846 | ||
|
|
934427ce16 | ||
|
|
f100adf0ea | ||
|
|
63094c91ba | ||
|
|
9f617f9d3f | ||
|
|
30eadcc9e5 | ||
|
|
bf62165e22 | ||
|
|
c797b8e99e | ||
|
|
fa4f49df00 | ||
|
|
6cca398f1c | ||
|
|
b4ae43986c | ||
|
|
c05a1c4e9a | ||
|
|
84cc8ef77a | ||
|
|
f2e13873b5 | ||
|
|
a0c004d877 | ||
|
|
14cd89ded5 | ||
|
|
8055521b49 | ||
|
|
aff59ef19a | ||
|
|
f93bec4ea5 | ||
|
|
087dd1d1ae | ||
|
|
1b86126ab1 | ||
|
|
ca27376211 | ||
|
|
c0fa5c3bcd | ||
|
|
46f32a7d22 | ||
|
|
5c6f46c952 | ||
|
|
e23c02340a | ||
|
|
b3188a299b | ||
|
|
570552c6fa | ||
|
|
636e0f0ace | ||
|
|
fecc3af674 | ||
|
|
0b9b0db408 | ||
|
|
a2b0b2a143 | ||
|
|
0fa381f3e7 | ||
|
|
d28b99ef6d | ||
|
|
38f1ecdd3b | ||
|
|
a0330a756f | ||
|
|
723aeb8b10 | ||
|
|
cba5e5503a | ||
|
|
4c640ff898 | ||
|
|
0bd950fd01 | ||
|
|
f004f6b67d | ||
|
|
50695cbf92 | ||
|
|
23e13a5e93 | ||
|
|
6423a83b78 | ||
|
|
4534c37aa7 | ||
|
|
431c185706 | ||
|
|
5260f0eee6 | ||
|
|
9fa987a550 | ||
|
|
1beefc2b50 | ||
|
|
1a918ea407 | ||
|
|
fac6179309 | ||
|
|
3c17c90bea | ||
|
|
5e3065ec7d | ||
|
|
71e5b353b1 | ||
|
|
9988dcc720 | ||
|
|
95373bc4fd | ||
|
|
6decc78fd5 | ||
|
|
bf41e733ba | ||
|
|
d7600ad9a7 | ||
|
|
52d586a7b4 | ||
|
|
4433d56a88 | ||
|
|
db317bf9a1 | ||
|
|
1642281176 | ||
|
|
8edc40e2f1 | ||
|
|
fe49d123c0 | ||
|
|
5ab572e0a7 | ||
|
|
2cb6431582 | ||
|
|
e48680f32b | ||
|
|
a743a9150f | ||
|
|
2f6b14525e | ||
|
|
df016cd309 | ||
|
|
d5c3fb9ecd | ||
|
|
0effc36f45 | ||
|
|
28697d9587 | ||
|
|
ea38e484b8 | ||
|
|
5bae0bb010 | ||
|
|
51fa4a25f9 | ||
|
|
b4cb02ccb9 | ||
|
|
77ec1b2027 | ||
|
|
68726eb097 | ||
|
|
b4dd2c4886 | ||
|
|
cf02d52d0d | ||
|
|
a4524c215f | ||
|
|
96abb8ea22 | ||
|
|
216151ffa7 | ||
|
|
7b0660b45b | ||
|
|
a4f949f173 | ||
|
|
0ed392fb62 | ||
|
|
3f0032f20b | ||
|
|
bfd5636bf0 | ||
|
|
f79ed842fa | ||
|
|
a67cd87eb0 | ||
|
|
c005932db9 | ||
|
|
af7f6abb95 | ||
|
|
2a1211baa5 | ||
|
|
3813c4d552 | ||
|
|
8fc8178ff7 | ||
|
|
fb0e55f5e7 | ||
|
|
fb9b97b26d | ||
|
|
80b34b5ab6 | ||
|
|
8db1712ccd | ||
|
|
6dc9de24d8 | ||
|
|
9c11e36cc5 | ||
|
|
1d02154638 | ||
|
|
b4bc25cab6 | ||
|
|
948fd166dd | ||
|
|
38f42f357e | ||
|
|
f24586323b | ||
|
|
bc0279572e | ||
|
|
20d9f15933 | ||
|
|
d42276a5c0 | ||
|
|
5c4489911c | ||
|
|
657624154d | ||
|
|
be8744264f | ||
|
|
0fec636da5 | ||
|
|
ce27ef9dc3 | ||
|
|
f7e5946d81 | ||
|
|
90f7fbd468 | ||
|
|
1545517fe8 | ||
|
|
1b9ddf9ae5 | ||
|
|
9bb9935f44 | ||
|
|
1ff3d3db68 | ||
|
|
18fea7ff0d | ||
|
|
357f697b16 | ||
|
|
e6f1d77ed5 | ||
|
|
4f8bf32b72 | ||
|
|
d8187b6e51 | ||
|
|
51940eac9c | ||
|
|
005f019a80 | ||
|
|
5f6bb5e6d3 | ||
|
|
7020120197 | ||
|
|
fe5dfd756f | ||
|
|
4808976d0c | ||
|
|
1b21b8220d | ||
|
|
bf55d1f6a6 | ||
|
|
855842410a | ||
|
|
33b2f09325 | ||
|
|
4713c3853b | ||
|
|
89e6b71b2d | ||
|
|
27cdf50c7d | ||
|
|
2b88685fbd | ||
|
|
52dcf83de6 | ||
|
|
a4a18e0652 | ||
|
|
6441436b0c | ||
|
|
0c5f2507d0 | ||
|
|
2515cf5b48 | ||
|
|
5283462286 | ||
|
|
f95edc85f5 | ||
|
|
f3107fee3f | ||
|
|
c42ee2fbac | ||
|
|
fc5053edf0 | ||
|
|
d8ec14027e | ||
|
|
96f444e3c6 | ||
|
|
9d4629c946 | ||
|
|
11f6a350f1 | ||
|
|
1366cadbb4 | ||
|
|
174a908786 | ||
|
|
2062d5e892 | ||
|
|
fb7b00365c | ||
|
|
1c535791cb | ||
|
|
090f7d923c | ||
|
|
3dce05e09e | ||
|
|
a154a4d674 | ||
|
|
934662cc48 | ||
|
|
b470071c4c | ||
|
|
d6c96ce1a5 | ||
|
|
60744157d8 | ||
|
|
43f64090e1 | ||
|
|
12f65f887a | ||
|
|
725611b2e9 | ||
|
|
e6fa1a1dd0 | ||
|
|
414cce2f70 | ||
|
|
7a7dc6011a | ||
|
|
3960b57102 | ||
|
|
698ecd3e62 | ||
|
|
f4602cc1fe | ||
|
|
2d813b2a87 | ||
|
|
d86435ee1e | ||
|
|
f6a1878ceb | ||
|
|
e5b5a1cc4c | ||
|
|
6824611958 | ||
|
|
672d2e2bb7 | ||
|
|
0755abe47f | ||
|
|
50589420b1 | ||
|
|
90e590e48d | ||
|
|
a7f890129e | ||
|
|
18e0cb102b | ||
|
|
7ee0f6af7e | ||
|
|
54c2928734 | ||
|
|
ef33df5e22 | ||
|
|
edf1a57b7b | ||
|
|
4c2f022bb2 | ||
|
|
bba6aad652 | ||
|
|
0e4ecfa890 | ||
|
|
a405b00a3f | ||
|
|
a1622aea28 | ||
|
|
102497957d | ||
|
|
74af4f2308 | ||
|
|
989ba1a78f | ||
|
|
635143cb88 | ||
|
|
24c6815889 | ||
|
|
ddb9f1ba8c | ||
|
|
b9f1ddaff4 | ||
|
|
97c0aaa005 | ||
|
|
98b7e92191 | ||
|
|
8778c6b985 | ||
|
|
b7d4cbf00f | ||
|
|
570317ecde | ||
|
|
bd08f6b0e3 | ||
|
|
8785f45e93 | ||
|
|
5df8a4c89c | ||
|
|
8300811b8c | ||
|
|
28ed561740 | ||
|
|
ff27ef544e | ||
|
|
7feebe3405 | ||
|
|
2f9fa672d0 | ||
|
|
70e973b9ab | ||
|
|
580a4165f2 | ||
|
|
7cc0898f58 | ||
|
|
e43ea0986e | ||
|
|
e9550e50d0 | ||
|
|
200da319f2 | ||
|
|
4144850837 | ||
|
|
d3d3248e3b | ||
|
|
f832cff60c | ||
|
|
53aa73e416 | ||
|
|
16100f839f | ||
|
|
67c0157d00 | ||
|
|
eb7235f17c | ||
|
|
5f66253fab | ||
|
|
699489b95f | ||
|
|
d1391c2ed5 | ||
|
|
518bd238f5 | ||
|
|
f6561d8cc0 | ||
|
|
486bcb0b08 | ||
|
|
236b90a90c | ||
|
|
6f636b2f49 | ||
|
|
11883543d1 | ||
|
|
8b7f903cff | ||
|
|
1a09485013 | ||
|
|
efac2084e1 | ||
|
|
7f4a5c2413 | ||
|
|
f0078b7935 | ||
|
|
14d8eecea6 | ||
|
|
bc94f7ead5 | ||
|
|
0a428a52e6 | ||
|
|
3bf5f2c47e | ||
|
|
584b62adc5 | ||
|
|
286ee05711 | ||
|
|
3113343c4d | ||
|
|
1d76929d5a | ||
|
|
401490c033 | ||
|
|
2fa4c57026 | ||
|
|
79e962d664 | ||
|
|
9daff34bb5 | ||
|
|
4af693ccef | ||
|
|
16d3302bff | ||
|
|
792d154608 | ||
|
|
d08f554ff4 | ||
|
|
e11a20ace4 | ||
|
|
1aafa481f3 | ||
|
|
9c210ea670 | ||
|
|
0c36f4a104 | ||
|
|
5f899e428a | ||
|
|
232f29c355 | ||
|
|
1bbb604d32 | ||
|
|
960bea8bae | ||
|
|
654a49d1bc | ||
|
|
75ba8d1dc4 | ||
|
|
d566192843 | ||
|
|
c592610ed3 | ||
|
|
2480e5a274 | ||
|
|
f547ef8726 | ||
|
|
639d410108 | ||
|
|
c9e59a5590 | ||
|
|
0f6a6227f5 | ||
|
|
a068c47ea9 | ||
|
|
bacf0c761f | ||
|
|
3a017e8ccc | ||
|
|
1fc040183c | ||
|
|
5b6e850b25 | ||
|
|
ce2eaab9f7 | ||
|
|
9badde4d65 | ||
|
|
dfc3bbe513 | ||
|
|
dced031c95 | ||
|
|
509f3407a5 | ||
|
|
963a28b497 | ||
|
|
db9b9b8993 | ||
|
|
f117048f41 | ||
|
|
1ea81f33ff | ||
|
|
54cc748a36 | ||
|
|
0cc53efe06 | ||
|
|
8253405c0b | ||
|
|
7ed4ab0b32 | ||
|
|
c3d5b5fa4d | ||
|
|
a78f716216 | ||
|
|
c1316dd30a | ||
|
|
27ea5e5790 | ||
|
|
cb044daf60 | ||
|
|
26d4b9ead8 | ||
|
|
67ab356116 | ||
|
|
4192299ad4 | ||
|
|
6d358eb680 | ||
|
|
f7dbed5d86 | ||
|
|
93c8b0fe18 | ||
|
|
ab666bc448 | ||
|
|
2da0db7df5 | ||
|
|
6f61401a91 | ||
|
|
404ba6a805 | ||
|
|
7a590a5b41 | ||
|
|
01b64254de | ||
|
|
fe09df3afb | ||
|
|
1ff8a5ff4f | ||
|
|
a50918dfe8 | ||
|
|
86cfb29b28 | ||
|
|
a7b1151a2c | ||
|
|
89ffe391be | ||
|
|
6fa4c9458a | ||
|
|
139ce49430 | ||
|
|
f25c4a3eaf | ||
|
|
befb18a86f | ||
|
|
bfcd0fdb39 | ||
|
|
206cf8fb94 | ||
|
|
a6b41ac6d1 | ||
|
|
151680eef9 | ||
|
|
d6491af103 | ||
|
|
11be5332bb | ||
|
|
a625c62a1d | ||
|
|
fb2dba0cf7 | ||
|
|
e811c23d37 | ||
|
|
4ee8095161 | ||
|
|
8fb2741963 | ||
|
|
905afb5be1 | ||
|
|
f7b594bf79 | ||
|
|
863ce1d70d | ||
|
|
9089ed40b9 | ||
|
|
ad7849a82b | ||
|
|
9a0961a4a9 | ||
|
|
1dfa8733a5 | ||
|
|
05df951373 | ||
|
|
bbaaaf980f | ||
|
|
af4f19840c | ||
|
|
1fa3245e83 | ||
|
|
6ba3d29f07 | ||
|
|
bf100beb97 | ||
|
|
22aff66cc0 | ||
|
|
11038c5936 | ||
|
|
99df0ca07f | ||
|
|
f9129bc500 | ||
|
|
2a66bf6f09 | ||
|
|
ee0efe0bdb | ||
|
|
679785b67e | ||
|
|
57c140144a | ||
|
|
d2c2e39ba7 | ||
|
|
3e787d11cc | ||
|
|
e78ce4db64 | ||
|
|
efd1fb0967 | ||
|
|
08a9d40096 | ||
|
|
126dee3da6 | ||
|
|
bfa243aecf | ||
|
|
38be7489ec | ||
|
|
e2bdeec273 | ||
|
|
de8433277f | ||
|
|
dace5ba264 | ||
|
|
bf189daea9 | ||
|
|
e6f0c8908c | ||
|
|
7f018fce7b | ||
|
|
6f61b91b6b | ||
|
|
57b9d73efe | ||
|
|
3a0acfedbb | ||
|
|
d96867fa58 | ||
|
|
bc38ce59f7 | ||
|
|
039bf03a31 | ||
|
|
90f0494c81 | ||
|
|
d02666d632 | ||
|
|
8e5b097011 | ||
|
|
2a3cf7edf5 | ||
|
|
ecadd45886 | ||
|
|
90df30cce9 | ||
|
|
2590d90769 | ||
|
|
b2a5b3beba | ||
|
|
6bb5e525d3 | ||
|
|
8dd33b88d8 | ||
|
|
dec1658200 | ||
|
|
b53e5f23c6 | ||
|
|
e95698d2cd | ||
|
|
78d338fe11 | ||
|
|
77cdee1f5b | ||
|
|
6f9cb382c4 | ||
|
|
f16702de80 | ||
|
|
3a88bc70a3 | ||
|
|
37bece696c | ||
|
|
b8a5c112a0 | ||
|
|
969a831b5b | ||
|
|
61dc68c3a7 | ||
|
|
4da38ea322 | ||
|
|
77d701ae81 | ||
|
|
6523584762 | ||
|
|
214aacd780 | ||
|
|
d913f3dd0e | ||
|
|
62e1c53c84 | ||
|
|
9bd86bf474 | ||
|
|
af36832bbf | ||
|
|
fad2a6c96f | ||
|
|
a24135ae83 | ||
|
|
ad9b85932b | ||
|
|
9df3e45719 | ||
|
|
9e13e339b8 | ||
|
|
697a244280 | ||
|
|
3a9636faad | ||
|
|
ceacf275b1 | ||
|
|
ce5dc6f314 | ||
|
|
b520bef0b1 | ||
|
|
d7630db953 | ||
|
|
fae098c6c0 | ||
|
|
5568aa0ea5 | ||
|
|
f12a876730 | ||
|
|
fbe69a114c | ||
|
|
d39d9ddb74 | ||
|
|
dbeebfc15d | ||
|
|
f495581a05 | ||
|
|
db6a4f5cd3 | ||
|
|
bc0636c4db | ||
|
|
e1ebd90bbe | ||
|
|
c4dbc4c830 | ||
|
|
b43889821d | ||
|
|
a81f6fed67 | ||
|
|
5fa40f1a5f | ||
|
|
13c12c1b38 | ||
|
|
a60167b390 | ||
|
|
41bc173636 | ||
|
|
3d436a7e31 | ||
|
|
104f3b239b | ||
|
|
3b8fc9c9b6 | ||
|
|
21d5e4e020 | ||
|
|
b85102c8e8 | ||
|
|
48189fedb4 | ||
|
|
d2fc434dc9 | ||
|
|
331e618961 | ||
|
|
26831445d0 | ||
|
|
d43594822b | ||
|
|
228541c15d | ||
|
|
6d88df5d7c | ||
|
|
6024141c26 | ||
|
|
7069c7127b | ||
|
|
bfa4a8b5e4 | ||
|
|
a504dfee27 | ||
|
|
1762181e58 | ||
|
|
9a5bd65e33 | ||
|
|
f418261c50 | ||
|
|
c4d4a42b4c | ||
|
|
ad9a5be560 | ||
|
|
40f859450a | ||
|
|
223039128f | ||
|
|
35e4e4f6bd | ||
|
|
d21518f8fe | ||
|
|
3edbba21b4 | ||
|
|
bfd7ac015f | ||
|
|
99ba5a57de | ||
|
|
ee151ee952 | ||
|
|
f384f9e7cf | ||
|
|
e18c171f74 | ||
|
|
b107d5abd4 | ||
|
|
bba566540d | ||
|
|
3d7f6f4496 | ||
|
|
5e76fc45b7 | ||
|
|
7dad80b1f9 | ||
|
|
93895fa7fb | ||
|
|
5e9017dbb8 | ||
|
|
81aa065608 | ||
|
|
81a65bd750 | ||
|
|
cddfe06a86 | ||
|
|
0825e6ca51 | ||
|
|
153cc72f17 | ||
|
|
28e2682986 | ||
|
|
64deb9c421 | ||
|
|
a14ebae6a4 | ||
|
|
d528dea83e | ||
|
|
8006e8e13d | ||
|
|
1203aa72c1 | ||
|
|
ff18b6de09 | ||
|
|
66bf75d1d8 | ||
|
|
f66773b63c | ||
|
|
4afc3cbd4f | ||
|
|
8b3c4db9ac | ||
|
|
f7ed1c0176 | ||
|
|
47a28bf262 | ||
|
|
fea6b6e999 | ||
|
|
e58e5b0879 | ||
|
|
a9227cf6f9 | ||
|
|
bffaccbc95 | ||
|
|
b721e438ba | ||
|
|
e6b13eaab9 | ||
|
|
9e7856f22b | ||
|
|
9c6c48b50b | ||
|
|
8b9f3016e6 | ||
|
|
9e4f0fa23a | ||
|
|
38f9d85d5a | ||
|
|
6a0039812d | ||
|
|
a4d74f7c82 | ||
|
|
07dc8ebdbb | ||
|
|
cb4d8ab5ea | ||
|
|
6afe07f944 | ||
|
|
a5bc77eaa7 | ||
|
|
6b88a6e0c4 | ||
|
|
fe3600f149 | ||
|
|
b83f02be9a | ||
|
|
04dd4d11ec | ||
|
|
318964e4dc | ||
|
|
51dd877de9 | ||
|
|
5389f70719 | ||
|
|
43ac0fce5c | ||
|
|
79effdd498 | ||
|
|
7f7afc576c | ||
|
|
085a79c748 | ||
|
|
e7981a6f19 | ||
|
|
bb02d3efcc | ||
|
|
92d64db112 | ||
|
|
c6c891430c | ||
|
|
b769a3469b | ||
|
|
aa6dceeece | ||
|
|
4cc2f632b8 | ||
|
|
5b58f51460 | ||
|
|
0cdb9e82c0 | ||
|
|
122f95b976 | ||
|
|
2de83835cd | ||
|
|
10658e428b | ||
|
|
6c252e9059 | ||
|
|
bad3a86816 | ||
|
|
98d9298828 | ||
|
|
96c8cc4383 | ||
|
|
8e022cc3c1 | ||
|
|
cd61738f33 | ||
|
|
a3b2786b32 | ||
|
|
a1bb317892 | ||
|
|
f0d69e7b39 | ||
|
|
c96bbe2e08 | ||
|
|
d441dd543e | ||
|
|
a425a127f5 | ||
|
|
66f1e6568e | ||
|
|
8387590ace | ||
|
|
2c206d2792 | ||
|
|
b3c978caa6 | ||
|
|
1a415d1e02 | ||
|
|
445b194938 | ||
|
|
44dac4a90d | ||
|
|
798fd5e4c0 | ||
|
|
c3f603c4dc | ||
|
|
1dcfe38171 | ||
|
|
31dfa21f36 | ||
|
|
3ecceb744b | ||
|
|
a43583a4a0 | ||
|
|
c529c3b2f1 | ||
|
|
e7cfe142bc | ||
|
|
4e0d7f7f9b | ||
|
|
d201dc1f09 | ||
|
|
f1da874b53 | ||
|
|
63bd623a63 | ||
|
|
3e44b51d7a | ||
|
|
f1d88f79f4 | ||
|
|
5f02726207 | ||
|
|
d4d2a4a988 | ||
|
|
90aa225cf0 | ||
|
|
dfe27fc75b | ||
|
|
8bdf01be3b | ||
|
|
7f59b65b6a | ||
|
|
608b1d10e0 | ||
|
|
5feddcb96a | ||
|
|
bce802c61f | ||
|
|
9e6c0c20d2 | ||
|
|
e7eb030109 | ||
|
|
40955e72a9 | ||
|
|
8c208ad206 | ||
|
|
4724779fe2 | ||
|
|
f70cea50c9 | ||
|
|
0468eee02f | ||
|
|
06f58809f2 | ||
|
|
647fec55d9 | ||
|
|
a1a1a42c42 | ||
|
|
87b4de1cda | ||
|
|
8c5dd51446 | ||
|
|
1007cf8294 | ||
|
|
adedbf1f12 | ||
|
|
57a6ccbd3b | ||
|
|
ebb875e0a5 | ||
|
|
677f2cf43f | ||
|
|
f71047f31a | ||
|
|
a062155841 | ||
|
|
a7cc6913af | ||
|
|
8e8a3c5414 | ||
|
|
f89c3e6ec7 | ||
|
|
e8c3419d1f | ||
|
|
4f29213cdc | ||
|
|
0f232ac4e7 | ||
|
|
4223b8eb0f | ||
|
|
62adebcf4e | ||
|
|
b577502a9b | ||
|
|
603176c17d | ||
|
|
6e91ee2694 | ||
|
|
cb1a8963e3 | ||
|
|
112e33a665 | ||
|
|
3f76dbe67a | ||
|
|
cd031ab423 | ||
|
|
dc9dd9c559 | ||
|
|
e65f45f17a | ||
|
|
8a69aa2884 | ||
|
|
f1c2917038 | ||
|
|
0669e4e033 | ||
|
|
0b8435da71 | ||
|
|
bb1797722f | ||
|
|
455951056a | ||
|
|
0c443b7666 | ||
|
|
cc44574543 | ||
|
|
75f203cdb9 | ||
|
|
da6a1b01d1 | ||
|
|
bb2945a1a3 | ||
|
|
bec2c6787a | ||
|
|
89df7a670a | ||
|
|
d60873dd76 | ||
|
|
fc062bfc6d | ||
|
|
e34b2f9045 | ||
|
|
dfe5d8af31 | ||
|
|
09ddcbe01e | ||
|
|
398addf0c1 | ||
|
|
1c4bcff490 | ||
|
|
bcda6b4570 | ||
|
|
e4eb3d0d92 | ||
|
|
e75b5f6bc9 | ||
|
|
0955b8b810 | ||
|
|
c9e0118ae9 | ||
|
|
2f00e647ef | ||
|
|
f3e5f41a3c | ||
|
|
80428a693a | ||
|
|
f3154e347e | ||
|
|
2873abd647 | ||
|
|
93d6ff3889 | ||
|
|
67f7a5517a | ||
|
|
2cdfe24c18 | ||
|
|
12d23062d4 | ||
|
|
a233b2f53a | ||
|
|
9e0763e189 | ||
|
|
970bbeca8d | ||
|
|
8acdb1538b | ||
|
|
a67f62e9aa | ||
|
|
efe506a0f5 | ||
|
|
d978fe710f | ||
|
|
7ba2cfb30b | ||
|
|
146b193ef7 | ||
|
|
c157e59d58 | ||
|
|
1006519012 | ||
|
|
e26dcf55a9 | ||
|
|
d43a23d8f5 | ||
|
|
22189f69f6 | ||
|
|
749d1f8d04 | ||
|
|
216180c7fd | ||
|
|
eeff2c01b1 | ||
|
|
4f463b1c46 | ||
|
|
8980506597 | ||
|
|
0df092d3c7 | ||
|
|
d138effca8 | ||
|
|
a57e04aa49 | ||
|
|
93287f22a8 | ||
|
|
8fc11b2927 | ||
|
|
a9cb17eb6c | ||
|
|
715bc7cd95 | ||
|
|
75f867da85 | ||
|
|
d5be01b253 | ||
|
|
b93101459d | ||
|
|
c17a96f02f | ||
|
|
60656a60cf | ||
|
|
eba589db89 | ||
|
|
fc0136647f | ||
|
|
c7423ffb2d | ||
|
|
5c0d3c4393 | ||
|
|
3be0cabf0a | ||
|
|
40f0b8a2a0 | ||
|
|
5e51fe2640 | ||
|
|
2df92204e9 | ||
|
|
5f978fec37 | ||
|
|
11a9627cbb | ||
|
|
62a286332a | ||
|
|
d91672c6d3 | ||
|
|
56a31bab8d | ||
|
|
a1a98e1087 | ||
|
|
80f6f72e8c | ||
|
|
86134ea99e | ||
|
|
60e983c493 | ||
|
|
cf34e3ee1a | ||
|
|
3e961dbb77 | ||
|
|
789cada297 | ||
|
|
1f6dadd22c | ||
|
|
e7d34f05ba | ||
|
|
4cb70b7421 | ||
|
|
4c124174c9 | ||
|
|
762dc5e8a6 | ||
|
|
4b0e260ac5 | ||
|
|
dde1d500b5 | ||
|
|
3c55dcc3d1 | ||
|
|
fde602dadf | ||
|
|
d69b19b567 | ||
|
|
00e5786067 | ||
|
|
ad90cb9111 | ||
|
|
a2acf62bf1 | ||
|
|
08c7a2c5f3 | ||
|
|
1b4ae3bcd2 | ||
|
|
2972468bc1 | ||
|
|
d93e5aa444 | ||
|
|
e6c9846726 | ||
|
|
6f37f0661d | ||
|
|
dcb7b36ad4 | ||
|
|
067a60e0ac | ||
|
|
b15fb30ff5 | ||
|
|
bb7114c2e8 | ||
|
|
7128456d57 | ||
|
|
751023c107 | ||
|
|
16f5e8738b | ||
|
|
173e92ea24 | ||
|
|
b5ee943a63 | ||
|
|
7919df7ef5 | ||
|
|
f8930aba34 | ||
|
|
cb6c04637b | ||
|
|
949f6c4ad4 | ||
|
|
7d7390ddaf | ||
|
|
b816754c06 | ||
|
|
09f301d969 | ||
|
|
95aeb0c362 | ||
|
|
336b134a40 | ||
|
|
e0673077a7 | ||
|
|
acf18aad13 | ||
|
|
1942925eb1 | ||
|
|
f5c14295b4 | ||
|
|
5355edefe3 | ||
|
|
b3b92f11af | ||
|
|
621ab7d19b | ||
|
|
0d8ad27b14 | ||
|
|
9e68c45058 | ||
|
|
6208b33e08 | ||
|
|
cea89f784f | ||
|
|
8504aaa0ef | ||
|
|
81abb7322d | ||
|
|
5b13b7a44d | ||
|
|
2619d172dc | ||
|
|
d9ff45022b | ||
|
|
550196e3b8 | ||
|
|
8e2058a962 | ||
|
|
df0460f876 | ||
|
|
65b4091402 | ||
|
|
e6a38fd793 | ||
|
|
8c98e3fad5 | ||
|
|
24f9f07752 | ||
|
|
4beffa97e0 | ||
|
|
aee0062cb2 | ||
|
|
863930836b | ||
|
|
a702b3bb2b | ||
|
|
692010f0fc | ||
|
|
363753a0c5 | ||
|
|
e982a3de33 | ||
|
|
137eb19de9 | ||
|
|
612a929907 | ||
|
|
29acaabc6a | ||
|
|
642ad2fffe | ||
|
|
8f7cca3ae2 | ||
|
|
b015aa416f | ||
|
|
ba1d5ba172 | ||
|
|
688107c3e5 | ||
|
|
d8c3f7c5ee | ||
|
|
69484a07e1 | ||
|
|
5f4b1f867d | ||
|
|
fc7193cf04 | ||
|
|
59021616d4 | ||
|
|
ab0e92b893 | ||
|
|
b0b495d243 | ||
|
|
6536ffc422 | ||
|
|
b7570ce4b7 | ||
|
|
907bc2558b | ||
|
|
95a6a14ed5 | ||
|
|
be7d11ca1d | ||
|
|
8129555642 | ||
|
|
f28d993607 | ||
|
|
0fc01fee3f | ||
|
|
bc716020c7 | ||
|
|
3cd1fc098c | ||
|
|
7664ad7149 | ||
|
|
b1eafb0d82 | ||
|
|
a1a10f17e3 | ||
|
|
6ae40b1f15 | ||
|
|
e577c007a0 | ||
|
|
02855848ea | ||
|
|
98090d60b3 | ||
|
|
59ee8878f9 | ||
|
|
82d86dcf98 | ||
|
|
183741b5f7 | ||
|
|
de3f3714ae | ||
|
|
415e999cef | ||
|
|
c25b439d8b | ||
|
|
324ee5f036 | ||
|
|
8707d0c82f | ||
|
|
4d9bda7422 | ||
|
|
88c64a8db9 | ||
|
|
a5445f2424 | ||
|
|
334a3043bc | ||
|
|
93dae7d8a0 | ||
|
|
ea98d38c3d | ||
|
|
18ac946e2b | ||
|
|
baf629dd36 | ||
|
|
a3dbf9293a | ||
|
|
3f982e3dc8 | ||
|
|
6bc7f01261 | ||
|
|
c4ea406586 | ||
|
|
7978352262 | ||
|
|
980a9d4ed4 | ||
|
|
d337c59916 | ||
|
|
c45e5386fb | ||
|
|
d6e4f48526 | ||
|
|
27c2f058fe | ||
|
|
8e064ffe98 | ||
|
|
fe39211aac | ||
|
|
770b83d9cc | ||
|
|
566b8857dd | ||
|
|
3ed28dce33 | ||
|
|
fdca3e2a1a | ||
|
|
6411d6235c | ||
|
|
1977355dd1 | ||
|
|
520e5e2beb | ||
|
|
5cbc42cd38 | ||
|
|
765e6338d2 | ||
|
|
62221bf8b8 | ||
|
|
8f2ff3a8fb | ||
|
|
f92f7e92c3 | ||
|
|
72458d5750 | ||
|
|
ce801f4445 | ||
|
|
57144b0094 | ||
|
|
b71dcb8253 | ||
|
|
762019a160 | ||
|
|
39f06b6f05 | ||
|
|
d0a86cfd4e | ||
|
|
336dd0b8c0 | ||
|
|
6da1b473e6 | ||
|
|
f021ee4dc0 | ||
|
|
280f81757d | ||
|
|
1952cff091 | ||
|
|
f8f71fdc68 | ||
|
|
9398482b53 | ||
|
|
5db79a77e4 | ||
|
|
02222e8fce | ||
|
|
5a5b9c6fec | ||
|
|
d25e2b51fc | ||
|
|
c6ca395042 | ||
|
|
7167d7d662 | ||
|
|
9e07c2dac6 | ||
|
|
6a00c23e49 | ||
|
|
750810ea81 | ||
|
|
b70ad7d424 | ||
|
|
ad86351cc1 | ||
|
|
8b8031710b | ||
|
|
94dff4dddc | ||
|
|
17ae89ff22 | ||
|
|
fce29e6f6a | ||
|
|
6130f081e0 | ||
|
|
8894b09c3b | ||
|
|
bf64390d7c | ||
|
|
884ece570e | ||
|
|
9d396524b9 | ||
|
|
8b3c2ee274 | ||
|
|
02f9b3ca7c | ||
|
|
09054169c4 | ||
|
|
0f3cde8120 | ||
|
|
2bdcbe96c5 | ||
|
|
3824323fe7 | ||
|
|
1264d29a4f | ||
|
|
f8dd276e2c | ||
|
|
37988de678 | ||
|
|
92110e1982 | ||
|
|
d8e7a97b25 | ||
|
|
e6fc0a8ba8 | ||
|
|
28e9a52ea5 | ||
|
|
efd90de70a | ||
|
|
aa208d2dd7 | ||
|
|
11bb82c731 | ||
|
|
78c85ae7c1 | ||
|
|
4c414988ee | ||
|
|
3bc4ac44e5 | ||
|
|
94fdda18e2 | ||
|
|
0b11d34d4b | ||
|
|
ff5d431efd | ||
|
|
97b5d8092c | ||
|
|
f7d6cd1afe | ||
|
|
1971450ad8 | ||
|
|
c8606db16b | ||
|
|
654324c0d9 | ||
|
|
650f8880ea | ||
|
|
f7e71ca9e1 | ||
|
|
290acf1b73 | ||
|
|
458c96d5ba | ||
|
|
2a554ab2d1 | ||
|
|
3ce262de05 | ||
|
|
3ea5f38e92 | ||
|
|
8c25190713 | ||
|
|
9c16c86597 | ||
|
|
d84088ef74 | ||
|
|
a38ddd9d02 | ||
|
|
d94204ec33 | ||
|
|
1db542c706 | ||
|
|
15021ad350 | ||
|
|
59383e88c2 | ||
|
|
05b00574aa | ||
|
|
5aac67f570 | ||
|
|
1be72af661 | ||
|
|
1ccac4792c | ||
|
|
d67a8323c5 | ||
|
|
ef20a16a2f | ||
|
|
1efc71c624 | ||
|
|
54298abf2d | ||
|
|
735d814dc0 | ||
|
|
3e12f0b9fb | ||
|
|
85b4626ac6 | ||
|
|
8266d741e8 | ||
|
|
3765a41b8c | ||
|
|
6a1b23935f | ||
|
|
bf54dd7814 | ||
|
|
1aa7ee29a1 | ||
|
|
a9319c86ee | ||
|
|
5a6191b96b | ||
|
|
ce31cdc585 | ||
|
|
32981687dd | ||
|
|
58d71bf9c9 | ||
|
|
82520c144f | ||
|
|
0d05eae517 | ||
|
|
c8e29d9a7d | ||
|
|
638dfd77a4 | ||
|
|
0047522b0d | ||
|
|
ac23430aca | ||
|
|
06482af260 | ||
|
|
30e6069851 | ||
|
|
021d5ceae7 | ||
|
|
73dd8739ef | ||
|
|
f5aaa50a30 | ||
|
|
8c9f248520 | ||
|
|
6e0e32848e | ||
|
|
6ba29b3f0c | ||
|
|
119e6af2a9 | ||
|
|
c563528a2d | ||
|
|
c4ace15afd | ||
|
|
d5a8ace1c4 | ||
|
|
86f8b847e9 | ||
|
|
1c6f0a0388 | ||
|
|
c937fcb21a | ||
|
|
0a1ce09dfb | ||
|
|
b9ac4d3cb1 | ||
|
|
e4cd2c72ad | ||
|
|
dfe396fb64 | ||
|
|
6b5952425d | ||
|
|
1299d99b2d | ||
|
|
36dfc5abd3 | ||
|
|
c7520d7c71 | ||
|
|
798a238e63 | ||
|
|
db5121828e | ||
|
|
ed184a6632 | ||
|
|
92016aa139 | ||
|
|
09a855dcef | ||
|
|
a6fe278662 | ||
|
|
960018253b | ||
|
|
8abff1b0b1 | ||
|
|
eb7a1829fe | ||
|
|
9ce92d8605 | ||
|
|
ddcdbb2d14 | ||
|
|
18d3990ae6 | ||
|
|
03e4bc50a2 | ||
|
|
370efc493c | ||
|
|
cf236aed8a | ||
|
|
48315be2b1 | ||
|
|
a9035a3264 | ||
|
|
39ce9f68fc | ||
|
|
ed9d3801ba | ||
|
|
f3bb73b671 | ||
|
|
bc845ea748 | ||
|
|
1afac21690 | ||
|
|
dd2e691ea8 | ||
|
|
f360a7bf94 | ||
|
|
caf7e90ca5 | ||
|
|
1e501cd75b | ||
|
|
45cb385d77 | ||
|
|
679514d40a | ||
|
|
9643dcacce | ||
|
|
fcb380044c | ||
|
|
d4ed92cb0a | ||
|
|
12f259ecae | ||
|
|
d9ca69d34f | ||
|
|
ebb0f12cd0 | ||
|
|
667d66c4dc | ||
|
|
ef92cb7c65 | ||
|
|
c9ea15a968 | ||
|
|
b56d30b366 | ||
|
|
8d6128957f | ||
|
|
e25ca611d8 | ||
|
|
44aec257bf | ||
|
|
2be3c3d69e | ||
|
|
09b199b280 | ||
|
|
b9764c4779 | ||
|
|
ff3cf5681f | ||
|
|
cfae2515fd | ||
|
|
b5982927de | ||
|
|
28a4859218 | ||
|
|
4f8a4c20fd | ||
|
|
21d540f760 | ||
|
|
fef28097cc | ||
|
|
3de20e0ba8 | ||
|
|
703f6d1780 | ||
|
|
2e1620c1ac | ||
|
|
4847447635 | ||
|
|
7ce751ffe8 | ||
|
|
7cb9aa2d3b | ||
|
|
3ab8476d2d | ||
|
|
643e2d66bf | ||
|
|
693e1b0fc5 | ||
|
|
70a513fc62 | ||
|
|
bec4ef6ac7 | ||
|
|
0024a845f7 | ||
|
|
0ab88ef36a | ||
|
|
7b3d97cb42 | ||
|
|
429edf4d82 | ||
|
|
5a9b6cb239 | ||
|
|
bda6bf3fee | ||
|
|
24287bcb0c | ||
|
|
3f7e6cdcb4 | ||
|
|
ea6c15b68e | ||
|
|
77998e41e4 | ||
|
|
aed1672366 | ||
|
|
11c922b5d4 | ||
|
|
ccd0f4b15d | ||
|
|
ab34f9ae09 | ||
|
|
9385e583ff | ||
|
|
5018f8aa8a | ||
|
|
ed45016475 | ||
|
|
9d6c846a49 | ||
|
|
8bdf702f73 | ||
|
|
c62947f1f1 | ||
|
|
24f5e2ac69 | ||
|
|
e18310e52e | ||
|
|
07119e3f00 | ||
|
|
a9b8c84e9b | ||
|
|
35a4533889 | ||
|
|
3a8fbcbd02 | ||
|
|
23150c2319 | ||
|
|
d6147456e3 | ||
|
|
7d5c68c2e1 | ||
|
|
385e8662bb | ||
|
|
6cb96adfbe | ||
|
|
373f33fd3b | ||
|
|
faca558bf5 | ||
|
|
b38d907ede | ||
|
|
0c3d08f355 | ||
|
|
a52adef203 | ||
|
|
3b05b5e553 | ||
|
|
92978f6d9f | ||
|
|
6fe87aaca5 | ||
|
|
37a927bf63 | ||
|
|
44e89d8844 | ||
|
|
7b1339a156 | ||
|
|
2ff3f7b533 | ||
|
|
34fdac2113 | ||
|
|
7d635d9f7e | ||
|
|
0ce41bfea1 | ||
|
|
92b93c9d37 | ||
|
|
4692741aa0 | ||
|
|
4ca0a10088 | ||
|
|
6ce0976265 | ||
|
|
5827ce2adf | ||
|
|
1d79b87307 | ||
|
|
9d8dacd0c8 | ||
|
|
720e1fab9b | ||
|
|
ca6f4e11f9 | ||
|
|
a5e284e6b1 | ||
|
|
3d08b2f89a | ||
|
|
43e59d3bc5 | ||
|
|
edc805c453 | ||
|
|
0ca99312c1 | ||
|
|
785ca4b915 | ||
|
|
c7b5a455f5 | ||
|
|
0c698744ab | ||
|
|
e425e18fca | ||
|
|
f4e50f3c8a | ||
|
|
aba3f9c1d6 | ||
|
|
979c8cc34b | ||
|
|
502418f707 | ||
|
|
ccfb47d2c5 | ||
|
|
1bb9183af9 | ||
|
|
de7e43a7ef | ||
|
|
b09691e5d2 | ||
|
|
6f70ca8d26 | ||
|
|
a7a30b20af | ||
|
|
cbd78c0073 | ||
|
|
97a3039a2d | ||
|
|
005edb7d47 | ||
|
|
b034368b3b | ||
|
|
43b6d8e32e | ||
|
|
248df5dd25 | ||
|
|
f97fc01c2f | ||
|
|
a6ace29e1a | ||
|
|
013b328555 | ||
|
|
d7b1531431 | ||
|
|
63acefa6d0 | ||
|
|
e2f6418fe4 | ||
|
|
2daa69c92e | ||
|
|
72b6a4e6ed | ||
|
|
b16a24f084 | ||
|
|
6e890524db | ||
|
|
e27eb51f8a | ||
|
|
2155adff5a | ||
|
|
c2c1876484 | ||
|
|
48f338e649 | ||
|
|
b4e13ec83e | ||
|
|
11f830a17b | ||
|
|
5550ec8ebf | ||
|
|
ea59256349 | ||
|
|
0f1536585e | ||
|
|
602a646dbd | ||
|
|
54ffbc7f0f | ||
|
|
ae20d64304 | ||
|
|
ee997d00fa | ||
|
|
98c2ffeec7 | ||
|
|
8e1c259a66 | ||
|
|
ea3fd4c093 | ||
|
|
930f4e6c26 | ||
|
|
356e3a8ab6 | ||
|
|
532489babd | ||
|
|
6fa9c14490 | ||
|
|
d0149c3f94 | ||
|
|
2f6e782215 | ||
|
|
414f211cde | ||
|
|
f1b48a93a9 | ||
|
|
8874f3c80b | ||
|
|
297fdc7cb8 | ||
|
|
73b15fc562 | ||
|
|
90a6b8c998 | ||
|
|
8d18931125 | ||
|
|
7444f96a1d | ||
|
|
8a33a9adb5 | ||
|
|
b78a3462c9 | ||
|
|
c38fb16efa | ||
|
|
2400c6c59d | ||
|
|
324ddb361d | ||
|
|
4f81005662 | ||
|
|
f2dfa462e1 | ||
|
|
14bc28ffbe | ||
|
|
5afce305e7 | ||
|
|
beecf5730a | ||
|
|
eeda983b17 | ||
|
|
e2e3521874 | ||
|
|
303ce70ac4 | ||
|
|
5fde1d096e | ||
|
|
3bcd97b643 | ||
|
|
20fdbcf36f | ||
|
|
c7f4422333 | ||
|
|
da6ca23b50 | ||
|
|
b064a13aa4 | ||
|
|
45e2d81be4 | ||
|
|
fe41e80f33 | ||
|
|
a2ac8ad106 | ||
|
|
bd4cfd5a7a | ||
|
|
0e975f6305 | ||
|
|
c94846ee2a | ||
|
|
9ce463fc24 | ||
|
|
5a0a12cb44 | ||
|
|
ba61ab4f9f | ||
|
|
891627b210 | ||
|
|
ba5e7d76fd | ||
|
|
809a6cff1e | ||
|
|
32c11fd06e | ||
|
|
04d2d9ff19 | ||
|
|
05499b9011 | ||
|
|
ca32e87683 | ||
|
|
122368f5e0 | ||
|
|
c267e73ca6 | ||
|
|
c649b84bf6 | ||
|
|
09f8f43d20 | ||
|
|
50d6c19ef4 | ||
|
|
6d89557355 | ||
|
|
30c304c6a7 | ||
|
|
76a91eb433 | ||
|
|
394b43376a | ||
|
|
02f0e8cffa | ||
|
|
3f0a9c5060 | ||
|
|
ce1aed8df5 | ||
|
|
c3d090fe4e | ||
|
|
d92cf5d198 | ||
|
|
ccf4d25321 | ||
|
|
4e02075f8d | ||
|
|
0f358f5bb3 | ||
|
|
a575ae5ef2 | ||
|
|
2aaac4dadb | ||
|
|
bec3890689 | ||
|
|
e3ab88f6de | ||
|
|
a679ee5644 | ||
|
|
96809473fc | ||
|
|
5ef8becd25 | ||
|
|
4249a0d052 | ||
|
|
64587eae43 | ||
|
|
4ce681d42f | ||
|
|
59c6a470bb | ||
|
|
b02072baee | ||
|
|
f6a472d948 | ||
|
|
45be4620fe | ||
|
|
08993dd622 | ||
|
|
219596c4df | ||
|
|
facb60abfe | ||
|
|
141cbf9832 | ||
|
|
8fb5dd8587 | ||
|
|
1651bcc774 | ||
|
|
c2e68335d4 | ||
|
|
177edaa1c6 | ||
|
|
edb32fba92 | ||
|
|
959cacdc00 | ||
|
|
582c73bc3b | ||
|
|
6eca353804 | ||
|
|
d43685bc79 | ||
|
|
56ebccf14d | ||
|
|
d31a7d47bf | ||
|
|
8031ea6d73 | ||
|
|
dfac3e524e | ||
|
|
fc7b51634d | ||
|
|
96bfcf20cd | ||
|
|
557fbec45f | ||
|
|
eaa9d877f1 | ||
|
|
b537fed907 | ||
|
|
b6319c819c | ||
|
|
b6694d462f | ||
|
|
ea6770c7a1 | ||
|
|
b0c5172e10 | ||
|
|
62a544a146 | ||
|
|
eec092f93d | ||
|
|
e0fd3b264a | ||
|
|
17c8ff6a33 | ||
|
|
c425e4cdd5 | ||
|
|
de9b456e82 | ||
|
|
62d06a3c73 | ||
|
|
09f20b7a14 | ||
|
|
0a1e52598f | ||
|
|
640bf56859 | ||
|
|
a958c2cadb | ||
|
|
f058e36084 | ||
|
|
9f364339cc | ||
|
|
3acc9470d4 | ||
|
|
9ddbc23b16 | ||
|
|
c903e93e8b | ||
|
|
0b36a0bbc0 | ||
|
|
4e44ade07f | ||
|
|
35132d6892 | ||
|
|
6edc8ba147 | ||
|
|
12b3b62a7f | ||
|
|
58653f2cdb | ||
|
|
ef176f130b | ||
|
|
c36161a73f | ||
|
|
4b189777c4 | ||
|
|
d08dc6162c | ||
|
|
b5e05516f4 | ||
|
|
9f048cd89b | ||
|
|
78dfce3b63 | ||
|
|
97d34ae6be | ||
|
|
ea0ee680dc | ||
|
|
9acdcbe2f8 | ||
|
|
0f63a05d04 | ||
|
|
3cd23d4ef8 | ||
|
|
e2852524be | ||
|
|
f8e05ebfc0 | ||
|
|
0ac005eb98 | ||
|
|
755c154b1f | ||
|
|
e3b3165e9a | ||
|
|
bf044cf19c | ||
|
|
1cf8db8395 | ||
|
|
c1bde25bcc | ||
|
|
8238684334 | ||
|
|
c9c7fb9962 | ||
|
|
b9248690b0 | ||
|
|
36dfc6c216 | ||
|
|
7a6f380f2c | ||
|
|
84e348c52b | ||
|
|
79b8d7a797 | ||
|
|
fb30dd2d58 | ||
|
|
a0ca3d2e81 | ||
|
|
204a906de8 | ||
|
|
146f402a8c | ||
|
|
d6f32a0267 | ||
|
|
288766171d | ||
|
|
7ab368f4a4 | ||
|
|
d0e2723e45 | ||
|
|
c085142e66 | ||
|
|
c647cfd6a3 | ||
|
|
29a4897e73 | ||
|
|
8df220c2b3 | ||
|
|
6e80f42f38 | ||
|
|
211344d0b0 | ||
|
|
6b5c04e7d3 | ||
|
|
6ea89dc7cb | ||
|
|
ff46c3d7d7 | ||
|
|
2f969afaf2 | ||
|
|
fbd38753fa | ||
|
|
2d1fb61885 | ||
|
|
7e3381e8ad | ||
|
|
190780e125 | ||
|
|
1f96da5e6d | ||
|
|
a8d5679a1c | ||
|
|
5bacb68115 | ||
|
|
af2fac75db | ||
|
|
616736e0f1 | ||
|
|
94323c0838 | ||
|
|
223998bd48 | ||
|
|
b3d770a69b | ||
|
|
9fb51b7e67 | ||
|
|
67366dd35c | ||
|
|
71b31e17b0 | ||
|
|
312bc4912d | ||
|
|
3925b5fa1b | ||
|
|
d4d30148bd | ||
|
|
12e6838403 | ||
|
|
489772908b | ||
|
|
6a37e1538a | ||
|
|
eeaaf11a51 | ||
|
|
6899c7720f | ||
|
|
51a007e84e | ||
|
|
6d185b6f40 | ||
|
|
7358c0f735 | ||
|
|
01460f681e | ||
|
|
750fce7e52 | ||
|
|
216d528f1b | ||
|
|
0ee89c1302 | ||
|
|
af382be837 | ||
|
|
d813edb945 | ||
|
|
9041251da5 | ||
|
|
9e04e4f5c2 | ||
|
|
28ba7033fa | ||
|
|
fbaf23dc8d | ||
|
|
9cc1f68364 | ||
|
|
059c9ce0b6 | ||
|
|
668fb4c14a | ||
|
|
4c06bcf000 | ||
|
|
7aba539e82 | ||
|
|
ef8544b173 | ||
|
|
bee269afe8 | ||
|
|
324b0f97ff | ||
|
|
7352944dec | ||
|
|
78c7fb9c5c | ||
|
|
8598af2a17 | ||
|
|
df07a0a1de | ||
|
|
a64a24b39c | ||
|
|
cd0e88c680 | ||
|
|
08008f6305 | ||
|
|
e3812cf72b | ||
|
|
4175d062f4 | ||
|
|
84f9b6530e | ||
|
|
3d02a12eb6 | ||
|
|
c1e94f8ee7 | ||
|
|
7fffd51535 | ||
|
|
a68e0bbc6f | ||
|
|
dd3cf53044 | ||
|
|
500e37e2fd | ||
|
|
44c5f1c011 | ||
|
|
7162450e83 | ||
|
|
3f62f3cd05 | ||
|
|
15483f1592 | ||
|
|
4c7b870062 | ||
|
|
48451f5adf | ||
|
|
f785af3cec | ||
|
|
aa5e8a5eff | ||
|
|
6a9efa8ffd | ||
|
|
4eb9a24997 | ||
|
|
b206e691ca | ||
|
|
3f354c2b06 | ||
|
|
8ae9d0ad8e | ||
|
|
0f583cfe75 | ||
|
|
df250423d4 | ||
|
|
b8934b743c | ||
|
|
976d061f9b | ||
|
|
96655436f4 | ||
|
|
648806bc9c | ||
|
|
64ebfe2235 | ||
|
|
ca4d7ff1f2 | ||
|
|
2917d1d51c | ||
|
|
c79b9821fa | ||
|
|
6422ef2b57 | ||
|
|
509ea9afc4 | ||
|
|
1828cc6a10 | ||
|
|
8d5ff67d05 | ||
|
|
ec63a26511 | ||
|
|
c2b3b89445 | ||
|
|
5967bd8e08 | ||
|
|
7e7548cd18 | ||
|
|
1ba3aa718e | ||
|
|
c7b1660650 | ||
|
|
f5e1f1590f | ||
|
|
09d0cca5b9 | ||
|
|
d8736be194 | ||
|
|
7f15f506f8 | ||
|
|
6aa3fa5193 | ||
|
|
c849be5e52 | ||
|
|
b3b3088a17 | ||
|
|
72fad39913 | ||
|
|
e12563a4b4 | ||
|
|
e8afed13cc | ||
|
|
7a72bb3571 | ||
|
|
08f30717ad | ||
|
|
2bdfbb9e61 | ||
|
|
06e757a9e9 | ||
|
|
7b84d4daca | ||
|
|
5e0d705a7f | ||
|
|
30ca836e03 | ||
|
|
b391dc56a0 | ||
|
|
606fac6e1c | ||
|
|
ed36ee5133 | ||
|
|
c35242731f | ||
|
|
d2d07d0345 | ||
|
|
8b908d6150 | ||
|
|
1017a76b4c | ||
|
|
9c5d76c299 | ||
|
|
83987b8eec | ||
|
|
cbd71699de | ||
|
|
5d58a25e52 | ||
|
|
764d9b5fbe | ||
|
|
5ffea6d30e | ||
|
|
2796210e18 | ||
|
|
1b2c71ac75 | ||
|
|
cc4bf22d07 | ||
|
|
7295d9306f | ||
|
|
2a66b49bc7 | ||
|
|
c944a25585 | ||
|
|
2067836851 | ||
|
|
6f95a071b5 | ||
|
|
a543fd3656 | ||
|
|
d94c4415af | ||
|
|
abbed23c64 | ||
|
|
5de4e5b3c0 | ||
|
|
1e17a55e79 | ||
|
|
465dab2eed | ||
|
|
532e0a77cc | ||
|
|
47835e6b25 | ||
|
|
11c537dc1e | ||
|
|
e4420227b5 | ||
|
|
f9e44fe86e | ||
|
|
b256e211dc | ||
|
|
2a34c7a714 | ||
|
|
04132b51f0 | ||
|
|
908f6ada4e | ||
|
|
e7da213f93 | ||
|
|
e7f789f185 | ||
|
|
f8d381e6c5 | ||
|
|
c29425c0fc | ||
|
|
612f9ee669 | ||
|
|
81a38df814 | ||
|
|
e9eb130731 | ||
|
|
4edaecc04d | ||
|
|
fc8d0a0187 | ||
|
|
96960499ef | ||
|
|
c2687c16b3 | ||
|
|
883944d289 | ||
|
|
a7156a0702 | ||
|
|
dee9d27af8 | ||
|
|
e06f0ee315 | ||
|
|
7522ae14b2 | ||
|
|
e09eee8fd1 | ||
|
|
b692ddd80c | ||
|
|
5ebb389d26 | ||
|
|
fff6f7cf2f | ||
|
|
516fd12b8d | ||
|
|
925ca49f21 | ||
|
|
a1577fc48c | ||
|
|
acda0341ed | ||
|
|
98378cfe03 | ||
|
|
3f89a3c742 | ||
|
|
e036075e22 | ||
|
|
5a84cde198 | ||
|
|
4e18ab0ad4 | ||
|
|
2a742486c5 | ||
|
|
d362bdbb4e | ||
|
|
60d6be5b13 | ||
|
|
cc1b55aaf7 | ||
|
|
d1fa17032e |
@@ -1,88 +1,15 @@
|
||||
# Rule Catalog — Architecture
|
||||
# Architecture review
|
||||
|
||||
## Scope
|
||||
- Covers: controller/service/core-domain/libs/model layering, dependency direction, responsibility placement, observability-friendly flow.
|
||||
The [API agent guide](../../../../api/AGENTS.md) owns package boundaries. In particular, `api/core/` is migration-only: do not propose new files or extracted implementations there.
|
||||
|
||||
## Rules
|
||||
## Transport and domain boundaries
|
||||
|
||||
### Keep business logic out of controllers
|
||||
- Category: maintainability
|
||||
- Description: Controllers should parse input, call services, and return serialized responses. Business decisions inside controllers make behavior hard to reuse and test.
|
||||
- Suggested fix: Move domain/business logic into the service or core/domain layer. Keep controller handlers thin and orchestration-focused.
|
||||
- Example:
|
||||
- Bad:
|
||||
```python
|
||||
@bp.post("/apps/<app_id>/publish")
|
||||
def publish_app(app_id: str):
|
||||
payload = request.get_json() or {}
|
||||
if payload.get("force") and current_user.role != "admin":
|
||||
raise ValueError("only admin can force publish")
|
||||
app = App.query.get(app_id)
|
||||
app.status = "published"
|
||||
db.session.commit()
|
||||
return {"result": "ok"}
|
||||
```
|
||||
- Good:
|
||||
```python
|
||||
@bp.post("/apps/<app_id>/publish")
|
||||
def publish_app(app_id: str):
|
||||
payload = PublishRequest.model_validate(request.get_json() or {})
|
||||
app_service.publish_app(app_id=app_id, force=payload.force, actor_id=current_user.id)
|
||||
return {"result": "ok"}
|
||||
```
|
||||
Controllers own request parsing, service calls, and response serialization. Trace business decisions to their service or domain owner; flag controller policy when it duplicates or bypasses that owner. Move extracted behavior to an appropriate owner outside `core/`.
|
||||
|
||||
### Preserve layer dependency direction
|
||||
- Category: best practices
|
||||
- Description: Controllers may depend on services, and services may depend on core/domain abstractions. Reversing this direction (for example, core importing controller/web modules) creates cycles and leaks transport concerns into domain code.
|
||||
- Suggested fix: Extract shared contracts into core/domain or service-level modules and make upper layers depend on lower, not the reverse.
|
||||
- Example:
|
||||
- Bad:
|
||||
```python
|
||||
# core/policy/publish_policy.py
|
||||
from controllers.console.app import request_context
|
||||
## Dependency direction
|
||||
|
||||
def can_publish() -> bool:
|
||||
return request_context.current_user.is_admin
|
||||
```
|
||||
- Good:
|
||||
```python
|
||||
# core/policy/publish_policy.py
|
||||
def can_publish(role: str) -> bool:
|
||||
return role == "admin"
|
||||
Transport layers may depend on services and domain contracts. Domain code must not import controller or request context. Pass validated actor, tenant, and resource data explicitly instead of reaching upward for it. Check existing owners and import-linter contracts before proposing a shared abstraction.
|
||||
|
||||
# service layer adapts web/user context to domain input
|
||||
allowed = can_publish(role=current_user.role)
|
||||
```
|
||||
## Business-agnostic libraries
|
||||
|
||||
### Keep libs business-agnostic
|
||||
- Category: maintainability
|
||||
- Description: Modules under `api/libs/` should remain reusable, business-agnostic building blocks. They must not encode product/domain-specific rules, workflow orchestration, or business decisions.
|
||||
- Suggested fix:
|
||||
- If business logic appears in `api/libs/`, extract it into the appropriate `services/` or `core/` module and keep `libs` focused on generic, cross-cutting helpers.
|
||||
- Keep `libs` dependencies clean: avoid importing service/controller/domain-specific modules into `api/libs/`.
|
||||
- Example:
|
||||
- Bad:
|
||||
```python
|
||||
# api/libs/conversation_filter.py
|
||||
from services.conversation_service import ConversationService
|
||||
|
||||
def should_archive_conversation(conversation, tenant_id: str) -> bool:
|
||||
# Domain policy and service dependency are leaking into libs.
|
||||
service = ConversationService()
|
||||
if service.has_paid_plan(tenant_id):
|
||||
return conversation.idle_days > 90
|
||||
return conversation.idle_days > 30
|
||||
```
|
||||
- Good:
|
||||
```python
|
||||
# api/libs/datetime_utils.py (business-agnostic helper)
|
||||
def older_than_days(idle_days: int, threshold_days: int) -> bool:
|
||||
return idle_days > threshold_days
|
||||
|
||||
# services/conversation_service.py (business logic stays in service/core)
|
||||
from libs.datetime_utils import older_than_days
|
||||
|
||||
def should_archive_conversation(conversation, tenant_id: str) -> bool:
|
||||
threshold_days = 90 if has_paid_plan(tenant_id) else 30
|
||||
return older_than_days(conversation.idle_days, threshold_days)
|
||||
```
|
||||
`api/libs/` must not own product policy or orchestration. Flag service/controller dependencies and domain-specific decisions in library helpers. Move that behavior to its existing service or domain owner outside `core/`; retain only reusable infrastructure in `libs/`.
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
```python
|
||||
from sqlalchemy.orm import Mapped
|
||||
|
||||
|
||||
class Dataset(TypeBase):
|
||||
__tablename__ = "datasets"
|
||||
id: Mapped[str] = mapped_column(StringUUID, primary_key=True)
|
||||
@@ -59,6 +60,7 @@
|
||||
```python
|
||||
from sqlalchemy.orm import Mapped
|
||||
|
||||
|
||||
class Dataset(TypeBase):
|
||||
__tablename__ = "datasets"
|
||||
id: Mapped[str] = mapped_column(StringUUID, primary_key=True)
|
||||
@@ -101,6 +103,7 @@
|
||||
from sqlalchemy.dialects.postgresql import JSONB
|
||||
from sqlalchemy.orm import Mapped
|
||||
|
||||
|
||||
class ToolConfig(TypeBase):
|
||||
__tablename__ = "tool_configs"
|
||||
config: Mapped[dict] = mapped_column(JSONB, nullable=False)
|
||||
@@ -111,6 +114,7 @@
|
||||
|
||||
from models.types import AdjustedJSON
|
||||
|
||||
|
||||
class ToolConfig(TypeBase):
|
||||
__tablename__ = "tool_configs"
|
||||
config: Mapped[dict] = mapped_column(AdjustedJSON(), nullable=False)
|
||||
@@ -146,7 +150,5 @@
|
||||
default_expr = sa.text("'database'::character varying") if _is_pg(conn) else sa.text("'database'")
|
||||
|
||||
with op.batch_alter_table("dataset_keyword_tables") as batch_op:
|
||||
batch_op.add_column(
|
||||
sa.Column("data_source_type", sa.String(255), server_default=default_expr, nullable=False)
|
||||
)
|
||||
batch_op.add_column(sa.Column("data_source_type", sa.String(255), server_default=default_expr, nullable=False))
|
||||
```
|
||||
|
||||
@@ -11,16 +11,14 @@
|
||||
- Description: If a table/model already has a repository abstraction, all reads/writes/queries for that table should use the existing repository. If no repository exists, introduce one only when complexity justifies it, such as large/high-volume tables, repeated complex query logic, or likely storage-strategy variation.
|
||||
- Suggested fix:
|
||||
- First check `api/repositories`, `api/core/repositories`, and `api/extensions/*/repositories/` to verify whether the table/model already has a repository abstraction. If it exists, route all operations through it and add missing repository methods instead of bypassing it with ad-hoc SQLAlchemy access.
|
||||
- If no repository exists, add one only when complexity warrants it (for example, repeated complex queries, large data domains, or multiple storage strategies), while preserving dependency direction (service/core depends on abstraction; infra provides implementation).
|
||||
- If no repository exists, add one only when complexity warrants it (for example, repeated complex queries, large data domains, or multiple storage strategies). Follow `api/AGENTS.md`: put new abstractions and implementations outside migration-only `api/core/`, with services/domain code depending on abstractions and infrastructure providing implementations.
|
||||
- Example:
|
||||
- Bad:
|
||||
```python
|
||||
# Existing repository is ignored and service uses ad-hoc table queries.
|
||||
class AppService:
|
||||
def archive_app(self, app_id: str, tenant_id: str) -> None:
|
||||
app = self.session.execute(
|
||||
select(App).where(App.id == app_id, App.tenant_id == tenant_id)
|
||||
).scalar_one()
|
||||
app = self.session.execute(select(App).where(App.id == app_id, App.tenant_id == tenant_id)).scalar_one()
|
||||
app.archived = True
|
||||
self.session.commit()
|
||||
```
|
||||
@@ -33,6 +31,7 @@
|
||||
app.archived = True
|
||||
self.app_repo.save(app)
|
||||
|
||||
|
||||
# If the query is missing, extend the existing abstraction.
|
||||
active_apps = self.app_repo.list_active_for_tenant(tenant_id=tenant_id)
|
||||
```
|
||||
@@ -50,9 +49,10 @@
|
||||
class ConversationRepository(Protocol):
|
||||
def list_recent_for_app(self, app_id: str, tenant_id: str, limit: int) -> list[Conversation]: ...
|
||||
|
||||
|
||||
class SqlAlchemyConversationRepository:
|
||||
def list_recent_for_app(self, app_id: str, tenant_id: str, limit: int) -> list[Conversation]:
|
||||
...
|
||||
def list_recent_for_app(self, app_id: str, tenant_id: str, limit: int) -> list[Conversation]: ...
|
||||
|
||||
|
||||
class ConversationService:
|
||||
def __init__(self, conversation_repo: ConversationRepository):
|
||||
|
||||
@@ -126,9 +126,7 @@
|
||||
|
||||
# 3) Pessimistic lock with SELECT ... FOR UPDATE (high contention)
|
||||
run = session.execute(
|
||||
select(WorkflowRun)
|
||||
.where(WorkflowRun.id == run_id, WorkflowRun.tenant_id == tenant_id)
|
||||
.with_for_update()
|
||||
select(WorkflowRun).where(WorkflowRun.id == run_id, WorkflowRun.tenant_id == tenant_id).with_for_update()
|
||||
).scalar_one()
|
||||
run.status = "cancelled"
|
||||
session.commit()
|
||||
|
||||
@@ -7,12 +7,14 @@ description: Use when writing, changing, or reviewing Cucumber and Playwright te
|
||||
|
||||
`e2e/AGENTS.md` owns the suite architecture, lifecycle, commands, tags, generated-client boundaries, fixtures, and cleanup contracts. Read the nearest feature-scoped `AGENTS.md` when one exists. This skill adds no parallel package policy.
|
||||
|
||||
Cucumber owns scenario and hook execution and reporting. Playwright provides browser automation, contexts, pages, locators, actions, assertions, request, and tracing APIs; protocol exceptions remain with the package-defined owner. Their timeout domains remain separate, and importing from `@playwright/test` does not make Playwright Test runner configuration, fixtures, or retries applicable to this suite.
|
||||
|
||||
## Topic Routing
|
||||
|
||||
Read only the bundled reference required by the change:
|
||||
|
||||
- Locator, assertion, isolation, or waiting decisions: [`references/playwright-best-practices.md`][playwright]
|
||||
- Scenario wording, step granularity, expressions, or tag design: [`references/cucumber-best-practices.md`][cucumber]
|
||||
- Scenario wording, step granularity, expressions, World state, hook visibility, or tag design: [`references/cucumber-best-practices.md`][cucumber]
|
||||
|
||||
Check current official Playwright or Cucumber documentation before introducing a framework pattern that local code and references do not already establish.
|
||||
|
||||
@@ -23,7 +25,7 @@ Check current official Playwright or Cucumber documentation before introducing a
|
||||
3. Read the target scenario, matching step definitions, and lifecycle files only when session or shared state matters.
|
||||
4. Reuse an existing step when wording and behavior match; add one coherent scenario or step when they do not.
|
||||
5. Keep browser actions and assertions at the public user boundary; keep setup, seed, polling, and cleanup at their package-defined owners.
|
||||
6. Run the narrowest tagged scenario and package checks documented in `e2e/AGENTS.md`; broaden only for shared hooks, tags, or support changes.
|
||||
6. For changes, run the narrowest tagged scenario and package checks documented in `e2e/AGENTS.md`; broaden only for shared hooks, tags, or support changes.
|
||||
|
||||
For review requests, lead with reproducible correctness failures, flake sources, or demonstrated architecture drift. Report the behavior verified and any external-runtime, browser, or environment gap.
|
||||
|
||||
|
||||
@@ -4,15 +4,18 @@ Use this reference when writing or reviewing Gherkin scenarios, step definitions
|
||||
|
||||
Official sources:
|
||||
|
||||
- https://cucumber.io/docs/guides/10-minute-tutorial
|
||||
- https://cucumber.io/docs/cucumber/step-definitions
|
||||
- https://cucumber.io/docs/bdd/better-gherkin
|
||||
- https://cucumber.io/docs/gherkin/reference
|
||||
- https://cucumber.io/docs/gherkin/step-organization
|
||||
- https://cucumber.io/docs/cucumber/state
|
||||
- https://cucumber.io/docs/cucumber/cucumber-expressions
|
||||
- https://github.com/cucumber/cucumber-js/blob/main/docs/support_files/world.md
|
||||
|
||||
## What Matters Most
|
||||
|
||||
### 1. Treat scenarios as executable specifications
|
||||
|
||||
Cucumber scenarios should describe examples of behavior, not test implementation recipes.
|
||||
Cucumber scenarios should usually describe behavior declaratively, not reproduce an interaction script.
|
||||
|
||||
Apply it like this:
|
||||
|
||||
@@ -20,11 +23,15 @@ Apply it like this:
|
||||
- avoid UI-internal wording such as selector details, DOM structure, or component names
|
||||
- keep language concrete enough that the scenario reads like living documentation
|
||||
|
||||
Procedural detail is appropriate when the interaction mechanism is the behavior under test, such as keyboard navigation, focus movement, or a required multi-actor sequence.
|
||||
|
||||
### 2. Keep scenarios focused
|
||||
|
||||
A scenario should usually prove one workflow or business outcome. If a scenario wanders across several unrelated behaviors, split it.
|
||||
A scenario should prove one business rule or coherent outcome. Cucumber's three-to-five-step recommendation is a review heuristic, not a hard limit: when a scenario is longer, check for multiple outcomes, incidental setup, or UI procedure that can move behind a domain step.
|
||||
|
||||
Keep each scenario centered on one coherent outcome. Avoid hidden dependencies on another scenario's side effects, and keep unavoidable setup outside the behavior narrative unless the precondition matters to the specification.
|
||||
Use `Given` for initial context, `When` for the event, and `Then` for the expected outcome. Restarting those phases is a prompt to review the narrative, not an automatic failure. Avoid hidden dependencies on another scenario's side effects.
|
||||
|
||||
Use `Rule` when several examples illustrate one named business rule. Use a short `Background` only for shared context the reader needs to understand; do not hide fixture preparation, runtime readiness, or long setup there.
|
||||
|
||||
### 3. Reuse steps, but only when behavior really matches
|
||||
|
||||
@@ -45,6 +52,8 @@ Write a new step when:
|
||||
|
||||
Do not optimize for a low step count by making vague steps. Optimize for a small set of truthful, domain-owned steps.
|
||||
|
||||
Step definitions share one global matching namespace regardless of their directory. Organize them by domain capability and avoid feature-coupled glue or expressions broad enough to overlap unrelated behavior.
|
||||
|
||||
### 4. Prefer Cucumber Expressions
|
||||
|
||||
Use Cucumber Expressions for parameters unless regex is clearly necessary.
|
||||
@@ -62,18 +71,24 @@ Use regex for a bounded natural-language alternative only when it keeps Gherkin
|
||||
|
||||
### 5. Keep step definitions thin and meaningful
|
||||
|
||||
Step definitions are glue between Gherkin and automation, not a second abstraction language.
|
||||
Step definitions are glue between Gherkin and automation, not a second abstraction language. A step should express one coherent domain action or outcome; it may call several implementation helpers when that keeps UI mechanics out of the specification.
|
||||
|
||||
Keep each step to one user-visible action or assertion. In JavaScript and TypeScript, use `async function` when the step reads Cucumber World state because Cucumber binds `this`; do not leak state across scenarios through module globals.
|
||||
Cucumber creates a new World for each scenario. Keep scenario state there rather than in module globals. Cucumber.js supports a `world` proxy for arrow functions, but this suite consistently uses typed `async function (this: DifyWorld, ...)` so ownership and TypeScript discovery remain explicit.
|
||||
|
||||
Hooks are invisible to feature readers. Keep them for low-level browser lifecycle, cleanup, and diagnostics; express business-relevant context in Gherkin.
|
||||
|
||||
### 6. Use tags intentionally
|
||||
|
||||
Tags should communicate selection or execution intent, not become ad hoc metadata. A tag does not change runtime behavior unless configuration or hooks implement it.
|
||||
Tags may communicate stable capability grouping, selection, fixture dependency, or conditional-hook intent. A tag changes runtime behavior only when a runner, seed profile, or hook owns that meaning.
|
||||
|
||||
## Review Questions
|
||||
|
||||
- Does the scenario read like a real example of product behavior?
|
||||
- Does it prove one outcome, or combine several independent phases?
|
||||
- Are the steps behavior-oriented instead of implementation-oriented?
|
||||
- Is procedural wording necessary to the behavior being tested?
|
||||
- Is a reused step still truthful in this feature?
|
||||
- Could a new expression overlap an existing step in the global namespace?
|
||||
- Would `Rule` clarify the business rule, or would `Background` hide important setup?
|
||||
- Is a new tag documenting real behavior, or inventing semantics that the suite does not implement?
|
||||
- Would a new reader understand the outcome without opening the step-definition file?
|
||||
|
||||
@@ -6,8 +6,12 @@ Official sources:
|
||||
|
||||
- https://playwright.dev/docs/best-practices
|
||||
- https://playwright.dev/docs/locators
|
||||
- https://playwright.dev/docs/actionability
|
||||
- https://playwright.dev/docs/test-assertions
|
||||
- https://playwright.dev/docs/test-timeouts
|
||||
- https://playwright.dev/docs/browser-contexts
|
||||
- https://playwright.dev/docs/events
|
||||
- https://playwright.dev/docs/trace-viewer
|
||||
|
||||
## What Matters Most
|
||||
|
||||
@@ -21,28 +25,22 @@ Apply it like this:
|
||||
- keep scenario state in the runner's scenario-owned context rather than module globals
|
||||
- model special authentication or session setup through explicit per-scenario fixtures rather than shared mutable state
|
||||
|
||||
### 2. Prefer user-facing locators
|
||||
### 2. Select locators by user contract
|
||||
|
||||
Playwright recommends built-in locators that reflect what users perceive on the page.
|
||||
Prefer built-in locators that match how the target is exposed to users:
|
||||
|
||||
Preferred order:
|
||||
- interactive controls: role and accessible name
|
||||
- form controls: associated label; use placeholder when it is the relevant stable contract, especially when no label exists
|
||||
- non-interactive content: visible text or the relevant text alternative
|
||||
- elements without a meaningful user-facing contract: an intentional test id
|
||||
|
||||
1. `getByRole`
|
||||
2. `getByLabel`
|
||||
3. `getByPlaceholder`
|
||||
4. `getByText`
|
||||
5. `getByTestId` when an explicit test contract is the most stable option
|
||||
This is a semantic choice, not a fixed ranking. Do not add incorrect roles or accessible names solely to satisfy a locator. When the product element should have user-facing semantics, fix that contract instead.
|
||||
|
||||
Avoid raw CSS/XPath selectors unless no stable user-facing contract exists and adding one is not practical.
|
||||
|
||||
Also remember:
|
||||
Locators are strict for single-element actions. Scope to a stable region or use `filter({ has, hasText })` to make the intended target unique. Treat `.first()`, `.last()`, or `.nth()` as a review signal: the positional choice should be intentional and stable, not merely silence ambiguity.
|
||||
|
||||
- repeated content usually needs scoping to a stable container
|
||||
- exact text matching is often too brittle when role/name or label already exists
|
||||
- `getByTestId` is acceptable when semantics are weak but the contract is intentional
|
||||
- when a real UI region, card, status, or icon lacks an accessible name, prefer adding that semantic contract in product code before falling back to `getByTestId`
|
||||
|
||||
### 3. Use web-first assertions
|
||||
### 3. Use web-first assertions with the right timeout owner
|
||||
|
||||
Playwright assertions auto-wait and retry. Prefer them over manual state inspection.
|
||||
|
||||
@@ -64,6 +62,8 @@ If a condition genuinely needs custom retry logic, use Playwright's polling/asse
|
||||
|
||||
Use `expect.poll` for non-DOM truth such as API state, backend eventual consistency, generated resources, or captured browser events. For DOM state, use locator assertions so Playwright can apply actionability and web-first retry semantics.
|
||||
|
||||
Cucumber step and hook timeouts, Playwright locator/action timeouts, and Playwright assertion timeouts are separate budgets. `browserContext.setDefaultTimeout()` does not change the default five-second assertion timeout. Put an explicit longer assertion timeout only on the readiness owner that needs it; do not raise an outer timeout to mask a shorter inner failure.
|
||||
|
||||
### 4. Let actions wait for actionability
|
||||
|
||||
Locator actions already wait for the element to be actionable. Do not preface every click/fill with extra timing logic unless the action needs a specific visible/ready assertion for clarity.
|
||||
@@ -77,15 +77,20 @@ Bad pattern:
|
||||
|
||||
- stack arbitrary waits before every action
|
||||
- wait on unstable implementation details instead of the visible state the user cares about
|
||||
- use `force: true` to bypass a real hit-target, overlay, or disabled-state failure
|
||||
|
||||
When synchronizing on a one-shot popup, download, request, or response, create the wait before triggering the action, then await the event. A scenario-owned listener may instead capture events for a later assertion. Do not use `networkidle` as an application-readiness assertion; wait for the user-visible state or owned backend contract.
|
||||
|
||||
### 5. Match debugging to the active harness
|
||||
|
||||
Playwright supports traces, screenshots, page snapshots, and browser logs. Configure artifact capture at the runner boundary instead of adding parallel diagnostics to individual scenarios.
|
||||
Playwright supports traces, screenshots, page snapshots, and browser logs. Configure artifact capture in Cucumber hooks instead of adding parallel diagnostics to individual scenarios. If tracing is introduced, use `browserContext.tracing`; Playwright Test options such as `trace: 'on-first-retry'`, projects, workers, fixtures, reporters, and retries do not configure this harness.
|
||||
|
||||
## Review Questions
|
||||
|
||||
- Would this locator survive DOM refactors that do not change user-visible behavior?
|
||||
- Is a positional locator expressing product order, or hiding an ambiguous match?
|
||||
- Is this assertion using Playwright's retrying semantics?
|
||||
- Is any explicit wait masking a real readiness problem?
|
||||
- Does an explicit timeout belong to the condition that is actually slow?
|
||||
- Was an event wait registered before the action that emits it?
|
||||
- Does this code preserve per-scenario isolation?
|
||||
- Is a new abstraction really needed, or does it bypass the runner's scenario-owned context and lifecycle?
|
||||
|
||||
@@ -5,14 +5,14 @@ description: Use only when the user explicitly requests a review or audit of fro
|
||||
|
||||
# Frontend Code Review
|
||||
|
||||
Review the requested scope for concrete, reproducible regressions. This skill owns the review phase and routes directly to its bundled rule packs. For a combined review-and-fix request, establish findings before applying implementation or testing guidance.
|
||||
Review the requested scope for concrete defects and violations of explicit project contracts. This skill owns review decisions; its references route to canonical rules without activating another skill's implementation workflow.
|
||||
|
||||
## Evidence First
|
||||
|
||||
1. Establish the review scope from the requested files or current diff.
|
||||
2. Read the changed lines, their behavior owner, and the nearest scoped `AGENTS.md`.
|
||||
3. Trace public consumers, generated contracts, primitive APIs, or runtime configuration only when they decide correctness.
|
||||
4. Report only findings tied to an observable failure, violated contract, security boundary, or demonstrated maintenance risk.
|
||||
4. Report findings tied to an observable failure, violated contract, security boundary, or demonstrated maintenance risk. Explicit team conventions are contracts: establish their scope and exceptions, and do not invent user impact to justify a convention finding.
|
||||
|
||||
## Rule Routing
|
||||
|
||||
@@ -27,16 +27,16 @@ Read only the packs matched by the diff:
|
||||
- Stable Dify runtime invariants in the named paths: [`references/dify-invariants.md`][dify-invariants]
|
||||
- General TypeScript or styling quality not owned above: [`references/code-quality.md`][code-quality]
|
||||
|
||||
Read `packages/dify-ui/README.md`, `packages/dify-ui/AGENTS.md`, `web/docs/overlay.md`, or `web/docs/test.md` only when the reviewed code falls under that contract. Check current official documentation when local code and bundled references do not settle a framework, browser, or accessibility behavior.
|
||||
Read `packages/dify-ui/README.md`, `packages/dify-ui/AGENTS.md`, `packages/dify-ui/docs/overlays.md`, or `web/docs/test.md` only when the reviewed code falls under that contract. Check current official documentation when local code and bundled references do not settle a framework, browser, or accessibility behavior.
|
||||
|
||||
## Severity And Output
|
||||
|
||||
- **P0**: security or privacy leak, data loss, production crash, or inaccessible critical workflow.
|
||||
- **P1**: user-visible regression, invalid API or authorization contract, hydration failure, or broken primary interaction.
|
||||
- **P2**: concrete maintainability, performance, test, or accessibility defect likely to cause incorrect behavior.
|
||||
- **P2**: concrete maintainability, performance, test, or accessibility defect, or a material violation of an explicit project contract.
|
||||
- **P3**: minor actionable cleanup; omit unless the user requested a thorough audit.
|
||||
|
||||
Lead with findings ordered by severity. Include a tight file and line reference, the failing contract or reproduction path, impact, and a concrete fix direction. If there are no findings, say `No issues found.` and state any material verification gap. Do not add praise sections, speculative risks, or an unsolicited offer to implement fixes.
|
||||
Lead with findings ordered by severity. Include a tight file and line reference, the observed failure or applicable project rule, and a concrete fix direction. Explain the rule's applicability for convention findings; describe downstream consequences only when supported by evidence. When no findings remain, say so briefly and state any material verification gap. Do not add praise sections, speculative risks, or an unsolicited offer to implement fixes.
|
||||
|
||||
[accessibility]: references/accessibility-ui.md
|
||||
[code-quality]: references/code-quality.md
|
||||
|
||||
@@ -2,32 +2,51 @@
|
||||
|
||||
Accessibility findings are first-class review findings. Treat broken keyboard access, missing accessible names, focus loss, and unreachable popup content as correctness bugs, not polish.
|
||||
|
||||
Before finalizing UI or accessibility findings, fetch the latest Web Interface Guidelines as a required baseline:
|
||||
## Review Evidence
|
||||
|
||||
```text
|
||||
https://raw.githubusercontent.com/vercel-labs/web-interface-guidelines/main/command.md
|
||||
```
|
||||
|
||||
Do not treat that document as the complete accessibility rule set. Combine it with:
|
||||
Use the sources relevant to the changed contract:
|
||||
|
||||
- `packages/dify-ui/README.md`, `packages/dify-ui/AGENTS.md`, and the relevant primitive implementation when code uses `@langgenius/dify-ui/*`.
|
||||
- Base UI docs and local `.d.ts` contracts when primitive semantics, focus target, labels, or popup reachability are unclear.
|
||||
- MDN or relevant WAI-ARIA/browser standards when behavior, compatibility, or deprecation status matters.
|
||||
- The current feature's product semantics, because an accessible primitive can still be used in an inaccessible workflow.
|
||||
|
||||
Consult current official documentation or standards when these sources leave a behavior unresolved. The [Web Interface Guidelines] are an optional broader UI reference, not a required fetch for each review.
|
||||
|
||||
## Semantic HTML
|
||||
|
||||
Flag:
|
||||
|
||||
- Clickable `div` or `span` used for actions.
|
||||
- Router navigation implemented with button or `onClick` when a `Link` / `<a>` is the real semantic element.
|
||||
- Icon-only buttons without `aria-label` or `aria-labelledby`.
|
||||
- Icon-only controls without an accessible name; follow the naming rules below and the Dify UI `IconButton` contract.
|
||||
- Decorative icons missing `aria-hidden="true"`.
|
||||
- Images without `alt`; use `alt=""` only when truly decorative.
|
||||
- Heading levels that skip hierarchy in page-level content.
|
||||
|
||||
Prefer semantic HTML before ARIA.
|
||||
|
||||
## Page Landmarks
|
||||
|
||||
When reviewing Web page layouts, navigation, or landmark changes, read [Page landmarks].
|
||||
Inspect the composed page with its parent layouts for missing or duplicate main regions,
|
||||
inappropriate nesting or roles, and ambiguous or broken landmark names. Check affected
|
||||
unit and E2E locators when semantic elements change. Web owns these composition rules;
|
||||
use the existing naming contract for label-source decisions.
|
||||
|
||||
## Accessible Names And Descriptions
|
||||
|
||||
Read [Accessible names and descriptions] when a change affects labels, ARIA naming, help/error relationships, or hidden text. That document owns the shared implementation and review contract.
|
||||
|
||||
Flag violations supported by the final rendered behavior:
|
||||
|
||||
- Missing or insufficient names, redundant name overrides, or naming attributes prohibited by the element's role.
|
||||
- Overrides that omit visible label wording or suppress necessary descendant information.
|
||||
- Broken or stale label/description references, including relationships lost when responsive content or overlays unmount.
|
||||
- Descriptions used instead of names, repeated help text, or essential structured content available only as a flattened description.
|
||||
|
||||
Inspect the computed name and description in the relevant state. Matching an `aria-label` string to nearby text alone does not prove redundancy.
|
||||
|
||||
## Keyboard And Focus
|
||||
|
||||
Flag:
|
||||
@@ -48,7 +67,6 @@ Flag:
|
||||
- Missing stable `name` on form fields that submit or validate.
|
||||
- Incorrect input `type`, `inputMode`, `autoComplete`, or `spellCheck` for email, token, URL, number, search, code, or username fields.
|
||||
- Labels that are not clickable.
|
||||
- Submit buttons disabled before a request starts, preventing normal submit behavior.
|
||||
- Non-submit buttons inside forms missing `type="button"`.
|
||||
- Errors not associated with fields or not reachable by screen readers.
|
||||
- Error recovery that does not focus or expose the first invalid field.
|
||||
@@ -56,16 +74,20 @@ Flag:
|
||||
- Placeholder text used as the only label.
|
||||
- Password managers accidentally triggered on non-auth fields because autocomplete is missing or wrong.
|
||||
|
||||
Prefer visible labels. If visible surrounding text already labels the control, use a visually hidden label or a precise `aria-label`.
|
||||
Prefer visible labels and associate them through the appropriate field primitive, a native `label`, or `aria-labelledby`. Do not duplicate an existing label with hidden text or `aria-label`; follow [Accessible names and descriptions] when no suitable visible label exists.
|
||||
|
||||
## Disabled, Loading, And Async States
|
||||
|
||||
Flag:
|
||||
|
||||
- Loading state without `aria-busy`, `role="status"`, or another accessible update path when it changes user interaction.
|
||||
- Loading controls whose accessible name disappears, or whose user-relevant progress has no
|
||||
feature-owned status path. Follow the Dify UI Button contract for focused loading buttons; do not
|
||||
add `aria-busy` to a button as a generic pending-state substitute.
|
||||
- The same pending state passed to both Dify UI Button `loading` and `disabled`, which duplicates
|
||||
state ownership and obscures whether `disabled` expresses independent unavailability.
|
||||
- Spinner or decorative loading icon exposed to screen readers.
|
||||
- Disabled controls that hide the reason users cannot proceed.
|
||||
- `aria-disabled` used without manually blocking click, Space, and Enter.
|
||||
- Controls marked `aria-disabled` that still activate through supported pointer or keyboard input. Check the primitive's handling before requesting manual event guards.
|
||||
- Toasts, inline validation, or async status changes that are not announced when users need the update to continue.
|
||||
- Icon-only loading/error affordances without text or accessible status where the state matters.
|
||||
|
||||
@@ -90,7 +112,7 @@ Use Popover for explanatory content, rich help, and infotips. Use Tooltip only a
|
||||
Flag:
|
||||
|
||||
- Text in flex/grid children without `min-w-0` when it can overflow.
|
||||
- Names, labels, file names, model names, workspace names, or user content lacking `truncate`, `line-clamp`, or `break-words`.
|
||||
- Long names, labels, or user content that overflow, obscure adjacent controls, or become unreadable in supported layouts.
|
||||
- Right-side icons, badges, checks, or actions that shrink before the text area.
|
||||
- Empty arrays or empty strings rendering broken layout instead of an empty state.
|
||||
- Button, tab, badge, chip, menu item, or card text that can overlap sibling controls at common viewport widths.
|
||||
@@ -107,3 +129,7 @@ Flag:
|
||||
- Images without dimensions.
|
||||
- Loading copy using `...` instead of `…`.
|
||||
- Hardcoded dates, times, numbers, or currency formats instead of `Intl.*`.
|
||||
|
||||
[Accessible names and descriptions]: ../../../../packages/dify-ui/docs/accessible-names-and-descriptions.md
|
||||
[Page landmarks]: ../../../../web/docs/landmarks.md
|
||||
[Web Interface Guidelines]: https://raw.githubusercontent.com/vercel-labs/web-interface-guidelines/main/command.md
|
||||
|
||||
@@ -26,15 +26,17 @@ Prefer:
|
||||
|
||||
## Styling
|
||||
|
||||
For Dify UI/Base UI state styling and callback composition, apply the package's [Styling] contract,
|
||||
including its documented reasons for direct state access.
|
||||
|
||||
Flag:
|
||||
|
||||
- New CSS modules or ad hoc CSS when Tailwind utilities and Dify tokens cover the need.
|
||||
- Component-level plain `.css` files or component CSS imported through `globals.css`; use scoped `*.module.css` only when Tailwind and component variants cannot express the style.
|
||||
- Generic color utilities where Dify semantic tokens exist.
|
||||
- Hardcoded magic class values for colors, spacing, radius, shadow, z-index, or typography when Dify tokens, component variants, or documented radius mappings exist.
|
||||
- Hardcoded magic class values for colors, spacing, radius, shadow, z-index, or typography when Dify tokens, component variants, or standard Tailwind radius classes match the required design value. Apply [Styling] when choosing radius classes.
|
||||
- `!` important modifiers or important CSS overrides without a narrow, documented reason.
|
||||
- Manual string concatenation, template strings, array `.join(' ')`, or custom ternaries for conditional or multi-line classes.
|
||||
- JS conditional class branches for primitive visual states already exposed by Dify UI/Base UI `data-*` selectors.
|
||||
- Manual class-list assembly through string concatenation, template strings, array `.join(' ')`, or a custom conditional combiner instead of `cn(...)`. Conditional values passed to `cn(...)` remain valid.
|
||||
- Incoming `className` placed before default classes in `cn(...)`, preventing call-site overrides.
|
||||
- Arbitrary z-index or one-off layering fixes on overlays.
|
||||
|
||||
@@ -43,7 +45,6 @@ Use:
|
||||
- `cn(...)` from the local package or utility already used by the file.
|
||||
- Dify semantic tokens and Tailwind v4 utilities.
|
||||
- Existing component variants before one-off class forks.
|
||||
- Primitive selectors such as `data-disabled:*`, `data-checked:*`, `data-highlighted:*`, `group-data-*`, `peer-data-*`, and `has-[:focus-visible]` before adding React state or boolean props solely for styling.
|
||||
- Component-level variants, semantic tokens, and normal cascade/order before `!` overrides. Use `!` only for a contained compatibility override that cannot be expressed through the component API or local selector structure.
|
||||
|
||||
## Imports
|
||||
@@ -66,3 +67,5 @@ Flag:
|
||||
- Error messages that state only the failure and not the next step.
|
||||
|
||||
Use feature-local translation keys by default. Alias only when crossing namespaces. `pnpm i18n:check --file <name>` should pass for any touched translation namespace.
|
||||
|
||||
[Styling]: ../../../../packages/dify-ui/docs/styling.md
|
||||
|
||||
@@ -1,88 +1,31 @@
|
||||
# Component Architecture Rules
|
||||
# Component Architecture Review
|
||||
|
||||
Use these rules for React component structure, ownership, state, props, effects, and module organization.
|
||||
Use the canonical reference for the changed concern. These links share rules; they do not activate the implementation skill or its workflow.
|
||||
|
||||
## Ownership
|
||||
| Concern | Canonical rules |
|
||||
| --- | --- |
|
||||
| Vertical modules, public entrypoints, data/handler placement, wrappers, Props, and types | [Ownership] |
|
||||
| Local/Jotai state, form drafts, route identity, URL state, and persistence | [State] |
|
||||
| Effects, navigation, memoization, and subscriptions | [Runtime] |
|
||||
| Hotkeys, focus, and secondary surfaces | [Interactions] |
|
||||
|
||||
Flag:
|
||||
## Apply Rules In Their Actual Scope
|
||||
|
||||
- State, query, mutation, or handlers hoisted above the lowest component that actually uses them.
|
||||
- Parent components owning row/item actions that do not coordinate a workflow.
|
||||
- Prop drilling through multiple pass-through layers.
|
||||
- A page/tab-level section component becoming the data owner without needing a shared snapshot or shared loading/error/empty UI.
|
||||
- Feature code promoted to shared only because it appears once or might be reused later.
|
||||
Explicit team conventions are reviewable contracts, including module organization and public API boundaries. Check the documented exception before reporting a violation. Do not infer an exception solely because the code appears to work, or invent a user-facing failure for a convention finding.
|
||||
|
||||
Accept repeated TanStack Query calls in siblings when each component independently consumes the data. Cache deduplication is not a reason to hoist by itself.
|
||||
- For owner placement, trace the consumers and required lifetime. Establish whether the parent coordinates a snapshot, submission, navigation, shared UI, or persistence before asking to move state or handlers.
|
||||
- For component boundaries, identify the ownership or encapsulation the proposed extraction would improve; file length alone establishes neither.
|
||||
- For props and types, check the domain contract and public API. Do not report private props typing style alone; declaration/export syntax matters only for a documented package rule or concrete type, export, or framework defect.
|
||||
- For state and Effects, trace the source of truth, external synchronization target, and mount/reset boundary. Controlledness alone does not prove that a draft is lifted or persisted; follow the form and overlay contracts linked by [State].
|
||||
- For navigation, distinguish ordinary links from mutation success, guarded redirects, command flows, and submission side effects.
|
||||
|
||||
## Component Boundaries
|
||||
## Preserve Existing Product Contracts
|
||||
|
||||
Flag:
|
||||
During refactors, trace the interaction being moved through its real consumer. Navigation, sidebar, dropdown, webapp-list, and app-switching changes must preserve expansion controls, hover persistence, pin/delete actions, routing, keyboard/focus handling, and open-state ownership where present.
|
||||
|
||||
- React component files over 300 lines when the file mixes multiple responsibilities that can be split into focused colocated components, hooks, or utilities.
|
||||
- Shallow wrappers that only rename props or hide the real primitive.
|
||||
- Extra DOM wrappers that do not provide layout, semantics, accessibility, state ownership, or library integration.
|
||||
- Dialog/dropdown/popover hidden surfaces that obscure the parent flow when they should be extracted into a small local component.
|
||||
- Business forms, menu bodies, or one-off helpers moved away from their owner without reuse or semantic value.
|
||||
Check that the changed owner still handles reachable empty, loading, and missing optional-data states, and that primitive wrappers preserve accessible semantics and the public controlled-state contract. Report the actual lost behavior or explicit rule violation; use the package testing policy when assessing regression coverage.
|
||||
|
||||
Prefer colocated components split by actual data and state needs.
|
||||
|
||||
## Bad Component Design Patterns
|
||||
|
||||
Flag:
|
||||
|
||||
- Refactors of existing navigation, sidebar, dropdown, webapp list, or app-switching UI that do not preserve behavior-sensitive interactions such as expand/collapse arrows, hover persistence, pin/delete controls, routing, keyboard/focus handling, or open-state ownership.
|
||||
- Components that mix data fetching, mutation side effects, popup state, form validation, layout, and row rendering without a clear owner.
|
||||
- Generic components with many boolean props that encode one feature's workflow.
|
||||
- A shared component that imports feature-specific copy, routes, or API contracts.
|
||||
- A feature component that accepts pre-rendered fragments only to avoid placing ownership correctly.
|
||||
- A child component that receives both raw server data and separately derived flags for the same concept.
|
||||
- A wrapper that changes accessible semantics of the primitive it wraps.
|
||||
- A component that exposes controlled props but still keeps a competing private state for the same value.
|
||||
- A component that cannot render empty, loading, or missing optional API fields without caller-side preprocessing.
|
||||
|
||||
When existing components already own interaction logic, prefer reusing or extending them. If a refactor is necessary, preserve the old interaction contract and add or update focused tests for changed behavior.
|
||||
|
||||
## Props And Types
|
||||
|
||||
Flag:
|
||||
|
||||
- Declaration or export rewrites made only for stylistic uniformity, without changing an owned behavior or contract.
|
||||
- Named `Props` types for trivial one-off props where inline typing is clearer.
|
||||
- Props named by UI implementation instead of domain/API role.
|
||||
- API data converted too early or under a generic name that breaks traceability.
|
||||
- Callers duplicating fallback checks that the lowest rendering component already handles.
|
||||
|
||||
Do not flag `FC`, `React.FC`, function declarations, arrow functions, named exports, or default exports by syntax alone. Report them only when the chosen form causes a concrete type, lifecycle, export, framework, or enforced package-contract defect.
|
||||
|
||||
## Effects
|
||||
|
||||
Flag effects that:
|
||||
|
||||
- Transform props/state for rendering.
|
||||
- Copy one state value into another representing the same concept.
|
||||
- Handle user actions that belong in event handlers.
|
||||
- Reset state from props when a keyed reset, stable ID, or render-time derivation would work.
|
||||
- Fetch data that belongs in framework APIs or TanStack Query.
|
||||
|
||||
If an effect remains, it must synchronize with a named external system: browser API, subscription, timer, analytics-on-visibility, non-React widget, or imperative DOM integration.
|
||||
|
||||
## State Modeling
|
||||
|
||||
Flag:
|
||||
|
||||
- Storing derived booleans, disabled flags, default tabs, or loading labels that can be calculated from current query/feature state.
|
||||
- Local state used to fake server data or generated contract fields.
|
||||
- UI state persisted to localStorage when it is live app state.
|
||||
- Feature-local mock shells wired to unrelated existing APIs before the real API is confirmed.
|
||||
|
||||
Prefer render-time derivation. Keep true local state for user choices, transient input, controlled popups, and feature UI state that has no server source.
|
||||
|
||||
## Navigation
|
||||
|
||||
Flag:
|
||||
|
||||
- Imperative router navigation for ordinary links.
|
||||
- Button semantics used for navigation.
|
||||
- Navigation state hidden in component state when URL state is required for shareable filters, tabs, or pagination.
|
||||
|
||||
Use `Link` for normal navigation. Use router APIs for mutation success, guarded redirects, command flows, or form submission side effects.
|
||||
[Interactions]: ../../how-to-write-component/references/interactions.md
|
||||
[Ownership]: ../../how-to-write-component/references/ownership.md
|
||||
[Runtime]: ../../how-to-write-component/references/runtime.md
|
||||
[State]: ../../how-to-write-component/references/state.md
|
||||
|
||||
@@ -1,74 +1,28 @@
|
||||
# Data, Query, And Contract Rules
|
||||
# Data, Query, And Contract Review
|
||||
|
||||
Use these rules for generated contracts, TanStack Query, mutations, auth/SSR boundaries, URL state, and client persistence.
|
||||
[Data and queries] owns generated-client, Query options, mutation/cache, imperative access, SSR, authentication, and tenant rules. [State ownership] owns URL state and persistence. Read only the reference needed by the diff; reading a shared reference does not activate its implementation skill.
|
||||
|
||||
## Generated Contracts
|
||||
## Generated Contracts And Query Conventions
|
||||
|
||||
Flag:
|
||||
Review explicit team conventions as contracts, including direct generated options, `skipToken` for missing required input, and shared cache policy. A lint rule may enforce part of a convention; neither a green lint result nor a suppression proves the full contract is satisfied.
|
||||
|
||||
- New legacy service/helper wrappers around generated `queryOptions()` or `mutationOptions()`.
|
||||
- Continuing to use deprecated contract operations when a ready generated contract exists.
|
||||
- Assuming a generated file means an operation is ready without checking deprecated markers, schema shape, and the actual UI consumer.
|
||||
- Re-declaring API DTOs in components.
|
||||
- Adding compatibility layers instead of migrating the pointed line and deleting the old layer.
|
||||
- Establish whether the changed call belongs to a new or migrated surface and whether the generated operation is ready. Check deprecated markers, schema shape, and the real UI consumer before prescribing a migration.
|
||||
- Distinguish a pass-through wrapper from a feature hook with actual orchestration. Check whether an independent execution condition or Promise composition justifies the documented query/mutation exception.
|
||||
- Trace generated input and output types through their boundaries. Identify the exact DTO mirror, field widening, placeholder input, or lost intentional empty value when reporting a violation.
|
||||
- Check whether a local mutation callback owns feature feedback or replaces shared invalidation, retry, or cache defaults. Match optimistic changes to the current list/detail owner.
|
||||
|
||||
Backend Pydantic and OpenAPI schemas own API shape. Generated clients and schemas under `packages/contracts/generated/*` are authoritative at frontend boundaries and use the `{ params, query?, body? }` input shape.
|
||||
## Imperative Access And SSR
|
||||
|
||||
## Queries
|
||||
- Check freshness, projection, retries, and the caller's execution condition separately against [Data and queries]. Trace Promise ownership to distinguish an awaited hard gate from soft prefetching with an explicit failure owner.
|
||||
- For Server Components, identify who renders the data and who may revalidate it. Check dehydration, the same-key client consumer, error handling, and the intended Suspense/server-rendered-content contract when the diff changes streaming.
|
||||
- For auth, setup, roles, branding, or availability, trace authoritative data and the loading/fallback path. A static redirect or placeholder value cannot stand in for a request-dependent decision.
|
||||
|
||||
Flag:
|
||||
## Tenant, URL, And Persistence Boundaries
|
||||
|
||||
- `enabled` used to hide missing required input instead of `input: skipToken`.
|
||||
- Fake fallback IDs or placeholder inputs used to force a query to run.
|
||||
- Query results copied into local state for rendering.
|
||||
- Shared query behavior such as invalidation, stale defaults, or retry rules reimplemented at call sites.
|
||||
- `prefetchQuery` treated as a hard gate or as returning data/errors to the caller.
|
||||
- Trace the current workspace-switch flow and cache lifetime before reporting missing identity in a query key. Verify backend meaning before treating `workspace_id` and `tenant_id` as interchangeable.
|
||||
- For URL and storage changes, identify whether the value is shareable navigation state, live app state, a one-shot signal, or a low-frequency preference. Apply [State ownership] to that category and verify its write/reset owner.
|
||||
|
||||
Use `useQuery(consoleQuery.xxx.queryOptions(...))` or `useQuery(marketplaceQuery.xxx.queryOptions(...))` directly unless a feature hook performs real orchestration.
|
||||
Report the violated rule and applicable scope or the concrete failing path. Do not invent runtime impact when the finding is a team-convention violation.
|
||||
|
||||
## Mutations
|
||||
|
||||
Flag:
|
||||
|
||||
- Deprecated `useInvalid` or `useReset`.
|
||||
- `mutateAsync` used without a need for Promise semantics.
|
||||
- Awaited mutations without `try/catch`.
|
||||
- Components owning shared cache invalidation that belongs in query defaults.
|
||||
- Optimistic updates that do not match current list/detail ownership.
|
||||
|
||||
Use generated `mutationOptions()` directly when possible. Put shared cache behavior in `createTanstackQueryUtils(...experimental_defaults...)`.
|
||||
|
||||
## SSR, Auth, And Route Boundaries
|
||||
|
||||
Flag:
|
||||
|
||||
- Request-time auth, setup, workspace role, or tenant decisions moved into static `next.config redirects()`.
|
||||
- Dynamic role gates depending on `workspaces.current` implemented as static path redirects.
|
||||
- Authorization logic depending on soft `prefetchQuery`.
|
||||
- Removing a client fallback before server API unavailable behavior is defined.
|
||||
- Global placeholder query contracts introduced to solve a route-local Suspense issue.
|
||||
- Branding-sensitive UI reading placeholder defaults without checking pending/placeholder state.
|
||||
|
||||
Separate hard gates from soft prefetches. `fetchQuery` can be a server decision boundary; `prefetchQuery` is cache warmup.
|
||||
|
||||
## Workspace And Tenant
|
||||
|
||||
Flag:
|
||||
|
||||
- Treating workspace switch as ordinary CRUD invalidation when the current app flow performs server switch plus full reload.
|
||||
- Query keys that omit workspace/tenant identity when the query truly varies by workspace and no full reload boundary applies.
|
||||
- Mixing `workspace_id` and `tenant_id` without tracing the current backend/API contract.
|
||||
|
||||
Current Dify workspace switch should be reviewed as a tenant cache boundary first.
|
||||
|
||||
## URL State And Local Storage
|
||||
|
||||
Flag:
|
||||
|
||||
- Shareable filters, tabs, pagination, selected panels, or search state hidden only in component state.
|
||||
- One-shot navigation signals modeled as subscribed persistent state.
|
||||
- Live app state stored in localStorage.
|
||||
- Direct `window.localStorage`, `globalThis.localStorage`, or raw storage calls in app code.
|
||||
- High-frequency interaction state persisted on every change instead of on commit/settle.
|
||||
|
||||
Use URL state for shareable UI state, feature/Jotai/store state for live UI state, and `@/hooks/use-local-storage` only for low-frequency client-only preferences, dismissed notices, and UI defaults.
|
||||
[Data and queries]: ../../how-to-write-component/references/data.md
|
||||
[State ownership]: ../../how-to-write-component/references/state.md
|
||||
|
||||
@@ -1,141 +1,29 @@
|
||||
# Dify UI Rules
|
||||
# Dify UI Review Routing
|
||||
|
||||
Use these rules whenever a review touches `packages/dify-ui/` or code consuming `@langgenius/dify-ui/*`.
|
||||
Use this reference when a review touches `packages/dify-ui/` or consumes
|
||||
`@langgenius/dify-ui/*`. It routes to owner documentation; it does not redefine package
|
||||
contracts.
|
||||
|
||||
Before finalizing findings for those files, read the current local docs that apply:
|
||||
Read `packages/dify-ui/AGENTS.md` and the primitive implementation first, then only the matching
|
||||
owner:
|
||||
|
||||
- `packages/dify-ui/README.md`
|
||||
- `packages/dify-ui/AGENTS.md`
|
||||
- `web/docs/overlay.md` for floating UI
|
||||
- `packages/dify-ui/src/<primitive>/index.tsx` for the primitive being changed or consumed
|
||||
| Review area | Canonical owner |
|
||||
| ------------------------------------------ | ------------------------------------------------------------------- |
|
||||
| Package boundary and document routing | `packages/dify-ui/AGENTS.md` |
|
||||
| Imports, exports, public types, and anatomy | `packages/dify-ui/docs/authoring.md` |
|
||||
| Button or icon-only actions | `packages/dify-ui/src/button/README.md`, `packages/dify-ui/src/icon-button/README.md` |
|
||||
| Compound inputs | `packages/dify-ui/src/input-group/README.md` |
|
||||
| Forms and field semantics | `packages/dify-ui/docs/forms.md` |
|
||||
| Selection and typed values | `packages/dify-ui/docs/selection.md` |
|
||||
| Portals, layers, and floating surfaces | `packages/dify-ui/docs/overlays.md` |
|
||||
| State styling, callbacks, and Tailwind | `packages/dify-ui/docs/styling.md` |
|
||||
| Package tests and Storybook | `packages/dify-ui/docs/testing.md` |
|
||||
|
||||
## Package Boundary
|
||||
For consumer code under `web/`, also read `web/AGENTS.md` for application-owned reuse policy and
|
||||
`packages/dify-ui/README.md` for the available public subpaths.
|
||||
|
||||
Flag in `packages/dify-ui`:
|
||||
|
||||
- Imports from `web/`.
|
||||
- Dependencies on Next.js, i18n, ky, Jotai, Zustand, TanStack Query, oRPC, or business APIs.
|
||||
- Business-specific component behavior that belongs in `web/`.
|
||||
- Multiple unrelated primitives in one component folder.
|
||||
|
||||
`packages/dify-ui` is a primitive layer: Base UI headless components + `cva` + `cn` + Dify design tokens.
|
||||
|
||||
## Imports And Exports
|
||||
|
||||
Flag:
|
||||
|
||||
- Consumer imports from `@langgenius/dify-ui` without a subpath.
|
||||
- Missing `package.json#exports` entry for a new primitive.
|
||||
- Internal package imports using workspace subpaths instead of relative paths.
|
||||
- Exported props using internal-only types that consumers cannot import from the component subpath.
|
||||
- Canonical primitive boundaries or their associated public types using a redundant `Root` suffix when no higher-level convenience component exists in the same subpath.
|
||||
|
||||
Consumers use subpath exports such as `@langgenius/dify-ui/button`.
|
||||
|
||||
Canonical boundaries use the primitive name and matching public types (`Select` / `SelectProps`). Keep `Root` only to distinguish a low-level anatomy root from a higher-level convenience component (`CheckboxRoot` / `Checkbox`); implementation aliases should still show their Base UI source (`BaseSelect.Root.Props`).
|
||||
|
||||
## Props And State
|
||||
|
||||
Flag:
|
||||
|
||||
- Flattened props where related values need a discriminated union, such as `value` / `defaultValue`, `multiple` / `value`, or `clearable` / `onChange`.
|
||||
- React state used only to mirror Base UI state for class names.
|
||||
- JavaScript conditional class logic for visual states that the Dify UI/Base UI primitive already exposes through `data-*` attributes or CSS variables.
|
||||
- Controlled props added when uncontrolled DOM state or CSS variables would be enough.
|
||||
- Thin wrappers that rename Base UI parts without adding semantics.
|
||||
- Generic Base UI selection primitives wrapped without preserving their value generics, such as `Select.Root<Value, Multiple>`, `RadioGroup<Value>`, or `Radio.Root<Value>`.
|
||||
- Shared select/radio option components that type selected values as `string` while callers pass enums, unions, booleans, numbers, objects, or nullable placeholder values.
|
||||
|
||||
Prefer Base UI/Dify UI data attributes and CSS variables for visual state: `data-open`, `data-checked`, `data-disabled`, `data-highlighted`, `data-popup-open`, `group-data-*`, `peer-data-*`, `has-[:focus-visible]`, and primitive CSS variables such as anchor width or transform origin. Use JS conditional classes for product/business state that the primitive does not expose.
|
||||
|
||||
For non-string `Select` and `RadioGroup` values, prefer explicit domain generics at the root and at child value carriers. JSX children do not inherit the parent generic, so `RadioGroup<PromptMode>` should compose with `Radio<PromptMode>`, `RadioItem<PromptMode>`, or option values from a typed collection. For `Select`, prefer the Base UI `items` collection pattern for typed value-to-label rendering, and flag string coercion helpers used only to recover display labels.
|
||||
|
||||
## Forms
|
||||
|
||||
Flag:
|
||||
|
||||
- Form-like UI using unrelated `Input` and `Button` pieces without a submit boundary.
|
||||
- Text-like fields not composed through `Field`, `FieldLabel`, and `FieldControl` when using Dify UI form semantics.
|
||||
- Select fields using `FieldLabel` instead of `SelectLabel`.
|
||||
- Slider fields using a generic label instead of `SliderLabel`.
|
||||
- Checkbox/radio groups missing `Fieldset` and `FieldsetLegend`.
|
||||
- Field errors or descriptions rendered without `FieldDescription` / `FieldError` relationships.
|
||||
|
||||
`Form` is the submit boundary. Dify UI form primitives are not a form state-management framework; business validation and schema-driven behavior belong in `web/`.
|
||||
|
||||
## Overlay Contract
|
||||
|
||||
Flag:
|
||||
|
||||
- Legacy web overlay imports in new or modified code.
|
||||
- Manual portals around Dify UI overlay primitives.
|
||||
- Call-site `z-*` overrides on overlays.
|
||||
- Missing root `isolation: isolate` assumptions when debugging overlay stacking.
|
||||
- Repeated backdrop, z-index, or portal chrome at call sites.
|
||||
- Tooltip used for infotips, long text, or interactive content.
|
||||
|
||||
All Dify UI body-portalled overlays use `z-50`. Toast uses `z-60`. DOM order handles stacking between overlays.
|
||||
|
||||
## Primitive Selection
|
||||
|
||||
Flag:
|
||||
|
||||
- `Tabs` used for simple mode/filter/view selection where `SegmentedControl` is the semantic primitive.
|
||||
- `SegmentedControl` used where `tablist` / `tabpanel` semantics are required.
|
||||
- `Select` used for searchable or free-form input.
|
||||
- `Combobox` used for unrestricted search text where no selected option is remembered.
|
||||
- `Autocomplete` used for closed-list selection.
|
||||
- Tooltip or PreviewCard used for content that must be reachable on touch or by screen readers.
|
||||
|
||||
Use:
|
||||
|
||||
- `Autocomplete` for free-form text with optional suggestions.
|
||||
- `Combobox` for searchable selected values from a collection.
|
||||
- `Select` for closed, scannable option sets.
|
||||
- `Popover` for infotips, help text, rich content, or interactions.
|
||||
|
||||
## Bad Usage Patterns To Flag
|
||||
|
||||
Flag:
|
||||
|
||||
- Manually recreating UI behavior or chrome already owned by `@langgenius/dify-ui/*` or `web/app/components/base/*`, such as buttons, inputs, toggle groups, popovers, dropdown menus, alert dialogs, switches, avatars, scroll areas, toasts, borders, focus states, disabled states, segmented controls, or existing feature components.
|
||||
- Styling a raw Base UI primitive directly in `web/` when a Dify UI primitive exists.
|
||||
- Wrapping a Dify UI primitive in a feature component that hides its label, error, disabled, or focus contract.
|
||||
- Replacing a semantic primitive with a generic `div` plus classes to match a screenshot.
|
||||
- Using `Tooltip` because it is visually convenient when the content is actually help text or needs touch access.
|
||||
- Adding a `z-*` override to make a child popup appear over a parent dialog.
|
||||
- Adding a new app-level wrapper around Dialog, Drawer, Popover, Select, or Combobox that repeats portal/backdrop/positioner logic.
|
||||
- Using dify-ui `Input` as a drop-in replacement for legacy inputs that include search, clear, copy, unit, localized placeholder, or number normalization behavior.
|
||||
- Building a form row from loose text and controls instead of the matching Field/Form primitives.
|
||||
- Adding component state only to style `data-open`, `data-checked`, `data-disabled`, or highlighted states that Base UI already exposes.
|
||||
- Passing booleans down only so children can toggle classes already expressible with primitive `data-*` selectors.
|
||||
|
||||
## Tokens, Radius, And Styling
|
||||
|
||||
Flag:
|
||||
|
||||
- `radius-*` class names.
|
||||
- Custom Tailwind `borderRadius` extension for Figma radius values.
|
||||
- Generic colors where semantic Dify tokens exist.
|
||||
- Hardcoded design values where Dify tokens, component variants, or documented Figma radius mappings exist.
|
||||
- `!` important modifiers used to fight primitive styles instead of fixing the variant, selector, or component composition.
|
||||
- Manual class strings that duplicate primitive variants.
|
||||
- `min-w-(--anchor-width)` on picker popups when it defeats viewport clamping.
|
||||
|
||||
Use the Figma radius mapping from `packages/dify-ui/README.md`; for example `--radius/sm` maps to `rounded-md`, and `--radius/md` maps to `rounded-lg`.
|
||||
|
||||
Use `!` only for a tightly scoped compatibility override after confirming the primitive API, data attributes, and selector structure cannot express the state.
|
||||
|
||||
## Focus Details
|
||||
|
||||
Flag focus rings attached to the wrong element. For example, Base UI `Slider.Thumb` focuses an internal `input[type=range]`, so the visible thumb wrapper needs `has-[:focus-visible]` rather than direct wrapper `focus-visible`.
|
||||
|
||||
## Custom SVG Icons
|
||||
|
||||
Flag:
|
||||
|
||||
- New generated React icon components or JSON files under `web/app/components/base/icons/src/...` for custom SVG icons.
|
||||
- Custom SVG icons consumed outside the Tailwind `i-custom-*` icon class pipeline.
|
||||
- Generated `packages/iconify-collections/custom-*/icons.json` diffs where unrelated existing icons lost or changed intrinsic `width` or `height`.
|
||||
|
||||
New custom SVG icons belong in `packages/iconify-collections/assets/...`. Regenerate with `pnpm --filter @dify/iconify-collections generate`, validate with `pnpm --filter @dify/iconify-collections check:dimensions`, and consume the generated icon with Tailwind `i-custom-*` classes.
|
||||
Treat the implementation, public types, tests, and stories as evidence for the documented
|
||||
contract. If they disagree, identify the actual owner before reporting a finding. Read current
|
||||
official Base UI documentation and installed type declarations for upstream-derived behavior.
|
||||
Report only a reproducible contract violation or observable defect, not a preference inferred from
|
||||
this routing file.
|
||||
|
||||
@@ -71,8 +71,6 @@ Flag:
|
||||
|
||||
## React Flow
|
||||
|
||||
For workflow React Flow components, keep this Dify-specific rule:
|
||||
Use [Dify invariants] for React Flow node/edge consumption and provider availability in RAG Pipe template rendering. Callback-only reads or mutations can use `useStoreApi`.
|
||||
|
||||
- UI consumption should use React Flow hooks such as `useNodes` / `useEdges`.
|
||||
- Callback-only reads or mutations can use `useStoreApi`.
|
||||
- Node components under `web/app/components/workflow/nodes/[nodeName]/node.tsx` must not depend on workflow stores that are absent in RAG Pipe template rendering.
|
||||
[Dify invariants]: dify-invariants.md
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Testing Review Rules
|
||||
|
||||
`web/docs/test.md` is the canonical frontend testing policy. Use this file only to translate that policy into review findings.
|
||||
Use `web/docs/test.md` for tests owned by `web/` and `packages/dify-ui/docs/testing.md` for tests owned by Dify UI. These owners define their test boundaries, environments, and checks; this reference only adds review questions.
|
||||
|
||||
## Request Missing Tests When Risk Justifies Them
|
||||
|
||||
@@ -9,10 +9,11 @@ Flag missing coverage when a change alters a reachable contract such as:
|
||||
- User interaction, navigation, form submission, validation, or permissions.
|
||||
- Query or mutation behavior, URL state, persistence, or one-shot signals.
|
||||
- Loading, error, empty, and recovery states that users can encounter.
|
||||
- A hidden surface whose close-and-reopen behavior changes whether in-progress state resets or persists.
|
||||
- Accessibility-critical labels, keyboard flow, focus, disabled state, or overlay behavior.
|
||||
- A regression-prone business rule or bug fix that can be reproduced through a public boundary.
|
||||
|
||||
Do not request tests for mechanical changes, pass-through wrappers, implementation details, or visual-only styling unless they affect behavior. Low coverage alone is not a finding.
|
||||
Do not request tests for mechanical changes, pass-through wrappers, implementation details, or incidental visual styling. Low coverage alone is not a finding.
|
||||
|
||||
## Flag Low-Value or Fragile Tests
|
||||
|
||||
@@ -29,8 +30,8 @@ Flag tests that:
|
||||
|
||||
- Prefer semantic queries and accessible names.
|
||||
- Prefer real feature components when integration semantics matter.
|
||||
- Allow intentional child or provider mocks when setup would dominate the test and that boundary is covered independently.
|
||||
- Do not accept semantically inaccurate mocks of Dify UI or legacy base primitives.
|
||||
- Require a real-browser or visual verification plan when `happy-dom` cannot represent the risk.
|
||||
- Check mocks against the owning package's policy; allowed mocks must preserve the public contract and leave the behavior under review real.
|
||||
- Apply the owning package's admission policy before requesting new automation. Real-browser verification can be a one-off review; a simulator limitation alone does not justify a permanent test.
|
||||
- Check that assertions prove the claimed outcome and add evidence beyond existing tests; a browser runtime does not make weak assertions stronger.
|
||||
|
||||
Treat test quality, determinism, and regression value as the review criteria. Do not use test count or coverage percentage as a proxy for quality.
|
||||
|
||||
@@ -5,12 +5,9 @@ description: Use when writing or changing Vitest or React Testing Library tests
|
||||
|
||||
# Frontend Testing
|
||||
|
||||
`web/docs/test.md` is the single policy owner. Read it before changing frontend tests; this skill adds no separate requirements.
|
||||
Read the testing policy for the package that owns the changed tests:
|
||||
|
||||
1. Identify the observable contract and regression risk.
|
||||
2. Choose the smallest boundary that includes the behavior owner.
|
||||
3. Establish the failing case first when practical, then implement one coherent scenario.
|
||||
4. Run the focused spec before the affected suite and relevant static checks.
|
||||
5. Report the behavior verified and any remaining browser, visual, or end-to-end risk.
|
||||
- `web/`: `web/docs/test.md` owns Web test boundaries, environments, and commands.
|
||||
- `packages/dify-ui/`: `packages/dify-ui/docs/testing.md` owns primitive test boundaries, environments, Storybook, and commands.
|
||||
|
||||
Recommend deleting low-value tests as readily as adding missing behavior coverage. Use `web/docs/test.md` for policy and Web commands; use the `packages/dify-ui/README.md` Development section for Dify UI commands.
|
||||
This skill adds no parallel policy or check sequence. Follow the selected owner's requirements, including its validation commands. Recommend deleting low-value tests as readily as adding missing behavior coverage, and report the contract verified and any material verification gap.
|
||||
|
||||
@@ -7,33 +7,26 @@ description: Use when implementing or refactoring React/TypeScript components an
|
||||
|
||||
Use this skill to route component architecture decisions to its bundled references. Read only the references required by the current change.
|
||||
|
||||
## First Decisions
|
||||
|
||||
| Question | Default | Promote only when |
|
||||
| --- | --- | --- |
|
||||
| Where should code live? | In the product workflow, route, or feature owner. | Several verticals need the same stable contract. |
|
||||
| Who owns state and handlers? | The lowest visual owner that consumes them. | A parent coordinates one workflow or consistent snapshot. |
|
||||
| Should state enter Jotai? | Keep component and form state local. | Siblings need one source of truth or scoped workflow persistence. |
|
||||
| Who owns URL state? | Next.js route APIs and `nuqs`. | Atoms require a read-only route-identity bridge. |
|
||||
| Who owns remote state? | TanStack Query at the lowest consumer. | Atom state drives the query or shared derivations consume it. |
|
||||
| Is a wrapper needed? | Use the primitive or direct code. | The wrapper owns behavior, validation, state, or semantics. |
|
||||
| Is an Effect needed? | Derive during render or handle the user action. | A named external system must be synchronized. |
|
||||
|
||||
## Topic Routing
|
||||
|
||||
- Component moves, module boundaries, props, types, or owner placement: read [`references/ownership.md`][ownership].
|
||||
- Dify UI wrappers or primitive state styling: read the package's [Public API authoring] and [Styling] contracts.
|
||||
- Jotai, form drafts, route identity, URL state, or persistence: read [`references/state.md`][state].
|
||||
- Generated contracts, nullable API data, Query, mutations, SSR, auth, or workspace state: read [`references/data.md`][data].
|
||||
- Hotkeys, focus, dialogs, menus, popovers, or other secondary surfaces: read [`references/interactions.md`][interactions] and the overlay guide it references when applicable.
|
||||
- Hotkeys, focus, dialogs, menus, popovers, or other secondary surfaces: read [`references/interactions.md`][interactions] and the overlay guide it references when applicable. Also read [`references/state.md`][state] when the surface owns a draft or other local session state.
|
||||
- Effects, navigation, memoization, preloading, or render cost: read [`references/runtime.md`][runtime].
|
||||
|
||||
## Workflow
|
||||
## Scope And Verification
|
||||
|
||||
1. Identify the behavior owner and the public contract being changed.
|
||||
2. Read the nearby implementation, tests, and only the routed skill references.
|
||||
3. Implement one coherent vertical slice. Do not expand into equivalent patterns elsewhere unless the current contract cannot be completed without them.
|
||||
4. Verify observable behavior at the narrowest sufficient boundary, then run the checks documented by the owning package: `web/docs/test.md` or `web/docs/lint.md` for Web, and the `packages/dify-ui/README.md` Development section for Dify UI.
|
||||
Identify the behavior owner, state lifetime, and public contract from the nearby implementation and relevant references. Keep the change within that vertical slice unless the contract requires changes elsewhere. Verify the changed behavior and complete the owning package's required checks. For Web, read `web/docs/test.md` for test work and `web/docs/lint.md` for static checks. Dify UI verification is owned by `packages/dify-ui/docs/testing.md`.
|
||||
|
||||
## Tailwind CSS
|
||||
|
||||
- Write canonical Tailwind v4 classes; prefer canonical utilities over equivalent arbitrary values.
|
||||
- Common forms include `w-105` instead of `w-[420px]`, `px-2.25` instead of `px-[9px]`, `bg-linear-to-b` instead of `bg-gradient-to-b`, `wrap-break-word` instead of `break-words`, and `field-sizing-content` instead of `[field-sizing:content]`.
|
||||
|
||||
[Public API authoring]: ../../../packages/dify-ui/docs/authoring.md
|
||||
[Styling]: ../../../packages/dify-ui/docs/styling.md
|
||||
[data]: references/data.md
|
||||
[interactions]: references/interactions.md
|
||||
[ownership]: references/ownership.md
|
||||
|
||||
@@ -8,9 +8,10 @@ Read this document when a component consumes generated contracts, nullable API v
|
||||
- Backend Pydantic and OpenAPI schemas own API shape. Follow the generated `{ params, query?, body? }` input shape; when it is wrong, fix the backend schema and regenerate `packages/contracts/generated/*`.
|
||||
- Do not hand-write DTO mirrors, widen generated fields or enums, edit generated output, or add a parallel frontend status layer unless it models product state absent from the API.
|
||||
- Check deprecated markers, schema shape, and the actual consumer before assuming that a generated operation is ready to use.
|
||||
- When a ready generated operation exists for the changed call, migrate deprecated operations and remove the replaced layer instead of adding compatibility wrappers.
|
||||
- Normalize only at real boundaries such as user input, search, URL params, filenames, DOM IDs, or a required legacy adapter.
|
||||
- Preserve `null`, `undefined`, and intentional empty strings until the final boundary. Do not use `value || undefined` when an empty string means clearing a field.
|
||||
- Build required values in the branch that proves them. Avoid `filter(Boolean)`, truthiness filters, non-null assertions after filters, and placeholder values used only to satisfy types.
|
||||
- Build required values in the branch that proves them. Do not use truthiness filters, non-null assertions, or placeholders to conceal missing required input or discard valid `0`, `false`, or empty-string values.
|
||||
|
||||
## Queries
|
||||
|
||||
@@ -18,25 +19,40 @@ Read this document when a component consumes generated contracts, nullable API v
|
||||
- If query input comes from atom state, keep it in `atomWithQuery`; do not unwrap the atom in a component solely to call `useQuery`.
|
||||
- For missing required input, branch the whole generated input with `skipToken`. Add `enabled` only for an independent execution condition; do not put `skipToken` inside a placeholder payload or coerce IDs to empty strings.
|
||||
- Return generated `queryOptions()`, `infiniteOptions()`, or `mutationOptions()` directly from TanStack Query atoms. Pass supported options into the generated call instead of spreading into a parallel object.
|
||||
- Share the exact options between prefetch and render when they represent the same request. Do not extract option helpers merely to reuse input construction.
|
||||
- For the same logical request, preserve key, input, operation, and result contracts. Reuse exact options only when
|
||||
transport, context, and cache policy are shared; imperative and observer freshness may differ. Do not extract a helper
|
||||
merely to reuse input construction.
|
||||
- Avoid pass-through service hooks that only rename generated options. Keep feature hooks for actual orchestration or shared domain behavior.
|
||||
|
||||
## Mutations And Cache
|
||||
|
||||
- Use generated `mutationOptions()` directly for owner-local mutations.
|
||||
- Put shared invalidation, retries, and cache behavior in `createTanstackQueryUtils(...experimental_defaults...)`. Local callbacks may own toast, close, and navigation effects but must not replace shared cache policy.
|
||||
- Do not introduce deprecated `useInvalid` or `useReset` APIs.
|
||||
- Put shared invalidation, retries, and cache behavior in `createTanstackQueryUtils(...experimental_defaults...)`. In oRPC v1, caller options override defaults, including callbacks. Local callbacks may own toast, close, and navigation effects but must preserve shared cache behavior.
|
||||
- Prefer `mutate(...)`. Use `mutateAsync(...)` only when Promise composition is required, and catch awaited failures.
|
||||
- Preserve intentional empty values and current list/detail ownership when updating data. Do not add optimistic updates without a verified owner contract.
|
||||
|
||||
## Prefetch And Hidden Surfaces
|
||||
|
||||
- Prefetch expensive secondary content from the trigger or menu-open event when it benefits the visible path. Do not mount hidden subscribers solely to warm the cache.
|
||||
- `prefetchQuery` is cache warmup, not an authorization or availability gate. Use a hard fetch boundary when the server must decide whether rendering may proceed.
|
||||
- Use `query` or `infiniteQuery` for imperative access. `staleTime` defines cache acceptance; `select` projects the return
|
||||
value without replacing cached query-function data. Imperative queries default to no retries when `retry` is not
|
||||
configured, and observer-only `enabled` does not prevent an imperative call.
|
||||
- Migrate deprecated `fetchQuery`, `prefetchQuery`, `ensureQueryData`, and their infinite variants when the current `query` or `infiniteQuery` contract applies. A `staleTime` of `0` treats data as stale; a finite value accepts that freshness window; `Infinity` accepts data until invalidation; `'static'` accepts available data even after invalidation.
|
||||
- `await` blocks, `return` transfers the Promise, and `void` discards its value without handling rejection. Handle
|
||||
rejection before discarding a potentially rejecting Promise; use `.catch(noop)` only for intentional silence or
|
||||
feedback owned elsewhere. Hard server gates await the query and preserve rejection.
|
||||
|
||||
## SSR, Authentication, And Workspace
|
||||
|
||||
- Static configuration owns path-invariant routing. Request-dependent authentication, setup, role, and tenant decisions belong to SSR or runtime decision boundaries.
|
||||
- Distinguish soft SSR cache warming from authoritative decisions. Prefetched or placeholder data must not grant access or represent successful availability.
|
||||
- Treat Server Components as query prefetch-and-dehydrate owners by default. Do not render or pass an imperative query
|
||||
result when a browser observer can revalidate the same data unless ownership and freshness explicitly prevent drift.
|
||||
- Non-blocking RSC streaming requires pending-query dehydration without redacting Next.js server errors, a
|
||||
`HydrationBoundary` around the same-key client consumer, and Suspense when that content must be server-rendered.
|
||||
- Never reuse tenant-scoped state after switching workspaces. Discard it at the switch boundary or isolate it by workspace identity.
|
||||
- Trace the current switch flow before choosing cache handling: server switch plus full reload is a tenant boundary, not ordinary CRUD invalidation. Include workspace identity in varying query keys when no full-reload boundary applies, and trace the backend contract before interchanging `workspace_id` and `tenant_id`.
|
||||
- Do not make product or authorization decisions from bootstrap defaults. Wait for authoritative data, or render an explicit loading or error state.
|
||||
- Preserve an existing client fallback until server API-unavailable behavior has an explicit owner.
|
||||
- Keep loading and Suspense behavior inside the feature that owns the request. Do not add fake global data merely to bypass that boundary.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Component Interactions And Overlays
|
||||
|
||||
Read this document when a change involves application hotkeys, focus, dialogs, menus, popovers, or other secondary surfaces. Overlay primitive selection and layering are owned by the [overlay guide].
|
||||
Read this document when a change involves application hotkeys, focus, dialogs, menus, popovers, or other secondary surfaces. Overlay primitive selection and layering are owned by the [overlay contract].
|
||||
|
||||
## Focus And Semantics
|
||||
|
||||
@@ -10,22 +10,18 @@ Read this document when a change involves application hotkeys, focus, dialogs, m
|
||||
|
||||
## Keyboard Commands
|
||||
|
||||
- Distinguish application commands from widget-local keyboard semantics. Use `@tanstack/react-hotkeys` for application commands; keep menu navigation, dialog Escape handling, editor behavior, and ARIA widget keys in their local primitive or owner.
|
||||
- Use `useHotkey` or `useHotkeys` for registered commands. When an existing `onKeyDown` intentionally owns the command, use `matchesKeyboardEvent` rather than duplicating modifier parsing or adding another global listener.
|
||||
- Keep registration and keycap or menu display derived from one canonical command. Distinguish registered commands, held keys, and display-only accelerators.
|
||||
- Keep a single-owner command beside its component. Create a feature-local hotkey module only when several production files share it; tests alone do not justify extraction.
|
||||
- Make availability and scope explicit with `enabled`, `ignoreInputs`, and `target`. Put a target ref on the actual behavior owner rather than creating wrapper DOM solely for hotkey scope.
|
||||
- Preserve existing `preventDefault` and propagation behavior when migrating command APIs.
|
||||
- Test observable command behavior, disabled and input scope, target scope, and the registration/display contract at the owning feature boundary.
|
||||
- Keep widget navigation, dialog dismissal, and editor commands in their local primitive or owner.
|
||||
- For Web application commands, follow [Keyboard commands] for TanStack registration, typed bindings, targets, event consumption, display, and verification. Do not recreate that policy in a wrapper or a second command framework.
|
||||
|
||||
## Secondary Surfaces
|
||||
|
||||
- Follow `web/docs/overlay.md` for primitive choice. Dify UI primitives are the default, with package-approved Web wrappers such as `Infotip` where the overlay guide allows them.
|
||||
- Follow the [overlay contract] for primitive choice and shared mechanics. The nearest consumer `AGENTS.md` owns application-specific composite reuse policy.
|
||||
- Separate behavior ownership from placement ownership: the action may own trigger, open state, and menu content while the caller owns slots, offsets, and alignment.
|
||||
- Keep menu and dialog surfaces as siblings when a menu command opens a dialog. Mount the dialog outside popup content.
|
||||
- Mount controlled overlays unconditionally unless unmounting is required for performance or reset semantics. Prefer keyed or owner-local reset over conditional wrappers.
|
||||
- Put query and mutation work inside dialog or alert-dialog content when it should mount only after opening.
|
||||
- Prefer uncontrolled roots when the primitive can own open state. Use controlled state only for business coordination, analytics, cleanup, or explicit reset behavior.
|
||||
- Do not add manual portals or call-site z-index escalation. Fix ownership and stacking structure at the shared boundary.
|
||||
- Use the [overlay contract] to determine content lifetime and preserve the Root's closing lifecycle. Follow [state ownership] for draft placement and semantic identity; portal placement alone does not locate the state owner.
|
||||
- Place query subscriptions and mutation observers at the owner whose lifetime matches when they should run. Mounted-session work may belong inside content; work that must start or stop exactly with `open` needs an explicit open-state condition.
|
||||
- Prefer primitive-owned open state unless another owner must observe or coordinate it. Analytics callbacks and local cleanup alone do not require a controlled root.
|
||||
|
||||
[overlay guide]: ../../../../web/docs/overlay.md
|
||||
[overlay contract]: ../../../../packages/dify-ui/docs/overlays.md
|
||||
[Keyboard commands]: ../../../../web/docs/hotkeys.md
|
||||
[state ownership]: state.md
|
||||
|
||||
@@ -12,28 +12,34 @@ Read this document when adding, moving, splitting, or refactoring React componen
|
||||
|
||||
## Component Ownership
|
||||
|
||||
- Put state, data access, loading, empty, error, and handlers in the lowest visual owner that uses them.
|
||||
- Keep coordination in a parent only when it needs one consistent snapshot or coordinates submission, shared selection, batch behavior, navigation, or cross-section loading and errors.
|
||||
- Repeated TanStack Query calls in siblings are acceptable when each sibling independently consumes the data; the cache already deduplicates requests.
|
||||
- Put state, data access, loading, empty, error, and handlers in the lowest owner that uses them and whose mounted lifetime matches the required persistence.
|
||||
- Keep coordination in a parent only when it needs one consistent snapshot, the value must intentionally survive the local owner's unmount, or the parent coordinates submission, shared selection, batch behavior, navigation, or cross-section loading and errors.
|
||||
- Repeated TanStack Query hooks for the same key and input in Client Component siblings under one QueryClient are
|
||||
acceptable; shared cache is not a reason to hoist. Separate Server Component QueryClients do not share it, so
|
||||
request-level deduplication needs an identified request-local cache or verified framework or transport owner.
|
||||
- Pass stable domain identity across boundaries. Do not pass raw server data together with separately derived flags for the same concept.
|
||||
- One pass-through prop layer is acceptable. Repeated forwarding means ownership should move closer to the consumer or into feature-scoped shared state.
|
||||
- Revisit prop forwarding when intermediate components obscure the behavior owner; keep clear data flow rather than introducing shared state merely to avoid passing props.
|
||||
- Do not replace prop drilling with one large view-model hook. Move each query, derived value, and handler to the concrete owner that consumes it.
|
||||
- Keep source selection, defaults, validation, dirty checks, and payload shaping beside the workflow that owns submission.
|
||||
|
||||
## Boundaries
|
||||
|
||||
- Prefer reusing or extending the component that already owns an interaction over rebuilding that behavior in a parallel component.
|
||||
- State-heavy wizards, drawers, modals, and secondary workflows can form a small vertical surface with an entrypoint, optional feature-local state, and shallow owners matching real visual regions.
|
||||
- The entrypoint owns route integration, provider wiring, close behavior, and mounting. Composition owners handle workflow branches; the closest visual owner handles section branches.
|
||||
- The entrypoint owns route integration, provider wiring, placement, and open-state coordination. A content or session owner keeps state scoped to that mounted surface.
|
||||
- Judge hook lifetime by the component that declares the hook and the primitive's mount contract, not only by where its rendered controls appear in JSX.
|
||||
- Separate hidden dialogs, dropdowns, and popovers into small local owners when their content obscures the parent flow.
|
||||
- Keep cohesive forms, menu bodies, and one-off helpers local unless they have their own state, reuse, or semantic boundary.
|
||||
- Extract components or hooks when they clarify ownership or hide a cohesive implementation; keep logic local when extraction only shortens the file or relocates the same coordination.
|
||||
- Avoid wrapper components and wrapper DOM that only rename props, pass children through, or hide the real primitive. A wrapper must own behavior, validation, state, accessibility, layout, or library integration.
|
||||
- Keep feature workflows out of shared components: do not encode one feature through many boolean props or import its copy, routes, and API contracts into a generic component. Do not pass pre-rendered fragments merely to avoid assigning the behavior to its owner.
|
||||
- Loading states for page sections, cards, lists, tables, forms, and drawers should use skeletons scoped to the loaded content. Reserve spinners for small inline busy indicators.
|
||||
|
||||
## Components And Types
|
||||
|
||||
- Choose component declaration and export forms from the actual component contract, framework requirements, and enforced package rules. Existing style is context, not authority; do not rewrite unaffected code solely to normalize `FC`, `function`, arrow-function, named-export, or default-export forms.
|
||||
- Type simple one-off props inline. Name a `Props` type when it is reused, exported, complex, or materially clearer.
|
||||
- Use API-generated or API-returned types at component boundaries. Keep one-off UI refinements and conversions beside their owner.
|
||||
- Name props and converted data after their domain/API role, preserving traceability to the original contract.
|
||||
- Preserve domain value types for selections. Do not widen enums, unions, booleans, numbers, objects, or nullable values to `string` before a real boundary requires it.
|
||||
- Avoid generic `common.tsx` buckets and aliases that only rename another type. Name files, values, and public types after their domain role.
|
||||
- Put fallback and invariant checks in the lowest component that already renders that state. Do not extract helpers whose only purpose is hiding missing display data.
|
||||
|
||||
@@ -4,9 +4,10 @@ Read this document when a change introduces Effects, navigation side effects, me
|
||||
|
||||
## Effects
|
||||
|
||||
- Keep render pure: do not read or write `ref.current` during render except for predictable null-guarded lazy initialization. Update interaction-owned refs in event handlers, synchronize external-system refs after commit, and use state or derivation for rendered values.
|
||||
- Use Effects only to synchronize with a named external system such as a browser API, subscription, timer, analytics integration, non-React widget, or imperative DOM API.
|
||||
- Do not use Effects to transform render state, handle user actions, copy query data, reset state from props, or fetch data owned by framework APIs or TanStack Query.
|
||||
- Initialize query-backed forms with keyed remounts or surface-entry hydration instead of copying data through Effects.
|
||||
- Initialize query-backed form sessions after their defaults are available instead of copying data through Effects. Use a stable semantic identity key when the represented identity changes; use the intended surface lifecycle for per-session reset.
|
||||
|
||||
## Navigation
|
||||
|
||||
|
||||
@@ -9,18 +9,21 @@ Read this document when a change involves Jotai, form drafts, route identity, sh
|
||||
- Keep server and cache state in TanStack Query. Use existing feature stores for complex, high-frequency interaction state such as workflow canvas drag, resize, and runtime panels.
|
||||
- Use feature-owned storage only for low-frequency client preferences, dismissed notices, and UI defaults. Live application state does not belong in local storage.
|
||||
|
||||
## Forms
|
||||
## Forms And Sessions
|
||||
|
||||
- Prefer uncontrolled Dify UI form and field controls when values are only read at submit time. Initialize query-backed defaults with `defaultValue` and keyed remounts.
|
||||
- Promote form values to atoms only when another owner reacts to in-progress values, the draft must survive scoped unmounting, or several workflow steps edit the same draft.
|
||||
- Follow the [form contract] for field controlledness and the [overlay contract] for Root/content mounting and state lifetime. These primitive contracts also apply when reviewing a consumer.
|
||||
- Choose the Web draft owner from the required lifetime. Keep mounted-session drafts in the content owner; start with the lowest shared React owner when another component needs the draft or it must survive unmounting. Use feature-scoped atoms only when their coordination or persistence contract is needed.
|
||||
- For query-backed defaults, establish the form session after the required defaults are available. `defaultValue` initializes the current mount; a stable semantic identity key may create a fresh snapshot when the represented identity changes. Do not use a generated key as a routine reset command.
|
||||
- Keep validation, source priority, fallback behavior, dirty checks, and payload assembly in the workflow that owns submission.
|
||||
- Derive booleans, disabled flags, default tabs, and loading labels from current state. Do not mirror one value into competing prop, default, and local sources; controlled state alone is not a competing-source defect.
|
||||
- Do not use local state to fake server data or generated contract fields, or connect a feature mock shell to an unrelated API before its actual contract is confirmed.
|
||||
|
||||
## Route And URL State
|
||||
|
||||
- Treat `useParams`, route arguments, and `nuqs` as the owners of URL identity and updates.
|
||||
- Hydrate a primitive atom at the route or surface boundary only when query atoms or shared derived atoms require route identity. Keep URL writes in route and query-state APIs.
|
||||
- Within one route-owned feature, choose one route-identity source. Do not hydrate route identity into atoms while also threading the same ID through multiple component layers.
|
||||
- Put shareable filters, tabs, pagination, and search state in the URL. Keep one-shot navigation signals and transient UI state out of persistent subscriptions.
|
||||
- Put shareable filters, tabs, selected panels, pagination, and search state in the URL. Keep one-shot navigation signals and transient UI state out of persistent subscriptions.
|
||||
|
||||
## Jotai And Query
|
||||
|
||||
@@ -36,3 +39,6 @@ Read this document when a change involves Jotai, form drafts, route identity, sh
|
||||
- Use feature-owned storage modules built on `createLocalStorageState`; callers should not scatter direct storage access or raw keys.
|
||||
- Persist high-frequency interaction state only on commit or after updates settle.
|
||||
- Do not add ad hoc global event listeners for shared state. Centralize subscriptions through the owning atom, store, or subscription hook.
|
||||
|
||||
[form contract]: ../../../../packages/dify-ui/docs/forms.md
|
||||
[overlay contract]: ../../../../packages/dify-ui/docs/overlays.md
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Development with devcontainer
|
||||
|
||||
This project includes a devcontainer configuration that allows you to open the project in a container with a fully configured development environment.
|
||||
Both frontend and backend environments are initialized when the container is started.
|
||||
The create hook installs workspace JavaScript dependencies and `uv`; the start hook synchronizes backend dependencies. Follow the [backend setup](../api/README.md) and [frontend guide](../web/README.md) to configure environment files and start services.
|
||||
|
||||
## GitHub Codespaces
|
||||
|
||||
@@ -19,20 +19,6 @@ if you have VS Code installed, you can click the button above to open this proje
|
||||
|
||||
You can learn more in the [Dev Containers documentation](https://code.visualstudio.com/docs/devcontainers/containers).
|
||||
|
||||
## Pros of Devcontainer
|
||||
|
||||
Unified Development Environment: By using devcontainers, you can ensure that all developers are developing in the same environment, reducing the occurrence of "it works on my machine" type of issues.
|
||||
|
||||
Quick Start: New developers can set up their development environment in a few simple steps, without spending a lot of time on environment configuration.
|
||||
|
||||
Isolation: Devcontainers isolate your project from your host operating system, reducing the chance of OS updates or other application installations impacting the development environment.
|
||||
|
||||
## Cons of Devcontainer
|
||||
|
||||
Learning Curve: For developers unfamiliar with Docker and VS Code, using devcontainers may be somewhat complex.
|
||||
|
||||
Performance Impact: While usually minimal, programs running inside a devcontainer may be slightly slower than those running directly on the host.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
if you see such error message when you open this project in codespaces:
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/node:1": {
|
||||
"nodeGypDependencies": true,
|
||||
"version": "lts"
|
||||
"version": "24.20.0"
|
||||
},
|
||||
"ghcr.io/devcontainers-extra/features/npm-package:1": {
|
||||
"package": "typescript",
|
||||
@@ -46,4 +46,4 @@
|
||||
// Configure tool-specific properties.
|
||||
// "customizations": {},
|
||||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,3 +37,7 @@ indent_size = 2
|
||||
[package.json]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
# Oxlint writes its generated suppression baseline without a final newline.
|
||||
[oxlint-suppressions.json]
|
||||
insert_final_newline = false
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
have_fun: false
|
||||
memory_config:
|
||||
disabled: false
|
||||
code_review:
|
||||
disable: true
|
||||
comment_severity_threshold: MEDIUM
|
||||
max_review_comments: -1
|
||||
pull_request_opened:
|
||||
help: false
|
||||
summary: false
|
||||
code_review: false
|
||||
include_drafts: false
|
||||
ignore_patterns: []
|
||||
3
.gitattributes
vendored
3
.gitattributes
vendored
@@ -9,3 +9,6 @@
|
||||
# Codegen output must stay byte-identical across platforms so
|
||||
# `pnpm tree:check` in CI does not trip on CRLF rewrites.
|
||||
*.generated.ts text eol=lf
|
||||
|
||||
# Skill scripts run on every platform, so keep LF line endings.
|
||||
/skills/** text=auto eol=lf
|
||||
|
||||
43
.github/CODEOWNERS
vendored
43
.github/CODEOWNERS
vendored
@@ -26,24 +26,41 @@
|
||||
/cli/ @GareArc
|
||||
/.github/workflows/cli-tests.yml @GareArc
|
||||
|
||||
# Dify Agent
|
||||
/dify-agent/ @BeautyyuYanli
|
||||
|
||||
# E2E
|
||||
/e2e/ @lyzno1
|
||||
/.github/workflows/web-e2e.yml @lyzno1
|
||||
|
||||
# Backend (default owner, more specific rules below will override)
|
||||
/api/ @QuantumGhost
|
||||
|
||||
# Backend - Tests
|
||||
# Backend - Tests (default owners, domain-specific rules below will override)
|
||||
/api/tests/ @laipz8200 @QuantumGhost
|
||||
/api/tests/*/core/rag/ @JohnJyong
|
||||
/api/tests/*/services/rag_pipeline/ @JohnJyong
|
||||
/api/tests/*/services/dataset_service/ @JohnJyong
|
||||
/api/tests/*/controllers/console/datasets/ @JohnJyong
|
||||
/api/tests/*/controllers/service_api/dataset/ @JohnJyong
|
||||
/api/tests/*/vdb/ @JohnJyong
|
||||
/api/tests/*/core/plugin/ @WH-2099
|
||||
/api/tests/*/services/plugin/ @WH-2099
|
||||
/api/tests/*/controllers/inner_api/plugin/ @WH-2099
|
||||
/api/tests/*/plugin/ @WH-2099
|
||||
/api/tests/*/controllers/trigger/ @CourTeous33
|
||||
/api/tests/*/core/trigger/ @CourTeous33
|
||||
/api/tests/*/trigger/ @CourTeous33
|
||||
/api/tests/*/controllers/console/billing/ @zyssyz123
|
||||
/api/tests/*/services/enterprise/ @GareArc
|
||||
/api/tests/*/migrations/ @snakevash @laipz8200 @MRZHUH
|
||||
|
||||
# Backend - RAG (Retrieval Augmented Generation)
|
||||
/api/core/rag/ @JohnJyong
|
||||
/api/services/knowledge/ @JohnJyong
|
||||
/api/services/rag_pipeline/ @JohnJyong
|
||||
/api/services/dataset_service.py @JohnJyong
|
||||
/api/services/knowledge_service.py @JohnJyong
|
||||
/api/services/external_knowledge_service.py @JohnJyong
|
||||
/api/services/hit_testing_service.py @JohnJyong
|
||||
/api/services/metadata_service.py @JohnJyong
|
||||
/api/services/vector_service.py @JohnJyong
|
||||
/api/services/entities/knowledge_entities/ @JohnJyong
|
||||
/api/services/entities/external_knowledge_entities/ @JohnJyong
|
||||
/api/controllers/console/datasets/ @JohnJyong
|
||||
@@ -108,8 +125,8 @@
|
||||
/api/tasks/async_workflow_tasks.py @Mairuis
|
||||
|
||||
# Backend - Billing
|
||||
/api/services/billing_service.py @hj24 @zyssyz123
|
||||
/api/controllers/console/billing/ @hj24 @zyssyz123
|
||||
/api/services/billing_service.py @zyssyz123
|
||||
/api/controllers/console/billing/ @zyssyz123
|
||||
|
||||
# Backend - Enterprise
|
||||
/api/configs/enterprise/ @GareArc
|
||||
@@ -127,6 +144,12 @@
|
||||
# Frontend
|
||||
/web/ @iamjoel
|
||||
|
||||
# Frontend - Tooling
|
||||
/lint.config.ts @hyoban @lyzno1
|
||||
/eslint.config.mjs @hyoban @lyzno1
|
||||
/knip.config.ts @hyoban @lyzno1
|
||||
/vite.config.ts @hyoban @lyzno1
|
||||
|
||||
# Frontend - Platform and Features
|
||||
/web/config/ @lyzno1
|
||||
/web/env.ts @lyzno1
|
||||
@@ -245,7 +268,7 @@
|
||||
|
||||
# Frontend - Billing and Education
|
||||
/web/app/components/billing/ @iamjoel @zxhlyh
|
||||
/web/app/education-apply/ @iamjoel @zxhlyh
|
||||
/web/app/education/ @iamjoel @zxhlyh
|
||||
|
||||
# Frontend - Workspace
|
||||
/web/app/components/header/account-dropdown/workplace-selector/ @iamjoel @zxhlyh
|
||||
@@ -267,5 +290,9 @@
|
||||
/web/app/auth/refresh/route.ts @iamjoel @lyzno1
|
||||
/web/service/server.ts @iamjoel @lyzno1
|
||||
|
||||
# Frontend - Browser Mode Tests
|
||||
/web/app/**/*.browser.spec.ts @lyzno1
|
||||
/web/app/**/*.browser.spec.tsx @lyzno1
|
||||
|
||||
# Docker
|
||||
/docker/* @laipz8200
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
2
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@@ -1,7 +1,7 @@
|
||||
name: '🕷️ Bug report'
|
||||
description: Report errors or unexpected behavior
|
||||
labels:
|
||||
- bug
|
||||
- 🐞 bug
|
||||
body:
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
2
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
@@ -1,7 +1,7 @@
|
||||
name: '⭐ Feature or enhancement request'
|
||||
description: Propose something new.
|
||||
labels:
|
||||
- enhancement
|
||||
- 💪 enhancement
|
||||
body:
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
|
||||
29
.github/actions/setup-core-e2e/action.yml
vendored
Normal file
29
.github/actions/setup-core-e2e/action.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
name: Setup Core E2E Dependencies
|
||||
description: Install API dependencies alongside web dependencies and the selected browser
|
||||
|
||||
inputs:
|
||||
browser:
|
||||
description: Browser to install (chromium or webkit)
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Setup web toolchain
|
||||
uses: ./.github/actions/setup-web
|
||||
with:
|
||||
run-install: 'false'
|
||||
|
||||
- name: Setup UV and Python
|
||||
uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
|
||||
with:
|
||||
enable-cache: true
|
||||
python-version: '3.12'
|
||||
cache-dependency-glob: api/uv.lock
|
||||
|
||||
- name: Install dependencies in parallel
|
||||
shell: bash
|
||||
env:
|
||||
E2E_INSTALL_BROWSER: ${{ inputs.browser }}
|
||||
E2E_SETUP_ACTION_PATH: ${{ github.action_path }}
|
||||
run: bash "$E2E_SETUP_ACTION_PATH/install.sh"
|
||||
56
.github/actions/setup-core-e2e/install.sh
vendored
Executable file
56
.github/actions/setup-core-e2e/install.sh
vendored
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
case "${E2E_INSTALL_BROWSER:-}" in
|
||||
chromium|webkit) ;;
|
||||
*) echo "Expected chromium or webkit" >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
# Keep both branches in this step so failures are collected before tests start.
|
||||
started=$SECONDS
|
||||
timing_dir=$(mktemp -d)
|
||||
trap 'rm -rf "$timing_dir"' EXIT
|
||||
|
||||
(
|
||||
api_started=$SECONDS
|
||||
uv sync --project api --dev
|
||||
echo "$((SECONDS - api_started))" > "$timing_dir/api"
|
||||
) &
|
||||
api_pid=$!
|
||||
|
||||
(
|
||||
web_started=$SECONDS
|
||||
vp install --frozen-lockfile
|
||||
echo "$((SECONDS - web_started))" > "$timing_dir/web"
|
||||
browser_started=$SECONDS
|
||||
cd e2e
|
||||
vp run "e2e:install:ci:$E2E_INSTALL_BROWSER"
|
||||
echo "$((SECONDS - browser_started))" > "$timing_dir/browser"
|
||||
) &
|
||||
web_pid=$!
|
||||
|
||||
api_status=0
|
||||
web_status=0
|
||||
wait "$api_pid" || api_status=$?
|
||||
wait "$web_pid" || web_status=$?
|
||||
|
||||
{
|
||||
echo "### E2E dependency preparation ($E2E_INSTALL_BROWSER)"
|
||||
echo ""
|
||||
echo "Parallel install wall time: $((SECONDS - started))s"
|
||||
echo ""
|
||||
echo "| Phase | Seconds |"
|
||||
echo "| --- | ---: |"
|
||||
for phase in api web browser; do
|
||||
if [[ -f "$timing_dir/$phase" ]]; then
|
||||
echo "| $phase | $(cat "$timing_dir/$phase") |"
|
||||
fi
|
||||
done
|
||||
echo ""
|
||||
echo "API exit status: $api_status; Web/browser exit status: $web_status"
|
||||
} >> "${GITHUB_STEP_SUMMARY:-/dev/null}"
|
||||
|
||||
if (( api_status != 0 || web_status != 0 )); then
|
||||
echo "E2E dependency installation failed (API: $api_status, Web/browser: $web_status)" >&2
|
||||
exit 1
|
||||
fi
|
||||
25
.github/actions/setup-web/action.yml
vendored
25
.github/actions/setup-web/action.yml
vendored
@@ -1,16 +1,29 @@
|
||||
name: Setup Web Environment
|
||||
description: Set up Node.js, Vite+, pnpm, and web dependencies
|
||||
|
||||
inputs:
|
||||
run-install:
|
||||
description: Install web dependencies after setting up the toolchain
|
||||
default: 'true'
|
||||
cache-save:
|
||||
description: Save the dependency cache after the job completes
|
||||
default: 'true'
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
|
||||
- name: Setup pnpm and Node.js
|
||||
uses: pnpm/setup@fbda4c85fc2e1e08721cd8763afea8f48d60f024 # v3.0.0
|
||||
with:
|
||||
run_install: false
|
||||
install: false
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@143f5f385f39b1b753ffed1a01ad443811855c8b # v1.16.1
|
||||
uses: voidzero-dev/setup-vp@3754dd7dbdb32bd8f6d28b6043de13ad3a75f21f # v1.21.1
|
||||
with:
|
||||
node-version-file: .nvmrc
|
||||
node-manager: false
|
||||
package-manager: |
|
||||
pnpm: false
|
||||
npm: false
|
||||
cache: true
|
||||
run-install: true
|
||||
# Nested composite post actions can evaluate inputs in the outer scope.
|
||||
cache-save: ${{ inputs.cache-save || 'true' }}
|
||||
run-install: ${{ inputs.run-install }}
|
||||
|
||||
21
.github/actions/wait-e2e-web-build/action.yml
vendored
Normal file
21
.github/actions/wait-e2e-web-build/action.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
name: Wait for Core E2E Web Build
|
||||
description: Wait for the current workflow run's Web build artifact while the producer finishes independently
|
||||
|
||||
outputs:
|
||||
artifact-id:
|
||||
description: ID of the ready Web build artifact
|
||||
value: ${{ steps.wait.outputs.result }}
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Wait for build artifact
|
||||
id: wait
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
env:
|
||||
E2E_WAIT_ACTION_PATH: ${{ github.action_path }}
|
||||
with:
|
||||
result-encoding: string
|
||||
script: |
|
||||
const waitForBuild = require(`${process.env.E2E_WAIT_ACTION_PATH}/wait.cjs`)
|
||||
return await waitForBuild({ github, context, core, runAttempt: Number(process.env.GITHUB_RUN_ATTEMPT) })
|
||||
104
.github/actions/wait-e2e-web-build/download.cjs
vendored
Normal file
104
.github/actions/wait-e2e-web-build/download.cjs
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
const { execFile } = require('node:child_process')
|
||||
const { appendFile, mkdtemp, rm } = require('node:fs/promises')
|
||||
const os = require('node:os')
|
||||
const path = require('node:path')
|
||||
const { promisify } = require('node:util')
|
||||
const waitForBuild = require('./wait.cjs')
|
||||
|
||||
const execFileAsync = promisify(execFile)
|
||||
|
||||
async function downloadWebBuild({
|
||||
env = process.env,
|
||||
execute = execFileAsync,
|
||||
webDir = path.resolve(__dirname, '../../../web'),
|
||||
} = {}) {
|
||||
const repository = env.GITHUB_REPOSITORY
|
||||
const runId = env.GITHUB_RUN_ID
|
||||
const runAttempt = Number(env.GITHUB_RUN_ATTEMPT)
|
||||
if (
|
||||
!repository ||
|
||||
!/^\d+$/.test(runId || '') ||
|
||||
!Number.isInteger(runAttempt) ||
|
||||
runAttempt < 1 ||
|
||||
!env.GH_TOKEN
|
||||
) {
|
||||
throw new Error(
|
||||
'Downloading the Web build requires GITHUB_REPOSITORY, GITHUB_RUN_ID, GITHUB_RUN_ATTEMPT, and GH_TOKEN.',
|
||||
)
|
||||
}
|
||||
|
||||
const run = (command, args, timeout = 60_000) =>
|
||||
execute(command, args, {
|
||||
env,
|
||||
timeout,
|
||||
maxBuffer: 32 * 1024 * 1024,
|
||||
})
|
||||
const api = async (endpoint, paginate = false) => {
|
||||
const { stdout } = await run('gh', [
|
||||
'api',
|
||||
endpoint,
|
||||
...(paginate ? ['--paginate', '--slurp'] : []),
|
||||
])
|
||||
return JSON.parse(stdout)
|
||||
}
|
||||
const prefix = `repos/${repository}/actions`
|
||||
let summary = ''
|
||||
const artifactId = await waitForBuild({
|
||||
github: {
|
||||
rest: {
|
||||
actions: { listJobsForWorkflowRunAttempt: 'jobs', listWorkflowRunArtifacts: 'artifacts' },
|
||||
},
|
||||
paginate: async (kind) => {
|
||||
const endpoint =
|
||||
kind === 'jobs'
|
||||
? `${prefix}/runs/${runId}/attempts/${runAttempt}/jobs?per_page=100`
|
||||
: `${prefix}/runs/${runId}/artifacts?per_page=100`
|
||||
const pages = await api(endpoint, true)
|
||||
return pages.flatMap((page) => page[kind])
|
||||
},
|
||||
},
|
||||
context: { repo: {}, runId },
|
||||
core: {
|
||||
info: console.log,
|
||||
summary: {
|
||||
addHeading(text) {
|
||||
summary += `### ${text}\n\n`
|
||||
return this
|
||||
},
|
||||
addRaw(text) {
|
||||
summary += `${text}\n`
|
||||
return this
|
||||
},
|
||||
async write() {
|
||||
if (env.GITHUB_STEP_SUMMARY) await appendFile(env.GITHUB_STEP_SUMMARY, summary)
|
||||
},
|
||||
},
|
||||
},
|
||||
runAttempt,
|
||||
})
|
||||
|
||||
const artifact = await api(`${prefix}/artifacts/${artifactId}`)
|
||||
const directory = await mkdtemp(path.join(os.tmpdir(), 'dify-e2e-web-build-'))
|
||||
try {
|
||||
// Artifact names are immutable within a run. Use the name selected by wait.cjs,
|
||||
// including its matching upload timestamp when only consumer jobs are rerun.
|
||||
await run(
|
||||
'gh',
|
||||
['run', 'download', runId, '--repo', repository, '--name', artifact.name, '--dir', directory],
|
||||
300_000,
|
||||
)
|
||||
await run('tar', ['-xf', path.join(directory, 'e2e-web-build.tar'), '-C', webDir])
|
||||
console.log(`Web build artifact ${artifactId} extracted and ready.`)
|
||||
} finally {
|
||||
await rm(directory, { force: true, recursive: true })
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = downloadWebBuild
|
||||
|
||||
if (require.main === module) {
|
||||
downloadWebBuild().catch((error) => {
|
||||
console.error(error)
|
||||
process.exitCode = 1
|
||||
})
|
||||
}
|
||||
112
.github/actions/wait-e2e-web-build/download.test.cjs
vendored
Normal file
112
.github/actions/wait-e2e-web-build/download.test.cjs
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
const assert = require('node:assert/strict')
|
||||
const { access } = require('node:fs/promises')
|
||||
const { test } = require('node:test')
|
||||
const downloadWebBuild = require('./download.cjs')
|
||||
|
||||
function fixture({ downloadFails = false, producerFails = false } = {}) {
|
||||
const calls = []
|
||||
const env = {
|
||||
GITHUB_REPOSITORY: 'owner/repo',
|
||||
GITHUB_RUN_ID: '123',
|
||||
GITHUB_RUN_ATTEMPT: '4',
|
||||
GH_TOKEN: 'test-token',
|
||||
}
|
||||
const execute = async (command, args) => {
|
||||
calls.push({ command, args })
|
||||
if (command === 'tar') return { stdout: '' }
|
||||
if (args[0] === 'run') {
|
||||
if (downloadFails) throw new Error('artifact download failed')
|
||||
return { stdout: '' }
|
||||
}
|
||||
if (args[1].includes('/jobs?')) {
|
||||
return {
|
||||
stdout: JSON.stringify([
|
||||
{
|
||||
jobs: [
|
||||
{
|
||||
name: 'Run Web Full-Stack E2E / Prepare Core E2E Web Build',
|
||||
status: 'completed',
|
||||
conclusion: producerFails ? 'failure' : 'success',
|
||||
steps: [
|
||||
{
|
||||
name: 'Upload Web build',
|
||||
conclusion: 'success',
|
||||
started_at: '2026-09-22T04:08:08Z',
|
||||
completed_at: '2026-09-22T04:08:12Z',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]),
|
||||
}
|
||||
}
|
||||
if (args[1].includes('/artifacts?')) {
|
||||
return {
|
||||
stdout: JSON.stringify([
|
||||
{ artifacts: [] },
|
||||
{
|
||||
artifacts: [
|
||||
{
|
||||
id: 42,
|
||||
name: 'core-e2e-web-build-2',
|
||||
created_at: '2026-09-22T04:08:11Z',
|
||||
expired: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
]),
|
||||
}
|
||||
}
|
||||
assert.equal(args[1], 'repos/owner/repo/actions/artifacts/42')
|
||||
return { stdout: JSON.stringify({ name: 'core-e2e-web-build-2' }) }
|
||||
}
|
||||
return { calls, options: { env, execute, webDir: '/test/web' } }
|
||||
}
|
||||
|
||||
test('downloads the producer-selected artifact on consumer-only reruns, including paginated results', async () => {
|
||||
const { calls, options } = fixture()
|
||||
await downloadWebBuild(options)
|
||||
assert.match(calls[0].args[1], /runs\/123\/attempts\/4\/jobs/)
|
||||
const download = calls.find(({ args }) => args[0] === 'run')
|
||||
assert.deepEqual(download.args.slice(0, 7), [
|
||||
'run',
|
||||
'download',
|
||||
'123',
|
||||
'--repo',
|
||||
'owner/repo',
|
||||
'--name',
|
||||
'core-e2e-web-build-2',
|
||||
])
|
||||
const extract = calls.at(-1)
|
||||
assert.equal(extract.command, 'tar')
|
||||
assert.deepEqual(extract.args.slice(-2), ['-C', '/test/web'])
|
||||
await assert.rejects(access(download.args.at(-1)), { code: 'ENOENT' })
|
||||
})
|
||||
|
||||
test('does not extract a failed download and removes its temporary directory', async () => {
|
||||
const { calls, options } = fixture({ downloadFails: true })
|
||||
await assert.rejects(downloadWebBuild(options), /artifact download failed/)
|
||||
assert.equal(
|
||||
calls.some(({ command }) => command === 'tar'),
|
||||
false,
|
||||
)
|
||||
await assert.rejects(access(calls.at(-1).args.at(-1)), { code: 'ENOENT' })
|
||||
})
|
||||
|
||||
test('does not download or extract when the producer fails', async () => {
|
||||
const { calls, options } = fixture({ producerFails: true })
|
||||
await assert.rejects(downloadWebBuild(options), /Web build finished with failure/)
|
||||
assert.equal(calls.length, 1)
|
||||
})
|
||||
|
||||
test('requires CI metadata and credentials before starting preparation', async () => {
|
||||
const { calls, options } = fixture()
|
||||
for (const key of Object.keys(options.env)) {
|
||||
await assert.rejects(
|
||||
downloadWebBuild({ ...options, env: { ...options.env, [key]: '' } }),
|
||||
/requires GITHUB/,
|
||||
)
|
||||
}
|
||||
assert.equal(calls.length, 0)
|
||||
})
|
||||
65
.github/actions/wait-e2e-web-build/wait.cjs
vendored
Normal file
65
.github/actions/wait-e2e-web-build/wait.cjs
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
const { setTimeout: delay } = require('node:timers/promises')
|
||||
|
||||
module.exports = async function waitForBuild({
|
||||
github,
|
||||
context,
|
||||
core,
|
||||
runAttempt,
|
||||
now = Date.now,
|
||||
sleep = delay,
|
||||
timeoutMs = 30 * 60 * 1000,
|
||||
}) {
|
||||
const started = now()
|
||||
const run = { ...context.repo, run_id: context.runId, per_page: 100 }
|
||||
core.info('Waiting for core-e2e-web-build in this workflow run')
|
||||
|
||||
while (now() - started < timeoutMs) {
|
||||
const jobs = await github.paginate(github.rest.actions.listJobsForWorkflowRunAttempt, {
|
||||
...run,
|
||||
attempt_number: runAttempt,
|
||||
})
|
||||
const producer = jobs.find(
|
||||
(job) =>
|
||||
job.name === 'Prepare Core E2E Web Build' ||
|
||||
job.name.endsWith(' / Prepare Core E2E Web Build'),
|
||||
)
|
||||
if (producer?.status === 'completed' && producer.conclusion !== 'success') {
|
||||
throw new Error(
|
||||
`Web build finished with ${producer.conclusion} before publishing an artifact`,
|
||||
)
|
||||
}
|
||||
|
||||
if (producer && ['in_progress', 'completed'].includes(producer.status)) {
|
||||
const artifacts = await github.paginate(github.rest.actions.listWorkflowRunArtifacts, run)
|
||||
const upload = producer.steps?.find((step) => step.name === 'Upload Web build')
|
||||
const artifact = artifacts.find((item) => {
|
||||
if (item.expired || !/^core-e2e-web-build-[1-9]\d*$/.test(item.name)) return false
|
||||
if (producer.status === 'in_progress') {
|
||||
// A rebuilding producer must publish this attempt's immutable artifact.
|
||||
return item.name === `core-e2e-web-build-${runAttempt}`
|
||||
}
|
||||
// GitHub relabels reused successful jobs with the current run_attempt.
|
||||
// Their upload step keeps its original timestamps, identifying the artifact
|
||||
// to reuse when only consumers are rerun (including across several attempts).
|
||||
return (
|
||||
upload?.conclusion === 'success' &&
|
||||
item.created_at >= upload.started_at &&
|
||||
item.created_at <= upload.completed_at
|
||||
)
|
||||
})
|
||||
if (artifact) {
|
||||
const seconds = Math.round((now() - started) / 1000)
|
||||
core.info(`Web build artifact ${artifact.name} ready after ${seconds}s`)
|
||||
await core.summary
|
||||
.addHeading('E2E Web build wait')
|
||||
.addRaw(`Artifact wait: ${seconds}s`)
|
||||
.write()
|
||||
return String(artifact.id)
|
||||
}
|
||||
}
|
||||
|
||||
await sleep(Math.min(10000, timeoutMs - (now() - started)))
|
||||
}
|
||||
|
||||
throw new Error('Timed out waiting for core-e2e-web-build in this workflow run')
|
||||
}
|
||||
164
.github/actions/wait-e2e-web-build/wait.test.cjs
vendored
Normal file
164
.github/actions/wait-e2e-web-build/wait.test.cjs
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
const assert = require('node:assert/strict')
|
||||
const { test } = require('node:test')
|
||||
const waitForBuild = require('./wait.cjs')
|
||||
|
||||
function fixture({ artifacts = [], jobs = [producer], error, runAttempt = 2 } = {}) {
|
||||
let elapsed = 0
|
||||
const calls = []
|
||||
const summary = {
|
||||
addHeading() {
|
||||
return this
|
||||
},
|
||||
addRaw() {
|
||||
return this
|
||||
},
|
||||
async write() {},
|
||||
}
|
||||
return {
|
||||
calls,
|
||||
options: {
|
||||
context: { repo: { owner: 'owner', repo: 'repo' }, runId: 123 },
|
||||
core: { info() {}, summary },
|
||||
runAttempt,
|
||||
github: {
|
||||
rest: {
|
||||
actions: { listWorkflowRunArtifacts: 'artifacts', listJobsForWorkflowRunAttempt: 'jobs' },
|
||||
},
|
||||
async paginate(endpoint, params) {
|
||||
calls.push({ endpoint, params })
|
||||
if (error) throw error
|
||||
const values = endpoint === 'artifacts' ? artifacts : jobs
|
||||
return typeof values === 'function' ? values(elapsed) : values
|
||||
},
|
||||
},
|
||||
now: () => elapsed,
|
||||
sleep: async (ms) => {
|
||||
elapsed += ms
|
||||
},
|
||||
timeoutMs: 20000,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const producer = {
|
||||
name: 'Run Web Full-Stack E2E / Prepare Core E2E Web Build',
|
||||
status: 'in_progress',
|
||||
run_attempt: 2,
|
||||
}
|
||||
const artifact = {
|
||||
id: 42,
|
||||
name: 'core-e2e-web-build-2',
|
||||
expired: false,
|
||||
created_at: '2026-09-22T04:08:11Z',
|
||||
}
|
||||
const oldArtifact = {
|
||||
...artifact,
|
||||
id: 41,
|
||||
name: 'core-e2e-web-build-1',
|
||||
created_at: '2026-09-22T03:08:11Z',
|
||||
}
|
||||
const successfulProducer = {
|
||||
...producer,
|
||||
status: 'completed',
|
||||
conclusion: 'success',
|
||||
steps: [
|
||||
{
|
||||
name: 'Upload Web build',
|
||||
conclusion: 'success',
|
||||
started_at: '2026-09-22T04:08:08Z',
|
||||
completed_at: '2026-09-22T04:08:12Z',
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
test('starts consuming the current artifact without waiting for producer cache saves', async () => {
|
||||
const { options, calls } = fixture({ artifacts: (elapsed) => (elapsed ? [artifact] : []) })
|
||||
assert.equal(await waitForBuild(options), '42')
|
||||
assert.equal(options.now(), 10000)
|
||||
assert.deepEqual(
|
||||
calls.map((call) => call.endpoint),
|
||||
['jobs', 'artifacts', 'jobs', 'artifacts'],
|
||||
)
|
||||
for (const { endpoint, params } of calls) {
|
||||
assert.equal(params.run_id, 123)
|
||||
assert.equal(params.owner, 'owner')
|
||||
assert.equal(params.repo, 'repo')
|
||||
if (endpoint === 'jobs') assert.equal(params.attempt_number, 2)
|
||||
}
|
||||
})
|
||||
|
||||
test('full reruns ignore the old artifact until the rebuilding producer publishes this attempt', async () => {
|
||||
const { options } = fixture({
|
||||
artifacts: (elapsed) => (elapsed ? [oldArtifact, artifact] : [oldArtifact]),
|
||||
})
|
||||
assert.equal(await waitForBuild(options), '42')
|
||||
assert.equal(options.now(), 10000)
|
||||
})
|
||||
|
||||
test('does not use an old artifact before the current producer appears or while it is queued', async () => {
|
||||
const { options } = fixture({
|
||||
artifacts: [oldArtifact],
|
||||
jobs: (elapsed) => (elapsed ? [{ ...producer, status: 'queued' }] : []),
|
||||
})
|
||||
await assert.rejects(waitForBuild(options), /Timed out/)
|
||||
})
|
||||
|
||||
test('consumer-only reruns reuse the actual successful upload despite a relabeled run_attempt', async () => {
|
||||
const { options } = fixture({
|
||||
runAttempt: 4,
|
||||
artifacts: [oldArtifact, artifact],
|
||||
jobs: [{ ...successfulProducer, run_attempt: 4 }],
|
||||
})
|
||||
assert.equal(await waitForBuild(options), '42')
|
||||
assert.equal(options.now(), 0)
|
||||
})
|
||||
|
||||
for (const conclusion of ['failure', 'cancelled', 'skipped']) {
|
||||
test(`does not fall back to an old artifact when the producer finishes with ${conclusion}`, async () => {
|
||||
const { options } = fixture({
|
||||
artifacts: [oldArtifact, artifact],
|
||||
jobs: [{ ...producer, status: 'completed', conclusion }],
|
||||
})
|
||||
await assert.rejects(waitForBuild(options), new RegExp(`Web build finished with ${conclusion}`))
|
||||
assert.equal(options.now(), 0)
|
||||
})
|
||||
}
|
||||
|
||||
test('ignores unrelated and expired artifacts and stops at the deadline', async () => {
|
||||
const { options } = fixture({
|
||||
artifacts: [
|
||||
{ ...artifact, expired: true },
|
||||
{ ...artifact, name: 'other' },
|
||||
],
|
||||
})
|
||||
await assert.rejects(waitForBuild(options), /Timed out/)
|
||||
assert.equal(options.now(), 20000)
|
||||
})
|
||||
|
||||
test('completed rebuilt producers select their upload instead of the old artifact', async () => {
|
||||
const { options } = fixture({ artifacts: [oldArtifact, artifact], jobs: [successfulProducer] })
|
||||
assert.equal(await waitForBuild(options), '42')
|
||||
})
|
||||
|
||||
test('allows artifact visibility to catch up after a successful producer finishes', async () => {
|
||||
const { options } = fixture({
|
||||
artifacts: (elapsed) => (elapsed ? [oldArtifact, artifact] : [oldArtifact]),
|
||||
jobs: [successfulProducer],
|
||||
})
|
||||
assert.equal(await waitForBuild(options), '42')
|
||||
assert.equal(options.now(), 10000)
|
||||
})
|
||||
|
||||
test('does not reuse artifacts without a successful matching upload step', async () => {
|
||||
const { options } = fixture({
|
||||
artifacts: [artifact],
|
||||
jobs: [{ ...successfulProducer, steps: [] }],
|
||||
})
|
||||
await assert.rejects(waitForBuild(options), /Timed out/)
|
||||
})
|
||||
|
||||
test('reports API errors rather than silently waiting until timeout', async () => {
|
||||
const { options } = fixture({ error: new Error('Resource not accessible by integration') })
|
||||
await assert.rejects(waitForBuild(options), /Resource not accessible/)
|
||||
assert.equal(options.now(), 0)
|
||||
})
|
||||
1
.github/labeler.yml
vendored
1
.github/labeler.yml
vendored
@@ -6,7 +6,6 @@ web:
|
||||
- 'package.json'
|
||||
- 'pnpm-lock.yaml'
|
||||
- 'pnpm-workspace.yaml'
|
||||
- '.nvmrc'
|
||||
|
||||
e2e:
|
||||
- changed-files:
|
||||
|
||||
2
.github/linters/.yaml-lint.yml
vendored
2
.github/linters/.yaml-lint.yml
vendored
@@ -4,6 +4,8 @@ extends: default
|
||||
rules:
|
||||
brackets:
|
||||
max-spaces-inside: 1
|
||||
comments:
|
||||
min-spaces-from-content: 1
|
||||
comments-indentation: disable
|
||||
document-start: disable
|
||||
line-length: disable
|
||||
|
||||
6
.github/pull_request_template.md
vendored
6
.github/pull_request_template.md
vendored
@@ -1,7 +1,7 @@
|
||||
> [!IMPORTANT]
|
||||
>
|
||||
> 1. Make sure you have read our [contribution guidelines](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md)
|
||||
> 1. Ensure there is an associated issue and you have been assigned to it
|
||||
> 1. Ensure there is an associated issue
|
||||
> 1. Use the correct syntax to link this PR: `Fixes #<issue number>`.
|
||||
|
||||
## Summary
|
||||
@@ -19,6 +19,6 @@
|
||||
|
||||
- [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs)
|
||||
- [ ] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
|
||||
- [ ] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
|
||||
- [ ] I've verified the change and added or updated tests where meaningful regression risk justifies coverage.
|
||||
- [ ] I've updated the documentation accordingly.
|
||||
- [ ] I ran `make lint && make type-check` (backend) and `cd web && pnpm exec vp staged` (frontend) to appease the lint gods
|
||||
- [ ] I ran `make lint && make type-check` (backend) and `vp staged` (frontend) to appease the lint gods
|
||||
|
||||
5
.github/scripts/generate-i18n-changes.mjs
vendored
5
.github/scripts/generate-i18n-changes.mjs
vendored
@@ -8,7 +8,8 @@ const headSha = process.env.HEAD_SHA || ''
|
||||
const files = (process.env.CHANGED_FILES || '').split(/\s+/).filter(Boolean)
|
||||
const outputPath = process.env.I18N_CHANGES_OUTPUT_PATH || '/tmp/i18n-changes.json'
|
||||
|
||||
const englishPath = (fileStem) => path.join(repoRoot, 'web', 'i18n', 'en-US', `${fileStem}.json`)
|
||||
const englishPath = (fileStem) =>
|
||||
path.join(repoRoot, 'web', 'i18n', 'locales', 'en-US', `${fileStem}.json`)
|
||||
|
||||
const readCurrentJson = (fileStem) => {
|
||||
const filePath = englishPath(fileStem)
|
||||
@@ -21,7 +22,7 @@ const readBaseJson = (fileStem) => {
|
||||
if (!baseSha) return null
|
||||
|
||||
try {
|
||||
const relativePath = `web/i18n/en-US/${fileStem}.json`
|
||||
const relativePath = `web/i18n/locales/en-US/${fileStem}.json`
|
||||
const content = execFileSync('git', ['show', `${baseSha}:${relativePath}`], {
|
||||
encoding: 'utf8',
|
||||
})
|
||||
|
||||
94
.github/scripts/size-labeler.test.cjs
vendored
Normal file
94
.github/scripts/size-labeler.test.cjs
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
const fs = require('node:fs')
|
||||
const assert = require('node:assert/strict')
|
||||
const test = require('node:test')
|
||||
const source = fs.readFileSync(
|
||||
require('node:path').join(__dirname, '../workflows/size-labeler.yml'),
|
||||
'utf8',
|
||||
)
|
||||
const script = source
|
||||
.replace(/\r\n/g, '\n')
|
||||
.split(' script: |\n')[1]
|
||||
.split('\n')
|
||||
.map((l) => l.replace(/^ /, ''))
|
||||
.join('\n')
|
||||
const run = new (Object.getPrototypeOf(async function () {}).constructor)(
|
||||
'github',
|
||||
'context',
|
||||
'core',
|
||||
script,
|
||||
)
|
||||
async function scenario(files, existing = [], changed = files.length) {
|
||||
const calls = []
|
||||
const warnings = []
|
||||
const api = {
|
||||
pulls: {
|
||||
get: async () => ({ data: { changed_files: changed } }),
|
||||
listFiles: 'files',
|
||||
},
|
||||
issues: {
|
||||
listLabelsOnIssue: 'labels',
|
||||
addLabels: async (p) => calls.push(['add', p.labels[0]]),
|
||||
removeLabel: async (p) => calls.push(['remove', p.name]),
|
||||
},
|
||||
}
|
||||
await run(
|
||||
{
|
||||
rest: api,
|
||||
paginate: async (endpoint) =>
|
||||
endpoint === 'files' ? files : existing.map((name) => ({ name })),
|
||||
},
|
||||
{
|
||||
repo: { owner: 'test', repo: 'repo' },
|
||||
payload: { pull_request: { number: 1 } },
|
||||
},
|
||||
{ warning: (s) => warnings.push(s) },
|
||||
)
|
||||
return { calls, warnings }
|
||||
}
|
||||
for (const [n, label] of [
|
||||
[0, 'XS'],
|
||||
[9, 'XS'],
|
||||
[10, 'S'],
|
||||
[29, 'S'],
|
||||
[30, 'M'],
|
||||
[99, 'M'],
|
||||
[100, 'L'],
|
||||
[499, 'L'],
|
||||
[500, 'XL'],
|
||||
[999, 'XL'],
|
||||
[1000, 'XXL'],
|
||||
]) {
|
||||
test(`threshold ${n}`, async () =>
|
||||
assert.deepEqual((await scenario([{ filename: 'a.py', additions: n, deletions: 0 }])).calls, [
|
||||
['add', `size:${label}`],
|
||||
]))
|
||||
}
|
||||
test('count deletions', async () =>
|
||||
assert.deepEqual((await scenario([{ filename: 'a.py', additions: 0, deletions: 30 }])).calls, [
|
||||
['add', 'size:M'],
|
||||
]))
|
||||
test('ignore nested lockfiles', async () =>
|
||||
assert.deepEqual(
|
||||
(
|
||||
await scenario([
|
||||
{ filename: 'api/uv.lock', additions: 9000, deletions: 5 },
|
||||
{ filename: 'web/pnpm-lock.yaml', additions: 5000, deletions: 0 },
|
||||
])
|
||||
).calls,
|
||||
[['add', 'size:XS']],
|
||||
))
|
||||
test('replace stale size only', async () =>
|
||||
assert.deepEqual(
|
||||
(await scenario([{ filename: 'a.py', additions: 10, deletions: 0 }], ['size:L', 'bug', 'web']))
|
||||
.calls,
|
||||
[
|
||||
['add', 'size:S'],
|
||||
['remove', 'size:L'],
|
||||
],
|
||||
))
|
||||
test('idempotent', async () => assert.deepEqual((await scenario([], ['size:XS', 'bug'])).calls, []))
|
||||
test('incomplete file list', async () => {
|
||||
const r = await scenario([], ['size:L'], 3001)
|
||||
assert.deepEqual(r.calls, [])
|
||||
assert.equal(r.warnings.length, 1)
|
||||
})
|
||||
6
.github/workflows/accessibility-e2e.yml
vendored
6
.github/workflows/accessibility-e2e.yml
vendored
@@ -36,7 +36,7 @@ concurrency:
|
||||
jobs:
|
||||
accessibility:
|
||||
name: WCAG Level ${{ inputs.level == 'a' && 'A' || 'AA' }} · ${{ inputs.page }}
|
||||
runs-on: depot-ubuntu-24.04-4
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 120
|
||||
defaults:
|
||||
run:
|
||||
@@ -52,7 +52,7 @@ jobs:
|
||||
uses: ./.github/actions/setup-web
|
||||
|
||||
- name: Setup UV and Python
|
||||
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
|
||||
uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
|
||||
with:
|
||||
enable-cache: true
|
||||
python-version: '3.12'
|
||||
@@ -80,7 +80,7 @@ jobs:
|
||||
if [[ "$WCAG_PAGE" == "all" ]]; then
|
||||
vp run e2e:accessibility:${{ inputs.level }}
|
||||
else
|
||||
pnpm exec tsx ./scripts/run-cucumber.ts --full -- --tags "@axe and @wcag-${{ inputs.level }} and @wcag-page-$WCAG_PAGE"
|
||||
pnpm exec node ./scripts/run-cucumber.ts --full -- --tags "@axe and @wcag-${{ inputs.level }} and @wcag-page-$WCAG_PAGE"
|
||||
fi
|
||||
|
||||
- name: Upload accessibility Cucumber report
|
||||
|
||||
251
.github/workflows/api-tests.yml
vendored
251
.github/workflows/api-tests.yml
vendored
@@ -14,28 +14,79 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
api-unit-plan:
|
||||
name: Plan API unit shards
|
||||
runs-on: depot-ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Setup UV and Python
|
||||
uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
|
||||
with:
|
||||
python-version: '3.12'
|
||||
enable-cache: false
|
||||
- name: Download shared timing baseline
|
||||
# Public statistics are independent of PR refs and require no credentials.
|
||||
run: |
|
||||
if ! curl --fail --silent --show-error --location \
|
||||
--connect-timeout 5 --max-time 15 --retry 2 --retry-max-time 30 \
|
||||
https://raw.githubusercontent.com/langgenius/dify-test-infra/generated-stats/stats/test-times.json \
|
||||
--output unit-test-durations.json; then
|
||||
rm -f unit-test-durations.json
|
||||
echo '::warning::Timing baseline unavailable; using round-robin file allocation.'
|
||||
fi
|
||||
- name: Freeze file assignments for every shard
|
||||
run: |
|
||||
uv run --project api --no-sync python api/dev/pytest_sharding.py \
|
||||
--shard-index 1 --shard-total 2 \
|
||||
--durations unit-test-durations.json \
|
||||
--write-plan unit-test-plan.json \
|
||||
--split-threshold 60 \
|
||||
--ignore api/tests/unit_tests/controllers \
|
||||
api/tests/unit_tests \
|
||||
api/providers/vdb/*/tests/unit_tests \
|
||||
api/providers/trace/*/tests/unit_tests
|
||||
- name: Upload shared plan
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: api-unit-plan
|
||||
path: |
|
||||
unit-test-plan.json
|
||||
unit-test-durations.json
|
||||
retention-days: 7
|
||||
if-no-files-found: error
|
||||
|
||||
api-unit:
|
||||
name: API Unit Tests
|
||||
needs: api-unit-plan
|
||||
name: API Unit Tests (${{ matrix.python-version }}, shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }})
|
||||
runs-on: depot-ubuntu-24.04
|
||||
env:
|
||||
COVERAGE_FILE: coverage-unit
|
||||
PYTHONUNBUFFERED: '1'
|
||||
COVERAGE_FILE: coverage-unit-${{ matrix.python-version }}-${{ matrix.shardIndex }}
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
python-version:
|
||||
- '3.12'
|
||||
shardIndex:
|
||||
- 1
|
||||
- 2
|
||||
shardTotal:
|
||||
- 2
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup UV and Python
|
||||
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
|
||||
uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
|
||||
with:
|
||||
enable-cache: true
|
||||
python-version: ${{ matrix.python-version }}
|
||||
@@ -47,34 +98,116 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: uv sync --project api --dev
|
||||
|
||||
- name: Download shared plan
|
||||
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
with:
|
||||
name: api-unit-plan
|
||||
|
||||
- name: Run Unit Tests
|
||||
run: |
|
||||
uv run --project api python api/dev/pytest_sharding.py \
|
||||
--plan unit-test-plan.json \
|
||||
--shard-index "${{ matrix.shardIndex }}" \
|
||||
--shard-total "${{ matrix.shardTotal }}" \
|
||||
--ignore api/tests/unit_tests/controllers \
|
||||
api/tests/unit_tests \
|
||||
api/providers/vdb/*/tests/unit_tests \
|
||||
api/providers/trace/*/tests/unit_tests > "$RUNNER_TEMP/unit-test-files.txt"
|
||||
uv run --project api pytest \
|
||||
-p no:benchmark \
|
||||
--timeout "${PYTEST_TIMEOUT:-20}" \
|
||||
-n auto \
|
||||
api/tests/unit_tests \
|
||||
api/providers/vdb/*/tests/unit_tests \
|
||||
api/providers/trace/*/tests/unit_tests \
|
||||
--ignore=api/tests/unit_tests/controllers
|
||||
# Controller tests register Flask routes at import time, so keep them out of xdist.
|
||||
uv run --project api pytest \
|
||||
--timeout "${PYTEST_TIMEOUT:-20}" \
|
||||
--cov-append \
|
||||
api/tests/unit_tests/controllers
|
||||
-o 'addopts=-p no:opik -p no:langsmith_plugin --cov=./api --cov-branch --import-mode=importlib' \
|
||||
--cov-report= \
|
||||
--file-shard-plan unit-test-plan.json \
|
||||
--shard-index "${{ matrix.shardIndex }}" \
|
||||
--shard-total "${{ matrix.shardTotal }}" \
|
||||
--write-test-durations "test-results/durations-${{ matrix.shardIndex }}.json" \
|
||||
--junitxml=test-results/unit.xml \
|
||||
"@$RUNNER_TEMP/unit-test-files.txt"
|
||||
|
||||
- name: Upload unit test reports
|
||||
if: ${{ !cancelled() }}
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: api-test-results-unit-${{ matrix.python-version }}-${{ matrix.shardIndex }}
|
||||
path: test-results/*.xml
|
||||
if-no-files-found: warn
|
||||
retention-days: 7
|
||||
|
||||
- name: Upload successful timing observations
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: api-unit-durations-${{ matrix.shardIndex }}
|
||||
path: test-results/durations-*.json
|
||||
retention-days: 7
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Upload unit coverage data
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: api-coverage-unit
|
||||
path: coverage-unit
|
||||
name: api-coverage-unit-${{ matrix.python-version }}-${{ matrix.shardIndex }}
|
||||
path: ${{ env.COVERAGE_FILE }}
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
api-controllers:
|
||||
name: API Controller Tests (3.12)
|
||||
runs-on: depot-ubuntu-24.04
|
||||
env:
|
||||
PYTHONUNBUFFERED: '1'
|
||||
COVERAGE_FILE: coverage-controllers-3.12
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup UV and Python
|
||||
uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
|
||||
with:
|
||||
enable-cache: true
|
||||
python-version: '3.12'
|
||||
cache-dependency-glob: api/uv.lock
|
||||
|
||||
- name: Check UV lockfile
|
||||
run: uv lock --project api --check
|
||||
|
||||
- name: Install dependencies
|
||||
run: uv sync --project api --dev
|
||||
|
||||
- name: Run Controller Tests
|
||||
# Controller tests register Flask routes at import time, so keep them out of xdist.
|
||||
run: |
|
||||
uv run --project api pytest \
|
||||
--timeout "${PYTEST_TIMEOUT:-20}" \
|
||||
-o 'addopts=-p no:opik -p no:langsmith_plugin --cov=./api --cov-branch --import-mode=importlib' \
|
||||
--cov-report= \
|
||||
--junitxml=test-results/controllers.xml \
|
||||
api/tests/unit_tests/controllers
|
||||
|
||||
- name: Upload controller test reports
|
||||
if: ${{ !cancelled() }}
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: api-test-results-controllers-3.12
|
||||
path: test-results/*.xml
|
||||
if-no-files-found: warn
|
||||
retention-days: 7
|
||||
|
||||
- name: Upload controller coverage data
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: api-coverage-controllers-3.12
|
||||
path: ${{ env.COVERAGE_FILE }}
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
api-integration:
|
||||
name: API Integration Tests
|
||||
runs-on: depot-ubuntu-24.04
|
||||
name: API Integration Tests (${{ matrix.python-version }})
|
||||
runs-on: depot-ubuntu-24.04-4
|
||||
env:
|
||||
COVERAGE_FILE: coverage-integration
|
||||
COVERAGE_FILE: coverage-integration-${{ matrix.python-version }}
|
||||
STORAGE_TYPE: opendal
|
||||
OPENDAL_SCHEME: fs
|
||||
OPENDAL_FS_ROOT: /tmp/dify-storage
|
||||
@@ -82,6 +215,7 @@ jobs:
|
||||
run:
|
||||
shell: bash
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
python-version:
|
||||
- '3.12'
|
||||
@@ -90,11 +224,10 @@ jobs:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup UV and Python
|
||||
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
|
||||
uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
|
||||
with:
|
||||
enable-cache: true
|
||||
python-version: ${{ matrix.python-version }}
|
||||
@@ -111,7 +244,10 @@ jobs:
|
||||
uv run --project api pytest \
|
||||
-p no:benchmark \
|
||||
--start-middleware \
|
||||
--middleware-stop-timeout 2 \
|
||||
-n auto \
|
||||
-o 'addopts=-p no:opik -p no:langsmith_plugin --cov=./api --cov-branch --import-mode=importlib' \
|
||||
--cov-report= \
|
||||
--timeout "${PYTEST_TIMEOUT:-180}" \
|
||||
api/tests/integration_tests/workflow \
|
||||
api/tests/integration_tests/tools \
|
||||
@@ -120,8 +256,9 @@ jobs:
|
||||
- name: Upload integration coverage data
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: api-coverage-integration
|
||||
path: coverage-integration
|
||||
name: api-coverage-integration-${{ matrix.python-version }}
|
||||
path: ${{ env.COVERAGE_FILE }}
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
api-coverage:
|
||||
@@ -129,6 +266,7 @@ jobs:
|
||||
runs-on: depot-ubuntu-24.04
|
||||
needs:
|
||||
- api-unit
|
||||
- api-controllers
|
||||
- api-integration
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
@@ -141,18 +279,12 @@ jobs:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup UV and Python
|
||||
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
|
||||
uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
|
||||
with:
|
||||
enable-cache: true
|
||||
python-version: '3.12'
|
||||
cache-dependency-glob: api/uv.lock
|
||||
|
||||
- name: Install dependencies
|
||||
run: uv sync --project api --dev
|
||||
|
||||
- name: Download coverage data
|
||||
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
@@ -164,35 +296,48 @@ jobs:
|
||||
- name: Combine coverage
|
||||
run: |
|
||||
set -euo pipefail
|
||||
coverage_version=$(python3 -c 'import tomllib; print(next(p["version"] for p in tomllib.load(open("api/uv.lock", "rb"))["package"] if p["name"] == "coverage"))')
|
||||
|
||||
echo "### API Coverage" >> "$GITHUB_STEP_SUMMARY"
|
||||
echo "" >> "$GITHUB_STEP_SUMMARY"
|
||||
echo "Merged backend coverage report generated for Codecov project status." >> "$GITHUB_STEP_SUMMARY"
|
||||
echo "" >> "$GITHUB_STEP_SUMMARY"
|
||||
mapfile -t unit_coverage < <(find coverage-data -type f -name 'coverage-unit-*' -print | sort)
|
||||
mapfile -t controller_coverage < <(find coverage-data -type f -name 'coverage-controllers-*' -print | sort)
|
||||
mapfile -t integration_coverage < <(find coverage-data -type f -name 'coverage-integration-*' -print | sort)
|
||||
if [[ "${#unit_coverage[@]}" -ne 2 ]]; then
|
||||
echo "expected 2 unit coverage artifacts, found ${#unit_coverage[@]}" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "${#controller_coverage[@]}" -ne 1 ]]; then
|
||||
echo "expected 1 controller coverage artifact, found ${#controller_coverage[@]}" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "${#integration_coverage[@]}" -ne 1 ]]; then
|
||||
echo "expected 1 integration coverage artifact, found ${#integration_coverage[@]}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
unit_coverage="$(find coverage-data -type f -name coverage-unit -print -quit)"
|
||||
integration_coverage="$(find coverage-data -type f -name coverage-integration -print -quit)"
|
||||
: "${unit_coverage:?coverage-unit artifact not found}"
|
||||
: "${integration_coverage:?coverage-integration artifact not found}"
|
||||
uvx --from "coverage==$coverage_version" coverage combine "${unit_coverage[@]}" "${controller_coverage[@]}" "${integration_coverage[@]}"
|
||||
uvx --from "coverage==$coverage_version" coverage xml -o coverage.xml
|
||||
|
||||
report_file="$(mktemp)"
|
||||
uv run --project api coverage combine "$unit_coverage" "$integration_coverage"
|
||||
uv run --project api coverage report --show-missing | tee "$report_file"
|
||||
echo "Summary: \`$(tail -n 1 "$report_file")\`" >> "$GITHUB_STEP_SUMMARY"
|
||||
{
|
||||
echo ""
|
||||
echo "<details><summary>Coverage report</summary>"
|
||||
echo ""
|
||||
echo '```'
|
||||
cat "$report_file"
|
||||
echo '```'
|
||||
echo "</details>"
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
uv run --project api coverage xml -o coverage.xml
|
||||
# Reuse the XML totals instead of analyzing every source file again for a text report.
|
||||
python3 - <<'PY'
|
||||
import os
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
coverage = ET.parse("coverage.xml").getroot()
|
||||
with open(os.environ["GITHUB_STEP_SUMMARY"], "a") as summary:
|
||||
summary.write("### API Coverage\n\n")
|
||||
summary.write("Merged backend coverage report generated for Codecov project status.\n\n")
|
||||
summary.write("| Metric | Covered | Total | Coverage |\n")
|
||||
summary.write("| --- | ---: | ---: | ---: |\n")
|
||||
for label, metric in (("Lines", "lines"), ("Branches", "branches")):
|
||||
covered = int(coverage.attrib[f"{metric}-covered"])
|
||||
total = int(coverage.attrib[f"{metric}-valid"])
|
||||
percentage = f"{covered / total:.2%}" if total else "N/A"
|
||||
summary.write(f"| {label} | {covered} | {total} | {percentage} |\n")
|
||||
summary.write("\nSee Codecov for per-file coverage details.\n")
|
||||
PY
|
||||
|
||||
- name: Report coverage
|
||||
if: ${{ env.CODECOV_TOKEN != '' }}
|
||||
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
|
||||
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
|
||||
with:
|
||||
files: ./coverage.xml
|
||||
disable_search: true
|
||||
|
||||
46
.github/workflows/autofix.yml
vendored
46
.github/workflows/autofix.yml
vendored
@@ -5,8 +5,6 @@ on:
|
||||
merge_group:
|
||||
branches: ['main']
|
||||
types: [checks_requested]
|
||||
push:
|
||||
branches: ['main']
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
@@ -32,28 +30,6 @@ jobs:
|
||||
docker/.env.example
|
||||
docker/docker-compose-template.yaml
|
||||
docker/docker-compose.yaml
|
||||
- name: Check web inputs
|
||||
if: github.event_name != 'merge_group'
|
||||
id: web-changes
|
||||
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
|
||||
with:
|
||||
files: |
|
||||
web/**
|
||||
cli/**
|
||||
e2e/**
|
||||
packages/**
|
||||
sdks/nodejs-client/**
|
||||
package.json
|
||||
pnpm-lock.yaml
|
||||
pnpm-workspace.yaml
|
||||
.nvmrc
|
||||
vite.config.ts
|
||||
lint.config.ts
|
||||
eslint.config.mjs
|
||||
oxlint-suppressions.json
|
||||
eslint-suppressions.json
|
||||
.vscode/**
|
||||
.github/**
|
||||
- name: Check api inputs
|
||||
if: github.event_name != 'merge_group'
|
||||
id: api-changes
|
||||
@@ -82,13 +58,13 @@ jobs:
|
||||
dify-agent/**/*.py
|
||||
dify-agent/pyproject.toml
|
||||
dify-agent/uv.lock
|
||||
- if: github.event_name != 'merge_group'
|
||||
- if: github.event_name != 'merge_group' && (steps.docker-compose-changes.outputs.any_changed == 'true' || steps.api-changes.outputs.any_changed == 'true' || steps.frontend-contract-changes.outputs.any_changed == 'true' || steps.dify-agent-changes.outputs.any_changed == 'true')
|
||||
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
||||
with:
|
||||
python-version: '3.11'
|
||||
|
||||
- if: github.event_name != 'merge_group'
|
||||
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
|
||||
- if: github.event_name != 'merge_group' && (steps.api-changes.outputs.any_changed == 'true' || steps.frontend-contract-changes.outputs.any_changed == 'true' || steps.dify-agent-changes.outputs.any_changed == 'true')
|
||||
uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
|
||||
|
||||
- name: Generate Docker Compose
|
||||
if: github.event_name != 'merge_group' && steps.docker-compose-changes.outputs.any_changed == 'true'
|
||||
@@ -118,12 +94,6 @@ jobs:
|
||||
# Format code
|
||||
uv run ruff format .
|
||||
|
||||
- name: count migration progress
|
||||
if: github.event_name != 'merge_group' && steps.api-changes.outputs.any_changed == 'true'
|
||||
run: |
|
||||
cd api
|
||||
./cnt_base.sh
|
||||
|
||||
- name: ast-grep
|
||||
if: github.event_name != 'merge_group' && steps.api-changes.outputs.any_changed == 'true'
|
||||
run: |
|
||||
@@ -155,7 +125,7 @@ jobs:
|
||||
find . -name "*.py.bak" -type f -delete
|
||||
|
||||
- name: Setup web environment
|
||||
if: github.event_name != 'merge_group'
|
||||
if: github.event_name != 'merge_group' && steps.frontend-contract-changes.outputs.any_changed == 'true'
|
||||
uses: ./.github/actions/setup-web
|
||||
|
||||
- name: Generate API docs
|
||||
@@ -168,13 +138,5 @@ jobs:
|
||||
if: github.event_name != 'merge_group' && steps.frontend-contract-changes.outputs.any_changed == 'true'
|
||||
run: pnpm --dir packages/contracts gen-api-contract
|
||||
|
||||
- name: ESLint fallback autofix
|
||||
if: github.event_name != 'merge_group' && steps.web-changes.outputs.any_changed == 'true'
|
||||
run: pnpm lint:eslint:fix --quiet || true
|
||||
|
||||
- name: Vite+ static autofix
|
||||
if: github.event_name != 'merge_group' && (steps.web-changes.outputs.any_changed == 'true' || steps.frontend-contract-changes.outputs.any_changed == 'true')
|
||||
run: vp check --fix || true
|
||||
|
||||
- if: github.event_name != 'merge_group'
|
||||
uses: autofix-ci/action@c5b2d67aa2274e7b5a18224e8171550871fc7e4a # v1.3.4
|
||||
|
||||
41
.github/workflows/build-push.yml
vendored
41
.github/workflows/build-push.yml
vendored
@@ -103,7 +103,7 @@ jobs:
|
||||
password: ${{ env.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Set up Depot CLI
|
||||
uses: depot/setup-action@15c09a5f77a0840ad4bce955686522a257853461 # v1.7.1
|
||||
uses: depot/setup-action@91bc8495a33ebfc504ffc89e5674379ccf23c29c # v1.7.2
|
||||
|
||||
- name: Extract metadata for Docker
|
||||
id: meta
|
||||
@@ -160,10 +160,10 @@ jobs:
|
||||
file: 'docker/Dockerfile'
|
||||
steps:
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
|
||||
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
|
||||
|
||||
- name: Validate Docker image
|
||||
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
|
||||
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
|
||||
with:
|
||||
push: false
|
||||
context: ${{ matrix.build_context }}
|
||||
@@ -229,3 +229,38 @@ jobs:
|
||||
IMAGE_VERSION: ${{ steps.meta.outputs.version }}
|
||||
run: |
|
||||
docker buildx imagetools inspect "$IMAGE_NAME:$IMAGE_VERSION"
|
||||
|
||||
sync-e2b-template:
|
||||
needs: create-manifest
|
||||
runs-on: ubuntu-24.04
|
||||
if: github.repository == 'langgenius/dify' && startsWith(github.ref, 'refs/tags/')
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- project: dev
|
||||
api_key_secret: E2B_API_KEY_DEV
|
||||
- project: prod
|
||||
api_key_secret: E2B_API_KEY_PROD
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||
with:
|
||||
node-version-file: package.json
|
||||
cache: ''
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
|
||||
with:
|
||||
username: ${{ env.DOCKERHUB_USER }}
|
||||
password: ${{ env.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Sync E2B Template (${{ matrix.project }})
|
||||
env:
|
||||
E2B_API_KEY: ${{ secrets[matrix.api_key_secret] }}
|
||||
run: ./dify-agent-runtime/docker/sync-e2b-template.sh
|
||||
|
||||
61
.github/workflows/cli-e2e.yml
vendored
61
.github/workflows/cli-e2e.yml
vendored
@@ -78,7 +78,7 @@ jobs:
|
||||
ws2_app_id: ${{ steps.out.outputs.DIFY_E2E_WS2_APP_ID }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v4
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
ref: ${{ inputs.cli_ref || github.ref }}
|
||||
persist-credentials: false
|
||||
@@ -87,10 +87,9 @@ jobs:
|
||||
with:
|
||||
bun-version: latest
|
||||
|
||||
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
|
||||
- uses: pnpm/setup@fbda4c85fc2e1e08721cd8763afea8f48d60f024 # v3.0.0
|
||||
with:
|
||||
package_json_field: packageManager
|
||||
run_install: false
|
||||
install: false
|
||||
|
||||
- name: Install CLI dependencies
|
||||
working-directory: cli
|
||||
@@ -112,7 +111,7 @@ jobs:
|
||||
# ════════════════════════════════════════════════════════════════════════════
|
||||
suite-framework-output-error:
|
||||
name: 'Suite: framework + output + error-handling'
|
||||
if: ${{ inputs.suite_framework_output_error != 'false' }}
|
||||
if: ${{ inputs.suite_framework_output_error }}
|
||||
needs: provision
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
@@ -122,17 +121,15 @@ jobs:
|
||||
shell: bash
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v4
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
ref: ${{ inputs.cli_ref || github.ref }}
|
||||
persist-credentials: false
|
||||
|
||||
- uses: ./.github/actions/setup-web
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with: { bun-version: latest }
|
||||
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
|
||||
with: { package_json_field: packageManager, run_install: false }
|
||||
- run: pnpm install --frozen-lockfile
|
||||
with:
|
||||
bun-version: latest
|
||||
- run: pnpm tree:gen
|
||||
|
||||
- name: Run framework + output + error-handling
|
||||
@@ -159,7 +156,7 @@ jobs:
|
||||
# ════════════════════════════════════════════════════════════════════════════
|
||||
suite-discovery:
|
||||
name: 'Suite: discovery'
|
||||
if: ${{ inputs.suite_discovery != 'false' }}
|
||||
if: ${{ inputs.suite_discovery }}
|
||||
needs: provision
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
@@ -169,17 +166,15 @@ jobs:
|
||||
shell: bash
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v4
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
ref: ${{ inputs.cli_ref || github.ref }}
|
||||
persist-credentials: false
|
||||
|
||||
- uses: ./.github/actions/setup-web
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with: { bun-version: latest }
|
||||
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
|
||||
with: { package_json_field: packageManager, run_install: false }
|
||||
- run: pnpm install --frozen-lockfile
|
||||
with:
|
||||
bun-version: latest
|
||||
- run: pnpm tree:gen
|
||||
|
||||
- name: Run discovery suite
|
||||
@@ -207,7 +202,7 @@ jobs:
|
||||
# ════════════════════════════════════════════════════════════════════════════
|
||||
suite-run:
|
||||
name: 'Suite: run / ${{ matrix.name }}'
|
||||
if: ${{ inputs.suite_run != 'false' }}
|
||||
if: ${{ inputs.suite_run }}
|
||||
needs: provision
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
@@ -232,17 +227,15 @@ jobs:
|
||||
shell: bash
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v4
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
ref: ${{ inputs.cli_ref || github.ref }}
|
||||
persist-credentials: false
|
||||
|
||||
- uses: ./.github/actions/setup-web
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with: { bun-version: latest }
|
||||
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
|
||||
with: { package_json_field: packageManager, run_install: false }
|
||||
- run: pnpm install --frozen-lockfile
|
||||
with:
|
||||
bun-version: latest
|
||||
- run: pnpm tree:gen
|
||||
|
||||
- name: 'Run run/${{ matrix.name }}'
|
||||
@@ -273,7 +266,7 @@ jobs:
|
||||
|
||||
- name: Upload results on failure
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: e2e-run-${{ matrix.name }}-${{ github.run_id }}
|
||||
path: cli/test-results/
|
||||
@@ -284,7 +277,7 @@ jobs:
|
||||
# ════════════════════════════════════════════════════════════════════════════
|
||||
suite-auth-safe:
|
||||
name: 'Suite: auth (login / status / whoami)'
|
||||
if: ${{ inputs.suite_auth != 'false' }}
|
||||
if: ${{ inputs.suite_auth }}
|
||||
needs: provision
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
@@ -294,17 +287,15 @@ jobs:
|
||||
shell: bash
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v4
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
ref: ${{ inputs.cli_ref || github.ref }}
|
||||
persist-credentials: false
|
||||
|
||||
- uses: ./.github/actions/setup-web
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with: { bun-version: latest }
|
||||
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
|
||||
with: { package_json_field: packageManager, run_install: false }
|
||||
- run: pnpm install --frozen-lockfile
|
||||
with:
|
||||
bun-version: latest
|
||||
- run: pnpm tree:gen
|
||||
|
||||
- name: Run auth/login + status + whoami
|
||||
@@ -333,7 +324,7 @@ jobs:
|
||||
suite-last:
|
||||
name: 'Suite: auth-use + devices + logout + agent (last, serial)'
|
||||
# Runs when auth is selected; also runs after all parallel jobs finish
|
||||
if: ${{ inputs.suite_auth != 'false' || inputs.suite_agent != 'false' }}
|
||||
if: ${{ inputs.suite_auth || inputs.suite_agent }}
|
||||
needs:
|
||||
- provision
|
||||
- suite-framework-output-error
|
||||
@@ -350,17 +341,15 @@ jobs:
|
||||
shell: bash
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v4
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
ref: ${{ inputs.cli_ref || github.ref }}
|
||||
persist-credentials: false
|
||||
|
||||
- uses: ./.github/actions/setup-web
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with: { bun-version: latest }
|
||||
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
|
||||
with: { package_json_field: packageManager, run_install: false }
|
||||
- run: pnpm install --frozen-lockfile
|
||||
with:
|
||||
bun-version: latest
|
||||
- run: pnpm tree:gen
|
||||
|
||||
- name: Run use / devices / logout / agent (serial)
|
||||
@@ -407,7 +396,7 @@ jobs:
|
||||
|
||||
- name: Upload results on failure
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: e2e-last-${{ github.run_id }}
|
||||
path: cli/test-results/
|
||||
|
||||
1
.github/workflows/cli-edge.yml
vendored
1
.github/workflows/cli-edge.yml
vendored
@@ -5,6 +5,7 @@ on:
|
||||
branches: [main]
|
||||
paths:
|
||||
- 'cli/**'
|
||||
- 'skills/**'
|
||||
- 'packages/contracts/generated/api/openapi/**'
|
||||
workflow_dispatch:
|
||||
|
||||
|
||||
47
.github/workflows/cli-release.yml
vendored
47
.github/workflows/cli-release.yml
vendored
@@ -7,12 +7,22 @@ on:
|
||||
description: Dify release tag to attach difyctl assets to (blank = latest stable)
|
||||
required: false
|
||||
type: string
|
||||
dry_run:
|
||||
description: Build and checksum only — skip asset upload and stale-asset prune
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
workflow_call:
|
||||
inputs:
|
||||
release_tag:
|
||||
description: Dify release tag to attach difyctl assets to (blank = latest stable)
|
||||
required: false
|
||||
type: string
|
||||
dry_run:
|
||||
description: Build and checksum only — skip asset upload and stale-asset prune
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
release:
|
||||
types: [released]
|
||||
|
||||
@@ -39,11 +49,8 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Export manifest to env
|
||||
run: node scripts/release-naming.mjs github-env >> "$GITHUB_ENV"
|
||||
|
||||
- name: Validate manifest
|
||||
run: scripts/release-validate-manifest.sh
|
||||
run: node scripts/release-naming.mjs validate
|
||||
|
||||
- name: Resolve target Dify release
|
||||
id: resolve
|
||||
@@ -70,20 +77,6 @@ jobs:
|
||||
echo "dify_tag=${tag}" >> "$GITHUB_OUTPUT"
|
||||
echo "::notice::target Dify release ${tag}"
|
||||
|
||||
- name: Compatibility check
|
||||
env:
|
||||
DIFY_TAG: ${{ steps.resolve.outputs.dify_tag }}
|
||||
run: node scripts/release-naming.mjs compat-check "$DIFY_TAG"
|
||||
|
||||
- name: Reject duplicate difyctl version
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
if gh api "repos/${GITHUB_REPOSITORY}/git/ref/tags/${difyctlTag}" >/dev/null 2>&1; then
|
||||
echo "::error::difyctl ${version} already released (tag ${difyctlTag} exists); bump cli/package.json version"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
release:
|
||||
name: build + attach standalone binaries (all targets)
|
||||
needs: validate
|
||||
@@ -120,6 +113,7 @@ jobs:
|
||||
|
||||
- name: Compile standalone binaries (all targets)
|
||||
run: |
|
||||
CLI_VERSION="$version" \
|
||||
DIFYCTL_COMMIT="$(git rev-parse HEAD)" \
|
||||
DIFYCTL_BUILD_DATE="$(git log -1 --format=%cI HEAD)" \
|
||||
pnpm build:bin
|
||||
@@ -128,6 +122,7 @@ jobs:
|
||||
run: scripts/release-write-checksums.sh
|
||||
|
||||
- name: Attach difyctl assets to Dify release
|
||||
if: ${{ !inputs.dry_run }}
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
@@ -135,6 +130,7 @@ jobs:
|
||||
--repo "$GITHUB_REPOSITORY" --clobber
|
||||
|
||||
- name: Prune stale difyctl assets
|
||||
if: ${{ !inputs.dry_run }}
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
@@ -149,18 +145,3 @@ jobs:
|
||||
--repo "$GITHUB_REPOSITORY" --yes
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Create provenance tag
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
ref="refs/tags/${difyctlTag}"
|
||||
sha="$(git rev-parse HEAD)"
|
||||
status="$(gh api -X POST "repos/${GITHUB_REPOSITORY}/git/refs" \
|
||||
-f ref="$ref" -f sha="$sha" --silent --include 2>/dev/null \
|
||||
| awk 'NR==1 {print $2; exit}' || true)"
|
||||
case "$status" in
|
||||
201) echo "::notice::created ${ref}" ;;
|
||||
422) echo "::notice::tag ${ref} already exists; skipping (immutable)" ;;
|
||||
*) echo "::error::provenance tag ${ref} not created (HTTP ${status:-unknown})"; exit 1 ;;
|
||||
esac
|
||||
|
||||
2
.github/workflows/cli-smoke.yml
vendored
2
.github/workflows/cli-smoke.yml
vendored
@@ -51,7 +51,7 @@ jobs:
|
||||
|
||||
- name: Run smoke against live dify
|
||||
working-directory: ./cli
|
||||
run: pnpm exec tsx scripts/run-smoke.ts --base-url http://localhost:5001
|
||||
run: DIFY_SERVER=http://localhost:5001 bun scripts/run-smoke.ts
|
||||
|
||||
- name: Dump dify logs on failure
|
||||
if: failure()
|
||||
|
||||
4
.github/workflows/cli-tests.yml
vendored
4
.github/workflows/cli-tests.yml
vendored
@@ -44,14 +44,14 @@ jobs:
|
||||
|
||||
- name: Validate release manifest
|
||||
if: matrix.os == 'depot-ubuntu-24.04'
|
||||
run: scripts/release-validate-manifest.sh
|
||||
run: node scripts/release-naming.mjs validate
|
||||
|
||||
- name: CI pipeline (tree, coverage, build)
|
||||
run: pnpm run ci
|
||||
|
||||
- name: Report coverage
|
||||
if: ${{ env.CODECOV_TOKEN != '' && matrix.os == 'depot-ubuntu-24.04' }}
|
||||
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
|
||||
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
|
||||
with:
|
||||
directory: cli/coverage
|
||||
flags: cli
|
||||
|
||||
8
.github/workflows/db-migration-test.yml
vendored
8
.github/workflows/db-migration-test.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup UV and Python
|
||||
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
|
||||
uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
|
||||
with:
|
||||
enable-cache: true
|
||||
python-version: '3.12'
|
||||
@@ -40,7 +40,7 @@ jobs:
|
||||
cp envs/middleware.env.example middleware.env
|
||||
|
||||
- name: Set up Middlewares
|
||||
uses: hoverkraft-tech/compose-action@11beaa1c2dae4e8ed7b1665aa074723b6cecb0e4 # v3.0.0
|
||||
uses: hoverkraft-tech/compose-action@b659c744ee9bed25aea2307c017ad849bd104433 # v3.2.0
|
||||
with:
|
||||
compose-file: |
|
||||
docker/docker-compose.middleware.yaml
|
||||
@@ -69,7 +69,7 @@ jobs:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup UV and Python
|
||||
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
|
||||
uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
|
||||
with:
|
||||
enable-cache: true
|
||||
python-version: '3.12'
|
||||
@@ -94,7 +94,7 @@ jobs:
|
||||
sed -i 's/DB_USERNAME=postgres/DB_USERNAME=mysql/' middleware.env
|
||||
|
||||
- name: Set up Middlewares
|
||||
uses: hoverkraft-tech/compose-action@11beaa1c2dae4e8ed7b1665aa074723b6cecb0e4 # v3.0.0
|
||||
uses: hoverkraft-tech/compose-action@b659c744ee9bed25aea2307c017ad849bd104433 # v3.2.0
|
||||
with:
|
||||
compose-file: |
|
||||
docker/docker-compose.middleware.yaml
|
||||
|
||||
25
.github/workflows/deploy-hitl-im-dev.yml
vendored
Normal file
25
.github/workflows/deploy-hitl-im-dev.yml
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
name: Deploy HITL IM Dev
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ['Build and Push API & Web']
|
||||
branches:
|
||||
- 'build/feat/hitl-im-dev'
|
||||
types:
|
||||
- completed
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: depot-ubuntu-24.04
|
||||
if: |
|
||||
github.event.workflow_run.conclusion == 'success' &&
|
||||
github.event.workflow_run.head_branch == 'build/feat/hitl-im-dev'
|
||||
steps:
|
||||
- name: Deploy to server
|
||||
uses: appleboy/ssh-action@0ff4204d59e8e51228ff73bce53f80d53301dee2 # v1.2.5
|
||||
with:
|
||||
host: ${{ secrets.HITL_SSH_HOST }}
|
||||
username: ${{ secrets.SSH_USER }}
|
||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
script: |
|
||||
${{ vars.SSH_SCRIPT || secrets.SSH_SCRIPT }}
|
||||
2
.github/workflows/deploy-knowledge.yml
vendored
2
.github/workflows/deploy-knowledge.yml
vendored
@@ -67,5 +67,7 @@ jobs:
|
||||
host: ${{ secrets.SSH_NEW_RAG_HOST }}
|
||||
username: ${{ secrets.SSH_USER }}
|
||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
# Allow the shared deployment lock and Celery warm shutdown to finish.
|
||||
command_timeout: 300m
|
||||
script: |
|
||||
${{ vars.SSH_SCRIPT || secrets.SSH_SCRIPT }}
|
||||
|
||||
47
.github/workflows/dify-agent-tests.yml
vendored
Normal file
47
.github/workflows/dify-agent-tests.yml
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
name: Dify Agent Tests
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: dify-agent-tests-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
dify-agent-unit:
|
||||
name: Dify Agent Unit Tests
|
||||
runs-on: depot-ubuntu-24.04
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
working-directory: dify-agent
|
||||
strategy:
|
||||
matrix:
|
||||
python-version:
|
||||
- '3.12'
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup UV and Python
|
||||
uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
|
||||
with:
|
||||
enable-cache: true
|
||||
python-version: ${{ matrix.python-version }}
|
||||
cache-dependency-glob: dify-agent/uv.lock
|
||||
|
||||
- name: Check UV lockfile
|
||||
run: uv lock --check
|
||||
|
||||
- name: Install dependencies
|
||||
run: uv sync --extra server --dev
|
||||
|
||||
- name: Run unit tests
|
||||
run: uv run pytest
|
||||
6
.github/workflows/docker-build.yml
vendored
6
.github/workflows/docker-build.yml
vendored
@@ -65,7 +65,7 @@ jobs:
|
||||
file: 'docker/Dockerfile'
|
||||
steps:
|
||||
- name: Set up Depot CLI
|
||||
uses: depot/setup-action@15c09a5f77a0840ad4bce955686522a257853461 # v1.7.1
|
||||
uses: depot/setup-action@91bc8495a33ebfc504ffc89e5674379ccf23c29c # v1.7.2
|
||||
|
||||
- name: Build Docker Image
|
||||
uses: depot/build-push-action@98e78adca7817480b8185f474a400b451d74e287 # v1.18.0
|
||||
@@ -96,10 +96,10 @@ jobs:
|
||||
file: 'docker/Dockerfile'
|
||||
steps:
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
|
||||
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
|
||||
|
||||
- name: Build Docker Image
|
||||
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
|
||||
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
|
||||
with:
|
||||
push: false
|
||||
context: ${{ matrix.context }}
|
||||
|
||||
39
.github/workflows/image-resources.yml
vendored
Normal file
39
.github/workflows/image-resources.yml
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
name: Image optimization
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
image-resources:
|
||||
name: Image optimization
|
||||
runs-on: depot-ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
persist-credentials: false
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up workspace toolchain
|
||||
uses: ./.github/actions/setup-web
|
||||
with:
|
||||
run-install: 'false'
|
||||
|
||||
- name: Install image checker dependencies
|
||||
run: pnpm --filter @dify/image-resources... install --frozen-lockfile --ignore-scripts
|
||||
|
||||
- name: Type-check image checker
|
||||
run: pnpm --filter @dify/image-resources type-check
|
||||
|
||||
- name: Test image checker
|
||||
run: pnpm --filter @dify/image-resources test
|
||||
|
||||
- name: Check image optimization
|
||||
env:
|
||||
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
run: |
|
||||
pnpm --filter @dify/image-resources check:images --base "$BASE_SHA"
|
||||
348
.github/workflows/main-ci.yml
vendored
348
.github/workflows/main-ci.yml
vendored
@@ -15,13 +15,16 @@ permissions:
|
||||
statuses: write
|
||||
|
||||
concurrency:
|
||||
group: main-ci-${{ github.event.pull_request.number || github.event.merge_group.head_sha || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
# Pull request deduplication is owned by skip-duplicate-actions so pre_job can
|
||||
# publish should_skip before required status finalizers run.
|
||||
group: main-ci-${{ github.event.merge_group.head_sha || github.run_id }}
|
||||
cancel-in-progress: ${{ github.event_name == 'merge_group' }}
|
||||
|
||||
jobs:
|
||||
# Keep orchestration independent of the Depot pool used for test execution.
|
||||
pre_job:
|
||||
name: Skip Duplicate Checks
|
||||
runs-on: depot-ubuntu-24.04
|
||||
runs-on: ubuntu-24.04
|
||||
outputs:
|
||||
should_skip: ${{ steps.skip_check.outputs.should_skip || 'false' }}
|
||||
steps:
|
||||
@@ -35,9 +38,7 @@ jobs:
|
||||
# Check which paths were changed to determine which tests to run
|
||||
check-changes:
|
||||
name: Check Changed Files
|
||||
needs: pre_job
|
||||
if: needs.pre_job.outputs.should_skip != 'true'
|
||||
runs-on: depot-ubuntu-24.04
|
||||
runs-on: ubuntu-24.04
|
||||
outputs:
|
||||
api-changed: ${{ steps.changes.outputs.api }}
|
||||
cli-changed: ${{ steps.changes.outputs.cli }}
|
||||
@@ -46,6 +47,12 @@ jobs:
|
||||
vdb-changed: ${{ steps.changes.outputs.vdb }}
|
||||
migration-changed: ${{ steps.changes.outputs.migration }}
|
||||
sandbox-runtime-changed: ${{ steps.changes.outputs.sandbox-runtime }}
|
||||
dify-agent-changed: ${{ steps.changes.outputs.dify-agent }}
|
||||
python-style-changed: ${{ steps.changes.outputs.python-style }}
|
||||
dify-agent-style-changed: ${{ steps.changes.outputs.dify-agent-style }}
|
||||
web-style-changed: ${{ steps.changes.outputs.web-style }}
|
||||
ts-common-style-changed: ${{ steps.changes.outputs.ts-common-style }}
|
||||
superlinter-changed: ${{ steps.changes.outputs.superlinter }}
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
|
||||
@@ -56,10 +63,13 @@ jobs:
|
||||
- 'api/**'
|
||||
- 'scripts/ast_grep_guard.py'
|
||||
- 'scripts/check_no_new_getattr.py'
|
||||
- 'scripts/check_no_spec_mock.py'
|
||||
- 'scripts/check_no_new_controller_sqlalchemy.py'
|
||||
- 'scripts/lint_controller_sqlalchemy.py'
|
||||
- 'scripts/ast_grep_rules/no_new_getattr.yml'
|
||||
- 'scripts/ast_grep_rules/no_spec_mock.yml'
|
||||
- 'scripts/ast_grep_rules/no_new_controller_sqlalchemy.yml'
|
||||
- 'scripts/ast_grep_rules/no_new_session_mock.yml'
|
||||
- '.github/workflows/style.yml'
|
||||
- '.github/workflows/main-ci.yml'
|
||||
- '.github/workflows/api-tests.yml'
|
||||
@@ -72,6 +82,7 @@ jobs:
|
||||
- 'docker/volumes/sandbox/conf/**'
|
||||
cli:
|
||||
- 'cli/**'
|
||||
- 'skills/**'
|
||||
- 'packages/contracts/**'
|
||||
- 'packages/tsconfig/**'
|
||||
- 'package.json'
|
||||
@@ -79,7 +90,6 @@ jobs:
|
||||
- 'pnpm-workspace.yaml'
|
||||
- 'lint.config.ts'
|
||||
- '.npmrc'
|
||||
- '.nvmrc'
|
||||
- '.github/workflows/cli-tests.yml'
|
||||
- '.github/actions/setup-web/**'
|
||||
web:
|
||||
@@ -88,26 +98,26 @@ jobs:
|
||||
- 'package.json'
|
||||
- 'pnpm-lock.yaml'
|
||||
- 'pnpm-workspace.yaml'
|
||||
- '.nvmrc'
|
||||
- '.github/workflows/main-ci.yml'
|
||||
- '.github/workflows/web-tests.yml'
|
||||
- '.github/actions/setup-web/**'
|
||||
e2e:
|
||||
- 'api/**'
|
||||
- 'api/pyproject.toml'
|
||||
- 'api/uv.lock'
|
||||
- 'e2e/**'
|
||||
- 'web/**'
|
||||
- 'packages/**'
|
||||
- 'package.json'
|
||||
- 'pnpm-lock.yaml'
|
||||
- 'pnpm-workspace.yaml'
|
||||
- '.nvmrc'
|
||||
- 'docker/docker-compose.middleware.yaml'
|
||||
- 'docker/envs/middleware.env.example'
|
||||
- 'docker/ssrf_proxy/**'
|
||||
- 'docker/volumes/sandbox/conf/**'
|
||||
- '.github/workflows/web-e2e.yml'
|
||||
- '.github/workflows/main-ci.yml'
|
||||
- '.github/actions/setup-web/**'
|
||||
- '.github/actions/setup-core-e2e/**'
|
||||
- '.github/actions/wait-e2e-web-build/**'
|
||||
vdb:
|
||||
- 'api/core/rag/datasource/**'
|
||||
- 'api/tests/integration_tests/vdb/**'
|
||||
@@ -136,6 +146,9 @@ jobs:
|
||||
sandbox-runtime:
|
||||
- 'dify-agent-runtime/**'
|
||||
- '.github/workflows/sandbox-runtime-tests.yml'
|
||||
dify-agent:
|
||||
- 'dify-agent/**'
|
||||
- '.github/workflows/dify-agent-tests.yml'
|
||||
migration:
|
||||
- 'api/migrations/**'
|
||||
- 'api/.env.example'
|
||||
@@ -147,8 +160,70 @@ jobs:
|
||||
- 'docker/generate_docker_compose'
|
||||
- 'docker/ssrf_proxy/**'
|
||||
- 'docker/volumes/sandbox/conf/**'
|
||||
python-style:
|
||||
- 'api/**'
|
||||
- 'scripts/ast_grep_guard.py'
|
||||
- 'scripts/check_no_new_getattr.py'
|
||||
- 'scripts/check_no_spec_mock.py'
|
||||
- 'scripts/check_no_new_controller_sqlalchemy.py'
|
||||
- 'scripts/check_no_new_session_mock.py'
|
||||
- 'scripts/lint_controller_sqlalchemy.py'
|
||||
- 'scripts/ast_grep_rules/no_new_getattr.yml'
|
||||
- 'scripts/ast_grep_rules/no_spec_mock.yml'
|
||||
- 'scripts/ast_grep_rules/no_new_controller_sqlalchemy.yml'
|
||||
- 'scripts/ast_grep_rules/no_new_session_mock.yml'
|
||||
- '.github/workflows/style.yml'
|
||||
- '.github/workflows/main-ci.yml'
|
||||
dify-agent-style:
|
||||
- 'dify-agent/**'
|
||||
- '.github/workflows/style.yml'
|
||||
- '.github/workflows/main-ci.yml'
|
||||
web-style:
|
||||
- 'web/**'
|
||||
- 'e2e/**'
|
||||
- 'sdks/nodejs-client/**'
|
||||
- 'packages/**'
|
||||
- 'package.json'
|
||||
- 'pnpm-lock.yaml'
|
||||
- 'pnpm-workspace.yaml'
|
||||
- 'knip.config.ts'
|
||||
- 'scripts/check-web-production-unused-after-knip-fix.mjs'
|
||||
- '.npmrc'
|
||||
- '.github/workflows/main-ci.yml'
|
||||
- '.github/workflows/web-bundle-size.yml'
|
||||
- '.github/workflows/style.yml'
|
||||
- '.github/actions/setup-web/**'
|
||||
ts-common-style:
|
||||
- 'web/**'
|
||||
- 'cli/**'
|
||||
- 'skills/**'
|
||||
- 'e2e/**'
|
||||
- 'sdks/nodejs-client/**'
|
||||
- 'packages/**'
|
||||
- 'package.json'
|
||||
- 'pnpm-lock.yaml'
|
||||
- 'pnpm-workspace.yaml'
|
||||
- 'tsconfig.json'
|
||||
- 'vite.config.ts'
|
||||
- 'lint.config.ts'
|
||||
- 'eslint.config.mjs'
|
||||
- 'knip.config.ts'
|
||||
- 'scripts/check-web-production-unused-after-knip-fix.mjs'
|
||||
- 'oxlint-suppressions.json'
|
||||
- 'eslint-suppressions.json'
|
||||
- '.vscode/**'
|
||||
- '.github/**'
|
||||
superlinter:
|
||||
- '**.sh'
|
||||
- '**.yaml'
|
||||
- '**.yml'
|
||||
- '**Dockerfile'
|
||||
- 'dev/**'
|
||||
- '.editorconfig'
|
||||
- '.vite-hooks/**'
|
||||
|
||||
# Run tests in parallel while always emitting stable required checks.
|
||||
# Finalizers report unchanged paths directly, avoiding separate skip-only jobs.
|
||||
# Keep each required check name stable and fail closed if classification fails.
|
||||
api-tests-run:
|
||||
name: Run API Tests
|
||||
needs:
|
||||
@@ -158,17 +233,6 @@ jobs:
|
||||
uses: ./.github/workflows/api-tests.yml
|
||||
secrets: inherit
|
||||
|
||||
api-tests-skip:
|
||||
name: Skip API Tests
|
||||
needs:
|
||||
- pre_job
|
||||
- check-changes
|
||||
if: needs.pre_job.outputs.should_skip != 'true' && needs.check-changes.outputs.api-changed != 'true'
|
||||
runs-on: depot-ubuntu-24.04
|
||||
steps:
|
||||
- name: Report skipped API tests
|
||||
run: echo "No API-related changes detected; skipping API tests."
|
||||
|
||||
api-tests:
|
||||
name: API Tests
|
||||
if: ${{ always() }}
|
||||
@@ -176,21 +240,26 @@ jobs:
|
||||
- pre_job
|
||||
- check-changes
|
||||
- api-tests-run
|
||||
- api-tests-skip
|
||||
runs-on: depot-ubuntu-24.04
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Finalize API Tests status
|
||||
env:
|
||||
SHOULD_SKIP_WORKFLOW: ${{ needs.pre_job.outputs.should_skip }}
|
||||
TESTS_CHANGED: ${{ needs.check-changes.outputs.api-changed }}
|
||||
RUN_RESULT: ${{ needs.api-tests-run.result }}
|
||||
SKIP_RESULT: ${{ needs.api-tests-skip.result }}
|
||||
PRE_JOB_RESULT: ${{ needs.pre_job.result }}
|
||||
CHANGES_RESULT: ${{ needs.check-changes.result }}
|
||||
run: |
|
||||
if [[ "$SHOULD_SKIP_WORKFLOW" == 'true' ]]; then
|
||||
echo "API tests were skipped because this workflow run duplicated a successful or newer run."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "$PRE_JOB_RESULT" != 'success' || "$CHANGES_RESULT" != 'success' ]]; then
|
||||
echo "Cannot finalize tests: duplicate check=$PRE_JOB_RESULT, change detection=$CHANGES_RESULT" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$TESTS_CHANGED" == 'true' ]]; then
|
||||
if [[ "$RUN_RESULT" == 'success' ]]; then
|
||||
echo "API tests ran successfully."
|
||||
@@ -201,12 +270,12 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$SKIP_RESULT" == 'success' ]]; then
|
||||
if [[ "$TESTS_CHANGED" == 'false' && "$RUN_RESULT" == 'skipped' ]]; then
|
||||
echo "API tests were skipped because no API-related files changed."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "API tests were not required, but the skip job finished with result: $SKIP_RESULT" >&2
|
||||
echo "Unexpected test state: changed=$TESTS_CHANGED, result=$RUN_RESULT" >&2
|
||||
exit 1
|
||||
|
||||
cli-tests-run:
|
||||
@@ -218,17 +287,6 @@ jobs:
|
||||
uses: ./.github/workflows/cli-tests.yml
|
||||
secrets: inherit
|
||||
|
||||
cli-tests-skip:
|
||||
name: Skip CLI Tests
|
||||
needs:
|
||||
- pre_job
|
||||
- check-changes
|
||||
if: needs.pre_job.outputs.should_skip != 'true' && needs.check-changes.outputs.cli-changed != 'true'
|
||||
runs-on: depot-ubuntu-24.04
|
||||
steps:
|
||||
- name: Report skipped CLI tests
|
||||
run: echo "No CLI-related changes detected; skipping CLI tests."
|
||||
|
||||
cli-tests:
|
||||
name: CLI Tests
|
||||
if: ${{ always() }}
|
||||
@@ -236,21 +294,26 @@ jobs:
|
||||
- pre_job
|
||||
- check-changes
|
||||
- cli-tests-run
|
||||
- cli-tests-skip
|
||||
runs-on: depot-ubuntu-24.04
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Finalize CLI Tests status
|
||||
env:
|
||||
SHOULD_SKIP_WORKFLOW: ${{ needs.pre_job.outputs.should_skip }}
|
||||
TESTS_CHANGED: ${{ needs.check-changes.outputs.cli-changed }}
|
||||
RUN_RESULT: ${{ needs.cli-tests-run.result }}
|
||||
SKIP_RESULT: ${{ needs.cli-tests-skip.result }}
|
||||
PRE_JOB_RESULT: ${{ needs.pre_job.result }}
|
||||
CHANGES_RESULT: ${{ needs.check-changes.result }}
|
||||
run: |
|
||||
if [[ "$SHOULD_SKIP_WORKFLOW" == 'true' ]]; then
|
||||
echo "CLI tests were skipped because this workflow run duplicated a successful or newer run."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "$PRE_JOB_RESULT" != 'success' || "$CHANGES_RESULT" != 'success' ]]; then
|
||||
echo "Cannot finalize tests: duplicate check=$PRE_JOB_RESULT, change detection=$CHANGES_RESULT" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$TESTS_CHANGED" == 'true' ]]; then
|
||||
if [[ "$RUN_RESULT" == 'success' ]]; then
|
||||
echo "CLI tests ran successfully."
|
||||
@@ -261,12 +324,12 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$SKIP_RESULT" == 'success' ]]; then
|
||||
if [[ "$TESTS_CHANGED" == 'false' && "$RUN_RESULT" == 'skipped' ]]; then
|
||||
echo "CLI tests were skipped because no CLI-related files changed."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "CLI tests were not required, but the skip job finished with result: $SKIP_RESULT" >&2
|
||||
echo "Unexpected test state: changed=$TESTS_CHANGED, result=$RUN_RESULT" >&2
|
||||
exit 1
|
||||
|
||||
web-tests-run:
|
||||
@@ -278,17 +341,6 @@ jobs:
|
||||
uses: ./.github/workflows/web-tests.yml
|
||||
secrets: inherit
|
||||
|
||||
web-tests-skip:
|
||||
name: Skip Web Tests
|
||||
needs:
|
||||
- pre_job
|
||||
- check-changes
|
||||
if: needs.pre_job.outputs.should_skip != 'true' && needs.check-changes.outputs.web-changed != 'true'
|
||||
runs-on: depot-ubuntu-24.04
|
||||
steps:
|
||||
- name: Report skipped web tests
|
||||
run: echo "No web-related changes detected; skipping web tests."
|
||||
|
||||
web-tests:
|
||||
name: Web Tests
|
||||
if: ${{ always() }}
|
||||
@@ -296,21 +348,26 @@ jobs:
|
||||
- pre_job
|
||||
- check-changes
|
||||
- web-tests-run
|
||||
- web-tests-skip
|
||||
runs-on: depot-ubuntu-24.04
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Finalize Web Tests status
|
||||
env:
|
||||
SHOULD_SKIP_WORKFLOW: ${{ needs.pre_job.outputs.should_skip }}
|
||||
TESTS_CHANGED: ${{ needs.check-changes.outputs.web-changed }}
|
||||
RUN_RESULT: ${{ needs.web-tests-run.result }}
|
||||
SKIP_RESULT: ${{ needs.web-tests-skip.result }}
|
||||
PRE_JOB_RESULT: ${{ needs.pre_job.result }}
|
||||
CHANGES_RESULT: ${{ needs.check-changes.result }}
|
||||
run: |
|
||||
if [[ "$SHOULD_SKIP_WORKFLOW" == 'true' ]]; then
|
||||
echo "Web tests were skipped because this workflow run duplicated a successful or newer run."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "$PRE_JOB_RESULT" != 'success' || "$CHANGES_RESULT" != 'success' ]]; then
|
||||
echo "Cannot finalize tests: duplicate check=$PRE_JOB_RESULT, change detection=$CHANGES_RESULT" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$TESTS_CHANGED" == 'true' ]]; then
|
||||
if [[ "$RUN_RESULT" == 'success' ]]; then
|
||||
echo "Web tests ran successfully."
|
||||
@@ -321,12 +378,12 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$SKIP_RESULT" == 'success' ]]; then
|
||||
if [[ "$TESTS_CHANGED" == 'false' && "$RUN_RESULT" == 'skipped' ]]; then
|
||||
echo "Web tests were skipped because no web-related files changed."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Web tests were not required, but the skip job finished with result: $SKIP_RESULT" >&2
|
||||
echo "Unexpected test state: changed=$TESTS_CHANGED, result=$RUN_RESULT" >&2
|
||||
exit 1
|
||||
|
||||
web-e2e-run:
|
||||
@@ -340,17 +397,6 @@ jobs:
|
||||
run-external-runtime: false
|
||||
secrets: inherit
|
||||
|
||||
web-e2e-skip:
|
||||
name: Skip Web Full-Stack E2E
|
||||
needs:
|
||||
- pre_job
|
||||
- check-changes
|
||||
if: needs.pre_job.outputs.should_skip != 'true' && needs.check-changes.outputs.e2e-changed != 'true'
|
||||
runs-on: depot-ubuntu-24.04
|
||||
steps:
|
||||
- name: Report skipped web full-stack e2e
|
||||
run: echo "No E2E-related changes detected; skipping web full-stack E2E."
|
||||
|
||||
web-e2e:
|
||||
name: Web Full-Stack E2E
|
||||
if: ${{ always() }}
|
||||
@@ -358,21 +404,26 @@ jobs:
|
||||
- pre_job
|
||||
- check-changes
|
||||
- web-e2e-run
|
||||
- web-e2e-skip
|
||||
runs-on: depot-ubuntu-24.04
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Finalize Web Full-Stack E2E status
|
||||
env:
|
||||
SHOULD_SKIP_WORKFLOW: ${{ needs.pre_job.outputs.should_skip }}
|
||||
TESTS_CHANGED: ${{ needs.check-changes.outputs.e2e-changed }}
|
||||
RUN_RESULT: ${{ needs.web-e2e-run.result }}
|
||||
SKIP_RESULT: ${{ needs.web-e2e-skip.result }}
|
||||
PRE_JOB_RESULT: ${{ needs.pre_job.result }}
|
||||
CHANGES_RESULT: ${{ needs.check-changes.result }}
|
||||
run: |
|
||||
if [[ "$SHOULD_SKIP_WORKFLOW" == 'true' ]]; then
|
||||
echo "Web full-stack E2E was skipped because this workflow run duplicated a successful or newer run."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "$PRE_JOB_RESULT" != 'success' || "$CHANGES_RESULT" != 'success' ]]; then
|
||||
echo "Cannot finalize tests: duplicate check=$PRE_JOB_RESULT, change detection=$CHANGES_RESULT" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$TESTS_CHANGED" == 'true' ]]; then
|
||||
if [[ "$RUN_RESULT" == 'success' ]]; then
|
||||
echo "Web full-stack E2E ran successfully."
|
||||
@@ -383,21 +434,30 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$SKIP_RESULT" == 'success' ]]; then
|
||||
if [[ "$TESTS_CHANGED" == 'false' && "$RUN_RESULT" == 'skipped' ]]; then
|
||||
echo "Web full-stack E2E was skipped because no E2E-related files changed."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Web full-stack E2E was not required, but the skip job finished with result: $SKIP_RESULT" >&2
|
||||
echo "Unexpected test state: changed=$TESTS_CHANGED, result=$RUN_RESULT" >&2
|
||||
exit 1
|
||||
|
||||
style-check:
|
||||
name: Style Check
|
||||
needs: pre_job
|
||||
if: needs.pre_job.outputs.should_skip != 'true'
|
||||
if: ${{ always() }}
|
||||
needs:
|
||||
- pre_job
|
||||
- check-changes
|
||||
uses: ./.github/workflows/style.yml
|
||||
with:
|
||||
base-rev: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }}
|
||||
classification-succeeded: ${{ needs.check-changes.result == 'success' }}
|
||||
run-python-style: ${{ needs.check-changes.outputs.python-style-changed == 'true' }}
|
||||
run-dify-agent-style: ${{ needs.check-changes.outputs.dify-agent-style-changed == 'true' }}
|
||||
run-web-style: ${{ needs.check-changes.outputs.web-style-changed == 'true' }}
|
||||
run-ts-common-style: ${{ needs.check-changes.outputs.ts-common-style-changed == 'true' }}
|
||||
run-superlinter: ${{ needs.check-changes.outputs.superlinter-changed == 'true' }}
|
||||
skip-checks: ${{ needs.pre_job.outputs.should_skip == 'true' }}
|
||||
|
||||
vdb-tests-run:
|
||||
name: Run VDB Tests
|
||||
@@ -407,17 +467,6 @@ jobs:
|
||||
if: needs.pre_job.outputs.should_skip != 'true' && needs.check-changes.outputs.vdb-changed == 'true'
|
||||
uses: ./.github/workflows/vdb-tests.yml
|
||||
|
||||
vdb-tests-skip:
|
||||
name: Skip VDB Tests
|
||||
needs:
|
||||
- pre_job
|
||||
- check-changes
|
||||
if: needs.pre_job.outputs.should_skip != 'true' && needs.check-changes.outputs.vdb-changed != 'true'
|
||||
runs-on: depot-ubuntu-24.04
|
||||
steps:
|
||||
- name: Report skipped VDB tests
|
||||
run: echo "No VDB-related changes detected; skipping VDB tests."
|
||||
|
||||
vdb-tests:
|
||||
name: VDB Tests
|
||||
if: ${{ always() }}
|
||||
@@ -425,21 +474,26 @@ jobs:
|
||||
- pre_job
|
||||
- check-changes
|
||||
- vdb-tests-run
|
||||
- vdb-tests-skip
|
||||
runs-on: depot-ubuntu-24.04
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Finalize VDB Tests status
|
||||
env:
|
||||
SHOULD_SKIP_WORKFLOW: ${{ needs.pre_job.outputs.should_skip }}
|
||||
TESTS_CHANGED: ${{ needs.check-changes.outputs.vdb-changed }}
|
||||
RUN_RESULT: ${{ needs.vdb-tests-run.result }}
|
||||
SKIP_RESULT: ${{ needs.vdb-tests-skip.result }}
|
||||
PRE_JOB_RESULT: ${{ needs.pre_job.result }}
|
||||
CHANGES_RESULT: ${{ needs.check-changes.result }}
|
||||
run: |
|
||||
if [[ "$SHOULD_SKIP_WORKFLOW" == 'true' ]]; then
|
||||
echo "VDB tests were skipped because this workflow run duplicated a successful or newer run."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "$PRE_JOB_RESULT" != 'success' || "$CHANGES_RESULT" != 'success' ]]; then
|
||||
echo "Cannot finalize tests: duplicate check=$PRE_JOB_RESULT, change detection=$CHANGES_RESULT" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$TESTS_CHANGED" == 'true' ]]; then
|
||||
if [[ "$RUN_RESULT" == 'success' ]]; then
|
||||
echo "VDB tests ran successfully."
|
||||
@@ -450,12 +504,12 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$SKIP_RESULT" == 'success' ]]; then
|
||||
if [[ "$TESTS_CHANGED" == 'false' && "$RUN_RESULT" == 'skipped' ]]; then
|
||||
echo "VDB tests were skipped because no VDB-related files changed."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "VDB tests were not required, but the skip job finished with result: $SKIP_RESULT" >&2
|
||||
echo "Unexpected test state: changed=$TESTS_CHANGED, result=$RUN_RESULT" >&2
|
||||
exit 1
|
||||
|
||||
db-migration-test-run:
|
||||
@@ -466,17 +520,6 @@ jobs:
|
||||
if: needs.pre_job.outputs.should_skip != 'true' && needs.check-changes.outputs.migration-changed == 'true'
|
||||
uses: ./.github/workflows/db-migration-test.yml
|
||||
|
||||
db-migration-test-skip:
|
||||
name: Skip DB Migration Test
|
||||
needs:
|
||||
- pre_job
|
||||
- check-changes
|
||||
if: needs.pre_job.outputs.should_skip != 'true' && needs.check-changes.outputs.migration-changed != 'true'
|
||||
runs-on: depot-ubuntu-24.04
|
||||
steps:
|
||||
- name: Report skipped DB migration tests
|
||||
run: echo "No migration-related changes detected; skipping DB migration tests."
|
||||
|
||||
db-migration-test:
|
||||
name: DB Migration Test
|
||||
if: ${{ always() }}
|
||||
@@ -484,21 +527,26 @@ jobs:
|
||||
- pre_job
|
||||
- check-changes
|
||||
- db-migration-test-run
|
||||
- db-migration-test-skip
|
||||
runs-on: depot-ubuntu-24.04
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Finalize DB Migration Test status
|
||||
env:
|
||||
SHOULD_SKIP_WORKFLOW: ${{ needs.pre_job.outputs.should_skip }}
|
||||
TESTS_CHANGED: ${{ needs.check-changes.outputs.migration-changed }}
|
||||
RUN_RESULT: ${{ needs.db-migration-test-run.result }}
|
||||
SKIP_RESULT: ${{ needs.db-migration-test-skip.result }}
|
||||
PRE_JOB_RESULT: ${{ needs.pre_job.result }}
|
||||
CHANGES_RESULT: ${{ needs.check-changes.result }}
|
||||
run: |
|
||||
if [[ "$SHOULD_SKIP_WORKFLOW" == 'true' ]]; then
|
||||
echo "DB migration tests were skipped because this workflow run duplicated a successful or newer run."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "$PRE_JOB_RESULT" != 'success' || "$CHANGES_RESULT" != 'success' ]]; then
|
||||
echo "Cannot finalize tests: duplicate check=$PRE_JOB_RESULT, change detection=$CHANGES_RESULT" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$TESTS_CHANGED" == 'true' ]]; then
|
||||
if [[ "$RUN_RESULT" == 'success' ]]; then
|
||||
echo "DB migration tests ran successfully."
|
||||
@@ -509,12 +557,12 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$SKIP_RESULT" == 'success' ]]; then
|
||||
if [[ "$TESTS_CHANGED" == 'false' && "$RUN_RESULT" == 'skipped' ]]; then
|
||||
echo "DB migration tests were skipped because no migration-related files changed."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "DB migration tests were not required, but the skip job finished with result: $SKIP_RESULT" >&2
|
||||
echo "Unexpected test state: changed=$TESTS_CHANGED, result=$RUN_RESULT" >&2
|
||||
exit 1
|
||||
|
||||
sandbox-runtime-tests-run:
|
||||
@@ -526,17 +574,6 @@ jobs:
|
||||
uses: ./.github/workflows/sandbox-runtime-tests.yml
|
||||
secrets: inherit
|
||||
|
||||
sandbox-runtime-tests-skip:
|
||||
name: Skip Sandbox Runtime Tests
|
||||
needs:
|
||||
- pre_job
|
||||
- check-changes
|
||||
if: needs.pre_job.outputs.should_skip != 'true' && needs.check-changes.outputs.sandbox-runtime-changed != 'true'
|
||||
runs-on: depot-ubuntu-24.04
|
||||
steps:
|
||||
- name: Report skipped sandbox runtime tests
|
||||
run: echo "No sandbox-runtime-related changes detected; skipping sandbox runtime tests."
|
||||
|
||||
sandbox-runtime-tests:
|
||||
name: Sandbox Runtime Tests
|
||||
if: ${{ always() }}
|
||||
@@ -544,21 +581,26 @@ jobs:
|
||||
- pre_job
|
||||
- check-changes
|
||||
- sandbox-runtime-tests-run
|
||||
- sandbox-runtime-tests-skip
|
||||
runs-on: depot-ubuntu-24.04
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Finalize Sandbox Runtime Tests status
|
||||
env:
|
||||
SHOULD_SKIP_WORKFLOW: ${{ needs.pre_job.outputs.should_skip }}
|
||||
TESTS_CHANGED: ${{ needs.check-changes.outputs.sandbox-runtime-changed }}
|
||||
RUN_RESULT: ${{ needs.sandbox-runtime-tests-run.result }}
|
||||
SKIP_RESULT: ${{ needs.sandbox-runtime-tests-skip.result }}
|
||||
PRE_JOB_RESULT: ${{ needs.pre_job.result }}
|
||||
CHANGES_RESULT: ${{ needs.check-changes.result }}
|
||||
run: |
|
||||
if [[ "$SHOULD_SKIP_WORKFLOW" == 'true' ]]; then
|
||||
echo "Sandbox runtime tests were skipped because this workflow run duplicated a successful or newer run."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "$PRE_JOB_RESULT" != 'success' || "$CHANGES_RESULT" != 'success' ]]; then
|
||||
echo "Cannot finalize tests: duplicate check=$PRE_JOB_RESULT, change detection=$CHANGES_RESULT" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$TESTS_CHANGED" == 'true' ]]; then
|
||||
if [[ "$RUN_RESULT" == 'success' ]]; then
|
||||
echo "Sandbox runtime tests ran successfully."
|
||||
@@ -569,10 +611,64 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$SKIP_RESULT" == 'success' ]]; then
|
||||
if [[ "$TESTS_CHANGED" == 'false' && "$RUN_RESULT" == 'skipped' ]]; then
|
||||
echo "Sandbox runtime tests were skipped because no sandbox-runtime-related files changed."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Sandbox runtime tests were not required, but the skip job finished with result: $SKIP_RESULT" >&2
|
||||
echo "Unexpected test state: changed=$TESTS_CHANGED, result=$RUN_RESULT" >&2
|
||||
exit 1
|
||||
|
||||
dify-agent-tests-run:
|
||||
name: Run Dify Agent Tests
|
||||
needs:
|
||||
- pre_job
|
||||
- check-changes
|
||||
if: needs.pre_job.outputs.should_skip != 'true' && needs.check-changes.outputs.dify-agent-changed == 'true'
|
||||
uses: ./.github/workflows/dify-agent-tests.yml
|
||||
secrets: inherit
|
||||
|
||||
dify-agent-tests:
|
||||
name: Dify Agent Tests
|
||||
if: ${{ always() }}
|
||||
needs:
|
||||
- pre_job
|
||||
- check-changes
|
||||
- dify-agent-tests-run
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Finalize Dify Agent Tests status
|
||||
env:
|
||||
SHOULD_SKIP_WORKFLOW: ${{ needs.pre_job.outputs.should_skip }}
|
||||
TESTS_CHANGED: ${{ needs.check-changes.outputs.dify-agent-changed }}
|
||||
RUN_RESULT: ${{ needs.dify-agent-tests-run.result }}
|
||||
PRE_JOB_RESULT: ${{ needs.pre_job.result }}
|
||||
CHANGES_RESULT: ${{ needs.check-changes.result }}
|
||||
run: |
|
||||
if [[ "$SHOULD_SKIP_WORKFLOW" == 'true' ]]; then
|
||||
echo "Dify agent tests were skipped because this workflow run duplicated a successful or newer run."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "$PRE_JOB_RESULT" != 'success' || "$CHANGES_RESULT" != 'success' ]]; then
|
||||
echo "Cannot finalize tests: duplicate check=$PRE_JOB_RESULT, change detection=$CHANGES_RESULT" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$TESTS_CHANGED" == 'true' ]]; then
|
||||
if [[ "$RUN_RESULT" == 'success' ]]; then
|
||||
echo "Dify agent tests ran successfully."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Dify agent tests were required but finished with result: $RUN_RESULT" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$TESTS_CHANGED" == 'false' && "$RUN_RESULT" == 'skipped' ]]; then
|
||||
echo "Dify agent tests were skipped because no dify-agent-related files changed."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Unexpected test state: changed=$TESTS_CHANGED, result=$RUN_RESULT" >&2
|
||||
exit 1
|
||||
|
||||
50
.github/workflows/post-merge.yml
vendored
50
.github/workflows/post-merge.yml
vendored
@@ -36,15 +36,15 @@ jobs:
|
||||
- 'e2e/package.json'
|
||||
- 'e2e/test-env.ts'
|
||||
- 'e2e/tsconfig.json'
|
||||
- 'e2e/tsx-register.js'
|
||||
- 'package.json'
|
||||
- 'pnpm-lock.yaml'
|
||||
- '.nvmrc'
|
||||
- '.github/workflows/post-merge.yml'
|
||||
- '.github/workflows/web-e2e.yml'
|
||||
- '.github/actions/setup-web/**'
|
||||
- 'docker/docker-compose.middleware.yaml'
|
||||
- 'docker/envs/middleware.env.example'
|
||||
- 'docker/ssrf_proxy/**'
|
||||
- 'docker/volumes/sandbox/conf/**'
|
||||
- 'dify-agent/**'
|
||||
- 'dify-agent-runtime/**'
|
||||
- 'api/pyproject.toml'
|
||||
@@ -54,12 +54,30 @@ jobs:
|
||||
- 'api/core/app/apps/agent_app/**'
|
||||
- 'api/core/workflow/nodes/agent_v2/**'
|
||||
- 'api/controllers/console/agent/**'
|
||||
- 'api/controllers/console/app/agent*.py'
|
||||
- 'api/controllers/console/app/audio.py'
|
||||
- 'api/controllers/common/agent_access.py'
|
||||
- 'api/controllers/inner_api/agent/**'
|
||||
- 'api/controllers/inner_api/wraps.py'
|
||||
- 'api/controllers/service_api/app/completion.py'
|
||||
- 'api/controllers/service_api/wraps.py'
|
||||
- 'api/controllers/web/completion.py'
|
||||
- 'api/controllers/web/wraps.py'
|
||||
- 'api/services/agent_llm_inner_service.py'
|
||||
- 'api/services/agent_tool_inner_service.py'
|
||||
- 'api/services/audio_service.py'
|
||||
- 'api/services/entities/agent_llm_inner.py'
|
||||
- 'api/services/entities/agent_tool_inner.py'
|
||||
- 'api/services/errors/agent_tool_inner.py'
|
||||
- 'api/services/agent/**'
|
||||
- 'api/core/plugin/**'
|
||||
- 'api/services/plugin/**'
|
||||
- 'api/core/tools/**'
|
||||
- 'api/services/tools/**'
|
||||
- 'packages/contracts/package.json'
|
||||
- 'packages/contracts/console.ts'
|
||||
- 'packages/contracts/generated/api/console/router.gen.ts'
|
||||
- 'packages/contracts/generated/api/web/**'
|
||||
- 'packages/contracts/generated/api/console/agent/**'
|
||||
- 'packages/contracts/generated/api/console/apps/**'
|
||||
- 'packages/contracts/generated/api/console/datasets/**'
|
||||
@@ -67,20 +85,27 @@ jobs:
|
||||
- 'packages/contracts/generated/api/console/workspaces/**'
|
||||
- 'packages/contracts/generated/api/service/**'
|
||||
- 'web/features/agent-v2/**'
|
||||
- 'web/app/(commonLayout)/agents/**'
|
||||
- 'web/app/(commonLayout)/@detailSidebar/agents/**'
|
||||
- 'web/app/(commonLayout)/roster/**'
|
||||
- 'web/app/\(commonLayout\)/agents/**'
|
||||
- 'web/app/\(commonLayout\)/@detailSidebar/agents/**'
|
||||
- 'web/app/\(shareLayout\)/chat/**'
|
||||
- 'web/app/\(shareLayout\)/components/**'
|
||||
- 'web/app/components/base/chat/chat-with-history/**'
|
||||
- 'web/app/components/base/chat/chat/**'
|
||||
- 'web/app/components/base/voice-input/**'
|
||||
- 'web/app/components/workflow/index.tsx'
|
||||
- 'web/app/components/workflow/block-selector/**'
|
||||
- 'web/app/components/workflow/hooks/use-node-keyboard-interactions.ts'
|
||||
- 'web/app/components/workflow/hooks/use-nodes-interactions.ts'
|
||||
- 'web/app/components/workflow/hooks/use-nodes-sync-draft.ts'
|
||||
- 'web/app/components/workflow/nodes/_base/**'
|
||||
- 'web/app/components/workflow/nodes/agent-v2/**'
|
||||
- 'web/i18n/en-US/agent-v-2.json'
|
||||
- 'web/i18n/en-US/common.json'
|
||||
- 'web/i18n/locales/en-US/agent-v-2.json'
|
||||
- 'web/i18n/locales/en-US/common.json'
|
||||
- 'web/service/base.ts'
|
||||
- 'web/service/client.ts'
|
||||
- 'web/service/console-link.ts'
|
||||
- 'web/service/console-openapi-url.ts'
|
||||
- 'web/service/console-router-loader.ts'
|
||||
- 'web/service/console/**'
|
||||
- 'web/service/share.ts'
|
||||
- 'web/service/use-share.ts'
|
||||
- 'web/service/webapp-address.ts'
|
||||
- 'web/package.json'
|
||||
- 'pnpm-workspace.yaml'
|
||||
|
||||
@@ -88,6 +113,9 @@ jobs:
|
||||
name: External Runtime E2E
|
||||
needs: check-changes
|
||||
if: needs.check-changes.outputs.external-e2e-changed == 'true'
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
uses: ./.github/workflows/web-e2e.yml
|
||||
with:
|
||||
run-external-runtime: true
|
||||
|
||||
2
.github/workflows/pyrefly-diff.yml
vendored
2
.github/workflows/pyrefly-diff.yml
vendored
@@ -22,7 +22,7 @@ jobs:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Python & UV
|
||||
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
|
||||
uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
|
||||
with:
|
||||
enable-cache: true
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ jobs:
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
- name: Setup Python & UV
|
||||
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
|
||||
uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
|
||||
with:
|
||||
enable-cache: true
|
||||
|
||||
|
||||
2
.github/workflows/pyrefly-type-coverage.yml
vendored
2
.github/workflows/pyrefly-type-coverage.yml
vendored
@@ -22,7 +22,7 @@ jobs:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Python & UV
|
||||
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
|
||||
uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
|
||||
with:
|
||||
enable-cache: true
|
||||
|
||||
|
||||
55
.github/workflows/size-labeler.yml
vendored
Normal file
55
.github/workflows/size-labeler.yml
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
name: Pull Request Size Labeler
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [opened, reopened, synchronize, ready_for_review, edited]
|
||||
|
||||
permissions:
|
||||
pull-requests: write
|
||||
|
||||
concurrency:
|
||||
group: size-labeler-${{ github.event.pull_request.number }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
label:
|
||||
runs-on: depot-ubuntu-24.04
|
||||
steps:
|
||||
# Only read PR metadata. Never check out or execute the PR's code here.
|
||||
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
script: |
|
||||
const { owner, repo } = context.repo
|
||||
const issue_number = context.payload.pull_request.number
|
||||
const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number: issue_number })
|
||||
const files = await github.paginate(github.rest.pulls.listFiles, {
|
||||
owner, repo, pull_number: issue_number, per_page: 100,
|
||||
})
|
||||
// GitHub caps this endpoint at 3,000 files; avoid labeling a partial count.
|
||||
if (files.length !== pr.changed_files) {
|
||||
core.warning('Skipping size label because the changed-file list is incomplete')
|
||||
return
|
||||
}
|
||||
const ignoredNames = new Set(['uv.lock', 'pnpm-lock.yaml', 'package-lock.json', 'yarn.lock'])
|
||||
const changes = files
|
||||
.filter(file => !ignoredNames.has(file.filename.split('/').pop()))
|
||||
.reduce((total, file) => total + file.additions + file.deletions, 0)
|
||||
// Match the descriptions of the repository's existing size labels.
|
||||
const buckets = [
|
||||
[10, 'size:XS'], [30, 'size:S'], [100, 'size:M'],
|
||||
[500, 'size:L'], [1000, 'size:XL'], [Infinity, 'size:XXL'],
|
||||
]
|
||||
const label = buckets.find(([limit]) => changes < limit)[1]
|
||||
const sizeLabels = new Set(buckets.map(([, name]) => name))
|
||||
const labels = await github.paginate(github.rest.issues.listLabelsOnIssue, {
|
||||
owner, repo, issue_number, per_page: 100,
|
||||
})
|
||||
// Add first so an API error cannot leave the PR without a size label.
|
||||
if (!labels.some(item => item.name === label)) {
|
||||
await github.rest.issues.addLabels({ owner, repo, issue_number, labels: [label] })
|
||||
}
|
||||
for (const item of labels) {
|
||||
if (sizeLabels.has(item.name) && item.name !== label) {
|
||||
await github.rest.issues.removeLabel({ owner, repo, issue_number, name: item.name })
|
||||
}
|
||||
}
|
||||
228
.github/workflows/style.yml
vendored
228
.github/workflows/style.yml
vendored
@@ -6,6 +6,35 @@ on:
|
||||
base-rev:
|
||||
required: true
|
||||
type: string
|
||||
classification-succeeded:
|
||||
description: Whether the caller successfully classified the changed files.
|
||||
required: true
|
||||
type: boolean
|
||||
run-python-style:
|
||||
description: Run Python style checks for the changed files.
|
||||
required: true
|
||||
type: boolean
|
||||
run-dify-agent-style:
|
||||
description: Run Dify Agent style checks for the changed files.
|
||||
required: true
|
||||
type: boolean
|
||||
run-web-style:
|
||||
description: Run Web style checks for the changed files.
|
||||
required: true
|
||||
type: boolean
|
||||
run-ts-common-style:
|
||||
description: Run shared TypeScript style checks for the changed files.
|
||||
required: true
|
||||
type: boolean
|
||||
run-superlinter:
|
||||
description: Run SuperLinter for the changed files.
|
||||
required: true
|
||||
type: boolean
|
||||
skip-checks:
|
||||
description: Create the required check runs without repeating previously successful work.
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
permissions:
|
||||
checks: write
|
||||
@@ -15,70 +44,90 @@ permissions:
|
||||
jobs:
|
||||
python-style:
|
||||
name: Python Style
|
||||
if: ${{ !inputs.skip-checks && (!inputs.classification-succeeded || inputs.run-python-style || inputs.run-dify-agent-style) }}
|
||||
runs-on: depot-ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- name: Verify changed-file classification
|
||||
if: ${{ !inputs.classification-succeeded }}
|
||||
run: |
|
||||
echo "Changed-file classification failed; refusing to skip Python style checks." >&2
|
||||
exit 1
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Check changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
|
||||
with:
|
||||
files: |
|
||||
api/**
|
||||
scripts/ast_grep_guard.py
|
||||
scripts/check_no_new_getattr.py
|
||||
scripts/check_no_new_controller_sqlalchemy.py
|
||||
scripts/lint_controller_sqlalchemy.py
|
||||
scripts/ast_grep_rules/no_new_getattr.yml
|
||||
scripts/ast_grep_rules/no_new_controller_sqlalchemy.yml
|
||||
.github/workflows/style.yml
|
||||
.github/workflows/main-ci.yml
|
||||
|
||||
- name: Setup UV and Python
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
|
||||
uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
|
||||
with:
|
||||
enable-cache: false
|
||||
python-version: '3.12'
|
||||
cache-dependency-glob: api/uv.lock
|
||||
cache-dependency-glob: |
|
||||
api/uv.lock
|
||||
dify-agent/uv.lock
|
||||
|
||||
- name: Install dependencies
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
if: inputs.run-python-style
|
||||
run: uv sync --project api --dev
|
||||
|
||||
- name: Run Import Linter
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
if: inputs.run-python-style
|
||||
run: uv run --directory api --dev lint-imports
|
||||
|
||||
- name: Run Response Contract Linter
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
if: inputs.run-python-style
|
||||
run: uv run --project api --dev python api/dev/lint_response_contracts.py --fail-on-mismatch
|
||||
|
||||
- name: Run No New Getattr Guard
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
if: inputs.run-python-style
|
||||
run: uv run --project api python scripts/check_no_new_getattr.py --base-rev "${{ inputs.base-rev }}"
|
||||
|
||||
- name: Run No New Controller SQLAlchemy Guard
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
if: inputs.run-python-style
|
||||
run: uv run --project api python scripts/check_no_new_controller_sqlalchemy.py --base-rev "${{ inputs.base-rev }}"
|
||||
|
||||
- name: Run No New Session Mock Guard
|
||||
if: inputs.run-python-style
|
||||
run: uv run --project api python scripts/check_no_new_session_mock.py --base-rev "${{ inputs.base-rev }}"
|
||||
|
||||
- name: Run No Spec Mock Guard
|
||||
if: inputs.run-python-style
|
||||
run: uv run --project api python scripts/check_no_spec_mock.py
|
||||
|
||||
- name: Run Type Checks
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
if: inputs.run-python-style
|
||||
env:
|
||||
PYREFLY_OUTPUT_FORMAT: github
|
||||
run: make type-check-core
|
||||
|
||||
- name: Run Dify Agent Ruff
|
||||
if: inputs.run-dify-agent-style
|
||||
run: make -C dify-agent check
|
||||
|
||||
- name: Run Dify Agent Type Checks
|
||||
if: inputs.run-dify-agent-style
|
||||
run: make -C dify-agent typecheck
|
||||
|
||||
- name: Dotenv check
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
if: inputs.run-python-style
|
||||
run: uv run --project api dotenv-linter ./api/.env.example ./web/.env.example
|
||||
|
||||
web-style:
|
||||
name: Web Style
|
||||
web-build:
|
||||
name: Web Build and Bundle Analysis
|
||||
if: ${{ !inputs.skip-checks && inputs.classification-succeeded && inputs.run-web-style }}
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
uses: ./.github/workflows/web-bundle-size.yml
|
||||
with:
|
||||
base-rev: ${{ inputs.base-rev }}
|
||||
|
||||
web-style-checks:
|
||||
name: Web Static Checks
|
||||
if: ${{ !inputs.skip-checks && (!inputs.classification-succeeded || inputs.run-web-style) }}
|
||||
runs-on: depot-ubuntu-24.04
|
||||
defaults:
|
||||
run:
|
||||
@@ -88,131 +137,130 @@ jobs:
|
||||
pull-requests: read
|
||||
|
||||
steps:
|
||||
- name: Verify changed-file classification
|
||||
if: ${{ !inputs.classification-succeeded }}
|
||||
working-directory: .
|
||||
run: |
|
||||
echo "Changed-file classification failed; refusing to skip Web style checks." >&2
|
||||
exit 1
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Check changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
|
||||
with:
|
||||
files: |
|
||||
web/**
|
||||
e2e/**
|
||||
sdks/nodejs-client/**
|
||||
packages/**
|
||||
package.json
|
||||
pnpm-lock.yaml
|
||||
pnpm-workspace.yaml
|
||||
knip.config.ts
|
||||
scripts/check-web-production-unused-after-knip-fix.mjs
|
||||
.nvmrc
|
||||
.github/workflows/style.yml
|
||||
.github/actions/setup-web/**
|
||||
|
||||
- name: Setup web environment
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
uses: ./.github/actions/setup-web
|
||||
|
||||
- name: Check generated i18n types
|
||||
run: vp run i18n:check-types
|
||||
|
||||
- name: Web tsslint
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
env:
|
||||
NODE_OPTIONS: --max-old-space-size=4096
|
||||
run: vp run lint:tss
|
||||
|
||||
- name: Web dead code check
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
working-directory: .
|
||||
run: vp run knip
|
||||
|
||||
- name: Web dead code check production
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
working-directory: .
|
||||
run: vp run knip:production
|
||||
|
||||
- name: Web production unused declarations check
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
working-directory: .
|
||||
run: vp run knip:production-unused-check
|
||||
|
||||
# Preserve the existing required check while build and static checks run in parallel.
|
||||
web-style:
|
||||
name: Web Style
|
||||
if: ${{ always() && !inputs.skip-checks && (!inputs.classification-succeeded || inputs.run-web-style) }}
|
||||
needs: [web-build, web-style-checks]
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: {}
|
||||
steps:
|
||||
- name: Verify web checks
|
||||
env:
|
||||
BUILD_RESULT: ${{ needs.web-build.result }}
|
||||
STYLE_RESULT: ${{ needs.web-style-checks.result }}
|
||||
run: |
|
||||
if [[ "$BUILD_RESULT" != 'success' || "$STYLE_RESULT" != 'success' ]]; then
|
||||
echo "Web checks failed: build=$BUILD_RESULT, static checks=$STYLE_RESULT" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ts-common-style:
|
||||
name: TS Common
|
||||
if: ${{ !inputs.skip-checks && (!inputs.classification-succeeded || inputs.run-ts-common-style) }}
|
||||
runs-on: depot-ubuntu-24.04-4
|
||||
permissions:
|
||||
checks: write
|
||||
pull-requests: read
|
||||
|
||||
steps:
|
||||
- name: Verify changed-file classification
|
||||
if: ${{ !inputs.classification-succeeded }}
|
||||
run: |
|
||||
echo "Changed-file classification failed; refusing to skip TypeScript style checks." >&2
|
||||
exit 1
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Check changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
|
||||
with:
|
||||
files: |
|
||||
web/**
|
||||
cli/**
|
||||
e2e/**
|
||||
sdks/nodejs-client/**
|
||||
packages/**
|
||||
package.json
|
||||
pnpm-lock.yaml
|
||||
pnpm-workspace.yaml
|
||||
.nvmrc
|
||||
vite.config.ts
|
||||
lint.config.ts
|
||||
eslint.config.mjs
|
||||
oxlint-suppressions.json
|
||||
eslint-suppressions.json
|
||||
.vscode/**
|
||||
.github/**
|
||||
|
||||
- name: Setup web environment
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
uses: ./.github/actions/setup-web
|
||||
|
||||
- name: Restore static check task cache
|
||||
id: static-check-cache
|
||||
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
with:
|
||||
path: node_modules/.vite/task-cache
|
||||
key: vite-task-static-v1-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
restore-keys: |
|
||||
vite-task-static-v1-${{ runner.os }}-${{ runner.arch }}-
|
||||
|
||||
- name: Static check
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
run: pnpm -w check
|
||||
run: vp run -w check
|
||||
|
||||
- name: Save static check task cache
|
||||
if: success() && github.event_name != 'merge_group'
|
||||
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
with:
|
||||
path: node_modules/.vite/task-cache
|
||||
key: ${{ steps.static-check-cache.outputs.cache-primary-key }}
|
||||
|
||||
superlinter:
|
||||
name: SuperLinter
|
||||
if: ${{ !inputs.skip-checks && (!inputs.classification-succeeded || inputs.run-superlinter) }}
|
||||
runs-on: depot-ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- name: Verify changed-file classification
|
||||
if: ${{ !inputs.classification-succeeded }}
|
||||
run: |
|
||||
echo "Changed-file classification failed; refusing to skip SuperLinter." >&2
|
||||
exit 1
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- name: Check changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
|
||||
with:
|
||||
files: |
|
||||
**.sh
|
||||
**.yaml
|
||||
**.yml
|
||||
**Dockerfile
|
||||
dev/**
|
||||
.editorconfig
|
||||
|
||||
- name: Super-linter
|
||||
uses: super-linter/super-linter/slim@4ce20838b8ab83717e78138c5b3a1407148e0918 # v8.7.0
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
uses: super-linter/super-linter/slim@2da136927bd4a73596db63044b504547c62cb854 # v9.0.0
|
||||
env:
|
||||
BASH_SEVERITY: warning
|
||||
DEFAULT_BRANCH: origin/main
|
||||
EDITORCONFIG_FILE_NAME: editorconfig-checker.json
|
||||
FILTER_REGEX_INCLUDE: pnpm-lock.yaml
|
||||
ENABLE_GITHUB_PULL_REQUEST_SUMMARY_COMMENT: false
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
IGNORE_GENERATED_FILES: true
|
||||
IGNORE_GITIGNORED_FILES: true
|
||||
VALIDATE_ALL_CODEBASE: false
|
||||
VALIDATE_BASH: true
|
||||
VALIDATE_BASH_EXEC: true
|
||||
# FIXME: temporarily disabled until api-docker.yaml's run script is fixed for shellcheck
|
||||
|
||||
18
.github/workflows/tool-test-sdks.yaml
vendored
18
.github/workflows/tool-test-sdks.yaml
vendored
@@ -9,6 +9,8 @@ on:
|
||||
- package.json
|
||||
- pnpm-lock.yaml
|
||||
- pnpm-workspace.yaml
|
||||
- .github/actions/setup-web/**
|
||||
- .github/workflows/tool-test-sdks.yaml
|
||||
|
||||
concurrency:
|
||||
group: sdk-tests-${{ github.head_ref || github.run_id }}
|
||||
@@ -28,15 +30,13 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||
with:
|
||||
node-version: 22
|
||||
cache: ''
|
||||
cache-dependency-path: 'pnpm-lock.yaml'
|
||||
|
||||
- name: Install Dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
- name: Setup web environment
|
||||
uses: ./.github/actions/setup-web
|
||||
|
||||
- name: Test
|
||||
run: pnpm test
|
||||
|
||||
- name: Build and verify package entry points
|
||||
run: |
|
||||
pnpm build
|
||||
node --input-type=module -e "import { access } from 'node:fs/promises'; import 'dify-client'; await access('dist/index.d.ts')"
|
||||
|
||||
55
.github/workflows/translate-i18n-claude.yml
vendored
55
.github/workflows/translate-i18n-claude.yml
vendored
@@ -8,15 +8,19 @@ on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
files:
|
||||
description: 'Specific files to translate (space-separated, e.g., "app common"). Required for full mode; leave empty in incremental mode to use en-US files changed since HEAD~1.'
|
||||
description: 'Specific files to translate (space-separated, e.g., "app common").
|
||||
Required for full mode; leave empty in incremental mode to use en-US
|
||||
files changed since HEAD~1.'
|
||||
required: false
|
||||
type: string
|
||||
languages:
|
||||
description: 'Specific languages to translate (space-separated, e.g., "zh-Hans ja-JP"). Leave empty for all supported target languages except en-US.'
|
||||
description: 'Specific languages to translate (space-separated, e.g., "zh-Hans
|
||||
ja-JP"). Leave empty for all supported target languages except en-US.'
|
||||
required: false
|
||||
type: string
|
||||
mode:
|
||||
description: 'Sync mode: incremental (compare with previous en-US revision) or full (sync all keys in scope)'
|
||||
description: 'Sync mode: incremental (compare with previous en-US revision) or
|
||||
full (sync all keys in scope)'
|
||||
required: false
|
||||
default: incremental
|
||||
type: choice
|
||||
@@ -43,6 +47,7 @@ jobs:
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.event.client_payload.head_sha || github.sha }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Configure Git
|
||||
@@ -65,7 +70,7 @@ jobs:
|
||||
/supported: true/ && value != \"en-US\" {
|
||||
printf \"%s \", value
|
||||
}
|
||||
" web/i18n-config/languages.ts | sed 's/[[:space:]]*$//')
|
||||
" web/i18n/languages.ts | sed 's/[[:space:]]*$//')
|
||||
|
||||
generate_changes_json() {
|
||||
node .github/scripts/generate-i18n-changes.mjs
|
||||
@@ -106,9 +111,9 @@ jobs:
|
||||
elif [ "$SYNC_MODE" = "incremental" ]; then
|
||||
BASE_SHA=$(git rev-parse HEAD~1 2>/dev/null || true)
|
||||
if [ -n "$BASE_SHA" ]; then
|
||||
CHANGED_FILES=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA" -- 'web/i18n/en-US/*.json' 2>/dev/null | sed -n 's@^.*/@@p' | sed 's/\.json$//' | tr '\n' ' ' | sed 's/[[:space:]]*$//')
|
||||
CHANGED_FILES=$(git diff --name-only --find-renames=100% --diff-filter=AMDT "$BASE_SHA" "$HEAD_SHA" -- 'web/i18n/' 2>/dev/null | sed -n '\@^web/i18n/locales/en-US/[^/]*\.json$@p' | sed -n 's@^.*/@@p' | sed 's/\.json$//' | tr '\n' ' ' | sed 's/[[:space:]]*$//')
|
||||
else
|
||||
CHANGED_FILES=$(find web/i18n/en-US -maxdepth 1 -type f -name '*.json' -print | sed -n 's@^.*/@@p' | sed 's/\.json$//' | sort | tr '\n' ' ' | sed 's/[[:space:]]*$//')
|
||||
CHANGED_FILES=$(find web/i18n/locales/en-US -maxdepth 1 -type f -name '*.json' -print | sed -n 's@^.*/@@p' | sed 's/\.json$//' | sort | tr '\n' ' ' | sed 's/[[:space:]]*$//')
|
||||
fi
|
||||
elif [ "$SYNC_MODE" = "full" ]; then
|
||||
echo "workflow_dispatch full mode requires the files input to stay within CI limits." >&2
|
||||
@@ -158,7 +163,7 @@ jobs:
|
||||
|
||||
- name: Run Claude Code for Translation Sync
|
||||
if: steps.context.outputs.CHANGED_FILES != ''
|
||||
uses: anthropics/claude-code-action@c038e4dcdedfbbca18dfb17df35a17e40ded4ddc # v1.0.186
|
||||
uses: anthropics/claude-code-action@ed670b4cf9de2a5a570d130d2f6197b9e543cd64 # v1.0.240
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -166,12 +171,12 @@ jobs:
|
||||
show_full_output: ${{ github.event_name == 'workflow_dispatch' }}
|
||||
prompt: |
|
||||
You are the i18n sync agent for the Dify repository.
|
||||
Your job is to keep translations synchronized with the English source files under `${{ github.workspace }}/web/i18n/en-US/`.
|
||||
Your job is to keep translations synchronized with the English source files under `${{ github.workspace }}/web/i18n/locales/en-US/`.
|
||||
|
||||
Use absolute paths at all times:
|
||||
- Repo root: `${{ github.workspace }}`
|
||||
- Web directory: `${{ github.workspace }}/web`
|
||||
- Language config: `${{ github.workspace }}/web/i18n-config/languages.ts`
|
||||
- Language config: `${{ github.workspace }}/web/i18n/languages.ts`
|
||||
|
||||
Inputs:
|
||||
- Files in scope: `${{ steps.context.outputs.CHANGED_FILES }}`
|
||||
@@ -194,12 +199,12 @@ jobs:
|
||||
Required execution plan:
|
||||
1. Resolve target languages.
|
||||
- Use the provided `Target languages` value as the source of truth.
|
||||
- If it is unexpectedly empty, read `${{ github.workspace }}/web/i18n-config/languages.ts` and use every language with `supported: true` except `en-US`.
|
||||
- If it is unexpectedly empty, read `${{ github.workspace }}/web/i18n/languages.ts` and use every language with `supported: true` except `en-US`.
|
||||
2. Stay strictly in scope.
|
||||
- Only process the files listed in `Files in scope`.
|
||||
- Only process the resolved target languages, never `en-US`.
|
||||
- Do not touch unrelated i18n files.
|
||||
- Do not modify `${{ github.workspace }}/web/i18n/en-US/`.
|
||||
- Do not modify `${{ github.workspace }}/web/i18n/locales/en-US/`.
|
||||
3. Resolve source changes.
|
||||
- If `Structured change set available` is `true`, read `/tmp/i18n-changes.json` and use it as the source of truth for file-level and key-level changes.
|
||||
- For each file entry:
|
||||
@@ -223,7 +228,7 @@ jobs:
|
||||
- Match the existing terminology and register used by each locale.
|
||||
- Prefer one Edit per file when stable, but prioritize correctness over batching.
|
||||
6. Verify only the edited files.
|
||||
- Run `vp fmt <repo-relative edited paths such as web/i18n/...>`
|
||||
- Run `vp fmt <repo-relative edited paths such as web/i18n/locales/...>`
|
||||
- Run `vp run dify-web#i18n:check ${{ steps.context.outputs.FILE_ARGS }} ${{ steps.context.outputs.LANG_ARGS }}`
|
||||
- If verification fails, fix the remaining problems before continuing.
|
||||
7. Stop after the scoped locale files are updated and verification passes.
|
||||
@@ -237,7 +242,7 @@ jobs:
|
||||
if: steps.context.outputs.CHANGED_FILES != ''
|
||||
shell: bash
|
||||
run: |
|
||||
if [ -z "$(git -C "${{ github.workspace }}" status --porcelain -- web/i18n/)" ]; then
|
||||
if [ -z "$(git -C "${{ github.workspace }}" status --porcelain -- web/i18n/locales/)" ]; then
|
||||
echo "has_changes=false" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
@@ -256,7 +261,7 @@ jobs:
|
||||
shell: bash
|
||||
run: |
|
||||
git -C "${{ github.workspace }}" checkout -B "${{ steps.pr_meta.outputs.branch_name }}"
|
||||
git -C "${{ github.workspace }}" add web/i18n/
|
||||
git -C "${{ github.workspace }}" add web/i18n/locales/
|
||||
git -C "${{ github.workspace }}" commit -m "chore(i18n): sync translations with en-US"
|
||||
|
||||
- name: Push translation branch
|
||||
@@ -281,6 +286,7 @@ jobs:
|
||||
BASE_SHA: ${{ steps.context.outputs.BASE_SHA }}
|
||||
HEAD_SHA: ${{ steps.context.outputs.HEAD_SHA }}
|
||||
REPO_NAME: ${{ github.repository }}
|
||||
EVENT_NAME: ${{ github.event_name }}
|
||||
shell: bash
|
||||
run: |
|
||||
PR_BODY_FILE=/tmp/i18n-pr-body.md
|
||||
@@ -291,6 +297,7 @@ jobs:
|
||||
export LANG_COUNT
|
||||
|
||||
node <<'NODE' > "$PR_BODY_FILE"
|
||||
const { execFileSync } = require('node:child_process')
|
||||
const fs = require('node:fs')
|
||||
|
||||
const changesPath = '/tmp/i18n-changes.json'
|
||||
@@ -299,7 +306,25 @@ jobs:
|
||||
: { changes: {} }
|
||||
|
||||
const filesInScope = (process.env.FILES_IN_SCOPE || '').split(/\s+/).filter(Boolean)
|
||||
const sourceCommit = process.env.HEAD_SHA
|
||||
let sourcePr
|
||||
if (process.env.EVENT_NAME === 'repository_dispatch') {
|
||||
try {
|
||||
const pulls = JSON.parse(execFileSync('gh', [
|
||||
'api', `repos/${process.env.REPO_NAME}/commits/${sourceCommit}/pulls`,
|
||||
], { encoding: 'utf8' }))
|
||||
sourcePr = pulls.find(pr => pr.merged_at && pr.merge_commit_sha === sourceCommit)
|
||||
} catch (error) {
|
||||
console.error(`Could not resolve source PR: ${error.message}`)
|
||||
}
|
||||
}
|
||||
|
||||
const lines = [
|
||||
'## Source',
|
||||
'',
|
||||
...(sourcePr ? [`- **PR**: [#${sourcePr.number}](${sourcePr.html_url})`] : []),
|
||||
`- **Commit**: [\`${sourceCommit.slice(0, 12)}\`](https://github.com/${process.env.REPO_NAME}/commit/${sourceCommit})`,
|
||||
'',
|
||||
'## Summary',
|
||||
'',
|
||||
`- **Files synced**: \`${process.env.FILES_IN_SCOPE || '<none>'}\``,
|
||||
@@ -322,7 +347,7 @@ jobs:
|
||||
'## Verification',
|
||||
'',
|
||||
`- \`vp run dify-web#i18n:check --file ${process.env.FILES_IN_SCOPE} --lang ${process.env.TARGET_LANGS}\``,
|
||||
`- \`vp fmt <repo-relative edited paths such as web/i18n/...>\``,
|
||||
`- \`vp fmt <repo-relative edited paths such as web/i18n/locales/...>\``,
|
||||
'',
|
||||
'## Notes',
|
||||
'',
|
||||
|
||||
6
.github/workflows/trigger-i18n-sync.yml
vendored
6
.github/workflows/trigger-i18n-sync.yml
vendored
@@ -4,7 +4,7 @@ on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- 'web/i18n/en-US/*.json'
|
||||
- 'web/i18n/locales/en-US/*.json'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -36,9 +36,9 @@ jobs:
|
||||
HEAD_SHA="${{ github.sha }}"
|
||||
|
||||
if [ -n "$BASE_SHA" ]; then
|
||||
CHANGED_FILES=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA" -- 'web/i18n/en-US/*.json' 2>/dev/null | sed -n 's@^.*/@@p' | sed 's/\.json$//' | tr '\n' ' ' | sed 's/[[:space:]]*$//')
|
||||
CHANGED_FILES=$(git diff --name-only --find-renames=100% --diff-filter=AMDT "$BASE_SHA" "$HEAD_SHA" -- 'web/i18n/' 2>/dev/null | sed -n '\@^web/i18n/locales/en-US/[^/]*\.json$@p' | sed -n 's@^.*/@@p' | sed 's/\.json$//' | tr '\n' ' ' | sed 's/[[:space:]]*$//')
|
||||
else
|
||||
CHANGED_FILES=$(find web/i18n/en-US -maxdepth 1 -type f -name '*.json' -print | sed -n 's@^.*/@@p' | sed 's/\.json$//' | sort | tr '\n' ' ' | sed 's/[[:space:]]*$//')
|
||||
CHANGED_FILES=$(find web/i18n/locales/en-US -maxdepth 1 -type f -name '*.json' -print | sed -n 's@^.*/@@p' | sed 's/\.json$//' | sort | tr '\n' ' ' | sed 's/[[:space:]]*$//')
|
||||
fi
|
||||
|
||||
export BASE_SHA HEAD_SHA CHANGED_FILES
|
||||
|
||||
4
.github/workflows/vdb-tests-full.yml
vendored
4
.github/workflows/vdb-tests-full.yml
vendored
@@ -29,14 +29,14 @@ jobs:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Free Disk Space
|
||||
uses: endersonmenezes/free-disk-space@7901478139cff6e9d44df5972fd8ab8fcade4db1 # v3.2.2
|
||||
uses: endersonmenezes/free-disk-space@2a22f8c59cae9cddae7194b33e6b92d023b2b4b8 # v4.0.0
|
||||
with:
|
||||
remove_dotnet: true
|
||||
remove_haskell: true
|
||||
remove_tool_cache: true
|
||||
|
||||
- name: Setup UV and Python
|
||||
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
|
||||
uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
|
||||
with:
|
||||
enable-cache: true
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
4
.github/workflows/vdb-tests.yml
vendored
4
.github/workflows/vdb-tests.yml
vendored
@@ -26,14 +26,14 @@ jobs:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Free Disk Space
|
||||
uses: endersonmenezes/free-disk-space@7901478139cff6e9d44df5972fd8ab8fcade4db1 # v3.2.2
|
||||
uses: endersonmenezes/free-disk-space@2a22f8c59cae9cddae7194b33e6b92d023b2b4b8 # v4.0.0
|
||||
with:
|
||||
remove_dotnet: true
|
||||
remove_haskell: true
|
||||
remove_tool_cache: true
|
||||
|
||||
- name: Setup UV and Python
|
||||
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
|
||||
uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
|
||||
with:
|
||||
enable-cache: true
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
162
.github/workflows/web-bundle-size.yml
vendored
Normal file
162
.github/workflows/web-bundle-size.yml
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
name: Web Bundle Analysis
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
base-rev:
|
||||
description: Exact base revision selected by the main CI event.
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
measure:
|
||||
name: Measure ${{ matrix.revision }}
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 30
|
||||
permissions:
|
||||
contents: read
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- revision: base
|
||||
sha: ${{ inputs.base-rev }}
|
||||
- revision: merge
|
||||
sha: ${{ github.sha }}
|
||||
env:
|
||||
NEXT_TELEMETRY_DISABLED: '1'
|
||||
NODE_OPTIONS: --max-old-space-size=6144
|
||||
steps:
|
||||
# Keep one collector for both revisions, including when it does not exist on base yet.
|
||||
- name: Checkout reporting tools
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Preserve collector
|
||||
run: cp web/scripts/bundle-analysis.ts "$RUNNER_TEMP/bundle-analysis.ts"
|
||||
|
||||
- name: Checkout measured revision
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
ref: ${{ matrix.sha }}
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup web environment
|
||||
uses: ./.github/actions/setup-web
|
||||
|
||||
- name: Instrument selected revision
|
||||
run: node "$RUNNER_TEMP/bundle-analysis.ts" instrument web
|
||||
|
||||
- name: Full Vinext build with official Rolldown analysis
|
||||
working-directory: web
|
||||
shell: bash
|
||||
run: |
|
||||
set -o pipefail
|
||||
started=$SECONDS
|
||||
pnpm run build:vinext 2>&1 | tee "$RUNNER_TEMP/vinext-build.log"
|
||||
printf 'Full Vinext build: **%s seconds**.\n' "$((SECONDS - started))" >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
- name: Collect sizes
|
||||
env:
|
||||
COMMIT_SHA: ${{ matrix.sha }}
|
||||
run: node "$RUNNER_TEMP/bundle-analysis.ts" collect web "$COMMIT_SHA" "$RUNNER_TEMP/bundle-size/summary.json"
|
||||
|
||||
- name: Upload size snapshot
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: web-bundle-summary-${{ matrix.revision }}
|
||||
path: ${{ runner.temp }}/bundle-size/summary.json
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
|
||||
- name: Upload official Rolldown analysis
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: web-bundle-analyzer-${{ matrix.revision }}
|
||||
path: |
|
||||
web/dist/client/bundle-analysis.json
|
||||
web/dist/client/bundle-analysis.md
|
||||
${{ runner.temp }}/vinext-build.log
|
||||
include-hidden-files: true
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
|
||||
report:
|
||||
name: Compare bundle sizes
|
||||
needs: measure
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 5
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Checkout reporting tools
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: pnpm/setup@fbda4c85fc2e1e08721cd8763afea8f48d60f024 # v3.0.0
|
||||
with:
|
||||
install: false
|
||||
|
||||
- name: Download size snapshots
|
||||
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
with:
|
||||
pattern: web-bundle-summary-*
|
||||
path: bundle-results
|
||||
|
||||
- name: Compare and summarize
|
||||
id: compare
|
||||
env:
|
||||
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
run: |
|
||||
node web/scripts/bundle-analysis.ts compare \
|
||||
bundle-results/web-bundle-summary-base/summary.json \
|
||||
bundle-results/web-bundle-summary-merge/summary.json \
|
||||
bundle-report.md
|
||||
printf '\n[Download base/merge snapshots and official Rolldown analysis reports](%s#artifacts).\n' "$RUN_URL" >> bundle-report.md
|
||||
printf '\nComparison: event base SHA vs the tested merge commit at GITHUB_SHA (PR or merge queue).\n' >> bundle-report.md
|
||||
cat bundle-report.md >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
# Forks still receive the job summary and artifacts, without a privileged PR build.
|
||||
- name: Update PR report
|
||||
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
env:
|
||||
SHOULD_COMMENT: ${{ steps.compare.outputs.should-comment }}
|
||||
with:
|
||||
script: |
|
||||
const fs = require('node:fs');
|
||||
const { owner, repo } = context.repo;
|
||||
const pull_number = context.payload.pull_request.number;
|
||||
const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number });
|
||||
if (pr.state !== 'open' || pr.head.sha !== context.payload.pull_request.head.sha ||
|
||||
pr.base.sha !== context.payload.pull_request.base.sha) {
|
||||
core.info('Skipping a superseded bundle report.');
|
||||
return;
|
||||
}
|
||||
const body = fs.readFileSync('bundle-report.md', 'utf8');
|
||||
const comments = await github.paginate(github.rest.issues.listComments, {
|
||||
owner, repo, issue_number: pull_number, per_page: 100,
|
||||
});
|
||||
const existing = comments.find(comment =>
|
||||
comment.user?.login === 'github-actions[bot]' &&
|
||||
comment.body?.startsWith('<!-- dify-vinext-bundle-size -->'));
|
||||
if (process.env.SHOULD_COMMENT !== 'true') {
|
||||
if (existing) {
|
||||
await github.rest.issues.deleteComment({ owner, repo, comment_id: existing.id });
|
||||
}
|
||||
core.info('Bundle changes are below the PR comment thresholds. See the job summary.');
|
||||
return;
|
||||
}
|
||||
if (existing) {
|
||||
await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body });
|
||||
} else {
|
||||
await github.rest.issues.createComment({ owner, repo, issue_number: pull_number, body });
|
||||
}
|
||||
287
.github/workflows/web-e2e.yml
vendored
287
.github/workflows/web-e2e.yml
vendored
@@ -9,16 +9,15 @@ on:
|
||||
type: boolean
|
||||
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Web Full-Stack E2E
|
||||
core-build:
|
||||
name: Prepare Core E2E Web Build
|
||||
if: ${{ !inputs.run-external-runtime }}
|
||||
runs-on: depot-ubuntu-24.04-4
|
||||
timeout-minutes: 120
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
timeout-minutes: 30
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -26,16 +25,197 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Switch Ubuntu mirror
|
||||
- name: Test Web build synchronization
|
||||
run: node --test .github/actions/wait-e2e-web-build/*.test.cjs
|
||||
|
||||
- name: Compute build source hash
|
||||
id: build-source
|
||||
shell: bash
|
||||
run: |
|
||||
sudo sed -i 's|http://us-east-1.ec2.archive.ubuntu.com/ubuntu|http://azure.archive.ubuntu.com/ubuntu|g' /etc/apt/sources.list.d/ubuntu.sources
|
||||
sudo apt-get update
|
||||
# Hash tracked build inputs, excluding generated files and backend-only changes.
|
||||
source_hash=$(git ls-tree -r HEAD -- web packages e2e/scripts e2e/package.json e2e/test-env.ts package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc .github/actions/setup-web .github/workflows/web-e2e.yml | sha256sum | cut -d ' ' -f 1)
|
||||
echo "hash=$source_hash" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Setup web dependencies
|
||||
uses: ./.github/actions/setup-web
|
||||
with:
|
||||
# Browser jobs already save this dependency cache; avoid duplicate uploads.
|
||||
cache-save: 'false'
|
||||
|
||||
- name: Restore Next.js build cache
|
||||
id: next-cache
|
||||
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
with:
|
||||
path: web/.next/cache
|
||||
key: e2e-next-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json', 'pnpm-lock.yaml', 'pnpm-workspace.yaml') }}-${{ steps.build-source.outputs.hash }}
|
||||
restore-keys: |
|
||||
e2e-next-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json', 'pnpm-lock.yaml', 'pnpm-workspace.yaml') }}-
|
||||
|
||||
- name: Run E2E support unit tests
|
||||
working-directory: ./e2e
|
||||
run: vp run test:unit
|
||||
|
||||
- name: Build production Web app
|
||||
working-directory: ./e2e
|
||||
env:
|
||||
E2E_FORCE_WEB_BUILD: '1'
|
||||
CACHE_HIT: ${{ steps.next-cache.outputs.cache-hit || 'false' }}
|
||||
run: |
|
||||
started=$SECONDS
|
||||
vp run e2e:web:build
|
||||
{
|
||||
echo "### E2E Web build"
|
||||
echo "Build: $((SECONDS - started))s"
|
||||
echo "Exact cache hit: $CACHE_HIT (false can include a compatible fallback)"
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
- name: Package Web build
|
||||
run: >-
|
||||
tar -cf e2e-web-build.tar -C web
|
||||
.next/BUILD_ID
|
||||
.next/e2e-web-build.sha256
|
||||
.next/standalone
|
||||
.next/static
|
||||
|
||||
- name: Upload Web build
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: core-e2e-web-build-${{ github.run_attempt }}
|
||||
path: e2e-web-build.tar
|
||||
if-no-files-found: error
|
||||
retention-days: 7
|
||||
|
||||
- name: Save Next.js build cache
|
||||
if: github.event_name != 'merge_group' && steps.next-cache.outputs.cache-hit != 'true'
|
||||
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
with:
|
||||
path: web/.next/cache
|
||||
key: ${{ steps.next-cache.outputs.cache-primary-key }}
|
||||
|
||||
chromium-full:
|
||||
name: Chromium Full (${{ matrix.shard }}/3)
|
||||
if: ${{ !inputs.run-external-runtime }}
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 45
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
shard: [1, 2, 3]
|
||||
env:
|
||||
E2E_ADMIN_EMAIL: e2e-admin@example.com
|
||||
E2E_ADMIN_NAME: E2E Admin
|
||||
E2E_ADMIN_PASSWORD: E2eAdmin12345
|
||||
E2E_INIT_PASSWORD: E2eInit12345
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Prepare Chromium E2E dependencies
|
||||
timeout-minutes: 15
|
||||
uses: ./.github/actions/setup-core-e2e
|
||||
with:
|
||||
browser: chromium
|
||||
|
||||
# The runner prepares the backend while waiting for and downloading the build.
|
||||
- name: Run Chromium full shard
|
||||
working-directory: ./e2e
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: vp run e2e:full --download-web-build -- --shard ${{ matrix.shard }}/3
|
||||
|
||||
- name: Upload Cucumber report
|
||||
if: ${{ !cancelled() }}
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: cucumber-report-chromium-${{ matrix.shard }}
|
||||
path: e2e/cucumber-report
|
||||
if-no-files-found: ignore
|
||||
overwrite: true
|
||||
retention-days: 7
|
||||
|
||||
- name: Upload E2E logs
|
||||
if: ${{ !cancelled() }}
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: e2e-logs-chromium-${{ matrix.shard }}
|
||||
path: e2e/.logs/*.log
|
||||
if-no-files-found: ignore
|
||||
include-hidden-files: true
|
||||
overwrite: true
|
||||
retention-days: 7
|
||||
|
||||
webkit-smoke:
|
||||
name: WebKit Browser Smoke
|
||||
if: ${{ !inputs.run-external-runtime }}
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 45
|
||||
env:
|
||||
E2E_ADMIN_EMAIL: e2e-admin@example.com
|
||||
E2E_ADMIN_NAME: E2E Admin
|
||||
E2E_ADMIN_PASSWORD: E2eAdmin12345
|
||||
E2E_BROWSER: webkit
|
||||
E2E_INIT_PASSWORD: E2eInit12345
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Prepare WebKit E2E dependencies
|
||||
timeout-minutes: 15
|
||||
uses: ./.github/actions/setup-core-e2e
|
||||
with:
|
||||
browser: webkit
|
||||
|
||||
# Keep the same overlap and teardown ownership for the WebKit smoke lane.
|
||||
- name: Run WebKit browser smoke
|
||||
working-directory: ./e2e
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: vp run e2e:full --download-web-build -- --tags '@browser-smoke'
|
||||
|
||||
- name: Upload Cucumber report
|
||||
if: ${{ !cancelled() }}
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: cucumber-report-webkit
|
||||
path: e2e/cucumber-report
|
||||
if-no-files-found: ignore
|
||||
overwrite: true
|
||||
retention-days: 7
|
||||
|
||||
- name: Upload E2E logs
|
||||
if: ${{ !cancelled() }}
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: e2e-logs-webkit
|
||||
path: e2e/.logs/*.log
|
||||
if-no-files-found: ignore
|
||||
include-hidden-files: true
|
||||
overwrite: true
|
||||
retention-days: 7
|
||||
|
||||
external-runtime:
|
||||
name: Web Full-Stack E2E
|
||||
if: ${{ inputs.run-external-runtime }}
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 120
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup web dependencies
|
||||
uses: ./.github/actions/setup-web
|
||||
|
||||
- name: Setup UV and Python
|
||||
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
|
||||
uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
|
||||
with:
|
||||
enable-cache: true
|
||||
python-version: '3.12'
|
||||
@@ -46,82 +226,12 @@ jobs:
|
||||
- name: Install API dependencies
|
||||
run: uv sync --project api --dev
|
||||
|
||||
- name: Run E2E support unit tests
|
||||
if: ${{ !inputs.run-external-runtime }}
|
||||
working-directory: ./e2e
|
||||
run: vp run test:unit
|
||||
|
||||
- name: Install Playwright browsers for core E2E
|
||||
if: ${{ !inputs.run-external-runtime }}
|
||||
timeout-minutes: 15
|
||||
working-directory: ./e2e
|
||||
run: vp run e2e:install:ci
|
||||
|
||||
- name: Install Chromium for external runtime E2E
|
||||
if: ${{ inputs.run-external-runtime }}
|
||||
- name: Install Chromium
|
||||
timeout-minutes: 15
|
||||
working-directory: ./e2e
|
||||
run: vp run e2e:install:ci:chromium
|
||||
|
||||
- name: Run isolated source-api and built-web Cucumber E2E tests
|
||||
if: ${{ !inputs.run-external-runtime }}
|
||||
working-directory: ./e2e
|
||||
env:
|
||||
E2E_ADMIN_EMAIL: e2e-admin@example.com
|
||||
E2E_ADMIN_NAME: E2E Admin
|
||||
E2E_ADMIN_PASSWORD: E2eAdmin12345
|
||||
E2E_FORCE_WEB_BUILD: '1'
|
||||
E2E_INIT_PASSWORD: E2eInit12345
|
||||
run: vp run e2e:full
|
||||
|
||||
- name: Preserve Chromium E2E report and logs
|
||||
if: ${{ !cancelled() && !inputs.run-external-runtime }}
|
||||
run: |
|
||||
if [[ -d e2e/cucumber-report ]]; then
|
||||
mv e2e/cucumber-report e2e/cucumber-report-non-external
|
||||
fi
|
||||
if [[ -d e2e/.logs ]]; then
|
||||
mv e2e/.logs e2e/.logs-non-external
|
||||
fi
|
||||
|
||||
- name: Run WebKit keyboard and browser smoke tests
|
||||
if: ${{ !inputs.run-external-runtime }}
|
||||
working-directory: ./e2e
|
||||
env:
|
||||
E2E_ADMIN_EMAIL: e2e-admin@example.com
|
||||
E2E_ADMIN_NAME: E2E Admin
|
||||
E2E_ADMIN_PASSWORD: E2eAdmin12345
|
||||
E2E_BROWSER: webkit
|
||||
E2E_INIT_PASSWORD: E2eInit12345
|
||||
run: |
|
||||
teardown_webkit_smoke() {
|
||||
local run_status=$?
|
||||
trap - EXIT
|
||||
if ! vp run e2e:middleware:down; then
|
||||
echo "::error title=E2E teardown failed::WebKit smoke middleware did not shut down cleanly."
|
||||
if [[ "$run_status" -eq 0 ]]; then
|
||||
run_status=1
|
||||
fi
|
||||
fi
|
||||
exit "$run_status"
|
||||
}
|
||||
|
||||
trap teardown_webkit_smoke EXIT
|
||||
vp run e2e:middleware:up
|
||||
vp run e2e -- --tags '@browser-smoke'
|
||||
|
||||
- name: Preserve WebKit E2E report and logs
|
||||
if: ${{ !cancelled() && !inputs.run-external-runtime }}
|
||||
run: |
|
||||
if [[ -d e2e/cucumber-report ]]; then
|
||||
mv e2e/cucumber-report e2e/cucumber-report-webkit
|
||||
fi
|
||||
if [[ -d e2e/.logs ]]; then
|
||||
mv e2e/.logs e2e/.logs-webkit
|
||||
fi
|
||||
|
||||
- name: Run prepared and external runtime E2E tests
|
||||
if: ${{ inputs.run-external-runtime }}
|
||||
working-directory: ./e2e
|
||||
env:
|
||||
E2E_ADMIN_EMAIL: e2e-admin@example.com
|
||||
@@ -154,10 +264,8 @@ jobs:
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: cucumber-report
|
||||
path: |
|
||||
e2e/cucumber-report
|
||||
e2e/cucumber-report-non-external
|
||||
e2e/cucumber-report-webkit
|
||||
path: e2e/cucumber-report
|
||||
overwrite: true
|
||||
retention-days: 7
|
||||
|
||||
- name: Upload E2E logs
|
||||
@@ -165,18 +273,17 @@ jobs:
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: e2e-logs
|
||||
path: |
|
||||
e2e/.logs/*.log
|
||||
e2e/.logs-non-external/*.log
|
||||
e2e/.logs-webkit/*.log
|
||||
path: e2e/.logs/*.log
|
||||
include-hidden-files: true
|
||||
overwrite: true
|
||||
retention-days: 7
|
||||
|
||||
- name: Upload E2E seed report
|
||||
if: ${{ !cancelled() && inputs.run-external-runtime }}
|
||||
if: ${{ !cancelled() }}
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: e2e-seed-report
|
||||
path: e2e/seed-report
|
||||
if-no-files-found: ignore
|
||||
overwrite: true
|
||||
retention-days: 7
|
||||
|
||||
81
.github/workflows/web-tests.yml
vendored
81
.github/workflows/web-tests.yml
vendored
@@ -33,17 +33,52 @@ jobs:
|
||||
uses: ./.github/actions/setup-web
|
||||
|
||||
- name: Run tests
|
||||
run: vp test run --reporter=blob --reporter=minimal --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --coverage
|
||||
run: vp test run --project unit --reporter=blob --reporter=minimal --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --coverage
|
||||
|
||||
- name: Upload blob report
|
||||
if: ${{ !cancelled() }}
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: blob-report-${{ matrix.shardIndex }}
|
||||
path: web/.vitest-reports/*
|
||||
path: web/.vitest/blob/*
|
||||
include-hidden-files: true
|
||||
retention-days: 1
|
||||
|
||||
browser-test:
|
||||
name: Web Browser Tests
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 20
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
working-directory: ./web
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup web environment
|
||||
uses: ./.github/actions/setup-web
|
||||
|
||||
- name: Install Chromium for Browser Mode
|
||||
timeout-minutes: 15
|
||||
run: vp exec playwright install --with-deps --only-shell chromium
|
||||
|
||||
- name: Run browser tests
|
||||
run: vp test run --project browser --silent=passed-only
|
||||
|
||||
- name: Upload browser failure artifacts
|
||||
if: ${{ failure() && !cancelled() }}
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: browser-test-failures
|
||||
path: web/.vitest-browser/
|
||||
if-no-files-found: ignore
|
||||
include-hidden-files: true
|
||||
retention-days: 7
|
||||
|
||||
merge-reports:
|
||||
name: Merge Test Reports
|
||||
if: ${{ !cancelled() }}
|
||||
@@ -68,7 +103,7 @@ jobs:
|
||||
- name: Download blob reports
|
||||
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
with:
|
||||
path: web/.vitest-reports
|
||||
path: web/.vitest/blob
|
||||
pattern: blob-report-*
|
||||
merge-multiple: true
|
||||
|
||||
@@ -76,8 +111,7 @@ jobs:
|
||||
run: vp test --merge-reports --coverage --silent=passed-only
|
||||
|
||||
- name: Report coverage
|
||||
if: ${{ env.CODECOV_TOKEN != '' }}
|
||||
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
|
||||
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
|
||||
with:
|
||||
directory: web/coverage
|
||||
flags: web
|
||||
@@ -86,7 +120,7 @@ jobs:
|
||||
|
||||
dify-ui-test:
|
||||
name: dify-ui Tests
|
||||
runs-on: depot-ubuntu-24.04-4
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 20
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
@@ -101,11 +135,6 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Switch Ubuntu mirror
|
||||
run: |
|
||||
sudo sed -i 's|http://us-east-1.ec2.archive.ubuntu.com/ubuntu|http://azure.archive.ubuntu.com/ubuntu|g' /etc/apt/sources.list.d/ubuntu.sources
|
||||
sudo apt-get update
|
||||
|
||||
- name: Setup web environment
|
||||
uses: ./.github/actions/setup-web
|
||||
|
||||
@@ -116,9 +145,18 @@ jobs:
|
||||
- name: Run dify-ui tests
|
||||
run: vp test run --project unit --coverage --silent=passed-only
|
||||
|
||||
- name: Upload dify-ui test failure artifacts
|
||||
if: ${{ failure() && !cancelled() }}
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: dify-ui-test-failures
|
||||
path: packages/dify-ui/.vitest-browser/
|
||||
if-no-files-found: ignore
|
||||
include-hidden-files: true
|
||||
retention-days: 7
|
||||
|
||||
- name: Report coverage
|
||||
if: ${{ env.CODECOV_TOKEN != '' }}
|
||||
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
|
||||
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
|
||||
with:
|
||||
directory: packages/dify-ui/coverage
|
||||
flags: dify-ui
|
||||
@@ -127,7 +165,7 @@ jobs:
|
||||
|
||||
dify-ui-storybook-test:
|
||||
name: dify-ui Storybook Tests
|
||||
runs-on: depot-ubuntu-24.04-4
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 20
|
||||
defaults:
|
||||
run:
|
||||
@@ -140,11 +178,6 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Switch Ubuntu mirror
|
||||
run: |
|
||||
sudo sed -i 's|http://us-east-1.ec2.archive.ubuntu.com/ubuntu|http://azure.archive.ubuntu.com/ubuntu|g' /etc/apt/sources.list.d/ubuntu.sources
|
||||
sudo apt-get update
|
||||
|
||||
- name: Setup web environment
|
||||
uses: ./.github/actions/setup-web
|
||||
|
||||
@@ -154,3 +187,13 @@ jobs:
|
||||
|
||||
- name: Run dify-ui Storybook tests
|
||||
run: vp run test:storybook
|
||||
|
||||
- name: Upload dify-ui Storybook test failure artifacts
|
||||
if: ${{ failure() && !cancelled() }}
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: dify-ui-storybook-test-failures
|
||||
path: packages/dify-ui/.vitest-browser/
|
||||
if-no-files-found: ignore
|
||||
include-hidden-files: true
|
||||
retention-days: 7
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -185,6 +185,7 @@ docker/volumes/minio/*
|
||||
docker/volumes/milvus/*
|
||||
docker/volumes/chroma/*
|
||||
docker/volumes/opensearch/data/*
|
||||
docker/volumes/openshell-mtls/*
|
||||
docker/volumes/myscale/data/*
|
||||
docker/volumes/myscale/log/*
|
||||
docker/volumes/unstructured/*
|
||||
@@ -263,6 +264,7 @@ scripts/stress-test/reports/
|
||||
.qoder/*
|
||||
.context/
|
||||
# Vitest local reports
|
||||
web/.vitest-browser/
|
||||
web/.vitest-reports/
|
||||
|
||||
# dify-agent-runtime
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
#!/bin/sh
|
||||
# get the list of modified files
|
||||
files=$(git diff --cached --name-only)
|
||||
|
||||
# check if api or web directory is modified
|
||||
|
||||
api_modified=false
|
||||
web_modified=false
|
||||
skip_web_checks=false
|
||||
set -eu
|
||||
|
||||
git_path() {
|
||||
git rev-parse --git-path "$1"
|
||||
@@ -18,46 +11,7 @@ if [ -f "$(git_path MERGE_HEAD)" ] || \
|
||||
[ -f "$(git_path SQUASH_MSG)" ] || \
|
||||
[ -d "$(git_path rebase-merge)" ] || \
|
||||
[ -d "$(git_path rebase-apply)" ]; then
|
||||
skip_web_checks=true
|
||||
fi
|
||||
|
||||
for file in $files
|
||||
do
|
||||
# Use POSIX compliant pattern matching
|
||||
case "$file" in
|
||||
api/*.py)
|
||||
# set api_modified flag to true
|
||||
api_modified=true
|
||||
;;
|
||||
web/*)
|
||||
# set web_modified flag to true
|
||||
web_modified=true
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# run linters based on the modified modules
|
||||
|
||||
if $api_modified; then
|
||||
echo "Running Ruff linter on api module"
|
||||
|
||||
# run Ruff linter auto-fixing
|
||||
uv run --project api --dev ruff check --fix ./api
|
||||
|
||||
# run Ruff linter checks
|
||||
uv run --project api --dev ruff check ./api || status=$?
|
||||
|
||||
status=${status:-0}
|
||||
|
||||
if [ $status -ne 0 ]; then
|
||||
echo "Ruff linter on api module error, exit code: $status"
|
||||
echo "Please run 'dev/reformat' to fix the fixable linting errors."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if $skip_web_checks; then
|
||||
echo "Git operation in progress, skipping web checks"
|
||||
echo "Git operation in progress, skipping staged checks; CI validates the result."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
9
.vscode/README.md
vendored
9
.vscode/README.md
vendored
@@ -1,14 +1,11 @@
|
||||
# Debugging with VS Code
|
||||
|
||||
This `launch.json.template` file provides various debug configurations for the Dify project within VS Code / Cursor. To use these configurations, you should copy the contents of this file into a new file named `launch.json` in the same `.vscode` directory.
|
||||
[`launch.json.template`](launch.json.template) provides API and Celery worker debug configurations for VS Code / Cursor. Both use `api/.venv/bin/python`; complete the [backend setup](../api/README.md) first.
|
||||
|
||||
## How to Use
|
||||
|
||||
1. **Create `launch.json`**: If you don't have one, create a file named `launch.json` inside the `.vscode` directory.
|
||||
1. **Copy Content**: Copy the entire content from `launch.json.template` into your newly created `launch.json` file.
|
||||
1. Copy `.vscode/launch.json.template` to `.vscode/launch.json`, or merge the configurations into an existing file.
|
||||
1. **Select Debug Configuration**: Go to the Run and Debug view in VS Code / Cursor (Ctrl+Shift+D or Cmd+Shift+D).
|
||||
1. **Start Debugging**: Select the desired configuration from the dropdown menu and click the green play button.
|
||||
|
||||
## Tips
|
||||
|
||||
- If you need to debug with Edge browser instead of Chrome, modify the `serverReadyAction` configuration in the "Next.js: debug full stack" section, change `"debugWithChrome"` to `"debugWithEdge"` to use Microsoft Edge for debugging.
|
||||
Start the frontend separately using the [frontend guide](../web/README.md).
|
||||
|
||||
5
.vscode/settings.example.json
vendored
5
.vscode/settings.example.json
vendored
@@ -4,7 +4,6 @@
|
||||
|
||||
"tailwindCSS.experimental.configFile": "web/app/styles/globals.css",
|
||||
|
||||
// Format
|
||||
"[javascript]": { "editor.defaultFormatter": "oxc.oxc-vscode" },
|
||||
"[javascriptreact]": { "editor.defaultFormatter": "oxc.oxc-vscode" },
|
||||
"[typescript]": { "editor.defaultFormatter": "oxc.oxc-vscode" },
|
||||
@@ -25,9 +24,9 @@
|
||||
"[handlebars]": { "editor.defaultFormatter": "oxc.oxc-vscode" },
|
||||
"editor.formatOnSave": true,
|
||||
"editor.formatOnSaveMode": "file",
|
||||
"oxc.fmt.configPath": "./vite.config.ts",
|
||||
"oxc.disableNestedConfig": true,
|
||||
"oxc.fmt.disableNestedConfig": true,
|
||||
|
||||
// Lint fix
|
||||
"eslint.useFlatConfig": true,
|
||||
"eslint.validate": ["json", "jsonc", "markdown", "yaml", "toml"],
|
||||
"editor.codeActionsOnSave": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# AGENTS.md
|
||||
|
||||
Dify is an open-source platform for building LLM applications, agentic workflows, and RAG pipelines. This monorepo contains the backend API (`api/`), frontend application (`web/`), deployment assets (`docker/`), standalone agent backend (`dify-agent/`), CLI (`cli/`), and end-to-end suite (`e2e/`). Follow the nearest scoped `AGENTS.md` for the files being changed.
|
||||
Dify is an open-source platform for building LLM applications, agentic workflows, and RAG pipelines. This monorepo contains the backend API (`api/`), frontend application (`web/`), deployment assets (`docker/`), standalone agent backend (`dify-agent/`), CLI (`cli/`), and end-to-end suite (`e2e/`). Follow the nearest scoped `AGENTS.md` for the files being changed. Apply its guidance within the user's requested scope; explicit user instructions take precedence over workflow defaults.
|
||||
|
||||
## Repository Gotchas
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ Don't forget to link an existing issue or open a new issue in the PR's descripti
|
||||
|
||||
### Bug reports
|
||||
|
||||
For security vulnerabilities, follow our [security policy](./SECURITY.md) and report privately instead of opening a public issue.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Please make sure to include the following information when submitting a bug report:
|
||||
|
||||
@@ -36,7 +38,7 @@ How we prioritize:
|
||||
|
||||
| Issue Type | Priority |
|
||||
| ------------------------------------------------------------ | --------------- |
|
||||
| Bugs in core functions (cloud service, cannot login, applications not working, security loopholes) | Critical |
|
||||
| Bugs in core functions (cloud service, cannot login, applications not working) | Critical |
|
||||
| Non-critical bugs, performance boosts | Medium Priority |
|
||||
| Minor fixes (typos, confusing but working UI) | Low Priority |
|
||||
|
||||
@@ -71,28 +73,21 @@ How we prioritize:
|
||||
1. Please link the issue in the PR description, `fixes #<issue_number>`
|
||||
1. Get merged!
|
||||
|
||||
### AI-assisted contributions
|
||||
|
||||
AI tools are welcome, but you are responsible for understanding and verifying every change you submit. Describe the problem, your solution, and actual test results in your own words. Unreviewed or repetitive low-quality submissions may be closed.
|
||||
|
||||
### Setup the project
|
||||
|
||||
#### Frontend
|
||||
|
||||
For setting up the frontend service, please refer to our comprehensive [guide](https://github.com/langgenius/dify/blob/main/web/README.md) in the `web/README.md` file. This document provides detailed instructions to help you set up the frontend environment properly.
|
||||
For setting up the frontend service, please refer to our comprehensive [guide](web/README.md) in the `web/README.md` file. This document provides detailed instructions to help you set up the frontend environment properly.
|
||||
|
||||
**Testing**: Add focused tests when a change affects observable behavior or carries meaningful regression risk. See [web/docs/test.md](https://github.com/langgenius/dify/blob/main/web/docs/test.md) for the canonical frontend testing guidelines.
|
||||
**Testing**: Add focused tests when a change affects observable behavior or carries meaningful regression risk. See [web/docs/test.md](web/docs/test.md) for the canonical frontend testing guidelines.
|
||||
|
||||
#### Backend
|
||||
|
||||
For setting up the backend service, kindly refer to our detailed [instructions](https://github.com/langgenius/dify/blob/main/api/README.md) in the `api/README.md` file. This document contains step-by-step guidance to help you get the backend up and running smoothly.
|
||||
|
||||
#### Other things to note
|
||||
|
||||
We recommend reviewing this document carefully before proceeding with the setup, as it contains essential information about:
|
||||
|
||||
- Prerequisites and dependencies
|
||||
- Installation steps
|
||||
- Configuration details
|
||||
- Common troubleshooting tips
|
||||
|
||||
Feel free to reach out if you encounter any issues during the setup process.
|
||||
For setting up the backend service, kindly refer to our detailed [instructions](api/README.md) in the `api/README.md` file. This document contains step-by-step guidance to help you get the backend up and running smoothly.
|
||||
|
||||
## Getting Help
|
||||
|
||||
|
||||
11
Makefile
11
Makefile
@@ -80,6 +80,7 @@ lint:
|
||||
@uv run --project api --dev ruff format ./api
|
||||
@uv run --project api --dev ruff check --fix ./api
|
||||
@$(MAKE) api-contract-lint
|
||||
@uv run --project api python scripts/check_no_spec_mock.py
|
||||
@uv run --directory api --dev lint-imports
|
||||
@uv run --project api --dev dotenv-linter ./api/.env.example ./web/.env.example
|
||||
@echo "✅ Linting complete"
|
||||
@@ -90,15 +91,13 @@ api-contract-lint:
|
||||
@echo "✅ Response contract lint complete"
|
||||
|
||||
type-check:
|
||||
@echo "📝 Running type checks (pyrefly + mypy)..."
|
||||
@echo "📝 Running type checks (pyrefly)..."
|
||||
@./dev/pyrefly-check-local $(PATH_TO_CHECK)
|
||||
@uv --directory api run mypy --exclude-gitignore --exclude '(^|/)conftest\.py$$' --exclude 'tests/' --exclude 'migrations/' --exclude 'dev/generate_swagger_specs.py' --exclude 'dev/generate_fastopenapi_specs.py' --check-untyped-defs --disable-error-code=import-untyped .
|
||||
@echo "✅ Type checks complete"
|
||||
|
||||
type-check-core:
|
||||
@echo "📝 Running core type checks (pyrefly + mypy)..."
|
||||
@echo "📝 Running core type checks (pyrefly)..."
|
||||
@./dev/pyrefly-check-local $(PATH_TO_CHECK)
|
||||
@uv --directory api run mypy --exclude-gitignore --exclude '(^|/)conftest\.py$$' --exclude 'tests/' --exclude 'migrations/' --exclude 'dev/generate_swagger_specs.py' --exclude 'dev/generate_fastopenapi_specs.py' --check-untyped-defs --disable-error-code=import-untyped .
|
||||
@echo "✅ Core type checks complete"
|
||||
|
||||
test:
|
||||
@@ -214,8 +213,8 @@ help:
|
||||
@echo " make check - Check code with ruff"
|
||||
@echo " make lint - Format, fix, and lint code (ruff, imports, dotenv)"
|
||||
@echo " make api-contract-lint - Check Flask response docs against returned schemas"
|
||||
@echo " make type-check - Run type checks (pyrefly, mypy)"
|
||||
@echo " make type-check-core - Run core type checks (pyrefly, mypy)"
|
||||
@echo " make type-check - Run type checks (pyrefly)"
|
||||
@echo " make type-check-core - Run core type checks (pyrefly)"
|
||||
@echo " make test - Run backend unit tests (or TARGET_TESTS=./api/tests/<target_tests>)"
|
||||
@echo " make test-all - Run full backend tests, including Docker-backed suites"
|
||||
@echo ""
|
||||
|
||||
98
README.md
98
README.md
@@ -58,6 +58,7 @@
|
||||
<a href="./docs/sl-SI/README.md"><img alt="README Slovenščina" src="https://img.shields.io/badge/Sloven%C5%A1%C4%8Dina-d9d9d9"></a>
|
||||
<a href="./docs/bn-BD/README.md"><img alt="README in বাংলা" src="https://img.shields.io/badge/বাংলা-d9d9d9"></a>
|
||||
<a href="./docs/hi-IN/README.md"><img alt="README in हिन्दी" src="https://img.shields.io/badge/Hindi-d9d9d9"></a>
|
||||
<a href="./docs/id-ID/README.md"><img alt="README dalam Bahasa Indonesia" src="https://img.shields.io/badge/Bahasa%20Indonesia-d9d9d9"></a>
|
||||
</p>
|
||||
|
||||
Dify is an open-source LLM app development platform. Its intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features (including [Opik](https://www.comet.com/docs/opik/integrations/dify), [Langfuse](https://docs.langfuse.com), and [Arize Phoenix](https://docs.arize.com/phoenix)) and more, letting you quickly go from prototype to production. Here's a list of the core features:
|
||||
@@ -82,7 +83,7 @@ docker compose up -d
|
||||
|
||||
After running, you can access the Dify dashboard in your browser at [http://localhost/install](http://localhost/install) and start the initialization process.
|
||||
|
||||
#### Seeking help
|
||||
### Seeking help
|
||||
|
||||
Please refer to our [FAQ](https://docs.dify.ai/getting-started/install-self-hosted/faqs) if you encounter problems setting up Dify. Reach out to [the community and us](#community--contact) if you are still having issues.
|
||||
|
||||
@@ -104,8 +105,7 @@ Intuitive interface for crafting prompts, comparing model performance, and addin
|
||||
**4. RAG Pipeline**:
|
||||
Extensive RAG capabilities that cover everything from document ingestion to retrieval, with out-of-box support for text extraction from PDFs, PPTs, and other common document formats.
|
||||
|
||||
**5. Agent capabilities**:
|
||||
You can define agents based on LLM Function Calling or ReAct, and add pre-built or custom tools for the agent. Dify provides 50+ built-in tools for AI agents, such as Google Search, DALL·E, Stable Diffusion and WolframAlpha.
|
||||
**5. Agent**: Autonomous agents with a sandbox of their own: they run commands, install software, and handle files to get open-ended tasks done. Describe the agent you want and it builds itself. Give it skills, connect tools from [Dify Marketplace](https://marketplace.dify.ai/?category=tool), MCP servers, or your own APIs, and put it to work as a chat app or as a step in any workflow.
|
||||
|
||||
**6. LLMOps**:
|
||||
Monitor and analyze application logs and performance over time. You could continuously improve prompts, datasets, and models based on production data and annotations.
|
||||
@@ -116,96 +116,48 @@ All of Dify's offerings come with corresponding APIs, so you could effortlessly
|
||||
## Using Dify
|
||||
|
||||
- **Cloud <br/>**
|
||||
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. If you run into issues with Dify Cloud, [contact our Cloud support team](mailto:cloud@dify.ai?subject=%5BGitHub%5DDify%20Cloud%20Support).
|
||||
We host [Dify Cloud](https://cloud.dify.ai) so you can try Dify without managing a server. See the [pricing page](https://dify.ai/pricing) for current plans and usage allowances. If you run into issues, [contact our Cloud support team](mailto:cloud@dify.ai?subject=%5BGitHub%5DDify%20Cloud%20Support).
|
||||
|
||||
- **Self-hosting Dify Community Edition<br/>**
|
||||
Quickly get Dify running in your environment with this [starter guide](#quick-start).
|
||||
Use our [documentation](https://docs.dify.ai) for further references and more in-depth instructions.
|
||||
|
||||
- **Dify for enterprise / organizations<br/>**
|
||||
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/>
|
||||
- **[Dify Enterprise](https://dify.ai/dify-enterprise)<br/>**
|
||||
For organizations requiring self-hosting, SSO, RBAC Security and Enterprise Support SLAs, please fill out [this form](https://share-na2.hsforms.com/14-09ff5HS92Sh4m3f4yrcw40s9fk) to speak to a solution representative. <br/>
|
||||
|
||||
## Staying ahead
|
||||
|
||||
Star Dify on GitHub and be instantly notified of new releases.
|
||||
|
||||

|
||||
<img width="1344" height="720" alt="star" src="https://github.com/user-attachments/assets/dcd086d1-af0f-471b-ae52-1ad2fa040595" />
|
||||
|
||||
## Advanced Setup
|
||||
|
||||
### Custom configurations
|
||||
|
||||
If you need to customize the configuration, edit `docker/.env`. The essential startup defaults live in [`docker/.env.example`](docker/.env.example), and optional advanced variables are split under `docker/envs/` by theme. After making any changes, re-run `docker compose up -d` from the `docker` directory. You can find the full list of available environment variables [here](https://docs.dify.ai/getting-started/install-self-hosted/environments).
|
||||
|
||||
### Metrics Monitoring with Grafana
|
||||
|
||||
Import the dashboard to Grafana, using Dify's PostgreSQL database as data source, to monitor metrics in granularity of apps, tenants, messages, and more.
|
||||
|
||||
- [Grafana Dashboard by @bowenliang123](https://github.com/bowenliang123/dify-grafana-dashboard)
|
||||
|
||||
### Deployment with Kubernetes
|
||||
|
||||
If you'd like to configure a highly available setup, there are community-contributed [Helm Charts](https://helm.sh/) and YAML files which allow Dify to be deployed on Kubernetes.
|
||||
|
||||
- [Helm Chart by @LeoQuote](https://github.com/douban/charts/tree/master/charts/dify)
|
||||
- [Helm Chart by @BorisPolonsky](https://github.com/BorisPolonsky/dify-helm)
|
||||
- [Helm Chart by @magicsong](https://github.com/magicsong/ai-charts)
|
||||
- [YAML file by @Winson-030](https://github.com/Winson-030/dify-kubernetes)
|
||||
- [YAML file by @wyy-holding](https://github.com/wyy-holding/dify-k8s)
|
||||
- [🚀 NEW! YAML files (Supports Dify v1.6.0) by @Zhoneym](https://github.com/Zhoneym/DifyAI-Kubernetes)
|
||||
|
||||
#### Using Terraform for Deployment
|
||||
|
||||
Deploy Dify to Cloud Platform with a single click using [terraform](https://www.terraform.io/)
|
||||
|
||||
##### Azure Global
|
||||
|
||||
- [Azure Terraform by @nikawang](https://github.com/nikawang/dify-azure-terraform)
|
||||
|
||||
##### Google Cloud
|
||||
|
||||
- [Google Cloud Terraform by @sotazum](https://github.com/DeNA/dify-google-cloud-terraform)
|
||||
|
||||
#### Using AWS CDK for Deployment
|
||||
|
||||
Deploy Dify to AWS with [CDK](https://aws.amazon.com/cdk/)
|
||||
|
||||
##### AWS
|
||||
|
||||
- [AWS CDK by @KevinZhao (EKS based)](https://github.com/aws-samples/solution-for-deploying-dify-on-aws)
|
||||
- [AWS CDK by @tmokmss (ECS based)](https://github.com/aws-samples/dify-self-hosted-on-aws)
|
||||
|
||||
#### Using Alibaba Cloud Computing Nest
|
||||
|
||||
Quickly deploy Dify to Alibaba cloud with [Alibaba Cloud Computing Nest](https://computenest.console.aliyun.com/service/instance/create/default?type=user&ServiceName=Dify%E7%A4%BE%E5%8C%BA%E7%89%88)
|
||||
|
||||
#### Using Alibaba Cloud Data Management
|
||||
|
||||
One-Click deploy Dify to Alibaba Cloud with [Alibaba Cloud Data Management](https://www.alibabacloud.com/help/en/dms/dify-in-invitational-preview/)
|
||||
|
||||
#### Deploy to AKS with Azure Devops Pipeline
|
||||
|
||||
One-Click deploy Dify to AKS with [Azure Devops Pipeline Helm Chart by @LeoZhang](https://github.com/Ruiruiz30/Dify-helm-chart-AKS)
|
||||
For custom configuration, observability, and deployment options, see [Advanced Setup](docs/ADVANCED_SETUP.md).
|
||||
|
||||
## Contributing
|
||||
|
||||
For those who'd like to contribute code, see our [Contribution Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md).
|
||||
At the same time, please consider supporting Dify by sharing it on social media and at events and conferences.
|
||||
Dify welcomes contributions of all kinds:
|
||||
|
||||
> We are looking for contributors to help translate Dify into languages other than Mandarin or English. If you are interested in helping, please see the [i18n README](https://github.com/langgenius/dify/blob/main/web/i18n-config/README.md) for more information, and leave us a comment in the `global-users` channel of our [Discord Community Server](https://discord.gg/8Tpq4AcN9c).
|
||||
- **Code**: Read the [Contribution Guide](CONTRIBUTING.md), then browse [good first issues](https://github.com/langgenius/dify/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22good%20first%20issue%22).
|
||||
- **Ideas and feedback**: Start or join a [GitHub Discussion](https://github.com/langgenius/dify/discussions).
|
||||
- **Translations**: Follow the [internationalization guide](web/i18n/README.md) to add or update a locale.
|
||||
- **Community**: Share the apps you build, help other users, and spread the word about Dify.
|
||||
|
||||
### Contributors
|
||||
|
||||
<a href="https://github.com/langgenius/dify/graphs/contributors">
|
||||
<img alt="Dify contributors" src="https://contrib.rocks/image?repo=langgenius/dify" />
|
||||
</a>
|
||||
|
||||
## Community & contact
|
||||
|
||||
- [GitHub Discussion](https://github.com/langgenius/dify/discussions). Best for: sharing feedback and asking questions.
|
||||
- [GitHub Issues](https://github.com/langgenius/dify/issues). Best for: bugs you encounter using Dify.AI, and feature proposals. See our [Contribution Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md).
|
||||
- [Discord](https://discord.gg/FngNHpbcY7). Best for: sharing your applications and hanging out with the community.
|
||||
- [X(Twitter)](https://twitter.com/dify_ai). Best for: sharing your applications and hanging out with the community.
|
||||
Choose the channel that best fits your question:
|
||||
|
||||
**Contributors**
|
||||
|
||||
<a href="https://github.com/langgenius/dify/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=langgenius/dify" />
|
||||
</a>
|
||||
- [GitHub Discussions](https://github.com/langgenius/dify/discussions): Get help, share feedback, and propose ideas.
|
||||
- [GitHub Issues](https://github.com/langgenius/dify/issues): Report reproducible bugs and track engineering work. Read the [Contribution Guide](CONTRIBUTING.md) before opening one.
|
||||
- [Discord](https://discord.gg/FngNHpbcY7): Chat in real time, share your apps, and connect with other Dify users.
|
||||
- [X](https://x.com/dify_ai): Follow Dify for release news and project updates.
|
||||
|
||||
## Star History
|
||||
|
||||
@@ -219,7 +171,7 @@ At the same time, please consider supporting Dify by sharing it on social media
|
||||
|
||||
## Security disclosure
|
||||
|
||||
To protect your privacy, please avoid posting security issues on GitHub. Instead, report issues to security@dify.ai, and our team will respond with detailed answer.
|
||||
Report vulnerabilities privately through GitHub Security Advisories, following our [security policy](SECURITY.md). Do not disclose them in public issues, discussions, or pull requests.
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -98,9 +98,11 @@ REDIS_KEEPALIVE=true
|
||||
CELERY_BROKER_URL=redis://:difyai123456@localhost:${REDIS_PORT}/1
|
||||
CELERY_BACKEND=redis
|
||||
|
||||
# Ops trace retry configuration
|
||||
OPS_TRACE_RETRYABLE_DISPATCH_MAX_RETRIES=60
|
||||
# Ops trace configuration
|
||||
OPS_TRACE_UNIFIED_ENABLED=false
|
||||
OPS_TRACE_RETRYABLE_DISPATCH_MAX_RETRIES=780
|
||||
OPS_TRACE_RETRYABLE_DISPATCH_DELAY_SECONDS=5
|
||||
OPS_TRACE_PARENT_CONTEXT_TTL_SECONDS=3900
|
||||
|
||||
# Database configuration
|
||||
DB_TYPE=postgresql
|
||||
@@ -154,6 +156,7 @@ ARCHIVE_STORAGE_EXPORT_BUCKET=
|
||||
ARCHIVE_STORAGE_ACCESS_KEY=
|
||||
ARCHIVE_STORAGE_SECRET_KEY=
|
||||
ARCHIVE_STORAGE_REGION=auto
|
||||
ARCHIVE_STORAGE_ADDRESS_STYLE=path
|
||||
|
||||
# Azure Blob Storage configuration
|
||||
AZURE_BLOB_ACCOUNT_NAME=your-account-name
|
||||
@@ -220,6 +223,7 @@ SUPABASE_URL=your-server-url
|
||||
# CORS configuration
|
||||
WEB_API_CORS_ALLOW_ORIGINS=http://localhost:3000,*
|
||||
CONSOLE_CORS_ALLOW_ORIGINS=http://localhost:3000,*
|
||||
WEBSOCKET_MAX_HTTP_BUFFER_SIZE=10485760
|
||||
# When the frontend and backend run on different subdomains, set COOKIE_DOMAIN to the site’s top-level domain (e.g., `example.com`). Leading dots are optional.
|
||||
COOKIE_DOMAIN=
|
||||
|
||||
@@ -231,6 +235,7 @@ VECTOR_INDEX_NAME_PREFIX=Vector_index
|
||||
|
||||
# Weaviate configuration
|
||||
WEAVIATE_ENDPOINT=http://localhost:8080
|
||||
WEAVIATE_GRPC_ENDPOINT=grpc://localhost:50051
|
||||
WEAVIATE_API_KEY=WVF5YThaHlkYwhGUSmCRgsX3tD5ngdN8pkih
|
||||
WEAVIATE_BATCH_SIZE=100
|
||||
WEAVIATE_TOKENIZATION=word
|
||||
@@ -456,6 +461,12 @@ UPLOAD_IMAGE_FILE_SIZE_LIMIT=10
|
||||
UPLOAD_VIDEO_FILE_SIZE_LIMIT=100
|
||||
UPLOAD_AUDIO_FILE_SIZE_LIMIT=50
|
||||
UPLOAD_SKILL_FILE_SIZE_LIMIT=50
|
||||
SKILL_PACKAGE_MAX_UNCOMPRESSED_BYTES=209715200
|
||||
SKILL_PACKAGE_MAX_ENTRIES=5000
|
||||
SKILL_PACKAGE_MAX_SKILL_MD_BYTES=1048576
|
||||
AGENT_PACKAGE_MAX_BYTES=536870912
|
||||
AGENT_PACKAGE_MAX_MANIFEST_BYTES=5242880
|
||||
AGENT_PACKAGE_MAX_ENTRIES=5000
|
||||
|
||||
# Comma-separated list of file extensions blocked from upload for security reasons.
|
||||
# Extensions should be lowercase without dots (e.g., exe,bat,sh,dll).
|
||||
@@ -488,6 +499,13 @@ SENDGRID_API_KEY=
|
||||
# Sentry configuration
|
||||
SENTRY_DSN=
|
||||
|
||||
# Cloudflare Turnstile server-side verification for Dify Cloud sign-in
|
||||
TURNSTILE_SECRET_KEY=
|
||||
# Comma-separated parent or exact hostnames, for example: dify.ai,staging.dify.dev
|
||||
TURNSTILE_ALLOWED_HOSTNAMES=
|
||||
# Enable only after the compatible web client has been fully deployed.
|
||||
TURNSTILE_EMAIL_CODE_VERIFY_REQUIRED=false
|
||||
|
||||
# DEBUG
|
||||
DEBUG=false
|
||||
ENABLE_REQUEST_LOGGING=False
|
||||
@@ -578,7 +596,7 @@ INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH=4000
|
||||
|
||||
# Workflow runtime configuration
|
||||
WORKFLOW_MAX_EXECUTION_STEPS=500
|
||||
WORKFLOW_MAX_EXECUTION_TIME=1200
|
||||
WORKFLOW_MAX_EXECUTION_TIME=3600
|
||||
WORKFLOW_CALL_MAX_DEPTH=5
|
||||
MAX_VARIABLE_SIZE=204800
|
||||
# Maximum concurrent node-builder LLM calls per workflow generation request
|
||||
@@ -623,7 +641,7 @@ WORKFLOW_LOG_CLEANUP_BATCH_SIZE=100
|
||||
WORKFLOW_LOG_CLEANUP_SPECIFIC_WORKFLOW_IDS=
|
||||
|
||||
# App configuration
|
||||
APP_MAX_EXECUTION_TIME=1200
|
||||
APP_MAX_EXECUTION_TIME=3600
|
||||
APP_DEFAULT_ACTIVE_REQUESTS=0
|
||||
APP_MAX_ACTIVE_REQUESTS=0
|
||||
|
||||
@@ -698,11 +716,12 @@ INNER_API_KEY_FOR_PLUGIN=QaHbTe77CtuXmsfyhR7+vRjI/+XbV1AaFy691iy+kGDv2Jvy0/eAh8Y
|
||||
|
||||
# Dify Agent backend
|
||||
AGENT_BACKEND_BASE_URL=http://localhost:5050
|
||||
# Bearer token sent to the Agent backend /runs API. Must match DIFY_AGENT_API_TOKEN on the server side.
|
||||
# Bearer token sent to the Agent backend control-plane API. Must match DIFY_AGENT_API_TOKEN on the server side.
|
||||
AGENT_BACKEND_API_TOKEN=dify-agent-run-token-for-dev-only
|
||||
AGENT_BACKEND_STREAM_READ_TIMEOUT_SECONDS=30
|
||||
AGENT_BACKEND_STREAM_MAX_RECONNECTS=3
|
||||
AGENT_BACKEND_RUN_TIMEOUT_SECONDS=1200
|
||||
# Client deadline for converting a Binding file to a ToolFile through the Agent backend.
|
||||
AGENT_BACKEND_BINDING_FILE_DOWNLOAD_TIMEOUT_SECONDS=240
|
||||
|
||||
# KnowledgeFS (Dataset 2.0)
|
||||
KNOWLEDGE_FS_ENABLED=false
|
||||
@@ -729,6 +748,8 @@ RESET_PASSWORD_TOKEN_EXPIRY_MINUTES=5
|
||||
EMAIL_REGISTER_TOKEN_EXPIRY_MINUTES=5
|
||||
CHANGE_EMAIL_TOKEN_EXPIRY_MINUTES=5
|
||||
OWNER_TRANSFER_TOKEN_EXPIRY_MINUTES=5
|
||||
EMAIL_CODE_LOGIN_TOKEN_EXPIRY_MINUTES=5
|
||||
EMAIL_CODE_LOGIN_MAX_ATTEMPTS=5
|
||||
|
||||
CREATE_TIDB_SERVICE_JOB_ENABLED=false
|
||||
|
||||
@@ -825,6 +846,12 @@ ENABLE_HUMAN_INPUT_TIMEOUT_TASK=true
|
||||
# Human input timeout check interval in minutes
|
||||
HUMAN_INPUT_TIMEOUT_TASK_INTERVAL=1
|
||||
|
||||
# Whether to recover soft-deleted conversation cleanup jobs periodically
|
||||
ENABLE_CONVERSATION_CLEANUP_TASK=true
|
||||
# Recovery interval in minutes and maximum conversations dispatched per sweep
|
||||
CONVERSATION_CLEANUP_TASK_INTERVAL=5
|
||||
CONVERSATION_CLEANUP_BATCH_SIZE=100
|
||||
|
||||
# Nacos remote settings source HTTP timeouts (seconds).
|
||||
# Bound how long requests to the Nacos endpoint wait before failing, so a slow or
|
||||
# unresponsive Nacos server cannot stall API startup or token refresh.
|
||||
@@ -832,3 +859,6 @@ HUMAN_INPUT_TIMEOUT_TASK_INTERVAL=1
|
||||
DIFY_ENV_NACOS_REQUEST_TIMEOUT=10.0
|
||||
# Connect timeout for Nacos requests (default: 3.0)
|
||||
DIFY_ENV_NACOS_CONNECT_TIMEOUT=3.0
|
||||
|
||||
# skill entry
|
||||
ENABLE_SKILL=true
|
||||
|
||||
1021
api/.importlinter
1021
api/.importlinter
File diff suppressed because it is too large
Load Diff
@@ -15,7 +15,8 @@ Run direct Python commands through `uv run --project api`. Docker-backed integra
|
||||
|
||||
## Architecture And Boundaries
|
||||
|
||||
- Keep transport parsing and serialization in controllers, orchestration in services, and domain policy in `core/` or its domain owner. Keep `libs/` business-agnostic and reuse existing owners before adding abstractions.
|
||||
- Treat `api/core/` as a migration-only area: do not add files or move implementations into it. Move responsibilities out; limit changes to existing callers to the adaptations needed for that migration.
|
||||
- Keep transport parsing and serialization in controllers, orchestration in services, and domain policy in its domain owner. New or extracted implementations must stay outside `core/`. Keep `libs/` business-agnostic and reuse existing owners before adding abstractions.
|
||||
- Before changing controller schemas, generated API contracts, or `SystemFeatureModel`, read `controllers/API_SCHEMA_GUIDE.md`. Treat `/system-features` as a minimal unauthenticated bootstrap allowlist, not a general configuration registry.
|
||||
- Scope tenant-owned reads and writes by the complete owner chain, and propagate `tenant_id` across every affected layer. Reconstruct trusted internal references from validated database state after payload or async boundaries.
|
||||
- Keep write transactions explicit and bounded. Do not perform external I/O inside an open transaction unless a documented consistency contract requires it.
|
||||
@@ -23,3 +24,8 @@ Run direct Python commands through `uv run --project api`. Docker-backed integra
|
||||
- Use Pydantic v2 for request and response models. Reuse domain-specific exceptions and translate them at the controller boundary.
|
||||
- Use existing Celery task and queue owners for asynchronous work; do not route unrelated jobs through workflow-specific services.
|
||||
- Celery tasks that may be retried or redelivered must keep side effects idempotent and log affected resource identifiers.
|
||||
|
||||
## Typing Best Practises
|
||||
|
||||
- Treat nullable types (`T | None`) strictly as union types; document the semantic meaning for each branch.
|
||||
- Treat default parameter values as introducing distinct function overloads; verify that every added default has demonstrable practical utility and avoids masking unsafe runtime states.
|
||||
|
||||
@@ -33,7 +33,6 @@ RUN uv sync --frozen --no-dev --no-editable
|
||||
FROM base AS production
|
||||
|
||||
ENV FLASK_APP=app.py
|
||||
ENV EDITION=SELF_HOSTED
|
||||
ENV DEPLOY_ENV=PRODUCTION
|
||||
ENV CONSOLE_API_URL=http://127.0.0.1:5001
|
||||
ENV CONSOLE_WEB_URL=http://127.0.0.1:3000
|
||||
@@ -54,15 +53,14 @@ WORKDIR /app/api
|
||||
|
||||
# Create non-root user
|
||||
ARG dify_uid=1001
|
||||
ARG NODE_MAJOR=22
|
||||
ARG NODE_PACKAGE_VERSION=22.21.0-1nodesource1
|
||||
ARG NODE_PACKAGE_VERSION=24.20.0-1nodesource1
|
||||
ARG NODESOURCE_KEY_FPR=6F71F525282841EEDAF851B42F59B5F99B1BE0B4
|
||||
RUN groupadd -r -g ${dify_uid} dify && \
|
||||
useradd -r -u ${dify_uid} -g ${dify_uid} -s /bin/bash dify && \
|
||||
chown -R dify:dify /app
|
||||
|
||||
RUN \
|
||||
apt-get update \
|
||||
RUN NODE_MAJOR="${NODE_PACKAGE_VERSION%%.*}" \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
ca-certificates \
|
||||
curl \
|
||||
|
||||
@@ -2,19 +2,11 @@
|
||||
|
||||
## Setup and Run
|
||||
|
||||
> [!IMPORTANT]
|
||||
>
|
||||
> In the v1.3.0 release, `poetry` has been replaced with
|
||||
> [`uv`](https://docs.astral.sh/uv/) as the package manager
|
||||
> for Dify API backend service.
|
||||
|
||||
`uv` and `pnpm` are required to run the setup and development commands below.
|
||||
[`uv`](https://docs.astral.sh/uv/), Docker Compose, and the Node.js and pnpm versions pinned in the root `package.json` are required. Run the commands below from the repository root, with each long-running service in its own terminal.
|
||||
|
||||
### Using scripts (recommended)
|
||||
|
||||
The scripts resolve paths relative to their location, so you can run them from anywhere.
|
||||
|
||||
1. Run setup (copies env files and installs dependencies).
|
||||
1. Run setup for a new checkout (copies env files and installs dependencies). This overwrites `api/.env`, `web/.env.local`, and `docker/middleware.env`; preserve existing configuration before rerunning it.
|
||||
|
||||
```bash
|
||||
./dev/setup
|
||||
@@ -44,7 +36,7 @@ The scripts resolve paths relative to their location, so you can run them from a
|
||||
|
||||
1. Set up your application by visiting `http://localhost:3000`.
|
||||
|
||||
1. Start the worker service (async and scheduler tasks, runs from `api`).
|
||||
1. Start the worker service (executes queued async tasks).
|
||||
|
||||
```bash
|
||||
./dev/start-worker
|
||||
@@ -62,50 +54,35 @@ The scripts resolve paths relative to their location, so you can run them from a
|
||||
>
|
||||
> When the frontend and backend run on different subdomains, set COOKIE_DOMAIN to the site’s top-level domain (e.g., `example.com`). The frontend and backend must be under the same top-level domain in order to share authentication cookies.
|
||||
|
||||
- Generate a `SECRET_KEY` in the `.env` file.
|
||||
|
||||
bash for Linux
|
||||
|
||||
```bash
|
||||
sed -i "/^SECRET_KEY=/c\\SECRET_KEY=$(openssl rand -base64 42)" .env
|
||||
```
|
||||
|
||||
bash for Mac
|
||||
|
||||
```bash
|
||||
secret_key=$(openssl rand -base64 42)
|
||||
sed -i '' "/^SECRET_KEY=/c\\
|
||||
SECRET_KEY=${secret_key}" .env
|
||||
```
|
||||
Leave `SECRET_KEY` empty to let Dify generate a persistent key in the storage directory. To manage it explicitly, generate a value with `openssl rand -base64 42` and set `SECRET_KEY` in `api/.env`.
|
||||
|
||||
## Testing
|
||||
|
||||
1. Install dependencies for both the backend and the test environment
|
||||
Run from the repository root:
|
||||
|
||||
```bash
|
||||
cd api
|
||||
uv sync --group dev
|
||||
```
|
||||
|
||||
1. Run the tests locally with mocked system environment variables in `tool.pytest_env` section in `pyproject.toml`, more can check [Claude.md](../CLAUDE.md)
|
||||
|
||||
```bash
|
||||
cd api
|
||||
uv run pytest # Run all tests
|
||||
uv run pytest tests/unit_tests/ # Unit tests only
|
||||
uv run pytest tests/integration_tests/ # Integration tests
|
||||
|
||||
# Code quality
|
||||
./dev/reformat # Run all formatters and linters
|
||||
uv run ruff check --fix ./ # Fix linting issues
|
||||
uv run ruff format ./ # Format code
|
||||
uv run pyrefly check # Type checking
|
||||
```
|
||||
|
||||
## Generate TS stub
|
||||
|
||||
```
|
||||
uv run dev/generate_swagger_specs.py --output-dir openapi
|
||||
```bash
|
||||
uv sync --project api --group dev
|
||||
make test
|
||||
make test TARGET_TESTS=./api/tests/unit_tests/<path>
|
||||
make lint
|
||||
make type-check
|
||||
```
|
||||
|
||||
use https://jsontotable.org/openapi-to-typescript to convert to typescript
|
||||
`make test` includes provider unit tests and runs controller tests separately. Integration suites are CI-only and are not expected to run locally. Test environment defaults live in `api/pyproject.toml` under `tool.pytest_env`; see the backend [agent guide](AGENTS.md) for package conventions.
|
||||
|
||||
## API contracts
|
||||
|
||||
The [API schema guide](controllers/API_SCHEMA_GUIDE.md) owns schema changes and verification. Generate the OpenAPI specifications and TypeScript/Zod contracts through the workspace script:
|
||||
|
||||
```bash
|
||||
pnpm -C packages/contracts gen-api-contract
|
||||
```
|
||||
|
||||
Refresh the checked-in Markdown reference with:
|
||||
|
||||
```bash
|
||||
uv run --project api python api/dev/generate_swagger_markdown_docs.py \
|
||||
--swagger-dir packages/contracts/openapi --markdown-dir api/openapi/markdown --keep-swagger-json
|
||||
```
|
||||
|
||||
Update the backend schema owner and regenerate contracts instead of converting types manually or editing generated files.
|
||||
|
||||
@@ -14,6 +14,7 @@ from contexts.wrapper import RecyclableContextVar
|
||||
from controllers.console.error import UnauthorizedAndForceLogout
|
||||
from core.logging.context import init_request_context
|
||||
from dify_app import DifyApp
|
||||
from enums import DeploymentEdition
|
||||
from extensions.ext_socketio import sio
|
||||
from services.enterprise.enterprise_service import EnterpriseService
|
||||
from services.entities.feature_entities import LicenseStatus
|
||||
@@ -104,6 +105,10 @@ def create_flask_app_with_configs() -> DifyApp:
|
||||
dify_app = DifyApp(__name__)
|
||||
dify_app.config.from_mapping(dify_config.model_dump())
|
||||
dify_app.config["RESTX_INCLUDE_ALL_MODELS"] = True
|
||||
# flask-restx appends url-map suggestions to 404 bodies: they enumerate routes to
|
||||
# anonymous callers, and a policy 404 on an existing route (edition admission)
|
||||
# ends up suggesting the very path that was just requested.
|
||||
dify_app.config["RESTX_ERROR_404_HELP"] = False
|
||||
|
||||
# add before request hook
|
||||
@dify_app.before_request
|
||||
@@ -112,7 +117,7 @@ def create_flask_app_with_configs() -> DifyApp:
|
||||
init_request_context()
|
||||
RecyclableContextVar.increment_thread_recycles()
|
||||
|
||||
if dify_config.ENTERPRISE_ENABLED:
|
||||
if dify_config.DEPLOYMENT_EDITION == DeploymentEdition.ENTERPRISE:
|
||||
surface = _match_license_gated_surface(request.path)
|
||||
if surface is not None:
|
||||
try:
|
||||
|
||||
@@ -23,6 +23,7 @@ from dify_agent.protocol import (
|
||||
CancelRunResponse,
|
||||
CreateRunRequest,
|
||||
CreateRunResponse,
|
||||
RunCancelledEvent,
|
||||
RunEvent,
|
||||
RunStatusResponse,
|
||||
)
|
||||
@@ -45,6 +46,15 @@ class AgentBackendRunClient(Protocol):
|
||||
def cancel_run(self, run_id: str, request: CancelRunRequest | None = None) -> CancelRunResponse:
|
||||
"""Request explicit cancellation for one Agent backend run."""
|
||||
|
||||
def cancel_run_and_wait(
|
||||
self,
|
||||
run_id: str,
|
||||
request: CancelRunRequest | None = None,
|
||||
*,
|
||||
after: str | None = None,
|
||||
) -> RunCancelledEvent:
|
||||
"""Request cancellation and wait for runner cleanup to finish."""
|
||||
|
||||
def stream_events(
|
||||
self,
|
||||
run_id: str,
|
||||
@@ -67,6 +77,15 @@ class _DifyAgentSyncClient(Protocol):
|
||||
def cancel_run_sync(self, run_id: str, request: CancelRunRequest | None = None) -> CancelRunResponse:
|
||||
"""Cancel one run synchronously."""
|
||||
|
||||
def cancel_run_and_wait_sync(
|
||||
self,
|
||||
run_id: str,
|
||||
request: CancelRunRequest | None = None,
|
||||
*,
|
||||
after: str | None = None,
|
||||
) -> RunCancelledEvent:
|
||||
"""Cancel one run and wait for its terminal event synchronously."""
|
||||
|
||||
def stream_events_sync(
|
||||
self,
|
||||
run_id: str,
|
||||
@@ -92,11 +111,9 @@ class DifyAgentBackendRunClient:
|
||||
client: _DifyAgentSyncClient,
|
||||
*,
|
||||
stream_max_reconnects: int = 3,
|
||||
stream_timeout_seconds: float = 1200,
|
||||
) -> None:
|
||||
self.client = client
|
||||
self._stream_max_reconnects = stream_max_reconnects
|
||||
self._stream_timeout_seconds = stream_timeout_seconds
|
||||
|
||||
def create_run(self, request: CreateRunRequest) -> CreateRunResponse:
|
||||
"""Create one run through ``POST /runs`` and normalize client exceptions."""
|
||||
@@ -112,6 +129,19 @@ class DifyAgentBackendRunClient:
|
||||
except Exception as exc:
|
||||
raise _normalize_dify_agent_error(exc) from exc
|
||||
|
||||
def cancel_run_and_wait(
|
||||
self,
|
||||
run_id: str,
|
||||
request: CancelRunRequest | None = None,
|
||||
*,
|
||||
after: str | None = None,
|
||||
) -> RunCancelledEvent:
|
||||
"""Cancel one run, then wait for the cleanup-complete terminal event."""
|
||||
try:
|
||||
return self.client.cancel_run_and_wait_sync(run_id, request=request, after=after)
|
||||
except Exception as exc:
|
||||
raise _normalize_dify_agent_error(exc) from exc
|
||||
|
||||
def stream_events(
|
||||
self,
|
||||
run_id: str,
|
||||
@@ -125,7 +155,6 @@ class DifyAgentBackendRunClient:
|
||||
run_id,
|
||||
after=after,
|
||||
max_reconnects=self._stream_max_reconnects,
|
||||
timeout_seconds=self._stream_timeout_seconds,
|
||||
should_stop=should_stop,
|
||||
)
|
||||
except Exception as exc:
|
||||
|
||||
@@ -8,11 +8,40 @@ classes.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from http import HTTPStatus
|
||||
from typing import Any
|
||||
|
||||
from dify_agent.client import DifyAgentHTTPError
|
||||
from dify_agent.protocol import RunFailureType
|
||||
|
||||
|
||||
def backend_reported_failure(exc: DifyAgentHTTPError) -> bool:
|
||||
"""Whether the backend itself reported the failure.
|
||||
|
||||
``DifyAgentValidationError`` is a ``DifyAgentHTTPError`` that the client also
|
||||
raises when a *successful* response fails DTO validation. Those carry a 2xx
|
||||
status and a Pydantic error list, not a backend-authored error envelope.
|
||||
"""
|
||||
return exc.status_code >= HTTPStatus.BAD_REQUEST
|
||||
|
||||
|
||||
def backend_error_detail(
|
||||
exc: DifyAgentHTTPError,
|
||||
*,
|
||||
default_code: str = "agent_backend_error",
|
||||
) -> tuple[str, str]:
|
||||
"""Split an Agent backend HTTP error into the code and message the backend itself sent."""
|
||||
detail = exc.detail
|
||||
if isinstance(detail, dict):
|
||||
code = detail.get("code")
|
||||
message = detail.get("message")
|
||||
return (
|
||||
code if isinstance(code, str) and code else default_code,
|
||||
message if isinstance(message, str) and message else str(exc),
|
||||
)
|
||||
return default_code, str(detail)
|
||||
|
||||
|
||||
class AgentBackendError(Exception):
|
||||
"""Base error for API-side Agent backend integration failures."""
|
||||
|
||||
|
||||
@@ -99,6 +99,8 @@ class AgentBackendRunFailedInternalEvent(AgentBackendInternalEventBase):
|
||||
error: str
|
||||
error_type: RunFailureType | None = None
|
||||
reason: str | None = None
|
||||
session_snapshot: CompositorSessionSnapshot | None = None
|
||||
usage: dict[str, JsonValue] | None = None
|
||||
|
||||
|
||||
class AgentBackendRunCancelledInternalEvent(AgentBackendInternalEventBase):
|
||||
@@ -107,6 +109,8 @@ class AgentBackendRunCancelledInternalEvent(AgentBackendInternalEventBase):
|
||||
type: Literal[AgentBackendInternalEventType.RUN_CANCELLED] = AgentBackendInternalEventType.RUN_CANCELLED
|
||||
reason: str | None = None
|
||||
message: str | None = None
|
||||
session_snapshot: CompositorSessionSnapshot | None = None
|
||||
usage: dict[str, JsonValue] | None = None
|
||||
|
||||
|
||||
type AgentBackendInternalEvent = Annotated[
|
||||
@@ -184,6 +188,8 @@ class AgentBackendRunEventAdapter:
|
||||
error=event.data.error,
|
||||
error_type=event.data.error_type,
|
||||
reason=event.data.reason,
|
||||
session_snapshot=event.data.session_snapshot,
|
||||
usage=_agent_run_usage(event.data.usage),
|
||||
)
|
||||
]
|
||||
case RunCancelledEvent():
|
||||
@@ -193,6 +199,8 @@ class AgentBackendRunEventAdapter:
|
||||
source_event_id=event.id,
|
||||
reason=event.data.reason,
|
||||
message=event.data.message,
|
||||
session_snapshot=event.data.session_snapshot,
|
||||
usage=_agent_run_usage(event.data.usage),
|
||||
)
|
||||
]
|
||||
raise TypeError(f"unsupported agent backend run event: {type(event).__name__}")
|
||||
|
||||
@@ -8,6 +8,25 @@ from clients.agent_backend.client import AgentBackendRunClient, DifyAgentBackend
|
||||
from clients.agent_backend.fake_client import FakeAgentBackendRunClient, FakeAgentBackendScenario
|
||||
|
||||
|
||||
def create_agent_backend_client(
|
||||
*,
|
||||
base_url: str,
|
||||
api_token: str | None = None,
|
||||
stream_timeout: float = 30,
|
||||
timeout: float = 30.0,
|
||||
binding_file_download_timeout: float = 240,
|
||||
) -> Client:
|
||||
api_token = api_token.strip() if api_token else None
|
||||
headers = {"Authorization": f"Bearer {api_token}"} if api_token else None
|
||||
return Client(
|
||||
base_url=base_url,
|
||||
stream_timeout=stream_timeout,
|
||||
timeout=timeout,
|
||||
binding_file_download_timeout=binding_file_download_timeout,
|
||||
headers=headers,
|
||||
)
|
||||
|
||||
|
||||
def create_agent_backend_run_client(
|
||||
*,
|
||||
base_url: str | None = None,
|
||||
@@ -16,18 +35,17 @@ def create_agent_backend_run_client(
|
||||
fake_scenario: str | FakeAgentBackendScenario = FakeAgentBackendScenario.SUCCESS,
|
||||
stream_read_timeout_seconds: float = 30,
|
||||
stream_max_reconnects: int = 3,
|
||||
stream_run_timeout_seconds: float = 1200,
|
||||
) -> AgentBackendRunClient:
|
||||
"""Create the API-side run client without hiding the ``dify-agent`` protocol."""
|
||||
if use_fake:
|
||||
return FakeAgentBackendRunClient(scenario=FakeAgentBackendScenario(fake_scenario))
|
||||
if base_url is None:
|
||||
raise ValueError("base_url is required when creating a real Agent backend client")
|
||||
headers: dict[str, str] = {}
|
||||
if api_token:
|
||||
headers["Authorization"] = f"Bearer {api_token}"
|
||||
return DifyAgentBackendRunClient(
|
||||
Client(base_url=base_url, stream_timeout=stream_read_timeout_seconds, headers=headers),
|
||||
create_agent_backend_client(
|
||||
base_url=base_url,
|
||||
api_token=api_token,
|
||||
stream_timeout=stream_read_timeout_seconds,
|
||||
),
|
||||
stream_max_reconnects=stream_max_reconnects,
|
||||
stream_timeout_seconds=stream_run_timeout_seconds,
|
||||
)
|
||||
|
||||
@@ -18,6 +18,8 @@ from dify_agent.protocol import (
|
||||
CreateRunRequest,
|
||||
CreateRunResponse,
|
||||
DeferredToolCallPayload,
|
||||
RunCancelledEvent,
|
||||
RunCancelledEventData,
|
||||
RunEvent,
|
||||
RunFailedEvent,
|
||||
RunFailedEventData,
|
||||
@@ -69,6 +71,28 @@ class FakeAgentBackendRunClient:
|
||||
del request
|
||||
return CancelRunResponse(run_id=run_id, status="cancelled")
|
||||
|
||||
def cancel_run_and_wait(
|
||||
self,
|
||||
run_id: str,
|
||||
request: CancelRunRequest | None = None,
|
||||
*,
|
||||
after: str | None = None,
|
||||
) -> RunCancelledEvent:
|
||||
"""Return a deterministic cleanup-complete cancellation event."""
|
||||
del after
|
||||
request = request or CancelRunRequest()
|
||||
_ = self.cancel_run(run_id, request)
|
||||
return RunCancelledEvent(
|
||||
id="cancel-0",
|
||||
run_id=run_id,
|
||||
created_at=_FIXED_TIME,
|
||||
data=RunCancelledEventData(
|
||||
reason=request.reason,
|
||||
message=request.message,
|
||||
session_snapshot=CompositorSessionSnapshot(layers=[]),
|
||||
),
|
||||
)
|
||||
|
||||
def stream_events(
|
||||
self,
|
||||
run_id: str,
|
||||
@@ -133,7 +157,11 @@ class FakeAgentBackendRunClient:
|
||||
id="2-0",
|
||||
run_id=run_id,
|
||||
created_at=_FIXED_TIME,
|
||||
data=RunFailedEventData(error="fake failure", reason="unit_test"),
|
||||
data=RunFailedEventData(
|
||||
error="fake failure",
|
||||
reason="unit_test",
|
||||
session_snapshot=CompositorSessionSnapshot(layers=[]),
|
||||
),
|
||||
),
|
||||
)
|
||||
case FakeAgentBackendScenario.PAUSED:
|
||||
|
||||
@@ -25,11 +25,9 @@ from dify_agent.layers.dify_core_tools import DIFY_CORE_TOOLS_LAYER_TYPE_ID, Dif
|
||||
from dify_agent.layers.dify_plugin import (
|
||||
DIFY_PLUGIN_LLM_LAYER_TYPE_ID,
|
||||
DIFY_PLUGIN_TOOLS_LAYER_TYPE_ID,
|
||||
DifyPluginCredentialValue,
|
||||
DifyPluginLLMLayerConfig,
|
||||
DifyPluginToolsLayerConfig,
|
||||
)
|
||||
from dify_agent.layers.drive import DIFY_DRIVE_LAYER_TYPE_ID, DifyDriveLayerConfig
|
||||
from dify_agent.layers.execution_context import (
|
||||
DIFY_EXECUTION_CONTEXT_LAYER_TYPE_ID,
|
||||
DifyExecutionContextLayerConfig,
|
||||
@@ -38,6 +36,11 @@ from dify_agent.layers.knowledge import DIFY_KNOWLEDGE_BASE_LAYER_TYPE_ID, DifyK
|
||||
from dify_agent.layers.output import DIFY_OUTPUT_LAYER_TYPE_ID, DifyOutputLayerConfig
|
||||
from dify_agent.layers.runtime import DIFY_RUNTIME_LAYER_TYPE_ID, DifyRuntimeLayerConfig
|
||||
from dify_agent.layers.shell import DIFY_SHELL_LAYER_TYPE_ID, DifyShellLayerConfig
|
||||
from dify_agent.layers.user_prompt import (
|
||||
DIFY_USER_PROMPT_LAYER_TYPE_ID,
|
||||
DifyUserPromptFileConfig,
|
||||
DifyUserPromptLayerConfig,
|
||||
)
|
||||
from dify_agent.protocol import (
|
||||
DIFY_AGENT_HISTORY_LAYER_ID,
|
||||
DIFY_AGENT_MODEL_LAYER_ID,
|
||||
@@ -57,7 +60,6 @@ AGENT_APP_USER_PROMPT_LAYER_ID = "agent_app_user_prompt"
|
||||
DIFY_EXECUTION_CONTEXT_LAYER_ID = "execution_context"
|
||||
DIFY_RUNTIME_LAYER_ID = "runtime"
|
||||
DIFY_CONFIG_LAYER_ID = "config"
|
||||
DIFY_DRIVE_LAYER_ID = "drive"
|
||||
DIFY_PLUGIN_TOOLS_LAYER_ID = "tools"
|
||||
DIFY_CORE_TOOLS_LAYER_ID = "core_tools"
|
||||
DIFY_KNOWLEDGE_BASE_LAYER_ID = "knowledge"
|
||||
@@ -73,24 +75,10 @@ def _shell_layer_deps() -> dict[str, str]:
|
||||
}
|
||||
|
||||
|
||||
def _drive_layer_deps() -> dict[str, str]:
|
||||
return {"shell": DIFY_SHELL_LAYER_ID}
|
||||
|
||||
|
||||
def _config_layer_deps() -> dict[str, str]:
|
||||
return {"shell": DIFY_SHELL_LAYER_ID}
|
||||
|
||||
|
||||
def _shell_config_with_drive_ref(
|
||||
shell_config: DifyShellLayerConfig | None,
|
||||
drive_config: DifyDriveLayerConfig | None,
|
||||
) -> DifyShellLayerConfig:
|
||||
config = shell_config or DifyShellLayerConfig()
|
||||
if drive_config is None:
|
||||
return config
|
||||
return config.model_copy(update={"agent_stub_drive_ref": drive_config.drive_ref})
|
||||
|
||||
|
||||
def _markdown_backtick_fence(text: str) -> str:
|
||||
"""Choose a fence that will not terminate inside the prompt body."""
|
||||
longest_backtick_run = max((len(match.group(0)) for match in re.finditer(r"`+", text)), default=0)
|
||||
@@ -150,8 +138,8 @@ class AgentBackendModelConfig(BaseModel):
|
||||
plugin_id: str
|
||||
model_provider: str
|
||||
model: str
|
||||
credentials: dict[str, DifyPluginCredentialValue] = Field(default_factory=dict)
|
||||
model_settings: dict[str, JsonValue] = Field(default_factory=dict)
|
||||
context_window_tokens: int | None = Field(default=None, gt=0)
|
||||
|
||||
model_config: ClassVar[ConfigDict] = ConfigDict(extra="forbid")
|
||||
|
||||
@@ -159,8 +147,12 @@ class AgentBackendModelConfig(BaseModel):
|
||||
# ``DifyPluginLLMLayerConfig.model_settings`` is pydantic_ai's ``ModelSettings``
|
||||
# TypedDict (closed: unknown keys are rejected, explicit ``None`` values fail the
|
||||
# per-field type checks). Agent Soul model settings carry a wider, nullable shape
|
||||
# (``stop`` / ``response_format`` plus null-padded fields), so the layer config
|
||||
# only receives the keys the runtime contract accepts.
|
||||
# (``stop`` / ``response_format`` plus null-padded fields, plus arbitrary
|
||||
# plugin-declared parameters such as Qwen's ``enable_thinking``), so the layer
|
||||
# config only receives the keys the runtime contract accepts directly; anything
|
||||
# else is forwarded through ``extra_body``, the TypedDict's own escape hatch for
|
||||
# provider-specific parameters (see
|
||||
# ``dify_agent.adapters.llm.model._map_model_settings_to_parameters``).
|
||||
_AGENT_MODEL_SETTINGS_PASSTHROUGH_KEYS = (
|
||||
"temperature",
|
||||
"top_p",
|
||||
@@ -168,6 +160,7 @@ _AGENT_MODEL_SETTINGS_PASSTHROUGH_KEYS = (
|
||||
"frequency_penalty",
|
||||
"max_tokens",
|
||||
)
|
||||
_AGENT_MODEL_SETTINGS_KNOWN_KEYS = frozenset({*_AGENT_MODEL_SETTINGS_PASSTHROUGH_KEYS, "stop", "response_format"})
|
||||
|
||||
|
||||
def _agent_model_settings(settings: Mapping[str, JsonValue]) -> dict[str, JsonValue] | None:
|
||||
@@ -177,6 +170,15 @@ def _agent_model_settings(settings: Mapping[str, JsonValue]) -> dict[str, JsonVa
|
||||
stop = settings.get("stop")
|
||||
if isinstance(stop, list) and stop:
|
||||
sanitized["stop_sequences"] = stop
|
||||
|
||||
extra_body: dict[str, JsonValue] = {
|
||||
key: value
|
||||
for key, value in settings.items()
|
||||
if key not in _AGENT_MODEL_SETTINGS_KNOWN_KEYS and value is not None
|
||||
}
|
||||
if extra_body:
|
||||
sanitized["extra_body"] = extra_body
|
||||
|
||||
return sanitized or None
|
||||
|
||||
|
||||
@@ -211,9 +213,6 @@ class AgentBackendWorkflowNodeRunInput(BaseModel):
|
||||
core_tools: DifyCoreToolsLayerConfig | None = None
|
||||
knowledge: DifyKnowledgeBaseLayerConfig | None = None
|
||||
config_layer_config: DifyConfigLayerConfig | None = None
|
||||
# Drive Skills & Files declaration (dify.drive) — an index the agent pulls
|
||||
# through the back proxy, never inline content.
|
||||
drive_config: DifyDriveLayerConfig | None = None
|
||||
# Human-in-the-loop ask_human deferred tool (dify.ask_human). Present only when
|
||||
# the Agent Soul configures human involvement; a deferred call ends the run and
|
||||
# the workflow pauses via the existing HITL form mechanism (ENG-635).
|
||||
@@ -252,6 +251,7 @@ class AgentBackendAgentAppRunInput(BaseModel):
|
||||
execution_context: DifyExecutionContextLayerConfig
|
||||
backend_binding_ref: str = Field(min_length=1)
|
||||
user_prompt: str
|
||||
user_files: list[DifyUserPromptFileConfig] = Field(default_factory=list)
|
||||
agent_soul_prompt: str | None = None
|
||||
agent_config_version_kind: AgentConfigVersionKind = "snapshot"
|
||||
idempotency_key: str | None = None
|
||||
@@ -260,9 +260,6 @@ class AgentBackendAgentAppRunInput(BaseModel):
|
||||
core_tools: DifyCoreToolsLayerConfig | None = None
|
||||
knowledge: DifyKnowledgeBaseLayerConfig | None = None
|
||||
config_layer_config: DifyConfigLayerConfig | None = None
|
||||
# Drive Skills & Files declaration (dify.drive) — an index the agent pulls
|
||||
# through the back proxy, never inline content.
|
||||
drive_config: DifyDriveLayerConfig | None = None
|
||||
# Human-in-the-loop ask_human deferred tool (dify.ask_human). Present only when
|
||||
# the Agent Soul configures human involvement (ENG-635).
|
||||
ask_human_config: DifyAskHumanLayerConfig | None = None
|
||||
@@ -294,7 +291,7 @@ class AgentBackendRunRequestBuilder:
|
||||
"""Build an Agent App conversation-turn run request.
|
||||
|
||||
Layer graph: optional Agent Soul system prompt → user prompt →
|
||||
execution context → optional shell / config / drive / history
|
||||
execution context → optional shell / config / history
|
||||
(multi-turn) → LLM → optional plugin-direct tools / core-routed tools /
|
||||
knowledge search / ask_human / structured output. Mirrors the
|
||||
workflow-node layer ordering minus the workflow-job / previous-node
|
||||
@@ -319,9 +316,9 @@ class AgentBackendRunRequestBuilder:
|
||||
[
|
||||
RunLayerSpec(
|
||||
name=AGENT_APP_USER_PROMPT_LAYER_ID,
|
||||
type=PLAIN_PROMPT_LAYER_TYPE_ID,
|
||||
type=DIFY_USER_PROMPT_LAYER_TYPE_ID,
|
||||
metadata={**run_input.metadata, "origin": "agent_app_user_prompt"},
|
||||
config=PromptLayerConfig(user=run_input.user_prompt),
|
||||
config=DifyUserPromptLayerConfig(text=run_input.user_prompt, files=run_input.user_files),
|
||||
),
|
||||
RunLayerSpec(
|
||||
name=DIFY_EXECUTION_CONTEXT_LAYER_ID,
|
||||
@@ -332,9 +329,7 @@ class AgentBackendRunRequestBuilder:
|
||||
]
|
||||
)
|
||||
|
||||
include_shell = (
|
||||
run_input.include_shell or run_input.config_layer_config is not None or run_input.drive_config is not None
|
||||
)
|
||||
include_shell = run_input.include_shell or run_input.config_layer_config is not None
|
||||
if include_shell:
|
||||
layers.append(
|
||||
RunLayerSpec(
|
||||
@@ -344,16 +339,15 @@ class AgentBackendRunRequestBuilder:
|
||||
config=DifyRuntimeLayerConfig(backend_binding_ref=run_input.backend_binding_ref),
|
||||
)
|
||||
)
|
||||
# Sandboxed bash workspace (dify.shell). It enters before config/drive
|
||||
# so eager pulls materialize content in the same filesystem used by
|
||||
# model commands.
|
||||
# Sandboxed bash workspace (dify.shell). It enters before config so
|
||||
# eager pulls materialize content in the same filesystem used by model commands.
|
||||
layers.append(
|
||||
RunLayerSpec(
|
||||
name=DIFY_SHELL_LAYER_ID,
|
||||
type=DIFY_SHELL_LAYER_TYPE_ID,
|
||||
deps=_shell_layer_deps(),
|
||||
metadata=run_input.metadata,
|
||||
config=_shell_config_with_drive_ref(run_input.shell_config, run_input.drive_config),
|
||||
config=run_input.shell_config or DifyShellLayerConfig(),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -368,19 +362,6 @@ class AgentBackendRunRequestBuilder:
|
||||
)
|
||||
)
|
||||
|
||||
if run_input.drive_config is not None:
|
||||
# Drive Skills & Files declaration (dify.drive): the catalog plus
|
||||
# prompt-mentioned entries eagerly pulled through the shell layer.
|
||||
layers.append(
|
||||
RunLayerSpec(
|
||||
name=DIFY_DRIVE_LAYER_ID,
|
||||
type=DIFY_DRIVE_LAYER_TYPE_ID,
|
||||
deps=_drive_layer_deps(),
|
||||
metadata=run_input.metadata,
|
||||
config=run_input.drive_config,
|
||||
)
|
||||
)
|
||||
|
||||
if run_input.include_history:
|
||||
layers.append(
|
||||
RunLayerSpec(
|
||||
@@ -400,8 +381,8 @@ class AgentBackendRunRequestBuilder:
|
||||
plugin_id=run_input.model.plugin_id,
|
||||
model_provider=run_input.model.model_provider,
|
||||
model=run_input.model.model,
|
||||
credentials=run_input.model.credentials,
|
||||
model_settings=_agent_model_settings(run_input.model.model_settings),
|
||||
context_window_tokens=run_input.model.context_window_tokens,
|
||||
),
|
||||
)
|
||||
)
|
||||
@@ -482,7 +463,7 @@ class AgentBackendRunRequestBuilder:
|
||||
"""Build a workflow Agent Node run request without defining another wire schema.
|
||||
|
||||
Layer graph mirrors the workflow surface: prompts → execution context →
|
||||
optional shell / config / drive / history → LLM → optional
|
||||
optional shell / config / history → LLM → optional
|
||||
plugin-direct tools / core-routed tools / knowledge search /
|
||||
ask_human / structured output.
|
||||
"""
|
||||
@@ -524,9 +505,7 @@ class AgentBackendRunRequestBuilder:
|
||||
]
|
||||
)
|
||||
|
||||
include_shell = (
|
||||
run_input.include_shell or run_input.config_layer_config is not None or run_input.drive_config is not None
|
||||
)
|
||||
include_shell = run_input.include_shell or run_input.config_layer_config is not None
|
||||
if include_shell:
|
||||
layers.append(
|
||||
RunLayerSpec(
|
||||
@@ -536,16 +515,15 @@ class AgentBackendRunRequestBuilder:
|
||||
config=DifyRuntimeLayerConfig(backend_binding_ref=run_input.backend_binding_ref),
|
||||
)
|
||||
)
|
||||
# Sandboxed bash workspace (dify.shell). It enters before drive so
|
||||
# drive can materialize mentioned targets with `dify-agent drive pull`
|
||||
# in the same shell-visible filesystem used by model commands.
|
||||
# Sandboxed bash workspace (dify.shell). It enters before config so
|
||||
# eager pulls materialize content in the same filesystem used by model commands.
|
||||
layers.append(
|
||||
RunLayerSpec(
|
||||
name=DIFY_SHELL_LAYER_ID,
|
||||
type=DIFY_SHELL_LAYER_TYPE_ID,
|
||||
deps=_shell_layer_deps(),
|
||||
metadata=run_input.metadata,
|
||||
config=_shell_config_with_drive_ref(run_input.shell_config, run_input.drive_config),
|
||||
config=run_input.shell_config or DifyShellLayerConfig(),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -560,19 +538,6 @@ class AgentBackendRunRequestBuilder:
|
||||
)
|
||||
)
|
||||
|
||||
if run_input.drive_config is not None:
|
||||
# Drive Skills & Files declaration (dify.drive): the catalog plus
|
||||
# prompt-mentioned entries eagerly pulled through the shell layer.
|
||||
layers.append(
|
||||
RunLayerSpec(
|
||||
name=DIFY_DRIVE_LAYER_ID,
|
||||
type=DIFY_DRIVE_LAYER_TYPE_ID,
|
||||
deps=_drive_layer_deps(),
|
||||
metadata=run_input.metadata,
|
||||
config=run_input.drive_config,
|
||||
)
|
||||
)
|
||||
|
||||
if run_input.include_history:
|
||||
layers.append(
|
||||
RunLayerSpec(
|
||||
@@ -593,8 +558,8 @@ class AgentBackendRunRequestBuilder:
|
||||
plugin_id=run_input.model.plugin_id,
|
||||
model_provider=run_input.model.model_provider,
|
||||
model=run_input.model.model,
|
||||
credentials=run_input.model.credentials,
|
||||
model_settings=_agent_model_settings(run_input.model.model_settings),
|
||||
context_window_tokens=run_input.model.context_window_tokens,
|
||||
),
|
||||
),
|
||||
]
|
||||
@@ -673,7 +638,7 @@ class AgentBackendRunRequestBuilder:
|
||||
)
|
||||
|
||||
|
||||
_SENSITIVE_KEY_PARTS = ("secret", "credential", "token", "password", "api_key")
|
||||
_SENSITIVE_KEY_PARTS = ("secret", "credential", "token", "password", "api_key", "base64_data")
|
||||
|
||||
|
||||
def redact_for_agent_backend_log(value: object) -> object:
|
||||
@@ -682,9 +647,10 @@ def redact_for_agent_backend_log(value: object) -> object:
|
||||
return redact_for_agent_backend_log(value.model_dump(mode="json", warnings=False))
|
||||
if isinstance(value, dict):
|
||||
redacted: dict[object, object] = {}
|
||||
is_multimodal_file = value.get("type") == "image" and "filename" in value and "mime_type" in value
|
||||
for key, item in value.items():
|
||||
key_text = str(key).lower()
|
||||
if any(part in key_text for part in _SENSITIVE_KEY_PARTS):
|
||||
if any(part in key_text for part in _SENSITIVE_KEY_PARTS) or (is_multimodal_file and key_text == "url"):
|
||||
redacted[key] = "[REDACTED]"
|
||||
else:
|
||||
redacted[key] = redact_for_agent_backend_log(item)
|
||||
|
||||
@@ -22,7 +22,13 @@ from .plugin import (
|
||||
setup_system_trigger_oauth_client,
|
||||
transform_datasource_credentials,
|
||||
)
|
||||
from .rbac import migrate_dataset_permissions_to_rbac, migrate_member_roles_to_rbac
|
||||
from .rbac import (
|
||||
migrate_agent_permissions_to_rbac,
|
||||
migrate_dataset_permissions_to_rbac,
|
||||
migrate_member_roles_to_rbac,
|
||||
migrate_only_me_resource_whitelist_scopes_to_automatic_include,
|
||||
migrate_resource_whitelist_scopes_to_automatic_include,
|
||||
)
|
||||
from .retention import (
|
||||
archive_workflow_runs,
|
||||
archive_workflow_runs_plan,
|
||||
@@ -76,12 +82,15 @@ __all__ = [
|
||||
"install_plugins",
|
||||
"install_rag_pipeline_plugins",
|
||||
"legacy_model_types",
|
||||
"migrate_agent_permissions_to_rbac",
|
||||
"migrate_annotation_vector_database",
|
||||
"migrate_data_for_plugin",
|
||||
"migrate_dataset_permissions_to_rbac",
|
||||
"migrate_knowledge_vector_database",
|
||||
"migrate_member_roles_to_rbac",
|
||||
"migrate_only_me_resource_whitelist_scopes_to_automatic_include",
|
||||
"migrate_oss",
|
||||
"migrate_resource_whitelist_scopes_to_automatic_include",
|
||||
"migration_data_wizard",
|
||||
"old_metadata_migration",
|
||||
"remove_orphaned_files_on_storage",
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import base64
|
||||
import secrets
|
||||
|
||||
import click
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from constants.languages import languages
|
||||
from extensions.ext_database import db
|
||||
from extensions.ext_application_services import application_services
|
||||
from libs.helper import email as email_validate
|
||||
from libs.password import hash_password, password_pattern, valid_password
|
||||
from services.account_service import AccountService, RegisterService, TenantService
|
||||
from libs.password import password_pattern, valid_password
|
||||
|
||||
|
||||
@click.command("reset-password", help="Reset the account password.")
|
||||
@@ -20,12 +17,12 @@ def reset_password(email, new_password, password_confirm):
|
||||
Reset password of owner account
|
||||
Only available in SELF_HOSTED mode
|
||||
"""
|
||||
if str(new_password).strip() != str(password_confirm).strip():
|
||||
if new_password.strip() != password_confirm.strip():
|
||||
click.echo(click.style("Passwords do not match.", fg="red"))
|
||||
return
|
||||
normalized_email = email.strip().lower()
|
||||
|
||||
account = AccountService.get_account_by_email_with_case_fallback(email.strip(), session=db.session())
|
||||
account = application_services().accounts.lifecycle.get_account_by_email_with_case_fallback(email.strip())
|
||||
|
||||
if not account:
|
||||
click.echo(click.style(f"Account not found for email: {email}", fg="red"))
|
||||
@@ -33,23 +30,11 @@ def reset_password(email, new_password, password_confirm):
|
||||
|
||||
try:
|
||||
valid_password(new_password)
|
||||
except:
|
||||
except ValueError:
|
||||
click.echo(click.style(f"Invalid password. Must match {password_pattern}", fg="red"))
|
||||
return
|
||||
|
||||
# generate password salt
|
||||
salt = secrets.token_bytes(16)
|
||||
base64_salt = base64.b64encode(salt).decode()
|
||||
|
||||
# encrypt password with salt
|
||||
password_hashed = hash_password(new_password, salt)
|
||||
base64_password_hashed = base64.b64encode(password_hashed).decode()
|
||||
with Session(db.engine) as session:
|
||||
account = session.merge(account)
|
||||
account.password = base64_password_hashed
|
||||
account.password_salt = base64_salt
|
||||
session.commit()
|
||||
AccountService.reset_login_error_rate_limit(normalized_email)
|
||||
application_services().accounts.lifecycle.reset_password(account.id, new_password, email=normalized_email)
|
||||
click.echo(click.style("Password reset successfully.", fg="green"))
|
||||
|
||||
|
||||
@@ -62,12 +47,12 @@ def reset_email(email, new_email, email_confirm):
|
||||
Replace account email
|
||||
:return:
|
||||
"""
|
||||
if str(new_email).strip() != str(email_confirm).strip():
|
||||
if new_email.strip() != email_confirm.strip():
|
||||
click.echo(click.style("New emails do not match.", fg="red"))
|
||||
return
|
||||
normalized_new_email = new_email.strip().lower()
|
||||
|
||||
account = AccountService.get_account_by_email_with_case_fallback(email.strip(), session=db.session())
|
||||
account = application_services().accounts.lifecycle.get_account_by_email_with_case_fallback(email.strip())
|
||||
|
||||
if not account:
|
||||
click.echo(click.style(f"Account not found for email: {email}", fg="red"))
|
||||
@@ -75,14 +60,11 @@ def reset_email(email, new_email, email_confirm):
|
||||
|
||||
try:
|
||||
email_validate(normalized_new_email)
|
||||
except:
|
||||
except ValueError:
|
||||
click.echo(click.style(f"Invalid email: {new_email}", fg="red"))
|
||||
return
|
||||
|
||||
with Session(db.engine) as session:
|
||||
account = session.merge(account)
|
||||
account.email = normalized_new_email
|
||||
session.commit()
|
||||
application_services().accounts.lifecycle.set_email(account.id, normalized_new_email)
|
||||
click.echo(click.style("Email updated successfully.", fg="green"))
|
||||
|
||||
|
||||
@@ -127,15 +109,14 @@ def create_tenant(email: str, language: str | None = None, name: str | None = No
|
||||
return
|
||||
|
||||
# register account
|
||||
account = RegisterService.register(
|
||||
account = application_services().accounts.lifecycle.register(
|
||||
email=email,
|
||||
name=account_name,
|
||||
password=new_password,
|
||||
language=language,
|
||||
create_workspace_required=False,
|
||||
session=db.session(),
|
||||
)
|
||||
TenantService.create_owner_tenant_if_not_exist(account, name, session=db.session())
|
||||
application_services().workspaces.provisioning.create_owner_workspace(account.id, name=name, if_missing=True)
|
||||
|
||||
click.echo(
|
||||
click.style(
|
||||
|
||||
@@ -7,7 +7,11 @@ from typing import cast
|
||||
|
||||
import click
|
||||
|
||||
from commands.rbac import migrate_dataset_permissions_to_rbac
|
||||
from commands.rbac import (
|
||||
migrate_dataset_permissions_to_rbac,
|
||||
migrate_only_me_resource_whitelist_scopes_to_automatic_include,
|
||||
migrate_resource_whitelist_scopes_to_automatic_include, # noqa: F401
|
||||
)
|
||||
from extensions.ext_database import db
|
||||
from graphon.model_runtime.entities.model_entities import ModelType
|
||||
from services.legacy_model_type_migration import (
|
||||
@@ -179,3 +183,4 @@ def legacy_model_types(
|
||||
|
||||
data_migrate.add_command(legacy_model_types)
|
||||
data_migrate.add_command(migrate_dataset_permissions_to_rbac)
|
||||
data_migrate.add_command(migrate_only_me_resource_whitelist_scopes_to_automatic_include)
|
||||
|
||||
@@ -32,7 +32,7 @@ logger = logging.getLogger(__name__)
|
||||
@click.command("setup-system-tool-oauth-client", help="Setup system tool oauth client.")
|
||||
@click.option("--provider", prompt=True, help="Provider name")
|
||||
@click.option("--client-params", prompt=True, help="Client Params")
|
||||
def setup_system_tool_oauth_client(provider, client_params):
|
||||
def setup_system_tool_oauth_client(provider: str, client_params: str):
|
||||
"""
|
||||
Setup system tool oauth client
|
||||
"""
|
||||
@@ -79,7 +79,7 @@ def setup_system_tool_oauth_client(provider, client_params):
|
||||
@click.command("setup-system-trigger-oauth-client", help="Setup system trigger oauth client.")
|
||||
@click.option("--provider", prompt=True, help="Provider name")
|
||||
@click.option("--client-params", prompt=True, help="Client Params")
|
||||
def setup_system_trigger_oauth_client(provider, client_params):
|
||||
def setup_system_trigger_oauth_client(provider: str, client_params: str):
|
||||
"""
|
||||
Setup system trigger oauth client
|
||||
"""
|
||||
@@ -129,7 +129,7 @@ def setup_system_trigger_oauth_client(provider, client_params):
|
||||
@click.command("setup-datasource-oauth-client", help="Setup datasource oauth client.")
|
||||
@click.option("--provider", prompt=True, help="Provider name")
|
||||
@click.option("--client-params", prompt=True, help="Client Params")
|
||||
def setup_datasource_oauth_client(provider, client_params):
|
||||
def setup_datasource_oauth_client(provider: str, client_params: str):
|
||||
"""
|
||||
Setup datasource oauth client
|
||||
"""
|
||||
|
||||
@@ -3,6 +3,8 @@ from __future__ import annotations
|
||||
import json
|
||||
from collections.abc import Iterator
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
from dataclasses import dataclass
|
||||
from enum import StrEnum
|
||||
|
||||
import click
|
||||
from sqlalchemy import select
|
||||
@@ -11,10 +13,33 @@ from sqlalchemy.orm import Session
|
||||
from configs import dify_config
|
||||
from core.db.session_factory import session_factory
|
||||
from core.rbac import RBACResourceWhitelistScope
|
||||
from models import Dataset, DatasetPermission, DatasetPermissionEnum, TenantAccountJoin, TenantAccountRole
|
||||
from services.enterprise.rbac_service import ListOption, RBACService, ReplaceMemberBindings, ReplaceUserAccessPolicies
|
||||
from models import (
|
||||
Agent,
|
||||
AgentStatus,
|
||||
App,
|
||||
Dataset,
|
||||
DatasetPermission,
|
||||
DatasetPermissionEnum,
|
||||
Tenant,
|
||||
TenantAccountJoin,
|
||||
TenantAccountRole,
|
||||
)
|
||||
from services.enterprise.rbac_service import (
|
||||
LegacyAgentRoleMigration,
|
||||
ListOption,
|
||||
RBACResourceType,
|
||||
RBACService,
|
||||
ReplaceMemberBindings,
|
||||
ReplaceUserAccessPolicies,
|
||||
)
|
||||
|
||||
_RBAC_DEFAULT_ACCESS_POLICY_ID = "default"
|
||||
_RBAC_RESOURCE_ACCESS_POLICY_BATCH_SIZE = 500
|
||||
|
||||
_AGENT_MIGRATION_STATE_LABEL = {
|
||||
False: "would change",
|
||||
True: "changed",
|
||||
}
|
||||
|
||||
_LEGACY_ROLE_TO_BUILTIN_TAG = {
|
||||
TenantAccountRole.OWNER.value: "owner",
|
||||
@@ -66,6 +91,88 @@ def _resolve_builtin_role_id(tenant_id: str, operator_account_id: str, legacy_ro
|
||||
return _resolve_builtin_role_ids(tenant_id, operator_account_id)[legacy_role]
|
||||
|
||||
|
||||
def _iter_tenant_ids(tenant_id: str | None, *, batch_size: int) -> Iterator[str]:
|
||||
if tenant_id:
|
||||
yield tenant_id
|
||||
return
|
||||
last_id: str | None = None
|
||||
while True:
|
||||
with session_factory.create_session() as session:
|
||||
stmt = select(Tenant.id).order_by(Tenant.id.asc()).limit(batch_size)
|
||||
if last_id is not None:
|
||||
stmt = stmt.where(Tenant.id > last_id)
|
||||
rows = session.execute(stmt).scalars().all()
|
||||
if not rows:
|
||||
return
|
||||
for row in rows:
|
||||
yield str(row)
|
||||
last_id = str(rows[-1])
|
||||
|
||||
|
||||
def _emit_agent_migration_event(payload: dict[str, object]) -> None:
|
||||
click.echo(json.dumps(payload, sort_keys=True))
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class _AgentMigrationEventKind:
|
||||
event_stem: str
|
||||
include_tenant_id: bool = True
|
||||
|
||||
@property
|
||||
def skipped(self) -> str:
|
||||
return f"{self.event_stem}_skipped"
|
||||
|
||||
@property
|
||||
def failed(self) -> str:
|
||||
return f"{self.event_stem}_failed"
|
||||
|
||||
def outcome(self, *, apply: bool) -> str:
|
||||
return f"{self.event_stem}_applied" if apply else f"{self.event_stem}_proposed_change"
|
||||
|
||||
|
||||
_AGENT_ROLE_MIGRATION_EVENT_KIND = _AgentMigrationEventKind(event_stem="agent_manage_role_migration")
|
||||
_AGENT_ROLE_TEMPLATE_MIGRATION_EVENT_KIND = _AgentMigrationEventKind(
|
||||
event_stem="agent_manage_role_template_migration", include_tenant_id=False
|
||||
)
|
||||
_AGENT_ACCESS_BOOTSTRAP_EVENT_KIND = _AgentMigrationEventKind(event_stem="agent_access_bootstrap")
|
||||
|
||||
_AGENT_BACKING_APP_SPECIFIC_WHITELIST_EVENT = "agent_backing_app_has_specific_whitelist"
|
||||
_AGENT_ACCESS_BOOTSTRAP_MEMBER_SOURCE = "workspace_members"
|
||||
|
||||
|
||||
class _AgentAccessBootstrapReason(StrEnum):
|
||||
ALREADY_INITIALIZED = "already_initialized"
|
||||
MISSING_WHITELIST_SCOPE = "missing_whitelist_scope"
|
||||
NO_CREATOR = "no_creator"
|
||||
|
||||
|
||||
def _agent_manage_role_event(
|
||||
tenant_id: str | None,
|
||||
entry: LegacyAgentRoleMigration,
|
||||
*,
|
||||
apply: bool,
|
||||
kind: _AgentMigrationEventKind,
|
||||
) -> dict[str, object]:
|
||||
base: dict[str, object] = {
|
||||
"dry_run": not apply,
|
||||
"role_id": entry.role_id,
|
||||
"role_name": entry.role_name,
|
||||
}
|
||||
if kind.include_tenant_id:
|
||||
base["tenant_id"] = tenant_id
|
||||
if entry.skipped:
|
||||
return {**base, "event": kind.skipped, "reason": entry.skipped}
|
||||
return {
|
||||
**base,
|
||||
"event": kind.outcome(apply=apply),
|
||||
"after": {
|
||||
"added_keys": entry.added_keys,
|
||||
"removed_keys": entry.removed_keys,
|
||||
"bound_policies": entry.bound_policies,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def _iter_tenant_member_batches(
|
||||
tenant_id: str | None,
|
||||
*,
|
||||
@@ -310,6 +417,529 @@ def _emit_dataset_permission_migration_event(payload: dict[str, object]) -> None
|
||||
click.echo(json.dumps(payload, sort_keys=True))
|
||||
|
||||
|
||||
def _emit_resource_whitelist_scope_migration_event(payload: dict[str, object]) -> None:
|
||||
click.echo(json.dumps(payload, sort_keys=True))
|
||||
|
||||
|
||||
def _normalize_rbac_whitelist_scope(scope: object) -> RBACResourceWhitelistScope | None:
|
||||
if scope is None:
|
||||
return None
|
||||
try:
|
||||
return RBACResourceWhitelistScope(str(scope))
|
||||
except ValueError as exc:
|
||||
raise ValueError(f"Unsupported RBAC whitelist scope: {scope}") from exc
|
||||
|
||||
|
||||
def _owner_account_id(tenant_id: str, *, session: Session) -> str:
|
||||
account_id = session.scalar(
|
||||
select(TenantAccountJoin.account_id)
|
||||
.where(TenantAccountJoin.tenant_id == tenant_id, TenantAccountJoin.role == TenantAccountRole.OWNER)
|
||||
.order_by(TenantAccountJoin.id.asc())
|
||||
.limit(1)
|
||||
)
|
||||
if not account_id:
|
||||
raise ValueError(f"Workspace owner not found for tenant={tenant_id}")
|
||||
return str(account_id)
|
||||
|
||||
|
||||
def _workspace_member_account_id_batches(tenant_id: str, batch_size: int) -> Iterator[list[str]]:
|
||||
last_join_id: str | None = None
|
||||
while True:
|
||||
with session_factory.create_session() as session:
|
||||
stmt = (
|
||||
select(TenantAccountJoin.id, TenantAccountJoin.account_id)
|
||||
.where(TenantAccountJoin.tenant_id == tenant_id)
|
||||
.order_by(TenantAccountJoin.id.asc())
|
||||
.limit(batch_size)
|
||||
)
|
||||
if last_join_id:
|
||||
stmt = stmt.where(TenantAccountJoin.id > last_join_id)
|
||||
|
||||
rows = list(session.execute(stmt).all())
|
||||
if not rows:
|
||||
return
|
||||
|
||||
yield [str(row.account_id) for row in rows]
|
||||
last_join_id = str(rows[-1].id)
|
||||
|
||||
|
||||
def _workspace_non_admin_account_id_batches(
|
||||
tenant_id: str,
|
||||
operator_account_id: str,
|
||||
batch_size: int,
|
||||
) -> Iterator[list[str]]:
|
||||
"""Yield workspace members except accounts bound to RBAC's builtin Owner/Admin roles.
|
||||
|
||||
Resource administrators receive access implicitly through RBAC and their
|
||||
resource access-policy bindings are locked. Resolve their current RBAC
|
||||
bindings in batches instead of relying on the legacy workspace role column.
|
||||
"""
|
||||
for batch in _workspace_member_account_id_batches(tenant_id, batch_size):
|
||||
member_roles = RBACService.MemberRoles.batch_get(
|
||||
tenant_id=tenant_id,
|
||||
account_id=operator_account_id,
|
||||
member_account_ids=batch,
|
||||
)
|
||||
protected_account_ids = {
|
||||
member.account_id
|
||||
for member in member_roles
|
||||
if any(
|
||||
role.is_builtin and role.category == "global_system_default" and role.role_tag in {"owner", "admin"}
|
||||
for role in member.roles
|
||||
)
|
||||
}
|
||||
writable_batch = [account_id for account_id in batch if account_id not in protected_account_ids]
|
||||
if writable_batch:
|
||||
yield writable_batch
|
||||
|
||||
|
||||
def _replace_resource_whitelist(
|
||||
resource_type: str,
|
||||
*,
|
||||
tenant_id: str,
|
||||
operator_account_id: str,
|
||||
resource_id: str,
|
||||
automatic_include_workspace_members: bool,
|
||||
) -> None:
|
||||
payload = ReplaceMemberBindings(automatic_include_workspace_members=automatic_include_workspace_members)
|
||||
if resource_type == "app":
|
||||
RBACService.AppAccess.replace_whitelist(
|
||||
tenant_id=tenant_id,
|
||||
account_id=operator_account_id,
|
||||
app_id=resource_id,
|
||||
payload=payload,
|
||||
)
|
||||
return
|
||||
RBACService.DatasetAccess.replace_whitelist(
|
||||
tenant_id=tenant_id,
|
||||
account_id=operator_account_id,
|
||||
dataset_id=resource_id,
|
||||
payload=payload,
|
||||
)
|
||||
|
||||
|
||||
def _replace_resource_default_access_policies(
|
||||
resource_type: str,
|
||||
*,
|
||||
tenant_id: str,
|
||||
operator_account_id: str,
|
||||
resource_id: str,
|
||||
account_ids: list[str],
|
||||
) -> None:
|
||||
if not account_ids:
|
||||
return
|
||||
payload = ReplaceUserAccessPolicies(
|
||||
access_policy_ids=[_RBAC_DEFAULT_ACCESS_POLICY_ID],
|
||||
account_ids=account_ids,
|
||||
)
|
||||
if resource_type == "app":
|
||||
RBACService.AppAccess.replace_user_access_policies(
|
||||
tenant_id=tenant_id,
|
||||
account_id=operator_account_id,
|
||||
app_id=resource_id,
|
||||
target_account_id=None,
|
||||
payload=payload,
|
||||
)
|
||||
return
|
||||
RBACService.DatasetAccess.replace_user_access_policies(
|
||||
tenant_id=tenant_id,
|
||||
account_id=operator_account_id,
|
||||
dataset_id=resource_id,
|
||||
target_account_id=None,
|
||||
payload=payload,
|
||||
)
|
||||
|
||||
|
||||
def _resource_legacy_whitelist_config(
|
||||
resource_type: str,
|
||||
*,
|
||||
tenant_id: str,
|
||||
operator_account_id: str,
|
||||
resource_id: str,
|
||||
):
|
||||
if resource_type == "app":
|
||||
return RBACService.AppAccess.legacy_whitelist_config(
|
||||
tenant_id=tenant_id,
|
||||
account_id=operator_account_id,
|
||||
app_id=resource_id,
|
||||
)
|
||||
return RBACService.DatasetAccess.legacy_whitelist_config(
|
||||
tenant_id=tenant_id,
|
||||
account_id=operator_account_id,
|
||||
dataset_id=resource_id,
|
||||
)
|
||||
|
||||
|
||||
def _iter_rbac_resource_rows(
|
||||
resource_type: str,
|
||||
*,
|
||||
tenant_id: str | None,
|
||||
resource_id: str | None,
|
||||
batch_size: int,
|
||||
) -> Iterator[tuple[str, str, str, str | None]]:
|
||||
model = App if resource_type == "app" else Dataset
|
||||
last_resource_id: str | None = None
|
||||
while True:
|
||||
with session_factory.create_session() as session:
|
||||
stmt = select(model.id, model.tenant_id, model.maintainer).order_by(model.id.asc()).limit(batch_size)
|
||||
if tenant_id:
|
||||
stmt = stmt.where(model.tenant_id == tenant_id)
|
||||
if resource_id:
|
||||
stmt = stmt.where(model.id == resource_id)
|
||||
if last_resource_id:
|
||||
stmt = stmt.where(model.id > last_resource_id)
|
||||
|
||||
rows = list(session.execute(stmt).all())
|
||||
if not rows:
|
||||
return
|
||||
|
||||
for row in rows:
|
||||
yield resource_type, str(row.tenant_id), str(row.id), str(row.maintainer) if row.maintainer else None
|
||||
|
||||
last_resource_id = str(rows[-1].id)
|
||||
if resource_id:
|
||||
return
|
||||
|
||||
|
||||
def _iter_selected_rbac_resource_rows(
|
||||
resource_type: str,
|
||||
*,
|
||||
tenant_id: str | None,
|
||||
resource_id: str | None,
|
||||
batch_size: int,
|
||||
) -> Iterator[tuple[str, str, str, str | None]]:
|
||||
if resource_type in {"app", "all"}:
|
||||
yield from _iter_rbac_resource_rows(
|
||||
"app",
|
||||
tenant_id=tenant_id,
|
||||
resource_id=resource_id if resource_type == "app" else None,
|
||||
batch_size=batch_size,
|
||||
)
|
||||
if resource_type in {"dataset", "all"}:
|
||||
yield from _iter_rbac_resource_rows(
|
||||
"dataset",
|
||||
tenant_id=tenant_id,
|
||||
resource_id=resource_id if resource_type == "dataset" else None,
|
||||
batch_size=batch_size,
|
||||
)
|
||||
|
||||
|
||||
@click.command(
|
||||
"rbac-migrate-resource-whitelist-scopes",
|
||||
help=(
|
||||
"Migrate RBAC app/dataset whitelist scope values to automatic_include_workspace_members. "
|
||||
"Old scope all becomes true; specific and only_me become false."
|
||||
),
|
||||
)
|
||||
@click.option("--tenant-id", help="Only migrate resources in a single workspace.")
|
||||
@click.option(
|
||||
"--resource-type",
|
||||
type=click.Choice(["app", "dataset", "all"]),
|
||||
default="all",
|
||||
show_default=True,
|
||||
help="Resource type to migrate.",
|
||||
)
|
||||
@click.option("--resource-id", help="Only migrate a single resource. Requires --resource-type app or dataset.")
|
||||
@click.option("--batch-size", default=500, show_default=True, type=click.IntRange(min=1))
|
||||
@click.option(
|
||||
"--member-batch-size",
|
||||
default=_RBAC_RESOURCE_ACCESS_POLICY_BATCH_SIZE,
|
||||
show_default=True,
|
||||
type=click.IntRange(min=1),
|
||||
help="Workspace members written per default-policy call when migrating old scope all.",
|
||||
)
|
||||
@click.option(
|
||||
"--dry-run/--apply",
|
||||
default=True,
|
||||
show_default=True,
|
||||
help="Preview the migration without writing RBAC bindings. Use --apply to write changes.",
|
||||
)
|
||||
def migrate_resource_whitelist_scopes_to_automatic_include(
|
||||
tenant_id: str | None,
|
||||
resource_type: str,
|
||||
resource_id: str | None,
|
||||
batch_size: int,
|
||||
member_batch_size: int,
|
||||
dry_run: bool,
|
||||
) -> None:
|
||||
"""Backfill RBAC app/dataset automatic workspace-member inclusion from old RBAC scope."""
|
||||
if resource_id and resource_type == "all":
|
||||
raise click.BadParameter("--resource-id requires --resource-type app or dataset", param_hint="--resource-id")
|
||||
|
||||
click.echo(click.style("Starting RBAC resource whitelist scope migration.", fg="green"))
|
||||
|
||||
scanned_count = 0
|
||||
migrated_count = 0
|
||||
member_policy_batch_count = 0
|
||||
owner_account_ids_by_tenant_id: dict[str, str] = {}
|
||||
|
||||
for (
|
||||
current_resource_type,
|
||||
workspace_id,
|
||||
current_resource_id,
|
||||
maintainer_account_id,
|
||||
) in _iter_selected_rbac_resource_rows(
|
||||
resource_type,
|
||||
tenant_id=tenant_id,
|
||||
resource_id=resource_id,
|
||||
batch_size=batch_size,
|
||||
):
|
||||
scanned_count += 1
|
||||
with session_factory.create_session() as session:
|
||||
operator_account_id = maintainer_account_id or owner_account_ids_by_tenant_id.get(workspace_id)
|
||||
if not operator_account_id:
|
||||
operator_account_id = _owner_account_id(workspace_id, session=session)
|
||||
owner_account_ids_by_tenant_id[workspace_id] = operator_account_id
|
||||
|
||||
legacy_config = _resource_legacy_whitelist_config(
|
||||
current_resource_type,
|
||||
tenant_id=workspace_id,
|
||||
operator_account_id=operator_account_id,
|
||||
resource_id=current_resource_id,
|
||||
)
|
||||
scope = _normalize_rbac_whitelist_scope(legacy_config.rbac_whitelist_scope)
|
||||
if scope is None:
|
||||
_emit_resource_whitelist_scope_migration_event(
|
||||
{
|
||||
"event": "resource_whitelist_scope_migration_skipped",
|
||||
"reason": "missing_legacy_scope",
|
||||
"dry_run": dry_run,
|
||||
"tenant_id": workspace_id,
|
||||
"resource_type": current_resource_type,
|
||||
"resource_id": current_resource_id,
|
||||
}
|
||||
)
|
||||
continue
|
||||
|
||||
automatic_include_workspace_members = scope is RBACResourceWhitelistScope.ALL
|
||||
if scope is RBACResourceWhitelistScope.SPECIFIC:
|
||||
member_account_ids = sorted(set(legacy_config.account_ids))
|
||||
member_source = "legacy_specific_members"
|
||||
elif scope is RBACResourceWhitelistScope.ONLY_ME:
|
||||
member_account_ids = [maintainer_account_id] if maintainer_account_id else []
|
||||
member_source = "resource_maintainer"
|
||||
else:
|
||||
member_account_ids = []
|
||||
member_source = "workspace_members"
|
||||
|
||||
_emit_resource_whitelist_scope_migration_event(
|
||||
{
|
||||
"event": "resource_whitelist_scope_migration_proposed_change",
|
||||
"dry_run": dry_run,
|
||||
"tenant_id": workspace_id,
|
||||
"operator_account_id": operator_account_id,
|
||||
"resource_type": current_resource_type,
|
||||
"resource_id": current_resource_id,
|
||||
"before": {
|
||||
"rbac_whitelist_scope": scope.value,
|
||||
"legacy_account_ids": sorted(set(legacy_config.account_ids)),
|
||||
},
|
||||
"after": {
|
||||
"automatic_include_workspace_members": automatic_include_workspace_members,
|
||||
"default_policy_member_source": member_source,
|
||||
"default_policy_account_ids": member_account_ids,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
if dry_run:
|
||||
continue
|
||||
|
||||
_replace_resource_whitelist(
|
||||
current_resource_type,
|
||||
tenant_id=workspace_id,
|
||||
operator_account_id=operator_account_id,
|
||||
resource_id=current_resource_id,
|
||||
automatic_include_workspace_members=automatic_include_workspace_members,
|
||||
)
|
||||
migrated_count += 1
|
||||
|
||||
if scope is RBACResourceWhitelistScope.ALL:
|
||||
for batch in _workspace_non_admin_account_id_batches(workspace_id, operator_account_id, member_batch_size):
|
||||
_replace_resource_default_access_policies(
|
||||
current_resource_type,
|
||||
tenant_id=workspace_id,
|
||||
operator_account_id=operator_account_id,
|
||||
resource_id=current_resource_id,
|
||||
account_ids=batch,
|
||||
)
|
||||
member_policy_batch_count += 1
|
||||
else:
|
||||
_replace_resource_default_access_policies(
|
||||
current_resource_type,
|
||||
tenant_id=workspace_id,
|
||||
operator_account_id=operator_account_id,
|
||||
resource_id=current_resource_id,
|
||||
account_ids=member_account_ids,
|
||||
)
|
||||
if member_account_ids:
|
||||
member_policy_batch_count += 1
|
||||
|
||||
if scanned_count == 0:
|
||||
click.echo(click.style("No RBAC resources found for migration.", fg="yellow"))
|
||||
return
|
||||
|
||||
if dry_run:
|
||||
click.echo(
|
||||
click.style(
|
||||
f"Dry run completed. Scanned {scanned_count} RBAC resources. No RBAC bindings were written.",
|
||||
fg="yellow",
|
||||
)
|
||||
)
|
||||
else:
|
||||
click.echo(
|
||||
click.style(
|
||||
"RBAC resource whitelist scope migration completed. "
|
||||
f"Scanned {scanned_count} resources, migrated {migrated_count}, "
|
||||
f"wrote {member_policy_batch_count} default-policy batches.",
|
||||
fg="green",
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@click.command(
|
||||
"rbac-migrate-resource-whitelist-scopes",
|
||||
help=(
|
||||
"Migrate RBAC app/dataset whitelist configs whose old scope is only_me to "
|
||||
"automatic_include_workspace_members=true and sync workspace members into the whitelist."
|
||||
),
|
||||
)
|
||||
@click.option("--tenant-id", help="Only migrate resources in a single workspace.")
|
||||
@click.option(
|
||||
"--resource-type",
|
||||
type=click.Choice(["app", "dataset", "all"]),
|
||||
default="all",
|
||||
show_default=True,
|
||||
help="Resource type to migrate.",
|
||||
)
|
||||
@click.option("--resource-id", help="Only migrate a single resource. Requires --resource-type app or dataset.")
|
||||
@click.option("--batch-size", default=500, show_default=True, type=click.IntRange(min=1))
|
||||
@click.option(
|
||||
"--member-batch-size",
|
||||
default=_RBAC_RESOURCE_ACCESS_POLICY_BATCH_SIZE,
|
||||
show_default=True,
|
||||
type=click.IntRange(min=1),
|
||||
help="Workspace members written per default-policy call.",
|
||||
)
|
||||
@click.option(
|
||||
"--dry-run/--apply",
|
||||
default=True,
|
||||
show_default=True,
|
||||
help="Preview the migration without writing RBAC bindings. Use --apply to write changes.",
|
||||
)
|
||||
def migrate_only_me_resource_whitelist_scopes_to_automatic_include(
|
||||
tenant_id: str | None,
|
||||
resource_type: str,
|
||||
resource_id: str | None,
|
||||
batch_size: int,
|
||||
member_batch_size: int,
|
||||
dry_run: bool,
|
||||
) -> None:
|
||||
"""Backfill automatic workspace-member inclusion for old RBAC only_me resource scopes."""
|
||||
if resource_id and resource_type == "all":
|
||||
raise click.BadParameter("--resource-id requires --resource-type app or dataset", param_hint="--resource-id")
|
||||
|
||||
click.echo(click.style("Starting RBAC only_me resource whitelist scope migration.", fg="green"))
|
||||
|
||||
scanned_count = 0
|
||||
only_me_count = 0
|
||||
migrated_count = 0
|
||||
member_policy_batch_count = 0
|
||||
owner_account_ids_by_tenant_id: dict[str, str] = {}
|
||||
|
||||
for (
|
||||
current_resource_type,
|
||||
workspace_id,
|
||||
current_resource_id,
|
||||
maintainer_account_id,
|
||||
) in _iter_selected_rbac_resource_rows(
|
||||
resource_type,
|
||||
tenant_id=tenant_id,
|
||||
resource_id=resource_id,
|
||||
batch_size=batch_size,
|
||||
):
|
||||
scanned_count += 1
|
||||
with session_factory.create_session() as session:
|
||||
operator_account_id = maintainer_account_id or owner_account_ids_by_tenant_id.get(workspace_id)
|
||||
if not operator_account_id:
|
||||
operator_account_id = _owner_account_id(workspace_id, session=session)
|
||||
owner_account_ids_by_tenant_id[workspace_id] = operator_account_id
|
||||
|
||||
legacy_config = _resource_legacy_whitelist_config(
|
||||
current_resource_type,
|
||||
tenant_id=workspace_id,
|
||||
operator_account_id=operator_account_id,
|
||||
resource_id=current_resource_id,
|
||||
)
|
||||
scope = _normalize_rbac_whitelist_scope(legacy_config.rbac_whitelist_scope)
|
||||
if scope is not RBACResourceWhitelistScope.ONLY_ME:
|
||||
continue
|
||||
|
||||
only_me_count += 1
|
||||
_emit_resource_whitelist_scope_migration_event(
|
||||
{
|
||||
"event": "only_me_resource_whitelist_scope_migration_proposed_change",
|
||||
"dry_run": dry_run,
|
||||
"tenant_id": workspace_id,
|
||||
"operator_account_id": operator_account_id,
|
||||
"resource_type": current_resource_type,
|
||||
"resource_id": current_resource_id,
|
||||
"before": {
|
||||
"rbac_whitelist_scope": scope.value,
|
||||
"legacy_account_ids": sorted(set(legacy_config.account_ids)),
|
||||
},
|
||||
"after": {
|
||||
"automatic_include_workspace_members": True,
|
||||
"default_policy_member_source": "workspace_members",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
if dry_run:
|
||||
continue
|
||||
|
||||
_replace_resource_whitelist(
|
||||
current_resource_type,
|
||||
tenant_id=workspace_id,
|
||||
operator_account_id=operator_account_id,
|
||||
resource_id=current_resource_id,
|
||||
automatic_include_workspace_members=True,
|
||||
)
|
||||
migrated_count += 1
|
||||
|
||||
for batch in _workspace_non_admin_account_id_batches(workspace_id, operator_account_id, member_batch_size):
|
||||
_replace_resource_default_access_policies(
|
||||
current_resource_type,
|
||||
tenant_id=workspace_id,
|
||||
operator_account_id=operator_account_id,
|
||||
resource_id=current_resource_id,
|
||||
account_ids=batch,
|
||||
)
|
||||
member_policy_batch_count += 1
|
||||
|
||||
if scanned_count == 0:
|
||||
click.echo(click.style("No RBAC resources found for migration.", fg="yellow"))
|
||||
return
|
||||
|
||||
if dry_run:
|
||||
click.echo(
|
||||
click.style(
|
||||
f"Dry run completed. Scanned {scanned_count} RBAC resources, found {only_me_count} only_me resources. "
|
||||
"No RBAC bindings were written.",
|
||||
fg="yellow",
|
||||
)
|
||||
)
|
||||
else:
|
||||
click.echo(
|
||||
click.style(
|
||||
"RBAC only_me resource whitelist scope migration completed. "
|
||||
f"Scanned {scanned_count} resources, migrated {migrated_count}, "
|
||||
f"wrote {member_policy_batch_count} default-policy batches.",
|
||||
fg="green",
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@click.command(
|
||||
"rbac-migrate-dataset-permissions",
|
||||
help=(
|
||||
@@ -399,7 +1029,9 @@ def migrate_dataset_permissions_to_rbac(
|
||||
)
|
||||
|
||||
scanned_count += 1
|
||||
replace_whitelist_payload = ReplaceMemberBindings(scope=scope)
|
||||
replace_whitelist_payload = ReplaceMemberBindings(
|
||||
automatic_include_workspace_members=scope is RBACResourceWhitelistScope.ALL
|
||||
)
|
||||
if dry_run:
|
||||
_emit_dataset_permission_migration_event(
|
||||
{
|
||||
@@ -509,3 +1141,306 @@ def migrate_dataset_permissions_to_rbac(
|
||||
fg="green",
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
_AgentRow = tuple[str, str | None, str | None]
|
||||
|
||||
|
||||
def _iter_agent_row_batches(tenant_id: str, batch_size: int) -> Iterator[list[_AgentRow]]:
|
||||
last_agent_id: str | None = None
|
||||
while True:
|
||||
with session_factory.create_session() as session:
|
||||
stmt = (
|
||||
select(Agent.id, Agent.created_by, Agent.backing_app_id)
|
||||
.where(Agent.tenant_id == tenant_id, Agent.status != AgentStatus.ARCHIVED)
|
||||
.order_by(Agent.id.asc())
|
||||
.limit(batch_size)
|
||||
)
|
||||
if last_agent_id:
|
||||
stmt = stmt.where(Agent.id > last_agent_id)
|
||||
|
||||
rows = list(session.execute(stmt).all())
|
||||
if not rows:
|
||||
return
|
||||
|
||||
yield [
|
||||
(
|
||||
str(row.id),
|
||||
str(row.created_by) if row.created_by else None,
|
||||
str(row.backing_app_id) if row.backing_app_id else None,
|
||||
)
|
||||
for row in rows
|
||||
]
|
||||
|
||||
last_agent_id = str(rows[-1].id)
|
||||
|
||||
|
||||
@dataclass
|
||||
class _AgentAccessBootstrapCounts:
|
||||
changed: int = 0
|
||||
already_initialized: int = 0
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class _AgentAccessBootstrapOptions:
|
||||
tenant_id: str
|
||||
agent_id: str
|
||||
creator_account_id: str | None
|
||||
backing_app_id: str | None
|
||||
operator_account_id: str
|
||||
member_batch_size: int
|
||||
apply: bool
|
||||
initialized: bool
|
||||
|
||||
|
||||
def _report_backing_app_specific_whitelist(options: _AgentAccessBootstrapOptions) -> None:
|
||||
if not options.backing_app_id:
|
||||
return
|
||||
app_config = _resource_legacy_whitelist_config(
|
||||
"app",
|
||||
tenant_id=options.tenant_id,
|
||||
operator_account_id=options.operator_account_id,
|
||||
resource_id=options.backing_app_id,
|
||||
)
|
||||
if _normalize_rbac_whitelist_scope(app_config.rbac_whitelist_scope) is not RBACResourceWhitelistScope.SPECIFIC:
|
||||
return
|
||||
_emit_agent_migration_event(
|
||||
{
|
||||
"event": _AGENT_BACKING_APP_SPECIFIC_WHITELIST_EVENT,
|
||||
"dry_run": not options.apply,
|
||||
"tenant_id": options.tenant_id,
|
||||
"agent_id": options.agent_id,
|
||||
"app_id": options.backing_app_id,
|
||||
"backing_app_account_ids": sorted(set(app_config.account_ids)),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def _write_agent_access_rows(options: _AgentAccessBootstrapOptions) -> None:
|
||||
for batch in _workspace_non_admin_account_id_batches(
|
||||
options.tenant_id,
|
||||
options.operator_account_id,
|
||||
options.member_batch_size,
|
||||
):
|
||||
RBACService.AgentAccess.replace_user_access_policies(
|
||||
tenant_id=options.tenant_id,
|
||||
account_id=options.operator_account_id,
|
||||
agent_id=options.agent_id,
|
||||
target_account_id=None,
|
||||
payload=ReplaceUserAccessPolicies(
|
||||
access_policy_ids=[_RBAC_DEFAULT_ACCESS_POLICY_ID],
|
||||
account_ids=batch,
|
||||
),
|
||||
)
|
||||
if options.creator_account_id:
|
||||
RBACService.AccessPolicies.sync_creator_access_policy_member_bindings(
|
||||
tenant_id=options.tenant_id,
|
||||
account_id=options.creator_account_id,
|
||||
resource_type=RBACResourceType.AGENT,
|
||||
resource_id=options.agent_id,
|
||||
)
|
||||
RBACService.AgentAccess.replace_whitelist(
|
||||
tenant_id=options.tenant_id,
|
||||
account_id=options.operator_account_id,
|
||||
agent_id=options.agent_id,
|
||||
payload=ReplaceMemberBindings(automatic_include_workspace_members=True),
|
||||
)
|
||||
|
||||
|
||||
def _emit_agent_access_bootstrap_skipped(
|
||||
options: _AgentAccessBootstrapOptions,
|
||||
reason: _AgentAccessBootstrapReason,
|
||||
) -> None:
|
||||
_emit_agent_migration_event(
|
||||
{
|
||||
"event": _AGENT_ACCESS_BOOTSTRAP_EVENT_KIND.skipped,
|
||||
"reason": reason.value,
|
||||
"dry_run": not options.apply,
|
||||
"tenant_id": options.tenant_id,
|
||||
"agent_id": options.agent_id,
|
||||
"operator_account_id": options.operator_account_id,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def _agent_access_bootstrap_failure(
|
||||
options: _AgentAccessBootstrapOptions,
|
||||
exc: Exception,
|
||||
) -> click.ClickException:
|
||||
_emit_agent_migration_event(
|
||||
{
|
||||
"event": _AGENT_ACCESS_BOOTSTRAP_EVENT_KIND.failed,
|
||||
"tenant_id": options.tenant_id,
|
||||
"agent_id": options.agent_id,
|
||||
"error": str(exc),
|
||||
}
|
||||
)
|
||||
return click.ClickException(f"tenant {options.tenant_id} agent {options.agent_id}: {exc}")
|
||||
|
||||
|
||||
def _bootstrap_agent_access(options: _AgentAccessBootstrapOptions, counts: _AgentAccessBootstrapCounts) -> None:
|
||||
if options.initialized:
|
||||
counts.already_initialized += 1
|
||||
_emit_agent_access_bootstrap_skipped(options, _AgentAccessBootstrapReason.ALREADY_INITIALIZED)
|
||||
return
|
||||
|
||||
config = RBACService.AgentAccess.legacy_whitelist_config(
|
||||
tenant_id=options.tenant_id,
|
||||
account_id=options.operator_account_id,
|
||||
agent_id=options.agent_id,
|
||||
)
|
||||
try:
|
||||
scope = _normalize_rbac_whitelist_scope(config.rbac_whitelist_scope)
|
||||
except ValueError as exc:
|
||||
raise _agent_access_bootstrap_failure(options, exc) from exc
|
||||
if scope is None:
|
||||
_emit_agent_access_bootstrap_skipped(options, _AgentAccessBootstrapReason.MISSING_WHITELIST_SCOPE)
|
||||
return
|
||||
|
||||
account_ids = sorted(set(config.account_ids))
|
||||
_report_backing_app_specific_whitelist(options)
|
||||
|
||||
if options.apply:
|
||||
try:
|
||||
_write_agent_access_rows(options)
|
||||
except Exception as exc:
|
||||
raise _agent_access_bootstrap_failure(options, exc) from exc
|
||||
counts.changed += 1
|
||||
|
||||
event: dict[str, object] = {
|
||||
"event": _AGENT_ACCESS_BOOTSTRAP_EVENT_KIND.outcome(apply=options.apply),
|
||||
"dry_run": not options.apply,
|
||||
"tenant_id": options.tenant_id,
|
||||
"agent_id": options.agent_id,
|
||||
"operator_account_id": options.operator_account_id,
|
||||
"before": {"rbac_whitelist_scope": scope.value, "whitelist_account_ids": account_ids},
|
||||
"after": {
|
||||
"automatic_include_workspace_members": True,
|
||||
"default_policy_member_source": _AGENT_ACCESS_BOOTSTRAP_MEMBER_SOURCE,
|
||||
"creator_access_policy_synced": bool(options.creator_account_id),
|
||||
},
|
||||
}
|
||||
if not options.creator_account_id:
|
||||
event["reason"] = _AgentAccessBootstrapReason.NO_CREATOR.value
|
||||
_emit_agent_migration_event(event)
|
||||
|
||||
|
||||
def _bootstrap_tenant_agent_access(
|
||||
tenant_id: str,
|
||||
*,
|
||||
agent_batch_size: int,
|
||||
member_batch_size: int,
|
||||
apply: bool,
|
||||
counts: _AgentAccessBootstrapCounts,
|
||||
) -> None:
|
||||
owner_account_id: str | None = None
|
||||
for rows in _iter_agent_row_batches(tenant_id, agent_batch_size):
|
||||
initialized_agent_ids = set(
|
||||
RBACService.Migrations.list_configured_agent_ids(tenant_id, [agent_id for agent_id, _, _ in rows])
|
||||
)
|
||||
for agent_id, creator_account_id, backing_app_id in rows:
|
||||
if creator_account_id:
|
||||
operator_account_id = creator_account_id
|
||||
else:
|
||||
if owner_account_id is None:
|
||||
with session_factory.create_session() as session:
|
||||
owner_account_id = _owner_account_id(tenant_id, session=session)
|
||||
operator_account_id = owner_account_id
|
||||
_bootstrap_agent_access(
|
||||
_AgentAccessBootstrapOptions(
|
||||
tenant_id=tenant_id,
|
||||
agent_id=agent_id,
|
||||
creator_account_id=creator_account_id,
|
||||
backing_app_id=backing_app_id,
|
||||
operator_account_id=operator_account_id,
|
||||
member_batch_size=member_batch_size,
|
||||
apply=apply,
|
||||
initialized=agent_id in initialized_agent_ids,
|
||||
),
|
||||
counts,
|
||||
)
|
||||
|
||||
|
||||
@click.command(
|
||||
"rbac-migrate-agent-permissions",
|
||||
help=(
|
||||
"Upgrade step for agent RBAC. Phase 1 asks the RBAC service to replace agent.manage on every "
|
||||
"custom role with agent.create plus the agent.full_access binding. Phase 2 bootstraps the access "
|
||||
"rows pre-existing agents never got, so they stay visible to workspace members. Agents that "
|
||||
"already have a whitelist scope row are skipped. Dry run by default."
|
||||
),
|
||||
)
|
||||
@click.option("--tenant-id", help="Only migrate a single workspace.")
|
||||
@click.option(
|
||||
"--batch-size",
|
||||
default=500,
|
||||
show_default=True,
|
||||
type=click.IntRange(min=1),
|
||||
help="Tenants fetched per database batch.",
|
||||
)
|
||||
@click.option(
|
||||
"--agent-batch-size",
|
||||
default=500,
|
||||
show_default=True,
|
||||
type=click.IntRange(min=1),
|
||||
help="Agents fetched per database batch.",
|
||||
)
|
||||
@click.option(
|
||||
"--member-batch-size",
|
||||
default=_RBAC_RESOURCE_ACCESS_POLICY_BATCH_SIZE,
|
||||
show_default=True,
|
||||
type=click.IntRange(min=1),
|
||||
help="Workspace members written per default-policy call when bootstrapping an agent.",
|
||||
)
|
||||
@click.option("--apply", is_flag=True, default=False, help="Write changes. Without it nothing is written.")
|
||||
def migrate_agent_permissions_to_rbac(
|
||||
tenant_id: str | None,
|
||||
batch_size: int,
|
||||
agent_batch_size: int,
|
||||
member_batch_size: int,
|
||||
apply: bool,
|
||||
) -> None:
|
||||
click.echo(click.style("Starting agent RBAC migration: custom roles holding agent.manage.", fg="green"))
|
||||
tenant_count = 0
|
||||
role_count = 0
|
||||
skipped_count = 0
|
||||
seen_template_ids: set[str] = set()
|
||||
template_count = 0
|
||||
agent_counts = _AgentAccessBootstrapCounts()
|
||||
for workspace_id in _iter_tenant_ids(tenant_id, batch_size=batch_size):
|
||||
tenant_count += 1
|
||||
try:
|
||||
report = RBACService.Migrations.migrate_agent_manage_roles(workspace_id, apply=apply)
|
||||
except Exception as exc:
|
||||
raise click.ClickException(f"tenant {workspace_id}: {exc}") from exc
|
||||
for entry in report.roles:
|
||||
role_count += 1
|
||||
if entry.skipped:
|
||||
skipped_count += 1
|
||||
_emit_agent_migration_event(
|
||||
_agent_manage_role_event(workspace_id, entry, apply=apply, kind=_AGENT_ROLE_MIGRATION_EVENT_KIND)
|
||||
)
|
||||
for template in report.role_templates:
|
||||
if template.role_id in seen_template_ids:
|
||||
continue
|
||||
seen_template_ids.add(template.role_id)
|
||||
template_count += 1
|
||||
_emit_agent_migration_event(
|
||||
_agent_manage_role_event(None, template, apply=apply, kind=_AGENT_ROLE_TEMPLATE_MIGRATION_EVENT_KIND)
|
||||
)
|
||||
_bootstrap_tenant_agent_access(
|
||||
workspace_id,
|
||||
agent_batch_size=agent_batch_size,
|
||||
member_batch_size=member_batch_size,
|
||||
apply=apply,
|
||||
counts=agent_counts,
|
||||
)
|
||||
role_state = _AGENT_MIGRATION_STATE_LABEL[apply]
|
||||
click.echo(
|
||||
f"{tenant_count} tenant(s), {role_count} role(s) {role_state}, {skipped_count} skipped, "
|
||||
f"{template_count} template(s) {role_state}, "
|
||||
f"{agent_counts.changed} agent(s) {role_state}, "
|
||||
f"{agent_counts.already_initialized} already initialised"
|
||||
)
|
||||
if not apply:
|
||||
click.echo(click.style("Dry run: no changes written. Re-run with --apply.", fg="yellow"))
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user