bkper 5.3.4 → 5.4.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.
@@ -0,0 +1,8 @@
1
+ import { Event } from 'bkper-js';
2
+ /**
3
+ * Deletes one bot response without deleting its event or reversing bot effects.
4
+ *
5
+ * @returns The updated event payload after deletion
6
+ */
7
+ export declare function deleteEventBotResponse(bookId: string, eventId: string, agentId: string): Promise<Event>;
8
+ //# sourceMappingURL=delete.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/commands/events/delete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,EAAE,MAAM,UAAU,CAAC;AAG9C;;;;GAIG;AACH,wBAAsB,sBAAsB,CACxC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GAChB,OAAO,CAAC,KAAK,CAAC,CAOhB"}
@@ -0,0 +1,27 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { BotResponse, Event } from 'bkper-js';
11
+ import { getBkperInstance } from '../../bkper-factory.js';
12
+ /**
13
+ * Deletes one bot response without deleting its event or reversing bot effects.
14
+ *
15
+ * @returns The updated event payload after deletion
16
+ */
17
+ export function deleteEventBotResponse(bookId, eventId, agentId) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const bkper = getBkperInstance();
20
+ const book = yield bkper.getBook(bookId);
21
+ const event = new Event(book, { id: eventId });
22
+ const botResponse = new BotResponse(event, { agentId });
23
+ yield botResponse.remove();
24
+ return event;
25
+ });
26
+ }
27
+ //# sourceMappingURL=delete.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../src/commands/events/delete.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;;;GAIG;AACH,MAAM,UAAgB,sBAAsB,CACxC,MAAc,EACd,OAAe,EACf,OAAe;;QAEf,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACzC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QAC/C,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QACxD,MAAM,WAAW,CAAC,MAAM,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC;IACjB,CAAC;CAAA"}
@@ -1,3 +1,4 @@
1
1
  export { DEFAULT_EVENT_LIST_LIMIT, listEvents, listEventsFormatted, type ListBookEventsOptions, type ListBookEventsResult, } from './list.js';
2
2
  export { replayEventBotResponse } from './replay.js';
3
+ export { deleteEventBotResponse } from './delete.js';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/events/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,wBAAwB,EACxB,UAAU,EACV,mBAAmB,EACnB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,GAC5B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/events/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,wBAAwB,EACxB,UAAU,EACV,mBAAmB,EACnB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,GAC5B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export { DEFAULT_EVENT_LIST_LIMIT, listEvents, listEventsFormatted, } from './list.js';
2
2
  export { replayEventBotResponse } from './replay.js';
3
+ export { deleteEventBotResponse } from './delete.js';
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/events/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,wBAAwB,EACxB,UAAU,EACV,mBAAmB,GAGtB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/events/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,wBAAwB,EACxB,UAAU,EACV,mBAAmB,GAGtB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../src/commands/events/register.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAUrC;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAOvD;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAmD5D"}
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../src/commands/events/register.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAerC;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAOvD;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAuE5D"}
@@ -12,7 +12,7 @@ import { withAction } from '../action.js';
12
12
  import { parsePositiveInteger } from '../cli-helpers.js';
13
13
  import { renderItem, renderList } from '../../render/index.js';
14
14
  import { validateRequiredOptions, throwIfErrors } from '../../utils/validation.js';
15
- import { listEventsFormatted, replayEventBotResponse } from './index.js';
15
+ import { listEventsFormatted, replayEventBotResponse, deleteEventBotResponse } from './index.js';
16
16
  import { eventToJson } from './event-json.js';
17
17
  const EVENT_TYPE_VALUES = new Set(Object.values(EventType));
