bkper 4.13.7 → 4.15.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.
Files changed (59) hide show
  1. package/README.md +7 -3
  2. package/lib/agent/cli-dispatch.d.ts +7 -1
  3. package/lib/agent/cli-dispatch.d.ts.map +1 -1
  4. package/lib/agent/cli-dispatch.js +23 -2
  5. package/lib/agent/cli-dispatch.js.map +1 -1
  6. package/lib/cli.js +7 -2
  7. package/lib/cli.js.map +1 -1
  8. package/lib/commands/apps/build.d.ts +1 -2
  9. package/lib/commands/apps/build.d.ts.map +1 -1
  10. package/lib/commands/apps/build.js +13 -39
  11. package/lib/commands/apps/build.js.map +1 -1
  12. package/lib/commands/apps/config.d.ts +5 -14
  13. package/lib/commands/apps/config.d.ts.map +1 -1
  14. package/lib/commands/apps/config.js +13 -45
  15. package/lib/commands/apps/config.js.map +1 -1
  16. package/lib/commands/apps/deploy.d.ts +14 -4
  17. package/lib/commands/apps/deploy.d.ts.map +1 -1
  18. package/lib/commands/apps/deploy.js +42 -58
  19. package/lib/commands/apps/deploy.js.map +1 -1
  20. package/lib/commands/apps/dev.d.ts +1 -7
  21. package/lib/commands/apps/dev.d.ts.map +1 -1
  22. package/lib/commands/apps/dev.js +43 -115
  23. package/lib/commands/apps/dev.js.map +1 -1
  24. package/lib/commands/apps/index.d.ts +1 -1
  25. package/lib/commands/apps/index.d.ts.map +1 -1
  26. package/lib/commands/apps/index.js.map +1 -1
  27. package/lib/commands/apps/init.d.ts +1 -1
  28. package/lib/commands/apps/init.d.ts.map +1 -1
  29. package/lib/commands/apps/init.js +6 -12
  30. package/lib/commands/apps/init.js.map +1 -1
  31. package/lib/commands/apps/logs.d.ts +3 -3
  32. package/lib/commands/apps/logs.d.ts.map +1 -1
  33. package/lib/commands/apps/logs.js +31 -25
  34. package/lib/commands/apps/logs.js.map +1 -1
  35. package/lib/commands/apps/register.d.ts.map +1 -1
  36. package/lib/commands/apps/register.js +8 -16
  37. package/lib/commands/apps/register.js.map +1 -1
  38. package/lib/commands/apps/types.d.ts +5 -29
  39. package/lib/commands/apps/types.d.ts.map +1 -1
  40. package/lib/dev/local-assets.d.ts +15 -0
  41. package/lib/dev/local-assets.d.ts.map +1 -0
  42. package/lib/dev/local-assets.js +43 -0
  43. package/lib/dev/local-assets.js.map +1 -0
  44. package/lib/dev/logger.d.ts +3 -7
  45. package/lib/dev/logger.d.ts.map +1 -1
  46. package/lib/dev/logger.js +3 -6
  47. package/lib/dev/logger.js.map +1 -1
  48. package/lib/dev/miniflare.d.ts +2 -0
  49. package/lib/dev/miniflare.d.ts.map +1 -1
  50. package/lib/dev/miniflare.js +83 -21
  51. package/lib/dev/miniflare.js.map +1 -1
  52. package/lib/docs/app-building.md +151 -141
  53. package/lib/docs/app-management.md +69 -31
  54. package/lib/docs/bkper-js.md +2 -0
  55. package/lib/docs/cli-reference.md +7 -3
  56. package/lib/docs/index.md +1 -1
  57. package/lib/platform/client.d.ts +2 -2
  58. package/lib/platform/client.js +2 -2
  59. package/package.json +2 -2
@@ -12,47 +12,85 @@ Build, deploy, and manage Bkper apps using the `bkper` CLI.
12
12
  When scaffolding, developing, or deploying an app, verify each step before proceeding. This prevents broken deployments and silent failures.
13
13
 
14
14
  ### 1. Init
15
+
15
16
  ```bash
16
17
  bkper app init my-app
17
18
  ```
19
+
18
20
  Verify:
19
- - `packages/web/client/`, `packages/web/server/`, `packages/events/`, and `packages/shared/` exist
21
+
22
+ - `client/` and `server/` exist
20
23
  - `bkper.yaml` has `id`, `name`, `description`, and `developers`
