Skip to content

Commit 5d4aa9a

Browse files
committed
Add Flutter multi-platform package; add Android 16kb page size support; fix broken npmjs packages workflow
1 parent f4a5ed0 commit 5d4aa9a

File tree

16 files changed

+367
-10
lines changed

16 files changed

+367
-10
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: publish flutter package
2+
on:
3+
push:
4+
tags:
5+
- '*.*.*'
6+
7+
permissions:
8+
contents: read
9+
id-token: write
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-22.04
14+
name: publish to pub.dev
15+
16+
steps:
17+
18+
- uses: actions/checkout@v4.2.2
19+
20+
- name: download release assets
21+
run: |
22+
VERSION=${GITHUB_REF#refs/tags/}
23+
echo "VERSION=$VERSION" >> $GITHUB_ENV
24+
25+
mkdir -p artifacts
26+
cd artifacts
27+
28+
# Download all platform binaries from the GitHub release
29+
gh release download "$VERSION" --pattern "agent-*.tar.gz"
30+
31+
# Extract all archives
32+
for archive in agent-*.tar.gz; do
33+
name=$(basename "$archive" "-$VERSION.tar.gz")
34+
mkdir -p "$name"
35+
tar -xzf "$archive" -C "$name"
36+
rm "$archive"
37+
done
38+
39+
ls -la
40+
env:
41+
GH_TOKEN: ${{ github.token }}
42+
43+
- uses: dart-lang/setup-dart@v1.7.1
44+
45+
- name: assemble and publish flutter package
46+
run: |
47+
FLUTTER_DIR=packages/flutter
48+
49+
# Android
50+
mkdir -p $FLUTTER_DIR/native_libraries/android
51+
cp artifacts/agent-android-arm64-v8a/agent.so $FLUTTER_DIR/native_libraries/android/agent_android_arm64.so
52+
cp artifacts/agent-android-armeabi-v7a/agent.so $FLUTTER_DIR/native_libraries/android/agent_android_arm.so
53+
cp artifacts/agent-android-x86_64/agent.so $FLUTTER_DIR/native_libraries/android/agent_android_x64.so
54+
55+
# iOS device
56+
mkdir -p $FLUTTER_DIR/native_libraries/ios
57+
cp artifacts/agent-ios/agent.dylib $FLUTTER_DIR/native_libraries/ios/agent_ios_arm64.dylib
58+
59+
# iOS simulator (keep universal/fat binary as-is)
60+
mkdir -p $FLUTTER_DIR/native_libraries/ios-sim
61+
cp artifacts/agent-ios-sim/agent.dylib $FLUTTER_DIR/native_libraries/ios-sim/agent_ios-sim.dylib
62+
63+
# macOS (separate arch-specific dylibs)
64+
mkdir -p $FLUTTER_DIR/native_libraries/mac
65+
cp artifacts/agent-macos-arm64/agent.dylib $FLUTTER_DIR/native_libraries/mac/agent_mac_arm64.dylib
66+
cp artifacts/agent-macos-x86_64/agent.dylib $FLUTTER_DIR/native_libraries/mac/agent_mac_x64.dylib
67+
68+
# Linux
69+
mkdir -p $FLUTTER_DIR/native_libraries/linux
70+
cp artifacts/agent-linux-x86_64/agent.so $FLUTTER_DIR/native_libraries/linux/agent_linux_x64.so
71+
cp artifacts/agent-linux-arm64/agent.so $FLUTTER_DIR/native_libraries/linux/agent_linux_arm64.so
72+
73+
# Windows
74+
mkdir -p $FLUTTER_DIR/native_libraries/windows
75+
cp artifacts/agent-windows-x86_64/agent.dll $FLUTTER_DIR/native_libraries/windows/agent_windows_x64.dll
76+
77+
# Update version
78+
sed -i "s/^version: .*/version: $VERSION/" $FLUTTER_DIR/pubspec.yaml
79+
80+
# Publish to pub.dev
81+
cd $FLUTTER_DIR
82+
dart pub get
83+
dart pub publish --dry-run
84+
dart pub publish --force

.github/workflows/main.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
name: Build, Test and Release
99
on:
1010
push:
11+
branches:
12+
- '**'
13+
tags-ignore:
14+
- '**'
1115
workflow_dispatch:
1216

1317
permissions:
@@ -346,12 +350,9 @@ jobs:
346350
- uses: actions/setup-node@v4
347351
if: steps.tag.outputs.version != ''
348352
with:
349-
node-version: '20'
353+
node-version: '24'
350354
registry-url: 'https://registry.npmjs.org'
351355

352-
- name: update npm
353-
run: npm install -g npm@11.5.1
354-
355356
- name: build and publish npm packages
356357
if: steps.tag.outputs.version != ''
357358
run: |
@@ -407,10 +408,12 @@ jobs:
407408
- uses: softprops/action-gh-release@v2.2.1
408409
if: steps.tag.outputs.version != ''
409410
with:
411+
token: ${{ secrets.RELEASE_PAT }}
410412
body: |
411-
413+
412414
## Packages
413415
416+
[**Flutter/Dart**](https://pub.dev/packages/sqlite_agent): `flutter pub add sqlite_agent:${{ steps.tag.outputs.version }}` or `dart pub add sqlite_agent:${{ steps.tag.outputs.version }}`
414417
[**Node**](https://www.npmjs.com/package/@sqliteai/sqlite-agent): `npm install @sqliteai/sqlite-agent`
415418
[**Android**](https://central.sonatype.com/artifact/ai.sqlite/agent): `ai.sqlite:agent:${{ steps.tag.outputs.version }}`
416419
[**Swift**](https://github.com/sqliteai/sqlite-agent#swift-package): [Installation Guide](https://github.com/sqliteai/sqlite-agent#swift-package)

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,11 @@ Thumbs.db
5353
*.db
5454

5555
# Example files
56-
models/
56+
models/
57+
58+
# Dart/Flutter
59+
.dart_tool/
60+
pubspec.lock
61+
.flutter-plugins
62+
.flutter-plugins-dependencies
63+
packages/flutter/native_libraries/

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ else ifeq ($(PLATFORM),android)
8585
endif
8686
CC = $(BIN)/$(ARCH)-linux-$(ANDROID_ABI)-clang
8787
TARGET := $(DIST_DIR)/agent.so
88-
LDFLAGS += -shared
88+
LDFLAGS += -shared -Wl,-z,max-page-size=16384
8989
CFLAGS += -fPIC
9090
STRIP = $(BIN)/llvm-strip --strip-unneeded $@
9191
else ifeq ($(PLATFORM),ios)

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,27 @@ SQLiteDatabase db = SQLiteDatabase.openDatabase(config, null, null);
6565

6666
**Note:** Additional settings and configuration are required for a complete setup. For full implementation details, see the [complete Android example](https://github.com/sqliteai/sqlite-extensions-guide/blob/main/examples/android/README.md).
6767

68+
#### Flutter Package
69+
70+
Add the [sqlite_agent](https://pub.dev/packages/sqlite_agent) package to your project:
71+
72+
```bash
73+
flutter pub add sqlite_agent # Flutter projects
74+
dart pub add sqlite_agent # Dart projects
75+
```
76+
77+
Usage with `sqlite3` package:
78+
```dart
79+
import 'package:sqlite3/sqlite3.dart';
80+
import 'package:sqlite_agent/sqlite_agent.dart';
81+
82+
sqlite3.loadSqliteAgentExtension();
83+
final db = sqlite3.openInMemory();
84+
print(db.select('SELECT agent_version()'));
85+
```
86+
87+
For a complete example, see the [Flutter example](https://github.com/sqliteai/sqlite-extensions-guide/blob/main/examples/flutter/README.md).
88+
6889
### Basic Usage
6990

7091
```sql

packages/flutter/.pubignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Only ignore development files, NOT native_libraries
2+
.dart_tool/
3+
pubspec.lock
4+
5+
# Explicitly include native_libraries (override any parent .gitignore)
6+
!native_libraries/
7+
!native_libraries/**

packages/flutter/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Changelog
2+
3+
## 0.1.6
4+
5+
- Initial Flutter package release
6+
- Added support for Android 16kb page size devices

packages/flutter/LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../LICENSE

packages/flutter/README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# sqlite_agent
2+
3+
SQLite Agent is a cross-platform SQLite extension that brings autonomous AI agents to your database. It enables databases to run multi-step, tool-using agents that fetch data from external sources (web, APIs, etc.) through sqlite-mcp and populate database tables.
4+
5+
## Installation
6+
7+
```
8+
dart pub add sqlite_agent
9+
```
10+
11+
Requires Dart 3.10+ / Flutter 3.38+.
12+
13+
## Usage
14+
15+
### With `sqlite3`
16+
17+
```dart
18+
import 'package:sqlite3/sqlite3.dart';
19+
import 'package:sqlite_agent/sqlite_agent.dart';
20+
21+
void main() {
22+
// Load once at startup.
23+
sqlite3.loadSqliteAgentExtension();
24+
25+
final db = sqlite3.openInMemory();
26+
27+
// Check version.
28+
final result = db.select('SELECT agent_version() AS version');
29+
print(result.first['version']);
30+
31+
db.dispose();
32+
}
33+
```
34+
35+
### With `drift`
36+
37+
```dart
38+
import 'package:sqlite3/sqlite3.dart';
39+
import 'package:sqlite_agent/sqlite_agent.dart';
40+
import 'package:drift/native.dart';
41+
42+
Sqlite3 loadExtensions() {
43+
sqlite3.loadSqliteAgentExtension();
44+
return sqlite3;
45+
}
46+
47+
// Use when creating the database:
48+
NativeDatabase.createInBackground(
49+
File(path),
50+
sqlite3: loadExtensions,
51+
);
52+
```
53+
54+
## Supported platforms
55+
56+
| Platform | Architectures |
57+
|----------|---------------|
58+
| Android | arm64, arm, x64 |
59+
| iOS | arm64 (device + simulator) |
60+
| macOS | arm64, x64 |
61+
| Linux | arm64, x64 |
62+
| Windows | x64 |
63+
64+
## API
65+
66+
See the full [sqlite-agent API documentation](https://github.com/sqliteai/sqlite-agent/blob/main/API.md).
67+
68+
## License
69+
70+
See [LICENSE](LICENSE).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: package:lints/recommended.yaml

0 commit comments

Comments
 (0)