18
18
  /**
@@ -50,7 +50,8 @@ export function registerEventCommands(program) {
50
50
  });
51
51
  renderList(result);
52
52
  }))());
53
- eventCommand
53
+ const responseCommand = eventCommand.command('response').description('Manage event bot responses');
54
+ responseCommand
54
55
  .command('replay <eventId>')
55
56
  .description('Replay one bot response for an event')
56
57
  .option('-b, --book <bookId>', 'Book ID')
@@ -63,5 +64,18 @@ export function registerEventCommands(program) {
63
64
  const event = yield replayEventBotResponse(options.book, eventId, options.agentId);
64
65
  renderItem(eventToJson(event.json()));
65
66
  }))());
67
+ responseCommand
68
+ .command('delete <eventId>')
69
+ .description('Delete one bot response; preserves the event and does not undo bot effects')
70
+ .option('-b, --book <bookId>', 'Book ID')
71
+ .option('--agent-id <agentId>', 'Bot/agent ID whose response should be deleted')
72
+ .action((eventId, options) => withAction('deleting event bot response', () => __awaiter(this, void 0, void 0, function* () {
73
+ throwIfErrors(validateRequiredOptions(options, [
74
+ { name: 'book', flag: '--book' },
75
+ { name: 'agentId', flag: '--agent-id' },
76
+ ]));
77
+ const event = yield deleteEventBotResponse(options.book, eventId, options.agentId);
78
+ renderItem(eventToJson(event.json()));
79
+ }))());
66
80
  }
67
81
  //# sourceMappingURL=register.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"register.js","sourceRoot":"","sources":["../../../src/commands/events/register.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAS,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;AAEpE;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa;IACxC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CACX,uBAAuB,KAAK,mBAAmB,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACvF,CAAC;IACN,CAAC;IACD,OAAO,KAAkB,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,OAAgB;IAClD,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,uCAAuC,CAAC,CAAC;IAEnG,YAAY;SACP,OAAO,CAAC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AAsB,EAAE,+CAA+C,CAAC;SAC/E,MAAM,CAAC,CAAC,OAAe,EAAE,OAA6B,EAAE,EAAE,CACvD,UAAU,CAAC,6BAA6B,EAAE,GAAS,EAAE;QACjD,aAAa,CACT,uBAAuB,CAAC,OAAO,EAAE;YAC7B,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE;YAChC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE;SAC1C,CAAC,CACL,CAAC;QACF,MAAM,KAAK,GAAG,MAAM,sBAAsB,CAAC,OAAO,CAAC,IAAK,EAAE,OAAO,EAAE,OAAO,CAAC,OAAQ,CAAC,CAAC;QACrF,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC1C,CAAC,CAAA,CAAC,EAAE,CACP,CAAC;AACV,CAAC"}
@@ -244,6 +244,7 @@ TypeSafe's JavaScript SDK, `@typesafe-ai/sdk`, works with Bkper AI and infers an
244
244
 
245
245
  - **In a Bkper Platform app Worker**, send no `Authorization` header. Platform outbound adds authorization and app attribution.
246
246
  - **In scripts and servers**, send your own Bkper access token as a bearer token.
247
+ - **In a browser page**, send the signed-in user's access token. Any origin may call, usage counts against that user's allowance, and the user can see your questions. See [Call from a browser](https://bkper.com/docs/ai/ai-gateway.md#call-from-a-browser).
247
248
  - **In [Bkper CLI Agent](https://bkper.com/docs/ai/bkper-cli-agent.md#what-it-can-do)**, no setup is needed. Describe the outcome and the agent asks the decision model for you.
248
249
 
249
250
  See [Add Bkper AI to an App](https://bkper.com/docs/platform/apps/ai.md#ask-a-decision-model) for the SDK setup in both cases and its limits with Bkper AI.
@@ -9,7 +9,7 @@ Model output is a suggestion, not permission to change a Book. Keep decisions ab
9
9
  - **A yes/no, a choice, or a level on a scale?** Ask a decision model, such as `jev`, with TypeSafe's SDK, `@typesafe-ai/sdk`.
10
10
  - **Text or a custom JSON object?** Ask a language model (LLM), such as `gpt-luna`, with AI SDK's Open Responses provider, `@ai-sdk/open-responses`.
11
11
 
12
- Add the SDK to the **Worker** package. Keep the call in a server service used by your authenticated app API route, and define the route's request and response in the app's Zod/OpenAPI contract.
12
+ By default, add the SDK to the **Worker** package. Keep the call in a server service used by your authenticated app API route, and define the route's request and response in the app's Zod/OpenAPI contract. For inference used only by the UI, the client can also [call Bkper AI directly](#call-from-the-browser).
13
13
 
14
14
  ## Keep authentication in the platform
15
15
 
@@ -19,7 +19,20 @@ For an interactive app, the flow is:
19
19
  2. Bkper verifies the user's token, removes it before invoking the Worker, and establishes user and app context for outbound requests.
20
20
  3. The Worker calls Bkper AI. Platform outbound adds authorization and app attribution. **Do not read, forward, or store the user's token in the Worker.**
21
21
 
22
- An authenticated `/events` handler has the same outbound context. A page request does not; start inference from an authenticated `/api/*` route, not from the page handler or the browser.
22
+ An authenticated `/events` handler has the same outbound context. A page request does not, so the page handler cannot call Bkper AI.
23
+
24
+ ## Call from the browser
25
+
26
+ The client can call Bkper AI directly with `auth.authenticatedFetch()`, which sends the signed-in user's token. Choose the path by what the inference needs:
27
+
28
+ | | App API route | Browser |
29
+ | ----------------------------------- | ---------------------------------- | ----------------------------------------------- |
30
+ | Usage attribution | The app, set by platform outbound | The `bkper-ai-source` header the client sends |
31
+ | Prompts, questions, and criteria | Private to the Worker | Visible to the user |
32
+ | Reuse by scripts, agents, or events | Yes, through the route | No |
33
+ | Request path | Client → app Worker → Bkper AI | Client → Bkper AI |
34
+
35
+ In both cases usage counts against the user's allowance. See [Call from a browser](https://bkper.com/docs/ai/ai-gateway.md#call-from-a-browser) for a request example.
23
36
 
24
37
  ## Ask a decision model
25
38
 
@@ -49,6 +49,7 @@ Client code has two data paths. Choose based on who owns the behavior:
49
49
 
50
50
  - **Direct Bkper calls** use `bkper-js` for generic Bkper data needed only by the browser UI.
51
51
  - **App API calls** use the generated typed client in `client/src/api/` with `auth.authenticatedFetch()` for app-owned behavior, especially when it needs server-only capabilities or more than one caller.
52
+ - **Direct Bkper AI calls** use `auth.authenticatedFetch()` for inference needed only by the browser UI, when its prompts may be visible to the user. See [Call from the browser](https://bkper.com/docs/platform/apps/ai.md#call-from-the-browser).
52
53
 
53
54
  Keep app-owned behavior in one place. Do not implement the same behavior separately in the UI and the app API.
54
55
 
@@ -18,7 +18,7 @@ The same Worker can expose app-defined `/api/*` routes. Treat those routes as th
18
18
 
19
19
  ### AI inference
20
20
 
21
- When an app needs model inference, use Bkper AI by default. An authenticated app API route or event establishes the user and app identity, then platform outbound supplies authorization and usage attribution for the Worker's Bkper AI requests. The app does not need provider credentials.
21
+ When an app needs model inference, use Bkper AI by default. An authenticated app API route or event establishes the user and app identity, then platform outbound supplies authorization and usage attribution for the Worker's Bkper AI requests. The app does not need provider credentials. For inference used only by the UI, the client can also call Bkper AI directly with the signed-in user's token.
22
22
 
23
23
  See [Add Bkper AI to an App](https://bkper.com/docs/platform/apps/ai.md) for the client-to-Worker authentication flow and SDK setup for decision and language models.
24
24
 
@@ -566,7 +566,7 @@ Inside the interactive agent:
566
566
  - `--last <n>` - Show newest N requests after filters (default: 100)
567
567
  - `-p, --preview` - Query preview logs instead of production
568
568
  - `-w, --web` - Filter to normal web/API requests
569
- - `-e, --events` - Filter to `/events` requests
569
+ - `-e, --events` - Filter to `/events` requests (for bot errors shown in a Book, start with `event list --error`)
570
570
  - `--level <level>` - Minimum log level threshold (`info`, `warn`, or `error`)
571
571
  - `--status-code <code>` - Filter by HTTP status code
572
572
  - `app undeploy` - Remove app from platform
@@ -326,7 +326,7 @@ bkper transaction merge tx_123 tx_456 -b abc123
326
326
 
327
327
  ## Events
328
328
 
329
- Inspect book events and bot responses — useful for debugging automations and recovering from intermittent bot errors.
329
+ Inspect book events and bot responses — start here when debugging bot errors shown in a Book.
330
330
 
331
331
  ```bash
332
332
  # List recent events (one page, default limit 50)
@@ -345,7 +345,10 @@ bkper event list -b abc123 --type TRANSACTION_POSTED --after 2026-01-01T00:00:00
345
345
  bkper event list -b abc123 --limit 50 --cursor cursor_123
346
346
 
347
347
  # Replay one bot response after inspecting an error
348
- bkper event replay evt_789 -b abc123 --agent-id tax-bot
348
+ bkper event response replay evt_789 -b abc123 --agent-id tax-bot
349
+
350
+ # Delete one bot response
351
+ bkper event response delete evt_789 -b abc123 --agent-id tax-bot
349
352
  ```
350
353
 
351
354
  <details>
@@ -359,7 +362,8 @@ bkper event replay evt_789 -b abc123 --agent-id tax-bot
359
362
  - `--type <type>` - Filter by event type (e.g. `TRANSACTION_POSTED`, `ACCOUNT_CREATED`)
360
363
  - `--limit <number>` - Fetch one page with up to this many events (default `50`, max `200`)
361
364
  - `--cursor <cursor>` - Cursor for fetching the next page
362
- - `event replay <eventId> -b <bookId> --agent-id <agentId>` - Replay one bot response for an event (returns the updated event with bot responses)
365
+ - `event response replay <eventId> -b <bookId> --agent-id <agentId>` - Replay one bot response for an event (returns the updated event with bot responses)
366
+ - `event response delete <eventId> -b <bookId> --agent-id <agentId>` - Delete one bot response for an event (does not undo its effects; returns the updated event)
363
367
 
364
368
  Output includes the full event payload, including nested `botResponses` (`agentId`, `type`, `message`, `createdAt`), for LLM-assisted debugging.
365
369
 
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
  For Bkper app implementation, refactoring, or code review, always read `apps/quality.md` alongside the task-specific references. After implementation, review the changed code against the guidelines before considering the work complete.
6
6
 
7
- - `cli/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:), JSON output shapes and jq reshaping, human-review Bkper UI links, batch operations via stdin/piping, collections.
7
+ - `cli/data-management.md` — CLI reference for managing financial data and files: books, accounts, groups, files, transactions, events and bot responses (bot errors, replay, delete), per-account balance queries, query operators (on:, after:, before:, account:, group:), JSON output shapes and jq reshaping, human-review Bkper UI links, batch operations via stdin/piping, collections.
8
8
  - `cli/app-management.md` — CLI reference for building and deploying Bkper apps: init/git clone/credential helpers, dev/build/deploy workflow, app install/uninstall, secrets management, app logs, bkper.yaml configuration reference (identity, branding, events, menu integration, deployment).
9
9
  - `apps/overview.md` — Platform evaluation and capability overview: use when comparing managed Bkper hosting with self-managed infrastructure or clarifying platform responsibilities; use the task-specific app references for implementation.
10
10
  - `apps/ai.md` — Bkper AI in apps, scripts, and tools: ask the Jev decision model with TypeSafe's SDK or language models with AI SDK Open Responses, authenticate through app `/api/*` routes or a Bkper token outside the platform, handle errors, and keep Book writes under deterministic application control.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper",
3
- "version": "5.3.4",
3
+ "version": "5.4.0",
4
4
  "description": "Official Bkper CLI for accounting data, automation, apps, and AI agents",
5
5
  "bin": {
6
6
  "bkper": "lib/cli.js"
@@ -44,7 +44,7 @@
44
44
  "build:copy-themes": "mkdir -p lib/agent && rm -rf lib/agent/themes && cp -R src/agent/themes lib/agent/themes",
45
45
  "skill:package": "bun ./scripts/generate-skill-distribution.ts",
46
46
  "api:platform": "openapi-typescript https://platform.bkper.app/openapi.json -o src/platform/types.d.ts",
47
- "api:platform:local": "openapi-typescript http://localhost:8790/openapi.json -o src/platform/types.d.ts",
47
+ "api:platform:local": "openapi-typescript http://localhost:8703/openapi.json -o src/platform/types.d.ts",
48
48
  "predev": "bun run build",
49
49
  "dev": "tsc -w",
50
50
  "ports": "devpod ssh ../ -L 6274",
@@ -52,7 +52,7 @@
52
52
  "test": "bun run test:typecheck && TS_NODE_TRANSPILE_ONLY=true TS_NODE_PROJECT=tsconfig.test.json mocha",
53
53
  "test:unit": "bun run test:typecheck && TS_NODE_TRANSPILE_ONLY=true TS_NODE_PROJECT=tsconfig.test.json mocha --config .mocharc.json",
54
54
  "test:integration": "bun run test:typecheck && TS_NODE_TRANSPILE_ONLY=true BKPER_API_URL=${BKPER_API_URL:-http://localhost:8081/_ah/api/bkper} TS_NODE_PROJECT=tsconfig.test.json mocha --config .mocharc.integration.json",
55
- "test:deploy": "bun run test:typecheck && TS_NODE_TRANSPILE_ONLY=true BKPER_PLATFORM_URL=http://localhost:8790 BKPER_API_URL=https://api-dev.bkper.app TS_NODE_PROJECT=tsconfig.test.json mocha --config .mocharc.deploy.json",
55
+ "test:deploy": "bun run test:typecheck && TS_NODE_TRANSPILE_ONLY=true BKPER_PLATFORM_URL=http://localhost:8703 BKPER_API_URL=https://api-dev.bkper.app TS_NODE_PROJECT=tsconfig.test.json mocha --config .mocharc.deploy.json",
56
56
  "test:all": "bun run test:unit && bun run test:integration",
57
57
  "version": "bun ./scripts/sync-plugin-version.ts && git add .claude-plugin/plugin.json .claude-plugin/marketplace.json .codex-plugin/plugin.json",
58
58
  "release:patch": "npm version patch -m \"chore(release): v%s\"",