21
24
  - `package.json` scripts include `dev` and `build`
22
25
 
23
26
  ### 2. Develop
27
+
24
28
  ```bash
25
29
  npm run dev
26
30
  ```
31
+
27
32
  Verify:
28
- - Web server responds: `curl http://localhost:8787` (or the port you configured)
33
+
34
+ - Server worker responds: `curl http://localhost:8787/health` (or the port you configured)
29
35
  - Client dev server is reachable if running separately
30
- - Events tunnel URL is printed in terminal and registered in Bkper (check `webhookUrlDev` in app settings)
31
- - If any handler fails to start, fix before writing code
36
+ - If the app declares `events`, the events tunnel URL is printed in terminal and registered in Bkper as `webhookUrlDev`
37
+ - If the worker fails to start, fix before writing code
32
38
 
33
39
  ### 3. Build
40
+
34
41
  ```bash
35
42
  npm run build
36
43
  ```
44
+
37
45
  Verify:
38
- - `dist/web/server/` contains the web worker bundle
39
- - `dist/events/` contains the events handler bundle
46
+
47
+ - `dist/server/` contains the server Worker bundle
48
+ - `dist/client/` contains the Vite client build when `deployment.client` is configured
40
49
  - No build errors in terminal output
41
50
 
42
51
  ### 4. Sync & Deploy
52
+
43
53
  ```bash
44
54
  bkper app sync && bkper app deploy
45
55
  ```
56
+
46
57
  Verify:
58
+
47
59
  - `bkper app status` shows the deployed version
48
60
  - URLs in `bkper.yaml` match the deployed domain (`https://{appId}.bkper.app`)
49
61
 
62
+ #### Preview testing with menu and events
63
+
64
+ To test a preview deployment from the Bkper UI, keep production URLs unchanged and point the development URLs to the preview Worker:
65
+
66
+ ```yaml
67
+ menuUrl: https://{appId}.bkper.app?bookId=${book.id}
68
+ menuUrlDev: https://{appId}-preview.bkper.app?bookId=${book.id}
69
+
70
+ webhookUrl: https://{appId}.bkper.app/events
71
+ webhookUrlDev: https://{appId}-preview.bkper.app/events
72
+ ```
73
+
74
+ Then build, sync metadata, and deploy to preview:
75
+
76
+ ```bash
77
+ npm run build
78
+ bkper app sync
79
+ bkper app deploy --preview
80
+ ```
81
+
82
+ Bkper uses `menuUrlDev` for developer menu access and `webhookUrlDev` for development-mode events. If `bkper app dev` runs later, it may replace `webhookUrlDev` with a local tunnel URL; set it back to the preview URL and run `bkper app sync` before testing preview again.
83
+
50
84
  ### 5. Validate
85
+
51
86
  ```bash
52
87
  bkper app install <appId> -b <bookId>
53
88
  ```
89
+
54
90
  Verify:
91
+
55
92
  - Menu appears in the book's "More" menu (if configured)
93
+ - App server `/api/*` routes are called with `Authorization: Bearer <token>`
56
94
  - Trigger a subscribed event in the book
57
95
  - Check the Bkper activity stream for the handler response
58
96
  - If the handler writes back to the book, confirm loop prevention is in place (check `event.agent.id`)
@@ -66,11 +104,11 @@ Verify:
66
104
  bkper app init my-app
67
105
 
68
106
  # Start the worker runtime (Miniflare + tunnel + file watching)
69
- # In your project, use "npm run dev" to run both Vite and workers concurrently
107
+ # In your project, use "npm run dev" to run both Vite and the worker concurrently
70
108
  bkper app dev
71
109
 
72
- # Build worker bundles (web server + events handler)
73
- # In your project, use "npm run build" to build both client (Vite) and workers
110
+ # Build the server Worker bundle
111
+ # In your project, use "npm run build" to build both client (Vite) and worker
74
112
  bkper app build
75
113
 
76
114
  # Sync configuration and deploy to production
@@ -79,14 +117,11 @@ bkper app sync && bkper app deploy
79
117
  # Deploy to preview environment (URL: https://{appId}-preview.bkper.app)
80
118
  bkper app deploy --preview
81
119
 
82
- # Deploy only the events handler
83
- bkper app deploy --events
84
-
85
120
  # Check deployment status
86
121
  bkper app status
