Skip to content

Commit b0f2d5d

Browse files
authored
Merge pull request #48 from SentienceAPI/improve_agent
improve agent code
2 parents 38a3d3a + ad2efc4 commit b0f2d5d

Some content is hidden

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

62 files changed

+2062
-1493
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@
1111
*.md text eol=lf
1212
*.yml text eol=lf
1313
*.yaml text eol=lf
14-

.github/workflows/release.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@ on:
1313
jobs:
1414
build-and-publish:
1515
runs-on: ubuntu-latest
16-
16+
1717
steps:
1818
- name: Checkout code
1919
uses: actions/checkout@v4
20-
20+
2121
- name: Set up Python
2222
uses: actions/setup-python@v5
2323
with:
2424
python-version: '3.11'
25-
25+
2626
- name: Install build dependencies
2727
run: |
2828
python -m pip install --upgrade pip
2929
pip install build twine
30-
30+
3131
- name: Extract version from tag or input
3232
id: version
3333
run: |
@@ -39,32 +39,32 @@ jobs:
3939
fi
4040
echo "version=$VERSION" >> $GITHUB_OUTPUT
4141
echo "Version: $VERSION"
42-
42+
4343
- name: Update version in pyproject.toml
4444
run: |
4545
VERSION="${{ steps.version.outputs.version }}"
4646
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" pyproject.toml
47-
47+
4848
- name: Update version in __init__.py
4949
run: |
5050
VERSION="${{ steps.version.outputs.version }}"
5151
sed -i "s/^__version__ = \".*\"/__version__ = \"$VERSION\"/" sentience/__init__.py
52-
52+
5353
- name: Build package
5454
run: |
5555
python -m build
56-
56+
5757
- name: Check package
5858
run: |
5959
twine check dist/*
60-
60+
6161
- name: Publish to PyPI
6262
env:
6363
TWINE_USERNAME: __token__
6464
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
6565
run: |
6666
twine upload dist/*
67-
67+
6868
- name: Create GitHub Release
6969
if: github.event_name == 'workflow_dispatch'
7070
uses: softprops/action-gh-release@v1
@@ -73,7 +73,7 @@ jobs:
7373
name: Release v${{ steps.version.outputs.version }}
7474
body: |
7575
Release v${{ steps.version.outputs.version }} of sentience-python
76-
76+
7777
## Installation
7878
```bash
7979
pip install sentience-python==${{ steps.version.outputs.version }}
@@ -82,4 +82,3 @@ jobs:
8282
prerelease: false
8383
env:
8484
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85-

.github/workflows/sync-extension.yml

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ jobs:
1919
permissions:
2020
contents: write
2121
pull-requests: write
22-
22+
2323
steps:
2424
- name: Checkout sdk-python
2525
uses: actions/checkout@v4
2626
with:
2727
token: ${{ secrets.GITHUB_TOKEN }}
2828
fetch-depth: 0 # Fetch all history for proper branching
29-
29+
3030
- name: Set up Python
3131
uses: actions/setup-python@v5
3232
with:
3333
python-version: '3.11'
34-
34+
3535
- name: Determine release tag
3636
id: release
3737
run: |
@@ -45,58 +45,58 @@ jobs:
4545
HTTP_CODE=$(curl -s -o latest_release.json -w "%{http_code}" \
4646
-H "Authorization: token ${{ secrets.SENTIENCE_CHROME_TOKEN }}" \
4747
"https://api.github.com/repos/${{ secrets.SENTIENCE_CHROME_REPO }}/releases/latest")
48-
48+
4949
if [ "$HTTP_CODE" != "200" ]; then
5050
echo "❌ Failed to fetch latest release. HTTP Code: $HTTP_CODE"
5151
cat latest_release.json
5252
exit 1
5353
fi
54-
54+
5555
TAG=$(cat latest_release.json | jq -r '.tag_name // empty')
56-
56+
5757
# Check if we already processed this tag
5858
if git ls-remote --exit-code --heads origin "sync-extension-$TAG"; then
5959
echo "Branch for $TAG already exists, skipping."
6060
echo "skip=true" >> $GITHUB_OUTPUT
6161
exit 0
6262
fi
6363
fi
64-
64+
6565
if [ -z "$TAG" ]; then
6666
echo "Could not determine release tag."
6767
exit 1
6868
fi
69-
69+
7070
echo "Syncing tag: $TAG"
7171
echo "tag=$TAG" >> $GITHUB_OUTPUT
72-
72+
7373
- name: Download extension files
7474
if: steps.release.outputs.skip != 'true'
7575
run: |
7676
TAG="${{ steps.release.outputs.tag }}"
7777
REPO="${{ secrets.SENTIENCE_CHROME_REPO }}"
78-
78+
7979
# Setup temp directory
8080
mkdir -p extension-temp
8181
cd extension-temp
82-
82+
8383
echo "⬇️ Fetching release info for $TAG from $REPO..."
84-
84+
8585
# 1. Get Release Info
8686
HTTP_CODE=$(curl -s -w "%{http_code}" -o release.json \
8787
-H "Authorization: token ${{ secrets.SENTIENCE_CHROME_TOKEN }}" \
8888
"https://api.github.com/repos/$REPO/releases/tags/$TAG")
89-
89+
9090
if [ "$HTTP_CODE" != "200" ]; then
9191
echo "❌ Failed to fetch release info. HTTP Code: $HTTP_CODE"
9292
echo "Response Body:"
9393
cat release.json
9494
exit 1
9595
fi
96-
96+
9797
# Check for asset URL
9898
ASSET_URL=$(cat release.json | jq -r '.assets[]? | select(.name == "extension-files.tar.gz") | .url')
99-
99+
100100
if [ -z "$ASSET_URL" ] || [ "$ASSET_URL" == "null" ]; then
101101
echo "❌ Critical Error: extension-files.tar.gz not found in release assets!"
102102
echo "Available assets:"
@@ -107,7 +107,7 @@ jobs:
107107
echo "📦 Downloading tarball from asset API endpoint..."
108108
# NOTE: For private repos, we must use the API URL (.url) with Accept: application/octet-stream header
109109
# Using .browser_download_url often redirects to S3 which breaks auth headers
110-
110+
111111
HTTP_CODE=$(curl -L -s -w "%{http_code}" -o extension.tar.gz \
112112
-H "Authorization: token ${{ secrets.SENTIENCE_CHROME_TOKEN }}" \
113113
-H "Accept: application/octet-stream" \
@@ -125,7 +125,7 @@ jobs:
125125
# 3. Verify File Type before extracting
126126
FILE_TYPE=$(file -b --mime-type extension.tar.gz)
127127
echo "📄 Downloaded file type: $FILE_TYPE"
128-
128+
129129
if [[ "$FILE_TYPE" != *"gzip"* ]] && [[ "$FILE_TYPE" != *"octet-stream"* ]]; then
130130
echo "❌ Error: Downloaded file is not a gzip archive. It is: $FILE_TYPE"
131131
echo "First 100 bytes:"
@@ -137,50 +137,50 @@ jobs:
137137
echo "📂 Extracting..."
138138
tar -xzf extension.tar.gz
139139
rm extension.tar.gz
140-
140+
141141
if [ ! -f "manifest.json" ]; then
142142
echo "❌ Error: manifest.json missing after extraction"
143143
exit 1
144144
fi
145-
145+
146146
- name: Update extension files
147147
if: steps.release.outputs.skip != 'true'
148148
run: |
149149
# Target directory in sdk-python (inside the package source)
150150
TARGET_DIR="sentience/extension"
151-
151+
152152
# Ensure target directory exists and is clean
153153
rm -rf "$TARGET_DIR"
154154
mkdir -p "$TARGET_DIR"
155-
155+
156156
# Copy files from temp directory
157157
cp -r extension-temp/* "$TARGET_DIR/"
158-
158+
159159
# Verify copy
160160
if [ ! -f "$TARGET_DIR/manifest.json" ]; then
161161
echo "❌ Failed to copy manifest.json to $TARGET_DIR"
162162
exit 1
163163
fi
164-
164+
165165
# Cleanup
166166
rm -rf extension-temp
167-
167+
168168
echo "✅ Extension files updated in $TARGET_DIR"
169169
ls -la "$TARGET_DIR"
170-
170+
171171
- name: Check for changes
172172
if: steps.release.outputs.skip != 'true'
173173
id: changes
174174
run: |
175175
git add sentience/extension/
176-
176+
177177
if git diff --staged --quiet; then
178178
echo "No changes detected."
179179
echo "changed=false" >> $GITHUB_OUTPUT
180180
else
181181
echo "Changes detected."
182182
echo "changed=true" >> $GITHUB_OUTPUT
183-
183+
184184
# Show staged files
185185
echo "📊 Staged file sizes:"
186186
git diff --staged --name-only | while read file; do
@@ -190,7 +190,7 @@ jobs:
190190
fi
191191
done
192192
fi
193-
193+
194194
- name: Create Pull Request
195195
if: steps.release.outputs.skip != 'true' && steps.changes.outputs.changed == 'true'
196196
uses: peter-evans/create-pull-request@v5
@@ -200,14 +200,14 @@ jobs:
200200
title: "Sync Extension: ${{ steps.release.outputs.tag }}"
201201
body: |
202202
This PR syncs extension files from sentience-chrome release ${{ steps.release.outputs.tag }}.
203-
203+
204204
**Files updated:**
205205
- Extension manifest and scripts
206206
- WASM binary and bindings
207-
207+
208208
**Source:** [sentience-chrome release ${{ steps.release.outputs.tag }}](https://github.com/${{ secrets.SENTIENCE_CHROME_REPO }}/releases/tag/${{ steps.release.outputs.tag }})
209209
branch: sync-extension-${{ steps.release.outputs.tag }}
210210
delete-branch: true
211211
labels: |
212212
automated
213-
extension-sync
213+
extension-sync

.github/workflows/test.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,26 @@ jobs:
1313
matrix:
1414
os: [ubuntu-latest, macos-latest, windows-latest]
1515
python-version: ['3.11']
16-
16+
1717
steps:
1818
- name: Checkout code
1919
uses: actions/checkout@v4
20-
20+
2121
- name: Set up Python ${{ matrix.python-version }}
2222
uses: actions/setup-python@v5
2323
with:
2424
python-version: ${{ matrix.python-version }}
25-
25+
2626
- name: Install Playwright browsers
2727
run: |
2828
python -m pip install --upgrade pip
2929
pip install playwright
3030
playwright install chromium
31-
31+
3232
- name: Install dependencies
3333
run: |
3434
pip install -e ".[dev]"
35-
35+
3636
- name: Build extension (if needed)
3737
if: runner.os != 'Windows'
3838
shell: bash
@@ -42,10 +42,9 @@ jobs:
4242
else
4343
echo "Extension directory not found, skipping build"
4444
fi
45-
45+
4646
- name: Run tests
4747
run: |
4848
pytest tests/ -v
4949
env:
5050
CI: true
51-

0 commit comments

Comments
 (0)