Skip to content

Commit 814c8e3

Browse files
author
gozhuang
committed
Merge branch 'main' into feat-tool-email
2 parents 940a9c8 + 852c8dd commit 814c8e3

File tree

412 files changed

+55165
-6168
lines changed

Some content is hidden

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

412 files changed

+55165
-6168
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.resources/*.png filter=lfs diff=lfs merge=lfs -text
22
.resources/**/*.png filter=lfs diff=lfs merge=lfs -text
3+
.resources/**/*.gif filter=lfs diff=lfs merge=lfs -text
34
*.png filter=lfs diff=lfs merge=lfs -text
5+
*.gif filter=lfs diff=lfs merge=lfs -text
46
examples/artifact/**/*.png filter=lfs diff=lfs merge=lfs -text
57
examples/artifact/*.png filter=lfs diff=lfs merge=lfs -text

.github/codecov.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@ coverage: # https://docs.codecov.com/docs/codecovyml-reference#coverage
99
branches:
1010
- ^main$
1111
target: 85.0 # the minimum coverage ratio that the commit must meet to be considered a success.
12-
threshold: 1% # allow the coverage to drop by X%, and posting a success status.
12+
threshold: 1% # allow the coverage to drop by X%, and posting a success status.
13+
patch:
14+
default:
15+
target: 85.0 # require new/changed lines to be ≥ 85%
16+
threshold: 0% # do not allow patch coverage to fall below target

.github/scripts/run-go-tests.sh

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,43 @@ script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
55
repo_root="$(cd "${script_dir}/../.." && pwd)"
66
cd "${repo_root}"
77

8+
declare -a requested_modules=()
9+
while [[ $# -gt 0 ]]; do
10+
case "$1" in
11+
--module)
12+
if [[ $# -lt 2 ]]; then
13+
echo "missing value for --module" >&2
14+
exit 1
15+
fi
16+
requested_modules+=("$2")
17+
shift 2
18+
;;
19+
*)
20+
echo "unknown argument: $1" >&2
21+
exit 1
22+
;;
23+
esac
24+
done
25+
826
gomodules=()
9-
while IFS= read -r mod; do
10-
gomodules+=("${mod}")
11-
done < <(find . -name go.mod \
12-
-not -path "./.resource/*" \
13-
-not -path "./docs/*" \
14-
-not -path "./examples/*" | sort)
27+
if [ "${#requested_modules[@]}" -gt 0 ]; then
28+
for module in "${requested_modules[@]}"; do
29+
normalized="${module#./}"
30+
normalized="./${normalized}"
31+
if [ ! -f "${normalized}" ]; then
32+
echo "module file not found: ${module}" >&2
33+
exit 1
34+
fi
35+
gomodules+=("${normalized}")
36+
done
37+
else
38+
while IFS= read -r mod; do
39+
gomodules+=("${mod}")
40+
done < <(find . -name go.mod \
41+
-not -path "./.resource/*" \
42+
-not -path "./docs/*" \
43+
-not -path "./examples/*" | sort)
44+
fi
1545

1646
if [ "${#gomodules[@]}" -eq 0 ]; then
1747
echo "no go modules found"

.github/workflows/prc.yml

Lines changed: 104 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,96 @@ jobs:
1717
go-version: '1.21'
1818
- name: Build
1919
run: go build -v ./...
20-
- name: Test All Modules
20+
discover-go-modules:
21+
name: discover go modules
22+
runs-on: ubuntu-latest
23+
outputs:
24+
matrix: ${{ steps.set-matrix.outputs.matrix }}
25+
steps:
26+
- uses: actions/checkout@v3
27+
- id: set-matrix
28+
shell: bash
29+
run: |
30+
set -euo pipefail
31+
mapfile -t modules < <(find . -name go.mod \
32+
-not -path "./.resource/*" \
33+
-not -path "./docs/*" \
34+
-not -path "./examples/*" | sort)
35+
if [ "${#modules[@]}" -eq 0 ]; then
36+
echo "matrix={\"module\":[]}" >> "$GITHUB_OUTPUT"
37+
exit 0
38+
fi
39+
matrix=$(printf '%s\n' "${modules[@]}" | sed 's|^\./||' | jq -R -s -c 'split("\n") | map(select(length>0))')
40+
echo "matrix={\"module\":${matrix}}" >> "$GITHUB_OUTPUT"
41+
test-go-modules:
42+
name: go test (${{ matrix.module }})
43+
runs-on: ubuntu-latest
44+
needs: discover-go-modules
45+
strategy:
46+
fail-fast: false
47+
matrix: ${{ fromJson(needs.discover-go-modules.outputs.matrix) }}
48+
steps:
49+
- uses: actions/checkout@v3
50+
- uses: actions/setup-go@v5
51+
with:
52+
go-version: '1.21'
53+
- name: Prepare module metadata
54+
id: module-info
55+
shell: bash
56+
run: |
57+
set -euo pipefail
58+
module='${{ matrix.module }}'
59+
if [ -z "${module}" ]; then
60+
echo "empty module path" >&2
61+
exit 1
62+
fi
63+
rel="${module#./}"
64+
if [ "${rel}" = "go.mod" ]; then
65+
readable="root"
66+
else
67+
readable="${rel%/go.mod}"
68+
fi
69+
safe="${readable//\//_}"
70+
safe="${safe//./_}"
71+
if [ -z "${safe}" ]; then
72+
safe="root"
73+
fi
74+
echo "safe_name=${safe}" >> "$GITHUB_OUTPUT"
75+
- name: Test module
2176
shell: bash
22-
run: bash .github/scripts/run-go-tests.sh
77+
run: bash .github/scripts/run-go-tests.sh --module "${{ matrix.module }}"
78+
- name: Prepare coverage artifact
79+
shell: bash
80+
run: mv coverage.out "coverage-${{ steps.module-info.outputs.safe_name }}.out"
81+
- name: Upload coverage artifact
82+
uses: actions/upload-artifact@v4
83+
with:
84+
name: coverage-${{ steps.module-info.outputs.safe_name }}
85+
path: coverage-${{ steps.module-info.outputs.safe_name }}.out
86+
if-no-files-found: error
87+
coverage:
88+
name: coverage
89+
runs-on: ubuntu-latest
90+
needs: test-go-modules
91+
steps:
92+
- uses: actions/download-artifact@v4
93+
with:
94+
pattern: coverage-*
95+
merge-multiple: true
96+
- name: Combine coverage reports
97+
shell: bash
98+
run: |
99+
set -euo pipefail
100+
shopt -s nullglob
101+
files=(coverage-*.out)
102+
if [ "${#files[@]}" -eq 0 ]; then
103+
echo "no coverage files found" >&2
104+
exit 1
105+
fi
106+
cp "${files[0]}" coverage.out
107+
for file in "${files[@]:1}"; do
108+
tail -n +2 "${file}" >> coverage.out
109+
done
23110
- name: Upload coverage reports to Codecov
24111
uses: codecov/codecov-action@v5
25112
with:
@@ -58,3 +145,18 @@ jobs:
58145
with:
59146
go-version: '1.21'
60147
- uses: joelanford/go-apidiff@main
148+
docs-build:
149+
name: docs-build
150+
runs-on: ubuntu-latest
151+
defaults:
152+
run:
153+
working-directory: docs
154+
steps:
155+
- uses: actions/checkout@v3
156+
- uses: actions/setup-python@v5
157+
with:
158+
python-version: '3.11'
159+
- name: Install MkDocs dependencies
160+
run: pip install -r mkdocs/assets/requirements.txt
161+
- name: Build documentation
162+
run: mkdocs build --strict
Lines changed: 3 additions & 0 deletions
Loading

.typos.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,5 @@ indexes = "indexes"
3232
indexs = "indexs"
3333
ba = "ba"
3434
UE = "UE"
35+
rin = "rin"
36+
dify = "dify"

agent/a2aagent/a2a_agent.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,10 @@ func (r *A2AAgent) runStreaming(ctx context.Context, invocation *agent.Invocatio
243243
return
244244
}
245245

246-
var aggregatedContentBuilder strings.Builder
246+
var (
247+
responseID string
248+
aggregatedContentBuilder strings.Builder
249+
)
247250
for streamEvent := range streamChan {
248251
if err := agent.CheckContextCancelled(ctx); err != nil {
249252
return
@@ -257,6 +260,9 @@ func (r *A2AAgent) runStreaming(ctx context.Context, invocation *agent.Invocatio
257260

258261
// Aggregate content from delta
259262
if evt.Response != nil && len(evt.Response.Choices) > 0 {
263+
if evt.Response.ID != "" {
264+
responseID = evt.Response.ID
265+
}
260266
if r.streamingRespHandler != nil {
261267
content, err := r.streamingRespHandler(evt.Response)
262268
if err != nil {
@@ -278,6 +284,8 @@ func (r *A2AAgent) runStreaming(ctx context.Context, invocation *agent.Invocatio
278284
invocation.InvocationID,
279285
r.name,
280286
event.WithResponse(&model.Response{
287+
ID: responseID,
288+
Object: model.ObjectTypeChatCompletion,
281289
Done: true,
282290
IsPartial: false,
283291
Timestamp: time.Now(),

agent/a2aagent/a2a_agent_option.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ func WithA2AClientExtraOptions(opts ...client.Option) Option {
7777
// WithStreamingChannelBufSize set the buf size of streaming protocol
7878
func WithStreamingChannelBufSize(size int) Option {
7979
return func(a *A2AAgent) {
80+
if size < 0 {
81+
size = defaultStreamingChannelSize
82+
}
8083
a.streamingBufSize = size
8184
}
8285
}

0 commit comments

Comments
 (0)