87
122
  ```
88
123
 
89
- > **Note:** `bkper app dev` runs the worker runtime only — Miniflare, file watching, and the Cloudflare tunnel. Miniflare is loaded from the app project's `devDependencies` so each app can keep its local Workers simulator aligned with its own code. The Vite client dev server is configured in the project's `vite.config.ts` and run separately. The project template composes both via `npm run dev` using `concurrently`. If needed, install Miniflare in the app root with `bun add -d miniflare` or `npm install -D miniflare`.
124
+ > **Note:** `bkper app dev` runs one local Worker runtime — Miniflare, file watching, and an optional Cloudflare tunnel to `/events` when the app subscribes to events. Miniflare is loaded from the app project's `devDependencies` so each app can keep its local Workers simulator aligned with its own code. The Vite client dev server is configured in the project's `vite.config.ts` and run separately. The project template composes both via `npm run dev` using `concurrently`. If needed, install Miniflare in the app root with `bun add -d miniflare` or `npm install -D miniflare`.
90
125
 
91
126
  ---
92
127
 
@@ -115,6 +150,8 @@ bkper app secrets list
115
150
  bkper app secrets delete EXTERNAL_SERVICE_TOKEN
116
151
  ```
117
152
 
153
+ Use `--preview` to manage preview secrets.
154
+
118
155
  ---
119
156
 
120
157
  ## Configuration
@@ -231,6 +268,7 @@ menuPopupHeight: 300
231
268
  # EVENT HANDLING (optional)
232
269
  # -----------------------------------------------------------------------------
233
270
  # When configured, Bkper calls your webhook URL when subscribed events occur.
271
+ # On the Bkper Platform, /events is handled by the same Worker as /api/*.
234
272
 
235
273
  # Production webhook URL
236
274
  webhookUrl: https://${id}.bkper.app/events
@@ -323,19 +361,23 @@ propertiesSchema:
323
361
  # -----------------------------------------------------------------------------
324
362
  # For apps deployed to Bkper's Workers for Platforms infrastructure.
325
363
  deployment:
326
- # Web handler (serves UI and API)
327
- web:
328
- bundle: packages/web/server/dist
329
- # assets: packages/web/client/dist # Static assets (when supported)
364
+ # Single server Worker entry point. It serves /api/* and /events.
365
+ server: server/src/index.ts
330
366
 
331
- # Events handler (processes webhooks)
332
- events:
333
- bundle: packages/events/dist
367
+ # Optional Vite/static client root. Built assets are deployed with the same Worker.
368
+ client: client
334
369
 
335
370
  # Platform services available to your app (one per type, auto-provisioned)
336
371
  # See: https://developers.cloudflare.com/kv/
337
372
  services:
338
373
  - KV # Key-value storage
