awd-skill 0.0.0-stage → 1.0.0
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/README.md +324 -3
- package/bin/install.js +756 -0
- package/commands/awd-skill-assets.md +25 -0
- package/commands/awd-skill-backend.md +12 -0
- package/commands/awd-skill-content.md +12 -0
- package/commands/awd-skill-deploy.md +12 -0
- package/commands/awd-skill-design.md +12 -0
- package/commands/awd-skill-frontend.md +12 -0
- package/commands/awd-skill-growth.md +12 -0
- package/commands/awd-skill-launch.md +12 -0
- package/commands/awd-skill-list.md +12 -0
- package/commands/awd-skill-mode-e.md +18 -0
- package/commands/awd-skill-mode-f.md +16 -0
- package/commands/awd-skill-motion.md +12 -0
- package/commands/awd-skill-qa.md +12 -0
- package/commands/awd-skill-research.md +12 -0
- package/commands/awd-skill-strategy.md +12 -0
- package/commands/awd-skill-taste.md +18 -0
- package/commands/awd-skill-template-submit.md +16 -0
- package/commands/awd-skill-template-use.md +15 -0
- package/commands/awd-skill.md +11 -0
- package/docs/EXAMPLES.md +124 -0
- package/docs/INSTALL.md +203 -0
- package/docs/LICENSING.md +150 -0
- package/docs/PRODUCTION.md +921 -0
- package/docs/TEMPLATES.md +105 -0
- package/docs/VISUAL-GATES.md +131 -0
- package/docs/animotion/AGENTIC-MODE.md +537 -0
- package/docs/animotion/API-REFERENCE.md +2457 -0
- package/docs/animotion/DECLARATIVE-ATTRIBUTES.md +8563 -0
- package/docs/animotion/EFFECTS-PLAYBOOK.md +377 -0
- package/docs/animotion/IMPERATIVE-API.md +9056 -0
- package/docs/design-editor-plan.md +259 -0
- package/docs/generative-ai-canvas-plan.md +144 -0
- package/docs/target-state-plan.md +466 -0
- package/package.json +68 -4
|
@@ -0,0 +1,921 @@
|
|
|
1
|
+
# Production runbook
|
|
2
|
+
|
|
3
|
+
Everything needed to ship **awd-skill 2.3.x** and operate it afterwards: the private skill payload, the npm installer, the legacy managed-credits proxy (Renderful — the **AWD Editor's** managed generation transport, not used by the free-lane skill), Stripe, the QA matrix, monitoring and Rollback. Skill assets come from the four **free-lane sources** only.
|
|
4
|
+
|
|
5
|
+
Read this top to bottom the first time. After that, use the [release checklist](#release-checklist) at the end.
|
|
6
|
+
|
|
7
|
+
> **⚠ OWNERSHIP / CREDITS — read [docs/target-state-plan.md](target-state-plan.md) §7.5 first.** The backend source exists at `C:\Users\creat\Projects\Animotionjs\backend`; it is the license/credits authority at `https://skills.animotion.click`. The editor keeps a swappable `BillingProvider` and mirrors its Stripe settings. Backend source/env and the live health endpoint now agree with the editor's 400-credit Template plan. `origin.animotion.click` is currently a Cloudflare tunnel to a local Node service on `127.0.0.1:4310`, so sign-in/API availability still depends on that machine and tunnel.
|
|
8
|
+
>
|
|
9
|
+
> - **Two separate products.** The shipped **skill** is free, runs in the user's AI agent, and uses the **free-lane Asset Builder only** (client brand files, hand-drawn SVG/procedural, Crucible local 3D stills, and the user's own agent-native AI models). Its free lane makes **no editor wallet calls, no Renderful generation calls, no generation proxy calls, and spends no credits**. Paid users may opt into the documented editor bridge with their own session (`awd-skill/references/editor-bridge.md`); skill-created projects stay in the skill namespace unless a user explicitly creates one through editor APIs/UI.
|
|
10
|
+
> - **This runbook's credits proxy is the AWD Editor's generation money transport for the managed lane** (admin uses the direct API lane and is unmetered). It is **legacy infrastructure**, not part of the skill. Statements below about "top-up packs only", "no monthly plan credits" or "no plan-credit grant path" refer **only to this legacy proxy's own packs** — not to the editor's plan/wallet.
|
|
11
|
+
> - **Authoritative editor plan/wallet (target state):** **$25/month** Template plan bought through **https://skills.animotion.click/checkout?plan=template**, including **400 AI credits/month** usable across all editor AI tools. Monthly credits reset each billing period, **no rollover**; **top-ups never expire**; monthly spent first, then top-ups; **1 credit = $0.05** for generation. **Design Agent turns intentionally debit the same wallet at `AWD_AGENT_CREDIT_USD=0.01` (5x faster), floor 2 credits**, settled from Renderful's real reported `cost` or real token usage. **Curated `freellmapi:*` models are the exception: they run as a genuine zero-credit lane for `awd.design` / `awd.generate` and do not require the plan.** **Admin sign-in uses the direct API lane for all tools, unmetered**, bypassing both buckets. Routes: `POST /api/plan/checkout`, `POST /api/credits/checkout`, `POST /api/stripe/webhook`, wallet endpoints. LLM catalogue is env-driven (`AWD_LLM_MODELS`, plus `AWD_LLM_BASE_URL`/`AWD_LLM_API_KEY` for an OpenAI-compatible provider or `RENDERFUL_API_KEY`/`RENDERFUL_BASE` for Renderful); an empty catalogue fails closed. The optional FreeLLMAPI router is host-only, opt-in and documented in Appendix A; it does not replace the paid lanes.
|
|
12
|
+
>
|
|
13
|
+
> **Stripe plan-checkout / webhook runbook (editor-owned billing in `awd-editor/server/src/`):** set `STRIPE_SECRET_KEY` and `STRIPE_WEBHOOK_SECRET` from the backend `.env`, and `STRIPE_PRICE_MONTHLY_25` from backend `TEMPLATE_PRICE_ID` (optional `STRIPE_PRICE_TOPUP_PACK`, `AWD_PUBLIC_ORIGIN`/`APP_ORIGIN`). Backend source defaults to `template: 400` and the live `https://skills.animotion.click/v1/credits/health` reports `planCredits: { "pro": 100, "studio": 215, "template": 400 }`; keep any `PLAN_CREDITS_JSON` override aligned. Verify `POST /api/plan/checkout` creates a $25/month session; point the Stripe webhook at `POST /api/stripe/webhook` and confirm signature verification plus `checkout.session.completed`, `invoice.payment_succeeded` (grants/reset 400 monthly credits) and `invoice.payment_failed`. Also verify `POST /api/plan/activate` closes the Stripe return path when the webhook lands on the separate license backend. On activation the editor sets `plan = "template"`, `aiCreditsMonthlyLimit = 400`, resets `aiCreditsUsed = 0` and stamps the billing period. Confirm `POST /api/credits/checkout` sells non-expiring top-ups and that the 402 paywall renders when both buckets are short. No live keys belong in this repository or its docs.
|
|
14
|
+
|
|
15
|
+
> **Maintainer runbook.** The public Git repository is docs-only. Paths such as `bin/`, `commands/`, `server/credits/`, `scripts/`, `package.json` and `render.yaml` exist in the local working tree and are ignored by Git; they ship through npm and the private tarball, not GitHub.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 0. What ships where
|
|
20
|
+
|
|
21
|
+
| Artifact | Contents | Lives at | How it updates |
|
|
22
|
+
|---|---|---|---|
|
|
23
|
+
| **Skill payload** (`skilltar.gz`) | `SKILL.md`, 11 departments, 27 references, templates | Private immutable CDN URL in `package.json → awd.source` | Upload a **new** file, bump `awd.source`, publish a patch |
|
|
24
|
+
| **npm package** (`awd-skill`) | `bin/install.js`, `commands/`, `docs/`, `README.md`, `package.json` | npm registry | `npm publish` |
|
|
25
|
+
| **Credits service** | `C:\Users\creat\Projects\Animotionjs\backend` (`credits/`, `stripe/`) — Postgres ledger folded into the license/CDN backend at `https://skills.animotion.click` | Deployed backend + local origin via Cloudflare tunnel | Update backend `.env`/source, redeploy backend, restart local origin service on `127.0.0.1:4310` |
|
|
26
|
+
| **Stripe** | Checkout sessions + webhook → credits | Stripe dashboard | Config only |
|
|
27
|
+
|
|
28
|
+
Hard rules:
|
|
29
|
+
|
|
30
|
+
- The npm tarball is **public forever**. It must never contain `awd-skill/`, the proxy source, `.env`, or any secret. `scripts/release-check.js` enforces this.
|
|
31
|
+
- The payload URL is **immutable** — never overwrite an uploaded `skilltar.gz`. Old installs keep working only if the old URL keeps serving the old bytes.
|
|
32
|
+
- The proxy is the **only** writer of managed balances. The skill never receives `RENDERFUL_API_KEY`, `STRIPE_SECRET_KEY` or `FILE_SIGNING_SECRET`.
|
|
33
|
+
- **Legacy proxy packs are top-up packs only.** This applies to the **legacy credits proxy's own ledger**, not to the editor plan: that proxy's generation credits come only from one-time top-up packs (`checkout.session.completed` → `chk_` intents), which never expire, and its `invoice.payment_succeeded` grants **nothing** — it has no plan-credit grant path. The **editor's** authoritative plan/wallet is the **$25/month** plan with **400 AI credits/month**, non-expiring top-ups and admin direct-API bypass (see the ownership note above and `target-state-plan.md` §7). The skill uses none of this.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 1. One-time preparation
|
|
38
|
+
|
|
39
|
+
### Accounts and keys
|
|
40
|
+
|
|
41
|
+
- [ ] npm account with publish rights to `awd-skill` (2FA enabled).
|
|
42
|
+
- [ ] Renderful account → API key (`RENDERFUL_API_KEY`).
|
|
43
|
+
- [ ] Stripe account, **live** keys, webhook signing secret.
|
|
44
|
+
- [ ] The deployed backend (`https://skills.animotion.click`) — credits are folded into it, no extra host. A VM/Vercel project is only needed if you choose the standalone fallback in §5.1.
|
|
45
|
+
- [ ] The license validator reachable at `https://skills.animotion.click/api/license/validate`.
|
|
46
|
+
|
|
47
|
+
### Tools
|
|
48
|
+
|
|
49
|
+
- Node **20 LTS** for the folded backend (it uses Postgres). The standalone fallback needs **22.5+** (`node:sqlite`).
|
|
50
|
+
- `git`, `tar`, `curl`, `jq` (optional), `stripe` CLI (optional), `openssl`.
|
|
51
|
+
- No local renderer is needed: **editor managed-lane generation goes through Renderful via the legacy credits proxy**; the skill's assets come from the four **free-lane sources** (no generation, credits or proxy).
|
|
52
|
+
|
|
53
|
+
### Repository sanity
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
git status --short # know exactly what is being committed
|
|
57
|
+
node -v # >= 22.5 for proxy work
|
|
58
|
+
cd server/credits && npm test && cd ../..
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Windows PowerShell equivalents work too; `scripts/release-check.js` handles `npm.cmd`.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 2. Pre-flight: the release gate
|
|
66
|
+
|
|
67
|
+
Run from the repository root:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npm run release:check
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
It checks, in order:
|
|
74
|
+
|
|
75
|
+
1. `package.json` parses, has semver, and `awd.source` is an https `.tar.gz` URL.
|
|
76
|
+
2. Installer floor and proxy floor (`server/credits/package.json` → `engines.node >= 22.5`).
|
|
77
|
+
3. Payload content: `SKILL.md`, 11 departments, 25+ references, 10+ templates, no local-renderer files.
|
|
78
|
+
4. All 16 command sources → 31 installed names, valid frontmatter, `/awd-assets` proxy wording, no stale model ids.
|
|
79
|
+
5. **Pricing math**: every `$min–$max` row equals `ceil(usd / 0.05)`, and every model id is on the verified Renderful allowlist.
|
|
80
|
+
6. Proxy files, `node --check`, 60+ passing tests, `.env.example` keys with blank secrets.
|
|
81
|
+
7. Docs keep plans and credits separate; `docs/PRODUCTION.md` exists.
|
|
82
|
+
8. Hygiene: `.gitignore` tracks `package.json`/`commands/`/`server/`/`scripts/`; no secret patterns; `npm pack` leaks neither `awd-skill/` nor `server/`.
|
|
83
|
+
|
|
84
|
+
Useful variants:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
node scripts/release-check.js --no-tests # skip the 60-test proxy suite
|
|
88
|
+
node scripts/release-check.js --json # CI output, non-zero exit on failure
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Do not continue past a red check.** Every failure prints the file and the fix.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## 3. Payload: build, verify, upload
|
|
96
|
+
|
|
97
|
+
### 3.1 Bump the version once
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
npm version 2.3.1 --no-git-tag-version # or edit package.json by hand
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Version lives in `package.json` only. `build-skill.js` stamps it into the manifest.
|
|
104
|
+
|
|
105
|
+
### 3.2 Build
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
npm run release:build
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Outputs:
|
|
112
|
+
|
|
113
|
+
```text
|
|
114
|
+
skilltar.gz ← upload this
|
|
115
|
+
dist/skill-<version>.json ← sha256, size, file counts, current awd.source
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Keep `dist/skill-<version>.json` with the release notes / upload record.
|
|
119
|
+
|
|
120
|
+
### 3.3 Verify the archive through the real installer
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
npm run release:verify
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
This installs `skilltar.gz` with `bin/install.js` into a throwaway HOME and asserts:
|
|
127
|
+
|
|
128
|
+
- the skill tree (`SKILL.md`, `departments/INDEX.md`, `references/asset-builder.md`, `asset-credits.md`, `mode-e.md`, `template-catalog.md`) and 25+ references are present;
|
|
129
|
+
- `SKILL.md` still names the Asset Builder, Stage AB., `asset-credits.md` and `motion-toolkit.md`;
|
|
130
|
+
- all 31 slash commands exist, including `/awd-assets` and `/awd-skill-assets`.
|
|
131
|
+
|
|
132
|
+
To test a URL instead of the local file (after upload):
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
node scripts/verify-release.js --source=https://your-cdn/skill-2.3.1.tar.gz
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 3.4 Upload to an immutable URL
|
|
139
|
+
|
|
140
|
+
Upload `skilltar.gz` to the private host. Use a new path per release, e.g. `…/skill-2.3.1.tar.gz`. Do **not** overwrite the 2.2.x file.
|
|
141
|
+
|
|
142
|
+
- [ ] Upload completed.
|
|
143
|
+
- [ ] `curl -sI <url>` returns `200` and a sane `Content-Length`.
|
|
144
|
+
- [ ] The URL works **without** cookies (private token, signed URL, or CDN auth as configured).
|
|
145
|
+
- [ ] SHA-256 of the downloaded file matches `dist/skill-<version>.json`.
|
|
146
|
+
|
|
147
|
+
### 3.5 Point `awd.source` at it
|
|
148
|
+
|
|
149
|
+
```jsonc
|
|
150
|
+
// package.json
|
|
151
|
+
"awd": {
|
|
152
|
+
"source": "https://your-cdn/skill-2.3.1.tar.gz"
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Verify the live upload through the installer:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
node scripts/verify-release.js --source=https://your-cdn/skill-2.3.1.tar.gz
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### 3.6 Deploy the same tree to the skills server (Google AI Studio + gated fetch)
|
|
163
|
+
|
|
164
|
+
The CDN payload and the skills-server payload are **two different consumers** of the same tree:
|
|
165
|
+
|
|
166
|
+
| Consumer | Reads | Updated by |
|
|
167
|
+
|---|---|---|
|
|
168
|
+
| Local agents via `npx awd-skill install` | `awd.source` tarball | §3.4–3.5 |
|
|
169
|
+
| Google AI Studio + browser parity fetches | `https://skills.animotion.click/api/skills/awd-skill/<path>` | **this step** |
|
|
170
|
+
| `npx` docs/commands | npm tarball | §4 |
|
|
171
|
+
|
|
172
|
+
`npm publish` does **not** update the skills server. Until the tree is deployed there, AI Studio (and any URL-Context-only client) keeps serving the previous release even when npm is current.
|
|
173
|
+
|
|
174
|
+
- [ ] Deploy the release `awd-skill/` tree (same files that went into `skilltar.gz`) through the skills server's existing upload/deploy path.
|
|
175
|
+
- [ ] `references/ai-studio-system-prompt.md` on the server is the **new** router — paste-safe, with no credentials in it.
|
|
176
|
+
- [ ] Fetch through the gated route with a real key (GET), e.g.
|
|
177
|
+
`curl -s "https://skills.animotion.click/api/skills/awd-skill/references/ai-studio-system-prompt.md?licenseKey=$KEY" | grep -c "ASSET BUILDER"`
|
|
178
|
+
→ `1` on 2.3.x.
|
|
179
|
+
- [ ] `SKILL.md` on the server names the Asset Builder, Stage AB., `asset-credits.md` and `motion-toolkit.md` (same assertions as `npm run release:verify`).
|
|
180
|
+
- [ ] No stray `.env`, `dist/`, `server/`, or credential file is inside the deployed tree.
|
|
181
|
+
- [ ] Re-paste the router into AI Studio **System instructions** in a *new* chat and run the freshness check in `awd-skill/references/google-ai-studio.md` → *Updates*.
|
|
182
|
+
|
|
183
|
+
> Admin secret hygiene: the router is published. It must never contain `AGENTIC_ADMIN_EMAIL`/`AGENTIC_ADMIN_SECRET` values or a real `sec_live_` key. `npm run release:check` fails on those patterns.
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## 4. npm publish
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
npm whoami # must print your npm user; a 401 means `npm login`
|
|
191
|
+
npm pack --dry-run # expect 23 files: bin/, commands/, docs/, README, package.json
|
|
192
|
+
npm publish # add --access public the first time / if config is lost
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Post-publish checks:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
npm view awd-skill version
|
|
199
|
+
npm view awd-skill dist.tarball
|
|
200
|
+
npx awd-skill@<version> detect
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Then a real install in a clean HOME:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
npx awd-skill@<version> install \
|
|
207
|
+
--agent=opencode \
|
|
208
|
+
--source=https://your-cdn/skill-2.3.1.tar.gz \
|
|
209
|
+
--license-key=YOUR_TEST_KEY \
|
|
210
|
+
--home=/tmp/awd-npm-smoke
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Confirm the skill directory and commands exist in the throwaway home. The installer no longer writes a credits config (`--credits-url` was removed) because the skill has no credits proxy. `AWD_CREDITS_API_URL` is **not a skill setting** — it configures only the editor's legacy managed generation transport, described below.
|
|
214
|
+
|
|
215
|
+
**Do not** publish from a dirty tree, and never `npm publish` a tarball that contains `awd-skill/` or `server/` — the dry-run check above is mandatory.
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## 5. Deploy the credits proxy
|
|
220
|
+
|
|
221
|
+
### 5.0 The deployed path: folded into the license backend
|
|
222
|
+
|
|
223
|
+
Credits now run **inside the existing license backend** (`backend/` in the
|
|
224
|
+
backend repo, the same Express app that serves licences and the skills CDN) at
|
|
225
|
+
`https://skills.animotion.click`. There is no separate container, no disk and no
|
|
226
|
+
SQLite file:
|
|
227
|
+
|
|
228
|
+
| Piece | Folded deployment |
|
|
229
|
+
|---|---|
|
|
230
|
+
| Ledger | the backend's existing Postgres (`DATABASE_URL` / `DB_*`) |
|
|
231
|
+
| Account identity | licence **email** (monthly key re-issues keep the balance) |
|
|
232
|
+
| Licence check | in-process `validateLicense()` — no `LICENSE_VALIDATE_URL` |
|
|
233
|
+
| Stripe webhook | `POST /api/stripe/webhook`, shared with plan subscriptions; on this **legacy proxy** only `chk_` intents are treated as its own credit-pack purchases and `invoice.payment_succeeded` grants nothing to that proxy's ledger. The **editor's** webhook grants/resets the 400 monthly credits — see the ownership note above. |
|
|
234
|
+
| Storage | `passthrough` by default (outputs stay as Renderful CDN URLs, so Vercel's 4.5 MB response cap never applies); R2 is opt-in |
|
|
235
|
+
| Reconciliation | on read + opportunistic + `GET|POST /v1/credits/cron/reconcile` with `x-cron-secret`; no Vercel cron entry |
|
|
236
|
+
|
|
237
|
+
Deploy from `backend/` (the backend GitHub repo publishes docs only, so this is
|
|
238
|
+
**not** a Git push):
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
cd backend
|
|
242
|
+
vercel deploy --prod --yes
|
|
243
|
+
vercel alias set <deployment-url> skills.animotion.click
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Production env already present: `STRIPE_SECRET_KEY`, `STRIPE_WEBHOOK_SECRET`,
|
|
247
|
+
`ADMIN_SECRET`, the DB credentials, `LICENSE_ENCRYPTION_KEY`,
|
|
248
|
+
`CREDITS_CRON_SECRET`, `PUBLIC_BASE_URL=https://skills.animotion.click`, and the
|
|
249
|
+
plan price id `TEMPLATE_PRICE_ID` for the single $25/month Template plan (legacy Pro and Studio ids are kept only for reading old verdicts; they are not sold).
|
|
250
|
+
(on this **legacy proxy** subscriptions unlock the paid gates only — they grant **no** credits to its own ledger. The separate **editor** plan grants 400 AI credits/month; see the ownership note above.)
|
|
251
|
+
`RENDERFUL_API_KEY` is the only key still required for editor managed-lane generation — without it
|
|
252
|
+
quotes/models/packs work and generation returns 503.
|
|
253
|
+
|
|
254
|
+
Verify:
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
node scripts/check-deploy.mjs --url=https://skills.animotion.click
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
The checker understands both layouts (folded `/health.credits` + `/v1/credits` +
|
|
261
|
+
`/api/stripe/webhook`, and the standalone `/v1/*` surface below).
|
|
262
|
+
|
|
263
|
+
### 5.1 Standalone host + TLS (fallback)
|
|
264
|
+
|
|
265
|
+
1. VM (1–2 vCPU, 1 GB RAM is enough for the first hundreds of accounts) with a persistent disk.
|
|
266
|
+
2. DNS `credits.your-host` → VM.
|
|
267
|
+
3. Reverse proxy (Caddy or nginx) terminates TLS and forwards to `127.0.0.1:8787`. Keep the service bound to localhost when TLS is in front.
|
|
268
|
+
4. Set `TRUST_PROXY=true` **only** when that proxy overwrites `X-Forwarded-For`.
|
|
269
|
+
|
|
270
|
+
Caddy example:
|
|
271
|
+
|
|
272
|
+
```caddyfile
|
|
273
|
+
credits.your-host {
|
|
274
|
+
reverse_proxy 127.0.0.1:8787
|
|
275
|
+
request_body { max_size 2MB }
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### 5.1a Render + Cloudflare (fallback)
|
|
280
|
+
|
|
281
|
+
> **Not currently deployed.** `credits.animotion.click` has no live host (the
|
|
282
|
+
> Cloudflare record returns 522). Credits run on the folded deployment in §5.0;
|
|
283
|
+
> the instructions below are kept only for a future standalone host.
|
|
284
|
+
|
|
285
|
+
`render.yaml` at the repo root describes the whole service: the image built from
|
|
286
|
+
the `Dockerfile` at the repo root, a 1 GB disk at `/data`, `/health` as the check, and every
|
|
287
|
+
non-secret env var. Three secrets are marked `sync: false`, so Render prompts for them and they
|
|
288
|
+
never enter Git.
|
|
289
|
+
|
|
290
|
+
1. Render → **New → Blueprint** → connect this repo → it detects `render.yaml`.
|
|
291
|
+
2. Fill the three prompted secrets:
|
|
292
|
+
- `RENDERFUL_API_KEY` — the live key (server-side only, never in the skill)
|
|
293
|
+
- `STRIPE_SECRET_KEY` — the **live** key from the account you already use
|
|
294
|
+
- `STRIPE_WEBHOOK_SECRET` — leave `whsec_pending` for now; step 5 sets the real one
|
|
295
|
+
3. Deploy. The plan **must** be `starter` or higher: Render will not attach a disk to a free
|
|
296
|
+
service, and without the disk the ledger resets on every deploy. Keep instances at **1** —
|
|
297
|
+
SQLite is single-writer and two containers over one volume corrupt it.
|
|
298
|
+
4. Cloudflare DNS → `CNAME credits → awd-credits.onrender.com`, **Proxy status: DNS only (grey
|
|
299
|
+
cloud)** for the first deploy, so Render can issue its certificate. Once `/health` answers over
|
|
300
|
+
HTTPS, you can switch to Proxied (orange) with SSL/TLS mode **Full (strict)**.
|
|
301
|
+
5. Stripe → Developers → Webhooks → **Add endpoint**
|
|
302
|
+
`https://credits.animotion.click/v1/stripe/webhook`, events
|
|
303
|
+
`checkout.session.completed` and `checkout.session.async_payment_succeeded`.
|
|
304
|
+
Copy that endpoint's `whsec_…` into Render as `STRIPE_WEBHOOK_SECRET` and let it redeploy.
|
|
305
|
+
6. Verify from this repo, before telling anyone:
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
npm run check:deploy -- --url=https://credits.animotion.click
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
**Render specifics worth knowing:**
|
|
312
|
+
|
|
313
|
+
- The image is built from the **root `Dockerfile`**, because Render uses the repo root as the build
|
|
314
|
+
context and defaults to `./Dockerfile`. Do not move it back under `server/credits`: a blueprint
|
|
315
|
+
`dockerContext`/`dockerfilePath` pair is not reliably honoured, and the first deploy died with
|
|
316
|
+
`failed to read dockerfile: open Dockerfile: no such file or directory`. A manual **Docker** web
|
|
317
|
+
service with no root-directory setting now builds correctly too.
|
|
318
|
+
- The disk is mounted **root-owned** while the app runs as `node`, so the image starts as root only
|
|
319
|
+
long enough for `deploy/entrypoint.sh` to chown the mount, then drops privileges. Without that the
|
|
320
|
+
service dies at boot with `EACCES` on `credits.sqlite`.
|
|
321
|
+
- `PORT` is injected by Render at runtime. The image therefore does not hard-code it, and its
|
|
322
|
+
HEALTHCHECK reads `${PORT:-8787}`.
|
|
323
|
+
- A disk prevents zero-downtime deploys and horizontal scaling — both are correct here; a deploy is
|
|
324
|
+
a short restart.
|
|
325
|
+
- Bandwidth is metered (100 GB/mo included, then $0.10/GB). Outputs are up to 200 MB each, so watch
|
|
326
|
+
this line if buyers generate long video. Signed URLs expire, which caps sharing but not re-downloads.
|
|
327
|
+
- If Stripe deliveries start failing with a Cloudflare `403`, disable **Bot Fight Mode** for the zone;
|
|
328
|
+
Stripe's servers must reach the webhook path un-challenged.
|
|
329
|
+
- `TRUST_PROXY=true` is correct on Render: both Render's edge and Cloudflare overwrite
|
|
330
|
+
`X-Forwarded-For`, so the rate limiter sees the real client IP.
|
|
331
|
+
|
|
332
|
+
### 5.2 Environment
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
cd server/credits
|
|
336
|
+
cp .env.example .env
|
|
337
|
+
openssl rand -hex 32 # FILE_SIGNING_SECRET
|
|
338
|
+
openssl rand -hex 32 # ADMIN_SECRET (operator grants)
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
This section is for the **standalone fallback** below. The folded deployment in
|
|
342
|
+
§5.0 reuses the backend's existing env (`DATABASE_URL`/`DB_*`,
|
|
343
|
+
`LICENSE_ENCRYPTION_KEY`, `STRIPE_*`, `ADMIN_SECRET`) plus `CREDITS_CRON_SECRET`
|
|
344
|
+
and `PUBLIC_BASE_URL`; `RENDERFUL_API_KEY` is the only generation key still
|
|
345
|
+
missing.
|
|
346
|
+
|
|
347
|
+
Required in production (the standalone service refuses to boot without them):
|
|
348
|
+
|
|
349
|
+
| Key | Value |
|
|
350
|
+
|---|---|
|
|
351
|
+
| `NODE_ENV` | `production` |
|
|
352
|
+
| `RENDERFUL_API_KEY` | live Renderful key, server-side only |
|
|
353
|
+
| `FILE_SIGNING_SECRET` | 64 hex chars, unique per environment |
|
|
354
|
+
| `PUBLIC_BASE_URL` | `https://credits.your-host` (no trailing slash) |
|
|
355
|
+
| `LICENSE_VALIDATE_URL` | `https://skills.animotion.click/api/license/validate` |
|
|
356
|
+
| `DATA_DIR` | absolute path, e.g. `/data` |
|
|
357
|
+
|
|
358
|
+
Also set: `CREDIT_USD=0.05`, `LICENSE_SKILL=awd-skill`, `LICENSE_PLAN=studio`, `STRIPE_SECRET_KEY`, `STRIPE_WEBHOOK_SECRET`, `ADMIN_SECRET`, `ALLOW_ORIGIN=https://skills.animotion.click`.
|
|
359
|
+
|
|
360
|
+
Leave `ALLOW_UNVERIFIED_LICENSES=false` — production validation rejects `true`.
|
|
361
|
+
|
|
362
|
+
Optional tuning: `MODELS_TTL_MS` (15 min), `*_TIMEOUT_MS` per asset type, `RATE_LIMIT_PER_MIN=60`, `MAX_OUTPUT_BYTES=209715200`, `FILE_URL_TTL_SEC=3600`.
|
|
363
|
+
|
|
364
|
+
### 5.3 Run it
|
|
365
|
+
|
|
366
|
+
Direct:
|
|
367
|
+
|
|
368
|
+
```bash
|
|
369
|
+
cd server/credits
|
|
370
|
+
npm start
|
|
371
|
+
curl -s localhost:8787/health | jq
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
Docker:
|
|
375
|
+
|
|
376
|
+
```bash
|
|
377
|
+
cd server/credits
|
|
378
|
+
docker compose up -d --build
|
|
379
|
+
docker compose ps
|
|
380
|
+
docker compose logs -f credits
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
Health must report `ok: true`, `renderful: true`, `stripe: true`, `stripeWebhook: true`, `licenseValidation: true`, `packs: 4`.
|
|
384
|
+
|
|
385
|
+
### 5.4 First live smoke test
|
|
386
|
+
|
|
387
|
+
Verify the deployment before you announce it. Two commands, no spend:
|
|
388
|
+
|
|
389
|
+
```bash
|
|
390
|
+
# 1. Is the .env fit to deploy? (catches placeholders, test keys, wrong hosts)
|
|
391
|
+
npm run check:deploy -- --env=server/credits/.env
|
|
392
|
+
|
|
393
|
+
# 2. Is the running deployment actually the code you think it is?
|
|
394
|
+
npm run check:deploy -- --url=https://skills.animotion.click
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
The live mode asserts `/health`, pack prices, the licence gate (401), the admin gate (401), both
|
|
398
|
+
post-checkout pages (HTML + `no-store`), the webhook route (400 on a forged signature — not 404 and
|
|
399
|
+
not 503), signed-file rejection (403 on the standalone layout; the folded passthrough layout serves
|
|
400
|
+
provider CDN URLs instead), and that an unknown path returns the proxy's JSON 404 rather
|
|
401
|
+
than a host page. Run it after every deploy: the 404 it checks for is exactly the bug that shipped
|
|
402
|
+
once already, and it is invisible until a buyer has paid.
|
|
403
|
+
|
|
404
|
+
Then exercise the API with a real licence key:
|
|
405
|
+
|
|
406
|
+
```bash
|
|
407
|
+
BASE=https://skills.animotion.click
|
|
408
|
+
KEY=YOUR_TEST_LICENSE_KEY
|
|
409
|
+
|
|
410
|
+
curl -s "$BASE/v1/credits/packs" | jq
|
|
411
|
+
curl -s "$BASE/v1/credits/models?kind=image" | jq '.models[:3]'
|
|
412
|
+
curl -s "$BASE/v1/credits/balance" -H "x-license-key: $KEY" | jq
|
|
413
|
+
|
|
414
|
+
curl -sX POST "$BASE/v1/credits/quote" \
|
|
415
|
+
-H "x-license-key: $KEY" -H "content-type: application/json" \
|
|
416
|
+
-d '{"type":"text-to-image","model":"flux-dev","prompt":"test"}' | jq
|
|
417
|
+
|
|
418
|
+
curl -sX POST "$BASE/v1/credits/generations" \
|
|
419
|
+
-H "x-license-key: $KEY" -H "content-type: application/json" \
|
|
420
|
+
-H "Idempotency-Key: smoke-$(date +%s)" \
|
|
421
|
+
-d '{"type":"text-to-image","model":"flux-dev","prompt":"a calm gradient sky"}' | jq
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
Poll `GET /v1/credits/generations/:id` until `completed`. The folded deployment defaults to
|
|
425
|
+
`passthrough`, so outputs are the provider's CDN URLs; if you enabled R2 the response carries
|
|
426
|
+
presigned URLs — fetch them **before** `expiresIn` runs out and re-request the job for a fresh one.
|
|
427
|
+
|
|
428
|
+
Grant a test balance (no Stripe needed):
|
|
429
|
+
|
|
430
|
+
```bash
|
|
431
|
+
# folded: /v1/credits/admin/grant · standalone: /v1/admin/grant
|
|
432
|
+
curl -sX POST "$BASE/v1/credits/admin/grant" \
|
|
433
|
+
-H "x-admin-secret: $ADMIN_SECRET" -H "content-type: application/json" \
|
|
434
|
+
-d '{"accountId":"acct_REPLACE","credits":20,"note":"smoke test","idempotencyKey":"smoke-01"}' | jq
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
### 5.5 Persistence and boot behaviour (standalone fallback)
|
|
438
|
+
|
|
439
|
+
- `DATA_DIR/credits.sqlite*` (WAL) holds accounts, ledger, jobs, intents, webhook ids.
|
|
440
|
+
- `DATA_DIR/files/` holds generated outputs.
|
|
441
|
+
- `DATA_DIR/renderful-models.json` is a 15-minute model-cache snapshot.
|
|
442
|
+
- `schema.sql` is applied idempotently at boot; there is no separate migration step.
|
|
443
|
+
- Mount `DATA_DIR` on a real volume. Docker Compose uses the `credits-data` volume; back that up, not the container.
|
|
444
|
+
|
|
445
|
+
---
|
|
446
|
+
|
|
447
|
+
## 6. Stripe
|
|
448
|
+
|
|
449
|
+
The service creates Checkout Sessions with **dynamic `price_data`** from its own pack catalogue — you do **not** need to create Stripe Products/Prices.
|
|
450
|
+
|
|
451
|
+
1. Stripe dashboard → Developers → API keys → copy the **secret** key into `STRIPE_SECRET_KEY`.
|
|
452
|
+
2. Developers → Webhooks → **Add endpoint**:
|
|
453
|
+
- URL (folded deployment): `https://skills.animotion.click/api/stripe/webhook`
|
|
454
|
+
- URL (standalone fallback): `https://credits.your-host/v1/stripe/webhook`
|
|
455
|
+
- Events: `checkout.session.completed`, `checkout.session.async_payment_succeeded`
|
|
456
|
+
- Copy the signing secret into `STRIPE_WEBHOOK_SECRET`. The folded endpoint is shared
|
|
457
|
+
with plan subscriptions; only sessions whose id starts `chk_` (credit packs) are
|
|
458
|
+
applied to the ledger.
|
|
459
|
+
3. Redeploy/restart; `GET /health` must show `stripe: true` and `stripeWebhook: true`
|
|
460
|
+
(folded: under `/health.credits`). Failures in the ledger return 500 so Stripe
|
|
461
|
+
re-delivers; grants are idempotent per event id.
|
|
462
|
+
4. Local test:
|
|
463
|
+
|
|
464
|
+
```bash
|
|
465
|
+
stripe login
|
|
466
|
+
stripe listen --forward-to localhost:5000/api/stripe/webhook # folded
|
|
467
|
+
# standalone: stripe listen --forward-to localhost:8787/v1/stripe/webhook
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
5. **Full end-to-end test (test mode, $0).** Do this before launch and after any change to the
|
|
471
|
+
checkout, webhook or ledger code:
|
|
472
|
+
|
|
473
|
+
```bash
|
|
474
|
+
# one time: paste a TEST-mode key into server/credits/.env.qa
|
|
475
|
+
# Dashboard -> Developers -> API keys -> toggle "Test mode" -> copy sk_test_…
|
|
476
|
+
npm run qa:stripe
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
`qa:stripe` starts `stripe listen` to capture a real `whsec_`, boots the proxy with it, creates a
|
|
480
|
+
Starter session, prints a `PAY NOW →` URL, and waits. Pay with `4242 4242 4242 4242`, any future
|
|
481
|
+
expiry, any CVC. It then asserts that Stripe echoes our amount/currency/metadata/success and cancel
|
|
482
|
+
URLs, that Stripe's own signed webhook granted exactly 100 credits, that the ledger holds one
|
|
483
|
+
`purchase` row, that the landing page says the credits are in the balance, and that a refund leaves
|
|
484
|
+
the balance untouched. The harness refuses `sk_live_`/`rk_live_` keys outright.
|
|
485
|
+
|
|
486
|
+
**Post-checkout pages:** the proxy serves `GET /checkout/success?session_id=…` and
|
|
487
|
+
`GET /checkout/cancel` itself (public, HTML, `no-store`, `default-src 'none'` CSP). The success page
|
|
488
|
+
names the pack and credit count and refreshes every 3s until the webhook lands, so a buyer never sees
|
|
489
|
+
a 404 and never has to guess whether the grant arrived. If you set `STRIPE_SUCCESS_URL` /
|
|
490
|
+
`STRIPE_CANCEL_URL` to your store's own pages instead, the proxy serves nothing after payment and the
|
|
491
|
+
store is responsible for confirming the grant.
|
|
492
|
+
|
|
493
|
+
6. Production verification: buy the cheapest pack with a real card, confirm the ledger entry `purchase +100`, then refund it in Stripe (see policy below).
|
|
494
|
+
|
|
495
|
+
**Webhook guarantees:** signature verified against the raw body, timestamp tolerance `STRIPE_TOLERANCE_SEC`, deduped by event id, amount checked against the pack price, and one grant per checkout intent. A wrong `STRIPE_WEBHOOK_SECRET` returns `400 Invalid Stripe signature`; a rewritten body (compression middleware) produces the same error.
|
|
496
|
+
|
|
497
|
+
**Refund policy:** a Stripe refund does **not** automatically claw back credits. Decide the policy before launch. Default recommendation: refunds within 7 days only if unused; for used credits, refund the unused remainder as goodwill. The admin API only grants positive credits, so a correction requires a manual, backed-up SQL update or an account-level block.
|
|
498
|
+
|
|
499
|
+
---
|
|
500
|
+
|
|
501
|
+
## 7. Asset generation (editor managed lane — Renderful only)
|
|
502
|
+
|
|
503
|
+
**Scope:** this section describes the **AWD Editor's managed generation transport** (the legacy `server/credits/` proxy). The **shipped skill does not generate assets through Renderful** — it uses only the four free-lane sources (client brand files as inputs, hand-drawn SVG/procedural, Crucible local 3D stills, and the user's own agent-native AI models), with no credits, balance, top-ups or proxy. Editor generation is paid from the **unified editor wallet** ($25/month on `awd.sign` → 400 AI credits/month + non-expiring top-ups, monthly-first spend, admin direct-API unmetered bypass) and carried over the managed transport described here.
|
|
504
|
+
|
|
505
|
+
Editor managed-lane outputs — image, audio, video, 3D mesh — are produced by **Renderful through the legacy credits proxy**. There is no local renderer in the editor: the old Blender path, the add-on and its QA scripts were removed. Client **brand files** (logo, brand photography, product shots) enter as inputs and are never generated.
|
|
506
|
+
|
|
507
|
+
Consequences for operations:
|
|
508
|
+
|
|
509
|
+
- The release machine needs **no GPU and no Blender** — only Node and network access to the proxy.
|
|
510
|
+
- On this **legacy proxy's own ledger**, generation is paid **exclusively with its prepaid top-up packs** (no monthly plan credits in that ledger). A zero or short balance is a **hard stop** for that lane: the editor's canvas shows the top-up gate (pack table + `POST /v1/credits/checkout` → Stripe). **This is not the editor plan's 400-credit allowance** — see the ownership note at the top of this runbook and `target-state-plan.md` §7.
|
|
511
|
+
- Model ids are pinned to the verified Renderful allowlist (`awd-skill/references/asset-builder.md`); `npm run release:check` fails on anything off-list or mispriced.
|
|
512
|
+
|
|
513
|
+
### Proxy health check (release machine)
|
|
514
|
+
|
|
515
|
+
```bash
|
|
516
|
+
curl -s "$AWD_CREDITS_API_URL/v1/credits/balance" -H "x-license-key: $TEST_KEY" | jq
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
Expect `200` with a numeric balance. `401` = bad/missing key; `402` on a generation = insufficient balance in the legacy proxy ledger (the editor canvas must show the top-up gate); `5xx` = upstream problem (balances/history keep working, generations refund).
|
|
520
|
+
|
|
521
|
+
### Failure ladder (QA must confirm)
|
|
522
|
+
|
|
523
|
+
Cheap model → smaller batch → report the failed slots to the user. Every retry is **re-quoted and re-gated**; each step stays on the allowlist and inside the proxy. There is no zero-credit lane to fall back to.
|
|
524
|
+
|
|
525
|
+
---
|
|
526
|
+
|
|
527
|
+
## 8. End-to-end QA
|
|
528
|
+
|
|
529
|
+
Run the matrix before every public release, and at least monthly against production.
|
|
530
|
+
|
|
531
|
+
### 8.0 Automated coverage (no spend, no live Stripe)
|
|
532
|
+
|
|
533
|
+
Four scripts run the parts of the matrix that do not need a real card or a paid generation:
|
|
534
|
+
|
|
535
|
+
```bash
|
|
536
|
+
npm run qa:credits # real proxy HTTP + SQLite against a local fake Renderful
|
|
537
|
+
npm run qa:catalog # read-only drift check against the live Renderful catalogue
|
|
538
|
+
npm run qa:stripe # real Stripe test-mode checkout -> webhook -> grant -> refund
|
|
539
|
+
npm run qa # unit tests + credits + catalog (no Stripe required)
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
`qa:stripe` is the only one that talks to Stripe. It needs the Stripe CLI, a test-mode secret key in
|
|
543
|
+
`server/credits/.env.qa`, and one manual card entry (`4242 4242 4242 4242`). It proves the pieces the
|
|
544
|
+
offline harness cannot: that Stripe accepts our session parameters, that a real Stripe-signed webhook
|
|
545
|
+
reaches the proxy and grants the pack, that the buyer's landing page confirms it, and that a refund
|
|
546
|
+
does not move the balance. It hard-refuses live keys, so it cannot charge money.
|
|
547
|
+
|
|
548
|
+
`qa:credits` boots the actual proxy (`createApp`, real DB, pricing, storage, signed URLs, Stripe
|
|
549
|
+
signature verifier) on an ephemeral port with `RENDERFUL_BASE` pointed at a fake upstream whose USD
|
|
550
|
+
ranges match the live catalogue. It asserts, in order: health/pack/catalogue shape; unknown model and
|
|
551
|
+
type rejection; min–max quote and reserve-max; `402 payment_required` on a zero balance with no
|
|
552
|
+
ledger row; `401` without a licence key; admin-grant auth and idempotency; reserve before submit;
|
|
553
|
+
`Idempotency-Key` replay; on-demand polling; output download; settle with no drift; refund of the
|
|
554
|
+
quote difference; overage settle above the quote; full refund on provider failure and on output
|
|
555
|
+
download failure; signed URL `200`/`HEAD`/`Range 206`; tampered, expired and traversal paths refused;
|
|
556
|
+
job re-read re-signing a working URL; concurrent jobs never overdrawing; and every Stripe webhook
|
|
557
|
+
branch (grant, replay by event id, second event for a paid intent, `client_reference_id`, bad
|
|
558
|
+
signature, stale timestamp, rewritten body, amount mismatch, unpaid session, missing/unknown intent,
|
|
559
|
+
unrelated event). It fails the process on any assertion.
|
|
560
|
+
|
|
561
|
+
`qa:catalog` parses the Image/Audio/3D/Video tables in `awd-skill/references/asset-credits.md` plus the
|
|
562
|
+
`VERIFIED_MODELS` allowlist in `scripts/release-check.js`, then compares each id with
|
|
563
|
+
`GET https://api.renderful.ai/api/v1/models`: id present for that media kind, live `cost.min/max`
|
|
564
|
+
equal to the documented range, and documented credits equal `ceil(usd / $0.05)`. Run it after any
|
|
565
|
+
Renderful catalogue change; `--tolerance=0.05` relaxes the price comparison.
|
|
566
|
+
|
|
567
|
+
Last run (2026-10-26): `qa:credits` **33/33**, `qa:catalog` **23/23 documented models**, 580 live
|
|
568
|
+
models (575 priced), `qa:stripe` **9/9** (test mode: session accepted, real webhook delivered,
|
|
569
|
+
`purchase +100`, landing page confirmed, refund honoured), compatible with `node:sqlite` on Node 25.9.
|
|
570
|
+
|
|
571
|
+
What still needs a human before launch:
|
|
572
|
+
|
|
573
|
+
| Check | Why it cannot be automated here |
|
|
574
|
+
|---|---|
|
|
575
|
+
| Real checkout in **test mode**: `npm run qa:stripe`, pay `4242…`, watch `purchase +100`, refund | needs a test-mode key and one card entry; automatable but not unattended |
|
|
576
|
+
| One live purchase with a real card, then refund | proves the live account end to end; costs Stripe's non-refundable fee and leaves an unrevokable grant |
|
|
577
|
+
| Stripe dashboard webhook delivery to the deployed proxy | needs a public HTTPS endpoint registered in Stripe |
|
|
578
|
+
| One paid generation per kind (image/audio/video/3D) | spends real Renderful credit; quote-only checks prove the pricing path |
|
|
579
|
+
| Short-balance hard stop on the **editor managed lane** | zero balance in the legacy proxy ledger → top-up gate shown, generation stops, no fallback asset appears (the skill has no credits) |
|
|
580
|
+
|
|
581
|
+
### 8.1 Install + entry points
|
|
582
|
+
|
|
583
|
+
| Case | Expected |
|
|
584
|
+
|---|---|
|
|
585
|
+
| Fresh HOME, `--agent=opencode`, remote payload | skill + 31 commands installed, `detect` says `INSTALLED` |
|
|
586
|
+
| `--home` throwaway + `--force` | idempotent reinstall |
|
|
587
|
+
| No key at all | every department, mode A–D and the free-lane `/awd-assets` work with no gate |
|
|
588
|
+
| Bad/expired Template key | Mode E/F gate blocks those stages only; departments and free-lane assets stay available |
|
|
589
|
+
| Valid Template key | passes the Mode E/F gate; credits are not a skill concept |
|
|
590
|
+
|
|
591
|
+
(`AWD_CREDITS_API_URL` is **not a skill installer setting** — the skill has no credits proxy; it belongs only to the editor's legacy managed generation transport in §7.)
|
|
592
|
+
|
|
593
|
+
Entry points: `/awd-assets` · Design **4.3** · Mode E **E.3** · Mode C asset protocol · a plain request in Modes A/B/D.
|
|
594
|
+
|
|
595
|
+
### 8.2 Transports (editor managed lane only)
|
|
596
|
+
|
|
597
|
+
These rows describe the **AWD Editor's legacy managed generation transport**, not the skill. Editor billing authority is the $25/month / 400-credit wallet in the ownership note above.
|
|
598
|
+
|
|
599
|
+
| Setup | Expected |
|
|
600
|
+
|---|---|
|
|
601
|
+
| `AWD_CREDITS_API_URL` set | managed calls only; no `RENDERFUL_API_KEY` requested |
|
|
602
|
+
| No proxy URL / no license key | **no editor managed-lane generation** — the editor canvas prints the auth/top-up gate and stops; no direct-Renderful fallback (the skill's free-lane assets are unaffected) |
|
|
603
|
+
| Proxy configured, user-supplied key present | proxy wins; a user-supplied key is never used or stored |
|
|
604
|
+
| `AWD_CREDITS_API_URL` empty string | treated as unset → same hard stop as above |
|
|
605
|
+
|
|
606
|
+
### 8.3 Credit paths
|
|
607
|
+
|
|
608
|
+
The first twelve items below are asserted end-to-end by `npm run qa:credits` (§8.0); the checkout
|
|
609
|
+
link, live Stripe delivery and a real paid generation remain manual.
|
|
610
|
+
|
|
611
|
+
- [ ] Balance 0 → quote shows the range and the shortfall → gate offers a pack → checkout link works.
|
|
612
|
+
- [ ] `402 payment_required` on create when balance < max reservation.
|
|
613
|
+
- [ ] Reserve = **max**, settle = actual, difference refunded (`reserve` then `settle`/`refund` in history).
|
|
614
|
+
- [ ] Provider failure → full refund, status `failed`, `charged: 0`.
|
|
615
|
+
- [ ] Timeout (per asset type) → full refund.
|
|
616
|
+
- [ ] Output download failure → full refund.
|
|
617
|
+
- [ ] Same `Idempotency-Key` twice → one job, `replay: true`, no double charge.
|
|
618
|
+
- [ ] Two concurrent jobs with only enough balance for one → one succeeds, one `402`; never a negative balance.
|
|
619
|
+
- [ ] Unknown model id → rejected (unless `ALLOW_UNKNOWN_MODELS=true`, which production must not use).
|
|
620
|
+
- [ ] Signed URL after expiry → `403`; re-read the job → fresh URL works.
|
|
621
|
+
- [ ] Video `Range` request → `206` with correct bytes.
|
|
622
|
+
- [ ] Stripe webhook replayed → no double credit; amount mismatch → ignored.
|
|
623
|
+
- [ ] Empty balance blocks generation with the top-up gate; no asset is written and no fallback asset appears.
|
|
624
|
+
|
|
625
|
+
### 8.4 Asset coverage (editor managed lane)
|
|
626
|
+
|
|
627
|
+
All editor managed-lane asset kinds ship through one route — Renderful via the legacy proxy and the editor wallet. Client brand files are inputs only. The skill's free-lane sources (brand files, SVG/procedural, Crucible stills, your own agent-native AI models) are not generation and spend no credits.
|
|
628
|
+
|
|
629
|
+
| Kind | Model | Credits |
|
|
630
|
+
|---|---|---|
|
|
631
|
+
| Image | `flux-dev` text→image | 1–2 |
|
|
632
|
+
| Voice | `speech-2.6-turbo` | 2–12 |
|
|
633
|
+
| Music/SFX | `music-2.5` / text-to-audio | 2–12 |
|
|
634
|
+
| Video | `wan-2.6` text→video | 10–20 |
|
|
635
|
+
| 3D | `hunyuan3d-v3` mesh | 8–30 |
|
|
636
|
+
|
|
637
|
+
For **editor managed-lane generation** there is no local lane or proxied-SVG fallback row: an unaffordable generation stops at the top-up gate. The skill's free-lane SVG/procedural source is a legitimate free source, not a fallback for paid generation.
|
|
638
|
+
|
|
639
|
+
### 8.5 Ingest and playback QA
|
|
640
|
+
|
|
641
|
+
- [ ] File lands at the exact slot path, correct extension and codec.
|
|
642
|
+
- [ ] Image optimized (WebP where appropriate); video muted/loop/poster; audio has controls; `.glb` uses Draco and loads in the target viewer.
|
|
643
|
+
- [ ] Budgets respected (hero video size/duration; total page weight).
|
|
644
|
+
- [ ] `prefers-reduced-motion` and keyboard fallbacks exist.
|
|
645
|
+
- [ ] Controls (play/scrub, orbit/zoom/reset, mute, scroll-linked rates) are implemented by the AnimotionJS agentic skill from the brief (`references/motion-toolkit.md`) and tested.
|
|
646
|
+
- [ ] `build-state.md` records route, model, reserved/charged credits and balance after.
|
|
647
|
+
|
|
648
|
+
### 8.6 Failure ladder (never fake an asset)
|
|
649
|
+
|
|
650
|
+
For each of: no proxy, proxy 5xx, validator down, empty/short balance, Renderful down, bad model id — the skill may re-quote and retry on a cheaper allowlisted model, shrink the batch (re-gated), or ask the user to buy a top-up. It must **not** substitute a user file for a non-brand slot, keep a demo asset, draw an SVG, call another generator, or skip the slot. If the asset stage cannot proceed, it stops there and says so; the rest of the build continues.
|
|
651
|
+
|
|
652
|
+
---
|
|
653
|
+
|
|
654
|
+
## 9. Monitoring and operations
|
|
655
|
+
|
|
656
|
+
### Health and alerts
|
|
657
|
+
|
|
658
|
+
- `GET /health` every 30 s; alert on non-2xx, `ok != true`, or a configured integration flipping to `false`.
|
|
659
|
+
- Alert on 5xx rate, `402` spikes (pricing/balance bug or abuse), webhook 4xx, job failures > 5%, and disk > 80%.
|
|
660
|
+
- Watch SQLite: `credits.sqlite-wal` growth, `database is locked` errors, volume latency.
|
|
661
|
+
- Log lines are structured JSON (`LOG_LEVEL=info`); bearer tokens and Stripe keys are redacted.
|
|
662
|
+
|
|
663
|
+
### Backups (nightly, and before every deploy)
|
|
664
|
+
|
|
665
|
+
```bash
|
|
666
|
+
# consistent SQLite copy (service may keep running)
|
|
667
|
+
sqlite3 "$DATA_DIR/credits.sqlite" ".backup '/backups/credits-$(date +%F).sqlite'"
|
|
668
|
+
|
|
669
|
+
# outputs
|
|
670
|
+
rsync -a "$DATA_DIR/files/" "/backups/files-$(date +%F)/"
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
Restore drill (quarterly): stop the service, restore DB + files to a scratch `DATA_DIR`, boot on another port, check `balance` and one signed URL. A backup you have not restored is not a backup.
|
|
674
|
+
|
|
675
|
+
### Reconciliation
|
|
676
|
+
|
|
677
|
+
- Daily: sum `reserve/settle/refund` per day from `/v1/credits/history` (or SQL) against Renderful spend. Differences mean pricing or settlement drift.
|
|
678
|
+
- Weekly: Stripe payouts vs `purchase` ledger entries.
|
|
679
|
+
- On a price change: refresh models (`GET /v1/credits/models`), sanity-check the quoted range for the default models, and update the skill's price tables only when Renderful's catalog changes (the release gate enforces the math).
|
|
680
|
+
|
|
681
|
+
### Operator tasks
|
|
682
|
+
|
|
683
|
+
| Task | How |
|
|
684
|
+
|---|---|
|
|
685
|
+
| Manual top-up / support credit | `POST /v1/admin/grant` with `x-admin-secret`, positive integer credits, stable `idempotencyKey` |
|
|
686
|
+
| Fallback checkout paid externally | Verify payment, then grant with the order id as the idempotency key |
|
|
687
|
+
| Stuck job | Check `/health` and logs; jobs fail + refund at their type timeout. Never edit balances by hand |
|
|
688
|
+
| Suspected key leak | Rotate the license key at the validator; credits are keyed by licence **email**, so the old key stops authenticating while the balance follows the email |
|
|
689
|
+
| Balance looks wrong | `GET /v1/credits/balance` reports `balance`; only top-up purchases (`chk_` checkout intents) and `POST /v1/admin/grant` should ever change it — check Stripe for the matching `checkout.session.completed` |
|
|
690
|
+
| Secret rotation | Update `.env`, restart; rotate `FILE_SIGNING_SECRET` last (it invalidates outstanding file URLs) |
|
|
691
|
+
|
|
692
|
+
### Scaling notes
|
|
693
|
+
|
|
694
|
+
One process + SQLite is right for a small business. Before running replicas: move the ledger to Postgres, use a shared output store (S3/R2) with signed URLs, and put the rate limiter at the edge. Do not mount one SQLite file on two writers.
|
|
695
|
+
|
|
696
|
+
---
|
|
697
|
+
|
|
698
|
+
## 10. Rollback
|
|
699
|
+
|
|
700
|
+
### Skill payload (bad content, bad references)
|
|
701
|
+
|
|
702
|
+
1. Put the previous `awd.source` URL back in `package.json` (old payloads are immutable and still online).
|
|
703
|
+
2. Publish a **patch** npm version (e.g. `2.3.2`) — npm versions are permanent.
|
|
704
|
+
3. Tell affected users: `npx awd-skill@latest install --force`.
|
|
705
|
+
4. Only delete the bad payload file after the previous URL is restored everywhere.
|
|
706
|
+
|
|
707
|
+
### npm package (bad installer)
|
|
708
|
+
|
|
709
|
+
```bash
|
|
710
|
+
npm dist-tag add awd-skill@2.2.1 latest # move `latest` back
|
|
711
|
+
npm deprecate awd-skill@2.3.1 "broken installer — use 2.2.1 or 2.3.2"
|
|
712
|
+
```
|
|
713
|
+
|
|
714
|
+
You cannot unpublish after 72 hours; a deprecated version + a fixed patch is the Rollback path.
|
|
715
|
+
|
|
716
|
+
### Credits proxy
|
|
717
|
+
|
|
718
|
+
1. `git checkout <previous-tag>` and redeploy, or deploy the previous image tag.
|
|
719
|
+
2. `schema.sql` is additive/idempotent — no down-migration is needed for the current schema.
|
|
720
|
+
3. If data is corrupted: stop the service, restore the last DB + files backup together, restart, then replay missing Stripe events from the dashboard (idempotent by event id).
|
|
721
|
+
4. If Renderful is the problem: the proxy keeps serving balances/history; new generations return upstream errors and refund. The skill reports the failure and stops the asset stage — it never substitutes a local render or an ungenerated file.
|
|
722
|
+
|
|
723
|
+
### Stripe
|
|
724
|
+
|
|
725
|
+
- Disable a misbehaving webhook endpoint in the dashboard (events stay queued for a while) or rotate `STRIPE_WEBHOOK_SECRET` and restart.
|
|
726
|
+
- Refund charges in Stripe, then reconcile credits per policy. Never bulk-edit balances without a fresh backup.
|
|
727
|
+
|
|
728
|
+
### Assets (no local renderer)
|
|
729
|
+
|
|
730
|
+
There is nothing local to roll back for **editor managed-lane generation**: every such asset is a Renderful generation held by the proxy. If the proxy or Renderful regresses, restore the proxy (§ Credits proxy) and re-run the generation — failed/timeout jobs refund automatically. Do not reintroduce an unmetered Renderful path. (The skill's free-lane sources are a separate, always-free capability, not a generation fallback.)
|
|
731
|
+
|
|
732
|
+
---
|
|
733
|
+
|
|
734
|
+
## 11. Incident playbooks
|
|
735
|
+
|
|
736
|
+
| Symptom | First move |
|
|
737
|
+
|---|---|
|
|
738
|
+
| Every generation `503 Could not verify your license` | Validator down and no cached grant. Restore the validator; do **not** flip `ALLOW_UNVERIFIED_LICENSES` in production |
|
|
739
|
+
| `402` for everyone | Pricing/catalog change made the reservation larger than balances; check `/v1/credits/models`, `CREDIT_USD`, `PRICING_BASIS` |
|
|
740
|
+
| Jobs stuck `queued` | Renderful latency or a rejected key at create. Check logs/`/health`; timeouts refund automatically |
|
|
741
|
+
| Signed URLs `403` | Expired or `FILE_SIGNING_SECRET` rotated. Re-read the job for a fresh URL |
|
|
742
|
+
| Webhook `400 Invalid Stripe signature` | Wrong secret, or a proxy rewrote the raw body |
|
|
743
|
+
| Credits double-granted | Stop the webhook endpoint, inspect ledger/intents; dedupe by event and intent id. Restore from backup if the ledger is inconsistent |
|
|
744
|
+
| Proxy disk full | Generated files fill `DATA_DIR/files/`. Apply a retention job (e.g. delete completed job files older than 30 days after delivery), then expand the volume |
|
|
745
|
+
|
|
746
|
+
---
|
|
747
|
+
|
|
748
|
+
## 12. Release checklist
|
|
749
|
+
|
|
750
|
+
Copy this into the release issue and tick it.
|
|
751
|
+
|
|
752
|
+
**Build**
|
|
753
|
+
|
|
754
|
+
- [ ] `npm run release:check` green (tests included)
|
|
755
|
+
- [ ] `package.json` version bumped
|
|
756
|
+
- [ ] `npm run release:build` → `skilltar.gz` + `dist/skill-<version>.json`
|
|
757
|
+
- [ ] `npm run release:verify` green
|
|
758
|
+
- [ ] `npm pack --dry-run` → 23 files, no `awd-skill/`, no `server/`
|
|
759
|
+
|
|
760
|
+
**Publish**
|
|
761
|
+
|
|
762
|
+
- [ ] New payload URL uploaded, SHA matches, `verify-release --source=<url>` green
|
|
763
|
+
- [ ] `awd.source` updated and committed
|
|
764
|
+
- [ ] Skills-server tree deployed (§3.6); gated router fetch contains `ASSET BUILDER`
|
|
765
|
+
- [ ] AI Studio router re-pasted in a new chat; freshness check passes
|
|
766
|
+
- [ ] `npm publish` done; `npm view … version` matches
|
|
767
|
+
- [ ] Clean-HOME `npx … install` smoke test (skill + commands + credits config)
|
|
768
|
+
- [ ] Git tag + GitHub release with the payload SHA and the changelog
|
|
769
|
+
|
|
770
|
+
**Deploy**
|
|
771
|
+
|
|
772
|
+
- [ ] Proxy `.env` complete; production validation passes
|
|
773
|
+
- [ ] `/health` shows renderful + stripe + stripeWebhook + licenseValidation + 4 packs
|
|
774
|
+
- [ ] Stripe webhook endpoint live and a test purchase credits the balance
|
|
775
|
+
- [ ] Short-balance and no-proxy paths verified: top-up gate shown, asset stage stops, no fallback asset
|
|
776
|
+
- [ ] Backup taken before deploy; restore drill current
|
|
777
|
+
|
|
778
|
+
**QA**
|
|
779
|
+
|
|
780
|
+
- [ ] Transport matrix (managed / no-proxy hard stop) green
|
|
781
|
+
- [ ] Credit paths: gate, 402, reserve/settle/refund, idempotency, concurrency, expiry
|
|
782
|
+
- [ ] Image, voice, music/SFX, video and 3D each generate through the proxy
|
|
783
|
+
- [ ] Playback + reduced motion + budgets checked
|
|
784
|
+
- [ ] Failure ladder never produces a placeholder, demo asset, SVG, external-generator file or skipped required slot
|
|
785
|
+
|
|
786
|
+
---
|
|
787
|
+
|
|
788
|
+
## Appendix A — environment reference
|
|
789
|
+
|
|
790
|
+
### Proxy
|
|
791
|
+
|
|
792
|
+
| Variable | Default | Notes |
|
|
793
|
+
|---|---|---|
|
|
794
|
+
| `NODE_ENV` | — | `production` enables strict config validation |
|
|
795
|
+
| `PORT` / `HOST` | `8787` / `0.0.0.0` | Bind localhost when TLS is terminated in front |
|
|
796
|
+
| `PUBLIC_BASE_URL` | — | Required; used in signed file URLs |
|
|
797
|
+
| `DATA_DIR` | `./data` | SQLite + files + model cache |
|
|
798
|
+
| `RENDERFUL_API_KEY` | — | Required for generation |
|
|
799
|
+
| `RENDERFUL_BASE` | `https://api.renderful.ai/api/v1` | Override only for a proxy |
|
|
800
|
+
| `CREDIT_USD` | `0.05` | 1 credit = $0.05 of raw spend |
|
|
801
|
+
| `PRICING_BASIS` | `max` | Reserve the max of the quote |
|
|
802
|
+
| `ALLOW_UNKNOWN_MODELS` | `false` | Never enable in production |
|
|
803
|
+
| `LICENSE_VALIDATE_URL` | — | Required |
|
|
804
|
+
| `LICENSE_SKILL` / `LICENSE_PLAN` | `awd-skill` / `studio` | Validator request |
|
|
805
|
+
| `LICENSE_CACHE_MS` | `3600000` | Positive/negative cache |
|
|
806
|
+
| `STRIPE_SECRET_KEY` | — | Enables Checkout |
|
|
807
|
+
| `STRIPE_WEBHOOK_SECRET` | — | Enables `/v1/stripe/webhook` |
|
|
808
|
+
| `STRIPE_SUCCESS_URL` / `STRIPE_CANCEL_URL` | store URLs | Checkout redirects |
|
|
809
|
+
| `CHECKOUT_FALLBACK_URL` | store URL | Manual mode when Stripe is absent |
|
|
810
|
+
| `FILE_SIGNING_SECRET` | — | Required; 32 random bytes (hex) |
|
|
811
|
+
| `FILE_URL_TTL_SEC` | `3600` | Signed-URL lifetime |
|
|
812
|
+
| `MAX_OUTPUT_BYTES` | `209715200` | Output size cap |
|
|
813
|
+
| `ADMIN_SECRET` | — | Enables `/v1/admin/grant` |
|
|
814
|
+
| `RATE_LIMIT_ENABLED` / `RATE_LIMIT_PER_MIN` | `true` / `60` | In-memory, per process |
|
|
815
|
+
| `POLL_INTERVAL_MS` / `MAX_POLL_BATCH` | `5000` / `5` | Background job poller |
|
|
816
|
+
| `TIMEOUT_*_MS` | image 120s · audio 180s · 3D 300s · video 600s | Failure → refund |
|
|
817
|
+
|
|
818
|
+
### Editor (design-agent LLM)
|
|
819
|
+
|
|
820
|
+
| Variable | Default | Notes |
|
|
821
|
+
|---|---|---|
|
|
822
|
+
| `AWD_LLM_MODELS` | — | Required JSON model catalogue; an empty list fails closed |
|
|
823
|
+
| `AWD_LLM_PROVIDER` | auto | `renderful`, `openai-compatible`, or `freellmapi` (opt-in); auto-detects from the configured keys |
|
|
824
|
+
| `AWD_LLM_BASE_URL` | Renderful base when provider is Renderful | OpenAI-compatible base, or the Renderful generations base |
|
|
825
|
+
| `AWD_LLM_API_KEY` | — | OpenAI-compatible key; not needed when Renderful supplies the key |
|
|
826
|
+
| `RENDERFUL_API_KEY` | — | Also serves as the design-agent LLM key on the Renderful transport |
|
|
827
|
+
| `RENDERFUL_BASE` | `https://api.renderful.ai/api/v1` | Renderful generations base (`POST /generations`, `type: "text-to-text"`) |
|
|
828
|
+
| `AWD_LLM_POLL_MS` / `AWD_LLM_TIMEOUT_MS` | `1500` / `60000` | Async-generation poll interval and deadline |
|
|
829
|
+
|
|
830
|
+
The editor loads this file with `--env-file-if-exists=.env` (or `server/src/env.mjs`); host environment variables always win. Renderful's response is normalised to the OpenAI shape the op parser expects. No `/chat/completions` route is assumed for Renderful.
|
|
831
|
+
|
|
832
|
+
### FreeLLMAPI provider (editor host only — not enabled)
|
|
833
|
+
|
|
834
|
+
**Do not enable FreeLLMAPI for this release.** No env var, admin config or skill lane turns it on; it is not a second paid/free path around the one $25/month plan and it is never presented to skill users. The section below documents the host-only code path for maintainers only.
|
|
835
|
+
|
|
836
|
+
`https://github.com/tashfeenahmed/freellmapi` is an **opt-in** router for the
|
|
837
|
+
`awd.design` text agent, `awd.generate` media jobs and coding-agent runs. It is
|
|
838
|
+
free-tier, local-first, single-user and explicitly has **no production SLA**.
|
|
839
|
+
Do not make it the only provider for paying customers: keep
|
|
840
|
+
`RENDERFUL_API_KEY` and/or the managed credits proxy configured as the paid
|
|
841
|
+
fallback, and let users choose `freellmapi:*` models deliberately.
|
|
842
|
+
|
|
843
|
+
| Variable | Default | Notes |
|
|
844
|
+
|---|---|---|
|
|
845
|
+
| `AWD_FREELLMAPI_ENABLED` | — | Opt-in flag. `AWD_LLM_PROVIDER=freellmapi` also enables it. |
|
|
846
|
+
| `AWD_FREELLMAPI_BASE_URL` | `http://127.0.0.1:3001/v1` | Docker/source default. Desktop app: `http://127.0.0.1:31415/v1`. |
|
|
847
|
+
| `AWD_FREELLMAPI_API_KEY` | — | Unified `freellmapi-…` key. Host-only; aliases `FREELLMAPI_BASE_URL` / `FREELLMAPI_API_KEY` are accepted by the Node origin. |
|
|
848
|
+
|
|
849
|
+
**Desktop setup without a Launcher `.env`.** On desktop, curated `freellmapi:*`
|
|
850
|
+
models are enabled by default so they appear in the picker with no manual setup.
|
|
851
|
+
If a local FreeLLMAPI router is running (desktop default
|
|
852
|
+
`http://127.0.0.1:31415/v1`), selecting a free model uses the zero-AWD-credit
|
|
853
|
+
lane; if the router is not running or needs a key, the call returns a clear
|
|
854
|
+
connection/config error. Set `AWD_FREELLMAPI_ENABLED=false` or disable it in
|
|
855
|
+
**Connections → AI connections** to opt out.
|
|
856
|
+
|
|
857
|
+
An admin can also save FreeLLMAPI URL/key, Renderful key/model catalogue, and a
|
|
858
|
+
GitHub OAuth App client ID once in `awd.design` under **Connections → AI
|
|
859
|
+
connections**. The origin stores them in `local-ai.json` under `AWD_EDITOR_DATA`
|
|
860
|
+
(on desktop, `%APPDATA%\click.animotion.awd-editor-studio\editor-data`), applies
|
|
861
|
+
them at startup and immediately after a save, and all accounts on that desktop
|
|
862
|
+
see the configured models. `GET /api/local-ai` returns only booleans/counts —
|
|
863
|
+
never the router URL, API key, or token — and `PUT /api/local-ai` is admin-only.
|
|
864
|
+
Explicit host env values and an active hosted pairing take priority over these
|
|
865
|
+
editor-saved fallback values, so `applyLocalAiConfig()` tracks which process-env
|
|
866
|
+
keys it injected and never clears or replaces a key owned by `.env` or pairing.
|
|
867
|
+
|
|
868
|
+
**Security boundary.** The router URL and unified key are read only by the Node
|
|
869
|
+
origin (`awd-editor/shared/freellmapi.mjs` + `awd-editor/server/src/freellmapi-client.mjs`).
|
|
870
|
+
They are never returned by `/api/models`, `/api/settings`, the redacted
|
|
871
|
+
`/api/local-ai` GET, the desktop pairing payload, or the Cloudflare Worker.
|
|
872
|
+
`scripts/set-worker-secrets.mjs` deliberately
|
|
873
|
+
excludes them. The Worker has only the non-secret `AWD_FREELLMAPI_ENABLED` var
|
|
874
|
+
in `wrangler.toml`, used to expose the curated catalog and the same zero-credit
|
|
875
|
+
quote. A Worker cannot reach a desktop's `127.0.0.1:31415` or a local
|
|
876
|
+
Docker `:3001`; all generation is executed by the Node origin behind the tunnel.
|
|
877
|
+
Hosted pairing (`applyHostedEnv()`) preserves the host's FreeLLMAPI provider,
|
|
878
|
+
models, base URL and key instead of overwriting them from the paired catalogue.
|
|
879
|
+
|
|
880
|
+
**Metering and limits.** Curated `freellmapi:*` models are genuinely free in
|
|
881
|
+
the editor wallet: text and media quotes return `0` credits with `free: true`,
|
|
882
|
+
no reservation is held for media, and design-agent reservations settle at zero
|
|
883
|
+
with a zero-credit audit row. This is host-only legacy behaviour, not a shipped lane and not a way around the one-plan gate.
|
|
884
|
+
Paid Renderful/managed models keep the authoritative meter: text uses the
|
|
885
|
+
configured per-model USD/M rates with the 2-credit Agent floor; media uses the
|
|
886
|
+
verified per-output USD prices converted at 1 credit = $0.05, with reservations
|
|
887
|
+
settled at the quote and refunded on failure. Only curated, prefixed ids are
|
|
888
|
+
exposed (`freellmapi:auto`, `auto:fast`,
|
|
889
|
+
`auto:smart`, `auto:cheap`, `auto:reliable`, `auto:balanced`, `fusion`,
|
|
890
|
+
`auto-image`, `auto-video`, `auto-video-i2v`, `auto-speech`); dynamic upstream
|
|
891
|
+
discovery is intentionally disabled so ids and billing behavior stay deterministic.
|
|
892
|
+
Media jobs are capped to one output because upstream `n > 1` is unreliable.
|
|
893
|
+
There is no FreeLLMAPI 3D route — `model3d` stays on the paid lanes.
|
|
894
|
+
|
|
895
|
+
**Coding agents.** When enabled and no agent API key is set in Settings, the
|
|
896
|
+
CLI child process receives `OPENAI_BASE_URL` / `OPENAI_API_BASE`,
|
|
897
|
+
`OPENAI_API_KEY`, `ANTHROPIC_BASE_URL` and `ANTHROPIC_AUTH_TOKEN` pointing at
|
|
898
|
+
the router, plus `AWD_AGENT_MODEL=auto` if unset. An explicit agent key always
|
|
899
|
+
wins, so paid keys stay intact. Use `AWD_RUNNER=local` for localhost routing;
|
|
900
|
+
the Docker runner uses
|
|
901
|
+
`--network=none` and cannot reach the host router without an explicit,
|
|
902
|
+
separately configured host-network override.
|
|
903
|
+
|
|
904
|
+
### Client (editor managed generation lane only — not the skill)
|
|
905
|
+
|
|
906
|
+
| Variable | Purpose |
|
|
907
|
+
|---|---|
|
|
908
|
+
| `AWD_CREDITS_API_URL` | Legacy managed proxy base URL for **editor** generation only (wins over the config file); the skill never reads it |
|
|
909
|
+
| `AWD_CREDITS_CHECKOUT_URL` | Override the legacy proxy's static purchase link |
|
|
910
|
+
| `AGENTIC_LICENSE_KEY` / `ANIMOTION_LICENSE_KEY` | License key for the skill's paid gates and legacy proxy auth; the editor's plan uses the single checkout at https://skills.animotion.click/checkout?plan=template |
|
|
911
|
+
| `AWD_CREDIT_BALANCE` | CI override for the legacy proxy's read-only balance display |
|
|
912
|
+
|
|
913
|
+
---
|
|
914
|
+
|
|
915
|
+
## Appendix B — versioning policy
|
|
916
|
+
|
|
917
|
+
- **Patch** (`2.3.x`): wording, price-table refresh, fallback catalog, proxy fixes that don't change the API.
|
|
918
|
+
- **Minor** (`2.x.0`): new references/commands/models, additive proxy routes, new packs.
|
|
919
|
+
- **Major** (`3.0.0`): payload layout, installer flags, proxy contract or ledger schema breaking changes.
|
|
920
|
+
|
|
921
|
+
Every release: bump `package.json` → rebuild payload → new immutable URL → `npm publish` → deploy proxy if `server/credits` changed → run the QA matrix → tag.
|