neoagent 3.0.1-beta.2 → 3.0.1-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +19 -0
- package/README.md +16 -0
- package/docs/benchmarking.md +102 -0
- package/docs/billing.md +224 -0
- package/docs/configuration.md +22 -0
- package/docs/index.md +1 -0
- package/flutter_app/lib/main.dart +4 -1
- package/flutter_app/lib/main_app_shell.dart +316 -0
- package/flutter_app/lib/main_billing.dart +1465 -0
- package/flutter_app/lib/main_chat.dart +1568 -231
- package/flutter_app/lib/main_controller.dart +263 -26
- package/flutter_app/lib/main_devices.dart +1 -1
- package/flutter_app/lib/main_install.dart +1147 -0
- package/flutter_app/lib/main_navigation.dart +12 -0
- package/flutter_app/lib/main_operations.dart +134 -9
- package/flutter_app/lib/main_settings.dart +148 -52
- package/flutter_app/lib/main_shared.dart +1 -0
- package/flutter_app/lib/src/backend_client.dart +69 -1
- package/landing/index.html +2 -2
- package/lib/manager.js +156 -0
- package/lib/schema_migrations.js +84 -0
- package/package.json +10 -4
- package/server/admin/access.js +12 -7
- package/server/admin/admin.css +78 -0
- package/server/admin/admin.js +511 -23
- package/server/admin/billing.js +415 -0
- package/server/admin/index.html +120 -13
- package/server/admin/users.js +15 -15
- package/server/db/database.js +13 -21
- package/server/db/sessions_db.js +8 -0
- package/server/http/middleware.js +4 -4
- package/server/http/routes.js +9 -0
- package/server/http/static.js +4 -2
- package/server/middleware/requireBilling.js +12 -0
- package/server/public/.last_build_id +1 -1
- package/server/public/assets/fonts/MaterialIcons-Regular.otf +0 -0
- package/server/public/flutter_bootstrap.js +1 -1
- package/server/public/main.dart.js +89120 -85431
- package/server/routes/admin.js +524 -29
- package/server/routes/agents.js +203 -21
- package/server/routes/billing.js +127 -0
- package/server/routes/billing_webhook.js +43 -0
- package/server/routes/memory.js +1 -4
- package/server/routes/settings.js +1 -2
- package/server/routes/skills.js +1 -1
- package/server/routes/triggers.js +2 -2
- package/server/services/account/sessions.js +1 -9
- package/server/services/ai/loop/agent_engine_core.js +42 -0
- package/server/services/ai/loop/blank_recovery.js +36 -0
- package/server/services/ai/loop/completion_judge.js +42 -0
- package/server/services/ai/loop/conversation_loop.js +248 -34
- package/server/services/ai/loop/progress_monitor.js +6 -6
- package/server/services/ai/loopPolicy.js +37 -44
- package/server/services/ai/messagingFallback.js +25 -1
- package/server/services/ai/models.js +18 -0
- package/server/services/ai/preModelCompaction.js +25 -5
- package/server/services/ai/rate_limits.js +28 -4
- package/server/services/ai/systemPrompt.js +23 -5
- package/server/services/ai/taskAnalysis.js +2 -0
- package/server/services/ai/tools.js +231 -20
- package/server/services/billing/billing_email.js +106 -0
- package/server/services/billing/config.js +17 -0
- package/server/services/billing/plans.js +121 -0
- package/server/services/billing/stripe_client.js +21 -0
- package/server/services/billing/subscriptions.js +462 -0
- package/server/services/billing/trial_guard.js +111 -0
- package/server/services/browser/contentExtractor.js +629 -0
- package/server/services/browser/controller.js +4 -8
- package/server/services/desktop/gateway.js +7 -4
- package/server/services/integrations/google/calendar.js +30 -2
- package/server/services/integrations/secrets.js +7 -4
- package/server/services/manager.js +11 -0
- package/server/services/messaging/automation.js +1 -1
- package/server/services/messaging/telnyx.js +12 -11
- package/server/services/messaging/whatsapp.js +1 -1
- package/server/services/recordings/manager.js +13 -7
- package/server/services/runtime/backends/local-vm.js +40 -22
- package/server/services/tasks/runtime.js +103 -15
- package/server/services/tasks/schedule_utils.js +5 -5
- package/server/services/voice/runtimeManager.js +19 -10
- package/server/services/wearable/gateway.js +8 -5
- package/server/services/websocket.js +26 -8
- package/server/services/workspace/manager.js +37 -3
package/.env.example
CHANGED
|
@@ -267,3 +267,22 @@ NEOAGENT_SCREEN_RECORDER_RETENTION_DAYS=7
|
|
|
267
267
|
|
|
268
268
|
MESHTASTIC_ENABLED=true
|
|
269
269
|
TELNYX_WEBHOOK_TOKEN=
|
|
270
|
+
|
|
271
|
+
########################################
|
|
272
|
+
# Stripe billing (optional)
|
|
273
|
+
########################################
|
|
274
|
+
|
|
275
|
+
# Set to true or 1 to enable the billing system. When disabled (default),
|
|
276
|
+
# no billing routes are exposed and no payment UI is shown anywhere.
|
|
277
|
+
# NEOAGENT_BILLING_ENABLED=false
|
|
278
|
+
|
|
279
|
+
# Stripe API keys — required when billing is enabled.
|
|
280
|
+
# Use test keys (sk_test_...) during development; live keys in production.
|
|
281
|
+
# STRIPE_SECRET_KEY=sk_test_...
|
|
282
|
+
# STRIPE_PUBLISHABLE_KEY=pk_test_...
|
|
283
|
+
|
|
284
|
+
# Webhook signing secret from your Stripe dashboard (Developers > Webhooks).
|
|
285
|
+
# STRIPE_WEBHOOK_SECRET=whsec_...
|
|
286
|
+
|
|
287
|
+
# Length of free trial periods in days (default: 14).
|
|
288
|
+
# BILLING_TRIAL_DAYS=14
|
package/README.md
CHANGED
|
@@ -18,6 +18,12 @@
|
|
|
18
18
|
<a href="LICENSE"><img src="https://img.shields.io/badge/license-AGPL--3.0-a855f7?style=flat-square" alt="AGPL-3.0 license"></a>
|
|
19
19
|
</p>
|
|
20
20
|
|
|
21
|
+
<p align="center">
|
|
22
|
+
<a href="https://github.com/NeoLabs-Systems/NeoAgent/releases/latest"><img alt="Android" src="https://img.shields.io/badge/Android-APK-3ddc84?style=flat-square&logo=android&logoColor=white"></a>
|
|
23
|
+
<a href="https://github.com/NeoLabs-Systems/NeoAgent/releases/latest"><img alt="iOS" src="https://img.shields.io/badge/iOS-coming_soon-lightgrey?style=flat-square&logo=apple&logoColor=white"></a>
|
|
24
|
+
<a href="https://github.com/NeoLabs-Systems/NeoAgent/releases/latest"><img alt="Windows" src="https://img.shields.io/badge/Windows-EXE-0078d4?style=flat-square&logo=windows&logoColor=white"></a>
|
|
25
|
+
</p>
|
|
26
|
+
|
|
21
27
|
<p align="center">
|
|
22
28
|
<a href="https://www.producthunt.com/products/neoagent-2?embed=true&utm_source=badge-featured&utm_medium=badge&utm_campaign=badge-neoagent-2" target="_blank" rel="noopener noreferrer"><img alt="NeoAgent - The next-gen self-hosted AI agent that works beyond chat | Product Hunt" width="250" height="54" src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=1171573&theme=light&t=1781447653039"></a>
|
|
23
29
|
</p>
|
|
@@ -37,6 +43,10 @@ npm install -g neoagent
|
|
|
37
43
|
neoagent install
|
|
38
44
|
```
|
|
39
45
|
|
|
46
|
+
<p align="center">
|
|
47
|
+
<a href="https://github.com/NeoLabs-Systems/NeoAgent/releases/latest"><img alt="Download macOS app" src="https://img.shields.io/badge/macOS_app-download-black?style=flat-square&logo=apple&logoColor=white"></a>
|
|
48
|
+
</p>
|
|
49
|
+
|
|
40
50
|
Open `http://localhost:3333`, create the first account, and configure a model.
|
|
41
51
|
Local models can run through [Ollama](https://ollama.com/); hosted providers
|
|
42
52
|
can be configured in the application.
|
|
@@ -51,6 +61,7 @@ service to a network.
|
|
|
51
61
|
- **It operates real devices.** The agent can use an isolated browser and shell, control an Android device or emulator over ADB, or work through a paired Chrome extension and desktop companion.
|
|
52
62
|
- **Automation can start without a message.** Tasks can run on a schedule or from supported Gmail, Outlook, Slack, Teams, personal WhatsApp, and weather events. Android notifications can also start an agent run.
|
|
53
63
|
- **Agents and users have separate state.** Specialist agents can have their own memory, settings, tools, account assignments, conversations, and task history. Multi-user deployments include administrative account controls and optional email confirmation.
|
|
64
|
+
- **SaaS billing is built in and off by default.** Set `NEOAGENT_BILLING_ENABLED=true` to activate Stripe subscriptions, plan management, free trials, and model access restrictions. When disabled, no payment routes or UI appear anywhere. See [Billing](docs/billing.md).
|
|
54
65
|
- **The same server has several interfaces.** NeoAgent includes web, Android, desktop, and Android launcher clients, messaging bridges, a Chrome extension, and firmware for a supported ESP32-S3 wearable.
|
|
55
66
|
|
|
56
67
|
## 🖥️ Interfaces
|
|
@@ -79,6 +90,11 @@ changes and rough edges. Review the
|
|
|
79
90
|
[security boundaries](docs/security-boundaries.md) before connecting sensitive
|
|
80
91
|
accounts or giving the agent access to a personal workstation.
|
|
81
92
|
|
|
93
|
+
## 📊 Benchmarks
|
|
94
|
+
|
|
95
|
+

|
|
96
|
+
See [Benchmarking](docs/benchmarking.md) for the reproducibility details and suite coverage.
|
|
97
|
+
|
|
82
98
|
Start with the [documentation](https://neolabs-systems.github.io/NeoAgent/docs/).
|
|
83
99
|
Use [GitHub Discussions](https://github.com/NeoLabs-Systems/NeoAgent/discussions)
|
|
84
100
|
for questions and [GitHub Issues](https://github.com/NeoLabs-Systems/NeoAgent/issues)
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Benchmarking
|
|
2
|
+
|
|
3
|
+
NeoAgent includes an end-to-end benchmark harness that drives the app through
|
|
4
|
+
its authenticated HTTP surface instead of calling internal engine methods
|
|
5
|
+
directly. The harness configures OpenRouter models, submits benchmark tasks,
|
|
6
|
+
collects run events and usage data, and writes normalized result artifacts.
|
|
7
|
+
|
|
8
|
+
## Latest dashboard
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
The generated image is backed by these local outputs:
|
|
13
|
+
|
|
14
|
+
- `benchmark/results/latest-results.json`
|
|
15
|
+
- `benchmark/results/latest-summary.json`
|
|
16
|
+
- `benchmark/results/latest-summary.md`
|
|
17
|
+
- `static/benchmarks/latest-dashboard.png`
|
|
18
|
+
|
|
19
|
+
## Commands
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm run benchmark:setup
|
|
23
|
+
npm run benchmark:run
|
|
24
|
+
npm run benchmark:report
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Model selection
|
|
28
|
+
|
|
29
|
+
The benchmark harness is OpenRouter-first. Edit the `OPENROUTER_MODEL_IDS`
|
|
30
|
+
variable in `benchmark/config.js` to pin exact model IDs, or leave it empty to
|
|
31
|
+
use the current cheap-tier OpenRouter models discovered at runtime.
|
|
32
|
+
|
|
33
|
+
## Benchmark coverage
|
|
34
|
+
|
|
35
|
+
- `GAIA`, `BrowseComp`, `WebArena`, `VisualWebArena`, and `SWE-bench` are wired
|
|
36
|
+
as exact public-suite adapters. When their official datasets or external
|
|
37
|
+
runners are not installed, they are reported as blocked instead of being
|
|
38
|
+
approximated.
|
|
39
|
+
- `NeoAgent Representative Tasks` runs first-party agent tasks through
|
|
40
|
+
`/api/agents` and scores them from the persisted run details.
|
|
41
|
+
- `NeoAgent Memory Retrieval` seeds memories over `/api/memory`, recalls them
|
|
42
|
+
through the app routes, and scores retrieval quality with the same metric
|
|
43
|
+
code used by the server evaluation module.
|
|
44
|
+
|
|
45
|
+
## Reproducibility
|
|
46
|
+
|
|
47
|
+
- Public-suite setup manifests are written under `benchmark/workdir/<suite>/`.
|
|
48
|
+
- The harness uses one benchmark account and persists per-run usage summaries
|
|
49
|
+
through the existing NeoAgent run detail endpoints.
|
|
50
|
+
- Blocked suites are intentional and explicit. The harness never substitutes a
|
|
51
|
+
simplified local task and labels it as a public benchmark result.
|
|
52
|
+
|
|
53
|
+
## Public benchmark prerequisites
|
|
54
|
+
|
|
55
|
+
### GAIA
|
|
56
|
+
|
|
57
|
+
- Access to the gated [GAIA dataset](https://huggingface.co/datasets/gaia-benchmark/GAIA).
|
|
58
|
+
- `HF_TOKEN` in the environment.
|
|
59
|
+
- A Python environment with `datasets` installed if you want `benchmark:setup`
|
|
60
|
+
to export a normalized local cache automatically.
|
|
61
|
+
- Either an exact evaluator wired through
|
|
62
|
+
`NEOAGENT_BENCHMARK_GAIA_RUNNER` or a repository-local exact runner added to
|
|
63
|
+
the harness. The current adapter intentionally reports `blocked` until an
|
|
64
|
+
official evaluator path is configured.
|
|
65
|
+
|
|
66
|
+
### BrowseComp
|
|
67
|
+
|
|
68
|
+
- A checkout of [openai/simple-evals](https://github.com/openai/simple-evals),
|
|
69
|
+
which `benchmark:setup` can clone into `benchmark/workdir/browsecomp/`.
|
|
70
|
+
- Exact BrowseComp case extraction from that repo.
|
|
71
|
+
- An official evaluator command exposed through
|
|
72
|
+
`NEOAGENT_BENCHMARK_BROWSECOMP_RUNNER`.
|
|
73
|
+
|
|
74
|
+
### WebArena
|
|
75
|
+
|
|
76
|
+
- Docker installed and running.
|
|
77
|
+
- The official [WebArena](https://webarena.dev/) environment and task sites.
|
|
78
|
+
- Browser automation dependencies required by the official runner.
|
|
79
|
+
- An exact runner command exposed through
|
|
80
|
+
`NEOAGENT_BENCHMARK_WEBARENA_RUNNER`.
|
|
81
|
+
|
|
82
|
+
### VisualWebArena
|
|
83
|
+
|
|
84
|
+
- Docker installed and running.
|
|
85
|
+
- The official VisualWebArena environment.
|
|
86
|
+
- A vision-capable configured benchmark model.
|
|
87
|
+
- An exact runner command exposed through
|
|
88
|
+
`NEOAGENT_BENCHMARK_VISUAL_WEBARENA_RUNNER`.
|
|
89
|
+
|
|
90
|
+
### SWE-bench
|
|
91
|
+
|
|
92
|
+
- Docker installed and running.
|
|
93
|
+
- A checkout of [SWE-bench](https://github.com/SWE-bench/SWE-bench), which
|
|
94
|
+
`benchmark:setup` can clone into `benchmark/workdir/swebench/`.
|
|
95
|
+
- The official dataset/runtime and enough disk/network budget for repo/image
|
|
96
|
+
setup.
|
|
97
|
+
- An exact runner command exposed through
|
|
98
|
+
`NEOAGENT_BENCHMARK_SWEBENCH_RUNNER`.
|
|
99
|
+
|
|
100
|
+
On this machine, `docker` is currently missing, so exact `WebArena`,
|
|
101
|
+
`VisualWebArena`, and `SWE-bench` execution remain blocked until Docker and the
|
|
102
|
+
official runners are installed.
|
package/docs/billing.md
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# Billing
|
|
2
|
+
|
|
3
|
+
NeoAgent includes an optional Stripe-based billing system for deployments that
|
|
4
|
+
charge users for access. When disabled — the default — no billing routes are
|
|
5
|
+
exposed, no payment UI is shown, and no payment-related information appears
|
|
6
|
+
anywhere in the application.
|
|
7
|
+
|
|
8
|
+
## Enable billing
|
|
9
|
+
|
|
10
|
+
Run the interactive setup wizard:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
neoagent billing setup
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The wizard prompts for your Stripe API keys, webhook secret, and trial length,
|
|
17
|
+
then asks whether to enable billing immediately. Use Stripe test keys
|
|
18
|
+
(`sk_test_...`, `pk_test_...`) during development.
|
|
19
|
+
|
|
20
|
+
To check the current configuration at any time:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
neoagent billing # or: neoagent billing status
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
To toggle billing without re-running setup:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
neoagent billing enable # set NEOAGENT_BILLING_ENABLED=true and restart
|
|
30
|
+
neoagent billing disable # set NEOAGENT_BILLING_ENABLED=false and restart
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
When enabled the admin dashboard will show a **Billing** navigation item and
|
|
34
|
+
the `/api/billing/*` endpoints become active.
|
|
35
|
+
|
|
36
|
+
> **Manual alternative** — you can also set variables directly and restart:
|
|
37
|
+
> ```bash
|
|
38
|
+
> neoagent env set STRIPE_SECRET_KEY sk_live_...
|
|
39
|
+
> neoagent env set STRIPE_PUBLISHABLE_KEY pk_live_...
|
|
40
|
+
> neoagent env set STRIPE_WEBHOOK_SECRET whsec_...
|
|
41
|
+
> neoagent env set NEOAGENT_BILLING_ENABLED true
|
|
42
|
+
> neoagent restart
|
|
43
|
+
> ```
|
|
44
|
+
|
|
45
|
+
## Subscription plans
|
|
46
|
+
|
|
47
|
+
Plans are managed in **Admin › Billing › Plans**. Each plan controls:
|
|
48
|
+
|
|
49
|
+
| Field | Purpose |
|
|
50
|
+
|---|---|
|
|
51
|
+
| Name | Displayed to users in the settings submenu |
|
|
52
|
+
| Price | Stripe price in cents (0 = free) |
|
|
53
|
+
| Billing interval | `month`, `year`, or blank for one-time or free |
|
|
54
|
+
| Stripe Price ID | The `price_...` ID from your Stripe dashboard |
|
|
55
|
+
| 4h token limit | Per-user 4-hour rolling token budget (blank = server default) |
|
|
56
|
+
| Weekly token limit | Per-user 7-day rolling token budget (blank = server default) |
|
|
57
|
+
| Allowed models | Comma-separated model IDs; blank = all models accessible |
|
|
58
|
+
| Features | Marketing feature strings shown on pricing pages |
|
|
59
|
+
|
|
60
|
+
Token limits are written directly to the user account when a subscription
|
|
61
|
+
becomes active or is updated via webhook. The existing rate-limit enforcement
|
|
62
|
+
in the runtime reads them with no additional configuration.
|
|
63
|
+
|
|
64
|
+
### Free plan
|
|
65
|
+
|
|
66
|
+
Create a plan with **Price = 0** to serve as the default for new users. If a
|
|
67
|
+
free plan exists when billing is enabled, every new registration is
|
|
68
|
+
automatically placed on it.
|
|
69
|
+
|
|
70
|
+
### Model restrictions
|
|
71
|
+
|
|
72
|
+
If **Allowed models** is non-empty, users on that plan can only use the listed
|
|
73
|
+
model IDs. Models outside the allowlist remain visible in the UI with an
|
|
74
|
+
unavailable status so users understand what upgrading unlocks.
|
|
75
|
+
|
|
76
|
+
Leave the field blank to allow all configured models on a plan.
|
|
77
|
+
|
|
78
|
+
## User subscriptions
|
|
79
|
+
|
|
80
|
+
Users manage their subscription in **Settings › Billing** (Flutter client). From
|
|
81
|
+
there they can:
|
|
82
|
+
|
|
83
|
+
- View their current plan, status, and next renewal date
|
|
84
|
+
- Upgrade or downgrade through Stripe Checkout
|
|
85
|
+
- Open the Stripe Customer Portal to update a payment method or download invoices
|
|
86
|
+
- Cancel at the end of the current billing period
|
|
87
|
+
|
|
88
|
+
### Stripe Checkout
|
|
89
|
+
|
|
90
|
+
When a user selects a paid plan, the server creates a Stripe Checkout session
|
|
91
|
+
and redirects the client to Stripe's hosted payment page. No card data passes
|
|
92
|
+
through NeoAgent.
|
|
93
|
+
|
|
94
|
+
### Stripe Customer Portal
|
|
95
|
+
|
|
96
|
+
The Customer Portal is a Stripe-hosted page where users can update their
|
|
97
|
+
payment method, view billing history, and cancel. Configure the portal in your
|
|
98
|
+
[Stripe dashboard](https://dashboard.stripe.com/settings/billing/portal) before
|
|
99
|
+
enabling it.
|
|
100
|
+
|
|
101
|
+
## Free trials
|
|
102
|
+
|
|
103
|
+
Enable free trials in **Admin › Billing › Plans** by configuring a Stripe price
|
|
104
|
+
that supports trials, then setting `BILLING_TRIAL_DAYS` to the desired length
|
|
105
|
+
(default: 14 days).
|
|
106
|
+
|
|
107
|
+
Trials start when a user calls `POST /api/billing/trial` with a plan ID. The
|
|
108
|
+
server runs anti-abuse checks before granting a trial:
|
|
109
|
+
|
|
110
|
+
| Check | Limit |
|
|
111
|
+
|---|---|
|
|
112
|
+
| IP address | 2 trials per IP per 30 days |
|
|
113
|
+
| Email domain | 3 trials per non-common domain per 30 days |
|
|
114
|
+
| Account age | Account must be at least 1 day old |
|
|
115
|
+
| Device fingerprint | 1 trial per device per 90 days (opaque hash from client) |
|
|
116
|
+
|
|
117
|
+
The Flutter client is responsible for generating and sending the device
|
|
118
|
+
fingerprint. The server hashes it with SHA-256 before storage — the raw
|
|
119
|
+
fingerprint is never persisted.
|
|
120
|
+
|
|
121
|
+
## Webhooks
|
|
122
|
+
|
|
123
|
+
Stripe sends events to `POST /api/billing/webhook`. Register this URL in your
|
|
124
|
+
[Stripe dashboard](https://dashboard.stripe.com/webhooks) under the endpoint
|
|
125
|
+
for your account.
|
|
126
|
+
|
|
127
|
+
Handled events:
|
|
128
|
+
|
|
129
|
+
| Event | Effect |
|
|
130
|
+
|---|---|
|
|
131
|
+
| `customer.subscription.created` | Creates a local subscription row |
|
|
132
|
+
| `customer.subscription.updated` | Syncs status, period dates, and token limits |
|
|
133
|
+
| `customer.subscription.deleted` | Marks subscription canceled |
|
|
134
|
+
| `customer.subscription.trial_will_end` | Sends trial-ending email (fires 3 days before) |
|
|
135
|
+
| `invoice.payment_succeeded` | Records payment; sends renewal email on cycle |
|
|
136
|
+
| `invoice.payment_failed` | Records failure; sends payment-failed email |
|
|
137
|
+
|
|
138
|
+
Events are idempotent — replaying a webhook event produces the same result.
|
|
139
|
+
|
|
140
|
+
**Required events to enable in Stripe:**
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
customer.subscription.created
|
|
144
|
+
customer.subscription.updated
|
|
145
|
+
customer.subscription.deleted
|
|
146
|
+
customer.subscription.trial_will_end
|
|
147
|
+
invoice.payment_succeeded
|
|
148
|
+
invoice.payment_failed
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Verifying the webhook locally
|
|
152
|
+
|
|
153
|
+
Use the Stripe CLI to forward events to a local server during development:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
stripe listen --forward-to http://localhost:3333/api/billing/webhook
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Email notifications
|
|
160
|
+
|
|
161
|
+
If [service email](configuration.md#service-email) is configured, users receive
|
|
162
|
+
emails at the following billing events:
|
|
163
|
+
|
|
164
|
+
| Event | Email |
|
|
165
|
+
|---|---|
|
|
166
|
+
| Trial started | Confirmation with trial end date |
|
|
167
|
+
| Trial ending soon | Reminder 3 days before end |
|
|
168
|
+
| Subscription activated | Welcome to the paid plan |
|
|
169
|
+
| Subscription renewed | Renewal confirmation |
|
|
170
|
+
| Payment failed | Action required with next retry date |
|
|
171
|
+
| Subscription canceled | Cancellation confirmation |
|
|
172
|
+
| Plan changed | Summary of the new plan |
|
|
173
|
+
|
|
174
|
+
No emails are sent if SMTP is not configured.
|
|
175
|
+
|
|
176
|
+
## AI context awareness
|
|
177
|
+
|
|
178
|
+
When billing is enabled, each AI request includes the user's subscription in
|
|
179
|
+
the system prompt:
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
SUBSCRIPTION: User is on the "Pro" plan, status: active.
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Agents and workflows can use this context to adapt their behavior — for
|
|
186
|
+
example, acknowledging feature limitations on a free plan or confirming
|
|
187
|
+
capabilities on a paid one.
|
|
188
|
+
|
|
189
|
+
## Admin controls
|
|
190
|
+
|
|
191
|
+
The **Admin › Billing** page provides:
|
|
192
|
+
|
|
193
|
+
- **Plans**: Create, edit, and deactivate subscription plans
|
|
194
|
+
- **Subscriptions**: Browse all user subscriptions with status filter and
|
|
195
|
+
pagination; override a user's plan without going through Stripe
|
|
196
|
+
|
|
197
|
+
Override a user's plan directly from the subscriptions table using the
|
|
198
|
+
**Override** button. This is useful for comped accounts, support escalations,
|
|
199
|
+
or fixing a webhook gap.
|
|
200
|
+
|
|
201
|
+
## Configuration reference
|
|
202
|
+
|
|
203
|
+
| Variable | Default | Purpose |
|
|
204
|
+
|---|---|---|
|
|
205
|
+
| `NEOAGENT_BILLING_ENABLED` | `false` | Master on/off switch |
|
|
206
|
+
| `STRIPE_SECRET_KEY` | required | Stripe server-side API key |
|
|
207
|
+
| `STRIPE_PUBLISHABLE_KEY` | required | Stripe client-side key (returned to Flutter) |
|
|
208
|
+
| `STRIPE_WEBHOOK_SECRET` | required | Webhook signing secret from Stripe dashboard |
|
|
209
|
+
| `BILLING_TRIAL_DAYS` | `14` | Free trial length in days |
|
|
210
|
+
|
|
211
|
+
All variables can be set with `neoagent env set` or added to `~/.neoagent/.env`
|
|
212
|
+
directly. Restart the server after any change.
|
|
213
|
+
|
|
214
|
+
## Security notes
|
|
215
|
+
|
|
216
|
+
- NeoAgent stores only Stripe customer IDs and subscription IDs — no card
|
|
217
|
+
numbers, bank details, or PII beyond what Stripe already holds.
|
|
218
|
+
- Webhook payloads are verified with HMAC-SHA256 using `STRIPE_WEBHOOK_SECRET`
|
|
219
|
+
before any processing. Requests missing the `stripe-signature` header are
|
|
220
|
+
rejected with 400.
|
|
221
|
+
- Trial fingerprints are stored as SHA-256 hashes — the raw IP, email domain,
|
|
222
|
+
and device identifiers are never persisted.
|
|
223
|
+
- All billing routes return 404 when `NEOAGENT_BILLING_ENABLED` is not set,
|
|
224
|
+
regardless of whether Stripe credentials are present.
|
package/docs/configuration.md
CHANGED
|
@@ -97,6 +97,28 @@ reset, email changes, and security notifications.
|
|
|
97
97
|
| `NEOAGENT_EMAIL_PUBLIC_URL` | Base URL used in email links |
|
|
98
98
|
| `NEOAGENT_EMAIL_TOKEN_TTL_HOURS` | Confirmation token lifetime |
|
|
99
99
|
|
|
100
|
+
## Billing
|
|
101
|
+
|
|
102
|
+
Billing is disabled by default. Use the interactive wizard to configure it:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
neoagent billing setup # guided Stripe key and webhook setup
|
|
106
|
+
neoagent billing # show current status
|
|
107
|
+
neoagent billing enable # activate billing and restart
|
|
108
|
+
neoagent billing disable # deactivate billing and restart
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
See [Billing](billing.md) for the full setup guide, webhook configuration, and
|
|
112
|
+
plan management.
|
|
113
|
+
|
|
114
|
+
| Variable | Default | Purpose |
|
|
115
|
+
|---|---|---|
|
|
116
|
+
| `NEOAGENT_BILLING_ENABLED` | `false` | Enable the Stripe billing system |
|
|
117
|
+
| `STRIPE_SECRET_KEY` | unset | Stripe server-side API key |
|
|
118
|
+
| `STRIPE_PUBLISHABLE_KEY` | unset | Stripe client-side key (returned to clients) |
|
|
119
|
+
| `STRIPE_WEBHOOK_SECRET` | unset | Webhook signing secret |
|
|
120
|
+
| `BILLING_TRIAL_DAYS` | `14` | Free trial length in days |
|
|
121
|
+
|
|
100
122
|
## Isolated runtime
|
|
101
123
|
|
|
102
124
|
| Variable | Purpose |
|
package/docs/index.md
CHANGED
|
@@ -45,6 +45,7 @@ Continue with:
|
|
|
45
45
|
| [Recordings and health](recordings-and-health.md) | Audio transcription and Health Connect |
|
|
46
46
|
| [Skills and MCP](skills.md) | Reusable instructions and external tool servers |
|
|
47
47
|
| [Operations](operations.md) | Updates, backups, logs, and recovery |
|
|
48
|
+
| [Billing](billing.md) | Stripe subscriptions, plans, trials, and webhooks |
|
|
48
49
|
| [Configuration](configuration.md) | Environment and runtime reference |
|
|
49
50
|
| [Why NeoAgent](why-neoagent.md) | Factual comparison with OpenClaw and Hermes |
|
|
50
51
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'dart:async';
|
|
2
2
|
import 'dart:convert';
|
|
3
|
-
import 'dart:io' show Platform;
|
|
3
|
+
import 'dart:io' show Directory, File, Platform, Process, ProcessSignal;
|
|
4
4
|
import 'dart:math' as math;
|
|
5
5
|
import 'dart:ui' show ImageFilter;
|
|
6
6
|
|
|
@@ -20,6 +20,7 @@ import 'package:image/image.dart' as img;
|
|
|
20
20
|
import 'package:mobile_scanner/mobile_scanner.dart';
|
|
21
21
|
import 'package:qr_flutter/qr_flutter.dart';
|
|
22
22
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
23
|
+
import 'package:url_launcher/url_launcher.dart' as url_launcher;
|
|
23
24
|
import 'package:socket_io_client/socket_io_client.dart' as io;
|
|
24
25
|
import 'package:audioplayers/audioplayers.dart';
|
|
25
26
|
import 'package:tray_manager/tray_manager.dart';
|
|
@@ -71,7 +72,9 @@ part 'main_security.dart';
|
|
|
71
72
|
part 'main_model_picker.dart';
|
|
72
73
|
part 'main_operations.dart';
|
|
73
74
|
part 'main_admin.dart';
|
|
75
|
+
part 'main_billing.dart';
|
|
74
76
|
part 'main_unified.dart';
|
|
77
|
+
part 'main_install.dart';
|
|
75
78
|
|
|
76
79
|
Future<void> main() async {
|
|
77
80
|
await runNeoAgentApp(mode: _appModeFromEnvironment());
|