374
+
375
+ # Secret names managed with bkper app secrets
376
+ secrets:
377
+ - EXTERNAL_SERVICE_TOKEN
378
+
379
+ # Cloudflare Workers compatibility date
380
+ compatibility_date: '2026-01-28'
339
381
  ```
340
382
 
341
383
  </details>
@@ -356,6 +398,7 @@ deployment:
356
398
 
357
399
  ### Agent
358
400
 
401
+ - `bkper` - Start the interactive Bkper Agent when run in an interactive terminal; print CLI help in non-interactive contexts
359
402
  - `agent` - Start the interactive Bkper Agent
360
403
  - `agent <pi-args...>` - Run Pi CLI with Bkper defaults (system prompt/resources)
361
404
 
@@ -364,30 +407,25 @@ deployment:
364
407
  - `app init <name>` - Scaffold a new app from the template
365
408
  - `app list` - List all apps you have access to
366
409
  - `app sync` - Sync [bkper.yaml][bkper.yaml reference] configuration (URLs, description) to Bkper API
367
- - `app build` - Build worker bundles for deployment
410
+ - `app build` - Build the server Worker bundle for deployment
368
411
  - `app deploy` - Deploy built artifacts to Cloudflare Workers for Platforms
369
412
  - `-p, --preview` - Deploy to preview environment
370
- - `--events` - Deploy events handler instead of web handler
371
413
  - `app status` - Show deployment status
372
- - `app logs` - View recent app logs
414
+ - `app logs [appId]` - View recent app logs. When `appId` is omitted, the app id is read from local app config.
373
415
  - `--since <time>` - ISO8601 or relative lower bound (e.g. `5m`, `1h`, `15d`)
374
416
  - `--until <time>` - ISO8601 or relative upper bound
375
- - `--last <n>` - Show newest N entries after filters (default: 100)
417
+ - `--last <n>` - Show newest N requests after filters (default: 100)
376
418
  - `-p, --preview` - Query preview logs instead of production
377
- - `-w, --web` - Filter to the web handler
378
- - `-e, --events` - Filter to the events handler
379
- - `--outcome <outcome>` - Filter by Cloudflare worker outcome
419
+ - `-w, --web` - Filter to normal web/API requests
420
+ - `-e, --events` - Filter to `/events` requests
421
+ - `--level <level>` - Minimum log level threshold (`info`, `warn`, or `error`)
380
422
  - `--status-code <code>` - Filter by HTTP status code
381
423
  - `app undeploy` - Remove app from platform
382
424
  - `-p, --preview` - Remove from preview environment
383
- - `--events` - Remove events handler instead of web handler
384
425
  - `--delete-data` - Permanently delete all associated data (requires confirmation)
385
426
  - `--force` - Skip confirmation prompts (use with `--delete-data` for automation)
386
427
  - `app dev` - Start the worker runtime for local development
387
428
  - `--sp, --server-port <port>` - Server simulation port (default: `8787`)
388
- - `--ep, --events-port <port>` - Events handler port (default: `8791`)
389
- - `-w, --web` - Run only the web handler
390
- - `-e, --events` - Run only the events handler
391
429
 
392
430
  > **Note:** `sync` and `deploy` are independent operations. Use `sync` to update your app's URLs in Bkper (required for webhooks and menu integration). Use `deploy` to push code to Cloudflare. For a typical deployment workflow, run both: `bkper app sync && bkper app deploy`
393
431
 
@@ -122,6 +122,8 @@ const books = await bkper.getBooks();
122
122
 
123
123
  See the [@bkper/web-auth documentation](https://bkper.com/docs/api/bkper-web-auth) for more details.
124
124
 
125
+ For Bkper Platform app server routes under `/api/*`, send `Authorization: Bearer ${auth.getAccessToken()}` from the client. The server route can use `new Bkper()` without a token provider because platform outbound auth injects the validated user's token on Bkper API calls.
126
+
125
127
  ### API Key (Optional)
126
128
 
127
129
  API keys are optional and only needed for dedicated quota limits. If not provided, requests use a shared managed quota via the Bkper API proxy.
@@ -4,7 +4,7 @@
4
4
 
5
5
  A unified **interface for [Bkper](https://bkper.com)**. Use `bkper` in two complementary modes:
6
6
 
7
- - **Interactive mode** — run `bkper agent` to open the Bkper Agent TUI
7
+ - **Interactive mode** — run `bkper` or `bkper agent` to open the Bkper Agent TUI
8
8
  - **Command mode** — run `bkper <command>` for explicit CLI workflows, scripts, and automation
9
9
 
10
10
  With one tool, you can build and deploy Bkper apps, and manage financial data -- books, accounts, transactions, and balances.
@@ -50,9 +50,11 @@ This is the only command that opens the browser OAuth flow. When you are done wo
50
50
  ### Interactive mode (recommended)
51
51
 
52
52
  ```bash
53
- bkper agent
53
+ bkper
54
54
  ```
55
55
 
56
+ `bkper agent` starts the same interactive experience. Bare `bkper` only opens the TUI in an interactive terminal; in non-interactive contexts it prints CLI help instead.
57
+
56
58
  ![Bkper CLI Agent TUI](https://raw.githubusercontent.com/bkper/bkper-cli/main/assets/bkper-agent-cli.png)
57
59
 
58
60
  On first launch, type `/login` and select a provider. We recommend [OpenCode Go](https://opencode.ai/go) for open-weights models and [OpenCode Zen](https://opencode.ai/zen) for frontier models — both give you access to high-quality models with no extra setup.
@@ -108,6 +110,7 @@ bkper agent <pi-args>
108
110
  ```
109
111
 
110
112
  If no Pi arguments are provided, `bkper agent` starts the interactive Bkper Agent experience.
113
+ A bare `bkper` command is a convenience shortcut for the same TUI when run in an interactive terminal.
111
114
  If Pi arguments are provided, everything after `bkper agent` is passed through to Pi.
112
115
 
113
116
  Examples:
@@ -153,9 +156,10 @@ bkper app init my-app
153
156
  bkper app dev
154
157
  bkper app sync && bkper app deploy
155
158
  bkper app logs --last 50
159
+ bkper app logs my-app --level error
156
160
  ```
157
161
 
158
- `bkper app logs` reads recent app logs kept for 15 days. The default output is human-readable, and JSON is available with `--json`.
162
+ `bkper app logs` reads recent app logs kept for 15 days. Run it inside an app directory, or pass an app id like `bkper app logs my-app`. Use `--level warn` or `--level error` to focus on requests with warnings or errors. The default output is human-readable, and JSON is available with `--json`.
159
163
 
160
164
  → [Full App Management reference](https://github.com/bkper/bkper-cli/blob/main/docs/app-management.md)
161
165
 
package/lib/docs/index.md CHANGED
@@ -4,7 +4,7 @@ Reference docs for Bkper tasks. Load only the specific doc(s) relevant to the ta
4
4
 
5
5
  - **data-management.md** — CLI reference for managing financial data and files: books, accounts, groups, files, transactions, per-account balance queries, query operators (on:, after:, before:, account:, group:), output formats (table/json/csv), batch operations via stdin/piping, collections.
6
6
  - **app-management.md** — CLI reference for building and deploying Bkper apps: dev/build/deploy workflow, app install/uninstall, secrets management, app logs, bkper.yaml configuration reference (identity, branding, events, menu integration, deployment).
7
- - **app-building.md** — Full app-building reference: architecture (packages, client/server/events), development loop, event handlers, deployment patterns, the Bkper Platform, and self-hosted alternatives. Includes authentication patterns for web clients (`@bkper/web-auth`), event handlers (`bkper-oauth-token` headers), and local development. Load this for scaffolding apps, understanding app structure, or debugging the dev/build/deploy lifecycle.
7
+ - **app-building.md** — Full app-building reference: single Worker app architecture (`client/` + `server/`), development loop, `/api/*` routes, `/events` handlers, deployment patterns, the Bkper Platform, and self-hosted alternatives. Includes authentication patterns for web clients (`@bkper/web-auth`), server API routes (`Authorization: Bearer` on `/api/*` with outbound auth injection), platform event handlers (`new Bkper()` with outbound auth injection), and local development.
8
8
  - **financial-statements.md** — Step-by-step workflow for aggregate financial reports (balance sheet, P&L): root group discovery, query patterns, date semantics (before: vs after:+before:), common mistakes to avoid.
9
9
  - **taxes.md** — Deterministic workflow for tax position and filing summaries: discovering tax-relevant groups, period-based balance queries, persisting a local tax runner. Jurisdiction-agnostic — outputs raw period balances, leaving rate/application to the user.
10
10
  - **bkper-js.md** — bkper-js Node.js/browser SDK: Bkper, Book, Account, Transaction, Group, Balance classes, all methods, getBalancesReport, OAuth configuration, library setup.
@@ -12,8 +12,8 @@
12
12
  *
13
13
  * // Deploy an app
14
14
  * const { data, error } = await client.POST('/api/apps/{appId}/deploy', {
15
- * params: { path: { appId: 'my-app' }, query: { env: 'dev', type: 'web' } },
16
- * body: bundleBuffer,
15
+ * params: { path: { appId: 'my-app' }, query: { env: 'preview' } },
16
+ * body: formData,
17
17
  * });
18
18
  * ```
19
19
  */
@@ -12,8 +12,8 @@
12
12
  *
13
13
  * // Deploy an app
14
14
  * const { data, error } = await client.POST('/api/apps/{appId}/deploy', {
15
- * params: { path: { appId: 'my-app' }, query: { env: 'dev', type: 'web' } },
16
- * body: bundleBuffer,
15
+ * params: { path: { appId: 'my-app' }, query: { env: 'preview' } },
16
+ * body: formData,
17
17
  * });
18
18
  * ```
19
19
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper",
3
- "version": "4.13.7",
3
+ "version": "4.15.0",
4
4
  "description": "Command line client for Bkper",
5
5
  "bin": {
6
6
  "bkper": "./lib/cli.js"
@@ -51,7 +51,7 @@
51
51
  "upgrade:api": "bun update @bkper/bkper-api-types --latest && bun update bkper-js --latest"
52
52
  },
53
53
  "dependencies": {
54
- "@earendil-works/pi-coding-agent": "0.75.5",
54
+ "@earendil-works/pi-coding-agent": "0.76.0",
55
55
  "bkper-js": "^2.35.2",
56
56
  "commander": "^13.1.0",
57
57
  "dotenv": "^8.2.0",