@blyp/core 0.1.2 → 0.1.22

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 (230) hide show
  1. package/README.md +273 -14
  2. package/STABILITY.md +56 -0
  3. package/dist/ai/anthropic/index.d.ts +3 -0
  4. package/dist/ai/anthropic/normalize.d.ts +9 -0
  5. package/dist/ai/anthropic/stream.d.ts +3 -0
  6. package/dist/ai/anthropic/wrap.d.ts +13 -0
  7. package/dist/ai/anthropic.js +701 -0
  8. package/dist/ai/anthropic.mjs +701 -0
  9. package/dist/ai/fetch.js +701 -0
  10. package/dist/ai/fetch.mjs +701 -0
  11. package/dist/ai/openai/index.d.ts +3 -0
  12. package/dist/ai/openai/normalize.d.ts +10 -0
  13. package/dist/ai/openai/stream.d.ts +3 -0
  14. package/dist/ai/openai/wrap.d.ts +24 -0
  15. package/dist/ai/openai.js +701 -0
  16. package/dist/ai/openai.mjs +701 -0
  17. package/dist/ai/shared/fetch.d.ts +5 -0
  18. package/dist/ai/shared/index.d.ts +2 -0
  19. package/dist/ai/shared/normalize.d.ts +17 -0
  20. package/dist/ai/shared/redaction.d.ts +6 -0
  21. package/dist/ai/shared/stream.d.ts +7 -0
  22. package/dist/ai/shared/trace.d.ts +116 -0
  23. package/dist/ai/shared/types.d.ts +161 -0
  24. package/dist/ai/shared.js +701 -0
  25. package/dist/ai/shared.mjs +701 -0
  26. package/dist/ai/vercel/index.d.ts +3 -0
  27. package/dist/ai/vercel/middleware.d.ts +3 -0
  28. package/dist/ai/vercel/model.d.ts +3 -0
  29. package/dist/ai/vercel.js +701 -0
  30. package/dist/ai/vercel.mjs +701 -0
  31. package/dist/astro.js +701 -0
  32. package/dist/astro.mjs +701 -0
  33. package/dist/client.js +1 -1132
  34. package/dist/client.mjs +1 -1125
  35. package/dist/connectors/betterstack.js +9 -1508
  36. package/dist/connectors/betterstack.mjs +9 -1483
  37. package/dist/connectors/databuddy/index.d.ts +7 -0
  38. package/dist/connectors/databuddy/sender.d.ts +5 -0
  39. package/dist/connectors/databuddy.js +9 -0
  40. package/dist/connectors/databuddy.mjs +9 -0
  41. package/dist/connectors/delivery/backoff.d.ts +2 -0
  42. package/dist/connectors/delivery/manager.d.ts +44 -0
  43. package/dist/connectors/delivery/queue-path.d.ts +1 -0
  44. package/dist/connectors/delivery/sqlite-adapter-bun.d.ts +1 -0
  45. package/dist/connectors/delivery/sqlite-adapter-node.d.ts +1 -0
  46. package/dist/connectors/delivery/sqlite-client.d.ts +37 -0
  47. package/dist/connectors/delivery/sqlite-worker.d.ts +1 -0
  48. package/dist/connectors/delivery/studio-queue.d.ts +12 -0
  49. package/dist/connectors/delivery/types.d.ts +98 -0
  50. package/dist/connectors/otlp/index.d.ts +1 -0
  51. package/dist/connectors/otlp.js +9 -1347
  52. package/dist/connectors/otlp.mjs +9 -1344
  53. package/dist/connectors/posthog/properties.d.ts +4 -0
  54. package/dist/connectors/posthog/sender.d.ts +0 -1
  55. package/dist/connectors/posthog.js +10 -1503
  56. package/dist/connectors/posthog.mjs +10 -1498
  57. package/dist/connectors/sentry.js +9 -1356
  58. package/dist/connectors/sentry.mjs +9 -1333
  59. package/dist/core/config.d.ts +7 -2
  60. package/dist/core/log-record.d.ts +5 -4
  61. package/dist/core/logger.d.ts +5 -0
  62. package/dist/core/optional-module.d.ts +1 -0
  63. package/dist/core/pino-pretty-loader.d.ts +4 -0
  64. package/dist/database.js +1 -24
  65. package/dist/database.mjs +1 -21
  66. package/dist/elysia.js +621 -4100
  67. package/dist/elysia.mjs +622 -4073
  68. package/dist/expo.js +1 -719
  69. package/dist/expo.mjs +1 -717
  70. package/dist/express.js +616 -4085
  71. package/dist/express.mjs +616 -4056
  72. package/dist/fastify.js +618 -4104
  73. package/dist/fastify.mjs +618 -4075
  74. package/dist/frameworks/astro/index.d.ts +2 -0
  75. package/dist/frameworks/astro/logger.d.ts +3 -0
  76. package/dist/frameworks/elysia/index.d.ts +1 -1
  77. package/dist/frameworks/elysia/logger.d.ts +2 -35
  78. package/dist/frameworks/nestjs/helpers.d.ts +2 -0
  79. package/dist/frameworks/nitro/index.d.ts +2 -0
  80. package/dist/frameworks/nitro/logger.d.ts +6 -0
  81. package/dist/frameworks/nuxt/index.d.ts +2 -0
  82. package/dist/frameworks/nuxt/logger.d.ts +3 -0
  83. package/dist/frameworks/react-router/index.d.ts +2 -0
  84. package/dist/frameworks/react-router/logger.d.ts +3 -0
  85. package/dist/frameworks/shared/h3.d.ts +19 -0
  86. package/dist/frameworks/shared/http.d.ts +3 -2
  87. package/dist/frameworks/shared/index.d.ts +2 -1
  88. package/dist/frameworks/shared/logger.d.ts +2 -0
  89. package/dist/frameworks/shared/request-context.d.ts +2 -0
  90. package/dist/frameworks/shared/trace.d.ts +6 -0
  91. package/dist/hono.js +624 -4079
  92. package/dist/hono.mjs +626 -4053
  93. package/dist/index.d.ts +57 -17
  94. package/dist/index.js +616 -6494
  95. package/dist/index.mjs +619 -6410
  96. package/dist/nestjs.js +626 -4574
  97. package/dist/nestjs.mjs +622 -4542
  98. package/dist/nextjs.js +625 -4107
  99. package/dist/nextjs.mjs +627 -4081
  100. package/dist/nitro.js +701 -0
  101. package/dist/nitro.mjs +701 -0
  102. package/dist/nuxt.js +701 -0
  103. package/dist/nuxt.mjs +701 -0
  104. package/dist/react-router.js +701 -0
  105. package/dist/react-router.mjs +701 -0
  106. package/dist/shared/redaction.d.ts +17 -0
  107. package/dist/standalone.js +606 -3258
  108. package/dist/standalone.mjs +611 -3234
  109. package/dist/sveltekit.js +625 -4106
  110. package/dist/sveltekit.mjs +626 -4079
  111. package/dist/tanstack-start.js +624 -4105
  112. package/dist/tanstack-start.mjs +626 -4079
  113. package/dist/types/connectors/databuddy.d.ts +52 -0
  114. package/dist/types/core/config.d.ts +89 -0
  115. package/dist/types/core/logger.d.ts +5 -0
  116. package/dist/types/core/structured-log.d.ts +2 -0
  117. package/dist/types/database.d.ts +1 -0
  118. package/dist/types/frameworks/astro.d.ts +33 -0
  119. package/dist/types/frameworks/client.d.ts +2 -0
  120. package/dist/types/frameworks/elysia.d.ts +2 -0
  121. package/dist/types/frameworks/express.d.ts +1 -0
  122. package/dist/types/frameworks/fastify.d.ts +1 -0
  123. package/dist/types/frameworks/hono.d.ts +1 -0
  124. package/dist/types/frameworks/http.d.ts +1 -0
  125. package/dist/types/frameworks/nestjs.d.ts +2 -0
  126. package/dist/types/frameworks/nextjs.d.ts +1 -0
  127. package/dist/types/frameworks/nitro.d.ts +63 -0
  128. package/dist/types/frameworks/nuxt.d.ts +12 -0
  129. package/dist/types/frameworks/react-router.d.ts +35 -0
  130. package/dist/types/frameworks/request-context.d.ts +1 -0
  131. package/dist/types/frameworks/shared.d.ts +28 -1
  132. package/dist/types/frameworks/standalone.d.ts +3 -2
  133. package/dist/types/frameworks/sveltekit.d.ts +1 -0
  134. package/dist/types/frameworks/tanstack-start.d.ts +9 -3
  135. package/dist/types/frameworks/workers.d.ts +3 -0
  136. package/dist/types/shared/client-log.d.ts +2 -1
  137. package/dist/workers.js +2 -626
  138. package/dist/workers.mjs +2 -623
  139. package/package.json +273 -143
  140. package/dist/client.js.map +0 -1
  141. package/dist/client.mjs.map +0 -1
  142. package/dist/connectors/betterstack.js.map +0 -1
  143. package/dist/connectors/betterstack.mjs.map +0 -1
  144. package/dist/connectors/otlp.js.map +0 -1
  145. package/dist/connectors/otlp.mjs.map +0 -1
  146. package/dist/connectors/posthog.js.map +0 -1
  147. package/dist/connectors/posthog.mjs.map +0 -1
  148. package/dist/connectors/sentry.js.map +0 -1
  149. package/dist/connectors/sentry.mjs.map +0 -1
  150. package/dist/database.js.map +0 -1
  151. package/dist/database.mjs.map +0 -1
  152. package/dist/elysia.js.map +0 -1
  153. package/dist/elysia.mjs.map +0 -1
  154. package/dist/expo.js.map +0 -1
  155. package/dist/expo.mjs.map +0 -1
  156. package/dist/express.js.map +0 -1
  157. package/dist/express.mjs.map +0 -1
  158. package/dist/fastify.js.map +0 -1
  159. package/dist/fastify.mjs.map +0 -1
  160. package/dist/hono.js.map +0 -1
  161. package/dist/hono.mjs.map +0 -1
  162. package/dist/index.js.map +0 -1
  163. package/dist/index.mjs.map +0 -1
  164. package/dist/nestjs.js.map +0 -1
  165. package/dist/nestjs.mjs.map +0 -1
  166. package/dist/nextjs.js.map +0 -1
  167. package/dist/nextjs.mjs.map +0 -1
  168. package/dist/standalone.js.map +0 -1
  169. package/dist/standalone.mjs.map +0 -1
  170. package/dist/sveltekit.js.map +0 -1
  171. package/dist/sveltekit.mjs.map +0 -1
  172. package/dist/tanstack-start.js.map +0 -1
  173. package/dist/tanstack-start.mjs.map +0 -1
  174. package/dist/workers.js.map +0 -1
  175. package/dist/workers.mjs.map +0 -1
  176. package/exports/client.js +0 -3
  177. package/exports/client.mjs +0 -3
  178. package/exports/connectors/betterstack.js +0 -1
  179. package/exports/connectors/betterstack.mjs +0 -1
  180. package/exports/connectors/otlp.js +0 -1
  181. package/exports/connectors/otlp.mjs +0 -1
  182. package/exports/connectors/posthog.js +0 -1
  183. package/exports/connectors/posthog.mjs +0 -1
  184. package/exports/connectors/sentry.js +0 -1
  185. package/exports/connectors/sentry.mjs +0 -1
  186. package/exports/database.js +0 -1
  187. package/exports/database.mjs +0 -1
  188. package/exports/expo.js +0 -1
  189. package/exports/expo.mjs +0 -1
  190. package/exports/frameworks/elysia.js +0 -1
  191. package/exports/frameworks/elysia.mjs +0 -1
  192. package/exports/frameworks/express.js +0 -1
  193. package/exports/frameworks/express.mjs +0 -1
  194. package/exports/frameworks/fastify.js +0 -1
  195. package/exports/frameworks/fastify.mjs +0 -1
  196. package/exports/frameworks/hono.js +0 -1
  197. package/exports/frameworks/hono.mjs +0 -1
  198. package/exports/frameworks/nestjs.js +0 -1
  199. package/exports/frameworks/nestjs.mjs +0 -1
  200. package/exports/frameworks/nextjs.js +0 -1
  201. package/exports/frameworks/nextjs.mjs +0 -1
  202. package/exports/frameworks/standalone.js +0 -1
  203. package/exports/frameworks/standalone.mjs +0 -1
  204. package/exports/frameworks/sveltekit.js +0 -1
  205. package/exports/frameworks/sveltekit.mjs +0 -1
  206. package/exports/frameworks/tanstack-start.js +0 -1
  207. package/exports/frameworks/tanstack-start.mjs +0 -1
  208. package/exports/workers.js +0 -1
  209. package/exports/workers.mjs +0 -1
  210. package/types/client.d.ts +0 -34
  211. package/types/connectors/betterstack.d.ts +0 -1
  212. package/types/connectors/otlp.d.ts +0 -1
  213. package/types/connectors/posthog.d.ts +0 -1
  214. package/types/connectors/sentry.d.ts +0 -1
  215. package/types/database.d.ts +0 -1
  216. package/types/expo.d.ts +0 -17
  217. package/types/frameworks/client.d.ts +0 -160
  218. package/types/frameworks/elysia.d.ts +0 -1
  219. package/types/frameworks/expo.d.ts +0 -50
  220. package/types/frameworks/express.d.ts +0 -1
  221. package/types/frameworks/fastify.d.ts +0 -1
  222. package/types/frameworks/hono.d.ts +0 -1
  223. package/types/frameworks/nestjs.d.ts +0 -1
  224. package/types/frameworks/nextjs.d.ts +0 -1
  225. package/types/frameworks/standalone.d.ts +0 -1
  226. package/types/frameworks/sveltekit.d.ts +0 -1
  227. package/types/frameworks/tanstack-start.d.ts +0 -1
  228. package/types/frameworks/workers.d.ts +0 -115
  229. package/types/index.d.ts +0 -1
  230. package/types/workers.d.ts +0 -13
package/README.md CHANGED
@@ -14,25 +14,27 @@
14
14
 
15
15
  - **Runtime detection** — Automatically optimizes for Bun vs Node.js
16
16
  - **TypeScript** — Full type safety throughout
17
- - **Framework integrations** — Elysia, Hono, Express, Fastify, NestJS, Next.js App Router, TanStack Start, SvelteKit, Cloudflare Workers
17
+ - **Framework integrations** — Elysia, Hono, Express, Fastify, NestJS, Next.js App Router, React Router, Astro, Nitro, Nuxt, TanStack Start, SvelteKit, Cloudflare Workers
18
18
  - **Expo integration** — Mobile client logging for Expo apps with structured backend sync
19
19
  - **PostHog connector** — Automatic or manual PostHog log forwarding for server, browser, and Expo flows
20
+ - **Databuddy connector** — Automatic or manual Databuddy log forwarding and handled-error tracking for server, browser, and Expo flows
20
21
  - **OTLP connector** — Automatic or manual OpenTelemetry log forwarding for Grafana, Datadog, Honeycomb, and any OTLP-compatible backend
22
+ - **Connector delivery queue** — Optional server-side memory + SQLite retry queue for connector delivery without Redis
21
23
  - **Standalone usage** — Use without any framework
22
24
  - **Structured file logging** — NDJSON with size-based rotation and gzip archives
23
25
  - **Database logging** — Serverless-friendly persistence with Prisma and Drizzle adapters for Postgres and MySQL
24
26
  - **Client log sync** — Browser logs ingested into your backend stream
27
+ - **AI SDK tracing** — AI SDK middleware-based tracing for `generateText` and `streamText` flows
25
28
 
26
29
  ## Project structure
27
30
 
28
31
  ```
29
32
  blyp/
30
- ├── exports/
31
- │ ├── client.js # Public client entry shim
33
+ ├── dist/ # Published JS and declaration output
32
34
  │ ├── connectors/
33
- │ │ └── posthog.js # Public connector entry shims
35
+ │ │ └── posthog.js # Public connector build output
34
36
  │ └── frameworks/
35
- │ └── elysia.js # Public framework entry shims
37
+ │ └── elysia.js # Public framework build output
36
38
  ├── index.ts # Main source export bridge
37
39
  ├── src/
38
40
  │ ├── core/ # Logger runtime and file logging internals
@@ -45,12 +47,6 @@ blyp/
45
47
  │ │ └── posthog.ts # Connector-specific source types
46
48
  │ └── frameworks/
47
49
  │ └── elysia.ts # Framework-specific source types
48
- ├── types/
49
- │ ├── index.d.ts # Public type entry shim
50
- │ ├── connectors/
51
- │ │ └── posthog.d.ts # Public connector type shims
52
- │ └── frameworks/
53
- │ └── elysia.d.ts # Public framework type shims
54
50
  ├── tests/
55
51
  │ ├── frameworks/ # One test file per server integration
56
52
  │ ├── helpers/ # Shared test utilities
@@ -68,6 +64,10 @@ npx expo install expo-network
68
64
 
69
65
  Also: `npm install @blyp/core` | `yarn add @blyp/core` | `pnpm add @blyp/core`
70
66
 
67
+ ## Stability
68
+
69
+ Blyp publishes a production stability contract in [STABILITY.md](./STABILITY.md). The core logger API, framework adapters, and connector APIs are Stable. Studio UI and CLI commands are Beta. Internal APIs and unexported symbols are Unstable.
70
+
71
71
  ## Usage
72
72
 
73
73
  ### Basic logger
@@ -138,6 +138,34 @@ const app = new Elysia()
138
138
 
139
139
  Inside framework handlers, the imported `createStructuredLog(...)` automatically binds to the active request-scoped logger. Structured logs are emitted only when you call `.emit()`. In framework request loggers, a structured emit replaces that request's normal auto request log. If you mix a request-scoped structured logger with the root `logger` in the same request, Blyp warns once and ignores the root logger call.
140
140
 
141
+ ### Automatic redaction
142
+
143
+ Blyp redacts sensitive values before they reach the console, files, database adapters, connectors, client ingestion, or framework request logs.
144
+
145
+ Default redacted keys:
146
+
147
+ `password`, `passwd`, `pwd`, `secret`, `token`, `api_key`, `apikey`, `api_secret`, `authorization`, `auth`, `x-api-key`, `private_key`, `privatekey`, `access_token`, `refresh_token`, `client_secret`, `session`, `cookie`, `set-cookie`, `ssn`, `credit_card`, `card_number`, `cvv`, `cvc`, `otp`, `pin`
148
+
149
+ Blyp also scans string values for common secret patterns and replaces matches with typed markers such as `[REDACTED:bearer]`, `[REDACTED:jwt]`, `[REDACTED:api_key]`, and `[REDACTED:card]`.
150
+
151
+ ```ts
152
+ export default {
153
+ redact: {
154
+ keys: ['my_custom_secret', 'internal_token'],
155
+ paths: ['user.ssn', 'payment.**.raw'],
156
+ patterns: [/MY_ORG_[A-Z0-9]{32}/],
157
+ disablePatternScanning: false,
158
+ },
159
+ };
160
+ ```
161
+
162
+ Notes:
163
+
164
+ - `redact.paths` supports exact paths, `*`, and `**`
165
+ - regex `patterns` require executable config such as `blyp.config.ts`
166
+ - request headers such as `Authorization`, `Cookie`, `Set-Cookie`, `X-API-Key`, and `X-Auth-Token` are redacted by default
167
+ - Blyp preserves keys and replaces values with `[REDACTED]` or a typed marker
168
+
141
169
  ### Errors
142
170
 
143
171
  ```typescript
@@ -150,7 +178,7 @@ For the full error API (`HTTP_CODES`, `extend`, `create`), see [Full documentati
150
178
 
151
179
  ### Framework integrations
152
180
 
153
- Blyp supports **Elysia**, **Hono**, **Express**, **Fastify**, **NestJS**, **Next.js**, **TanStack Start**, **SvelteKit**, and **Cloudflare Workers**. Example with Elysia:
181
+ Blyp supports **Elysia**, **Hono**, **Express**, **Fastify**, **NestJS**, **Next.js**, **React Router**, **Astro**, **Nitro**, **Nuxt**, **TanStack Start**, **SvelteKit**, and **Cloudflare Workers**. Example with Elysia:
154
182
 
155
183
  ```typescript
156
184
  import { Elysia } from 'elysia';
@@ -162,6 +190,19 @@ const app = new Elysia()
162
190
  .listen(3000);
163
191
  ```
164
192
 
193
+ Framework HTTP loggers also support path filtering:
194
+
195
+ ```typescript
196
+ import { createLogger } from '@blyp/core/express';
197
+
198
+ app.use(createLogger({
199
+ includePaths: ['/api/**'],
200
+ ignorePaths: ['/api/internal/**'],
201
+ }));
202
+ ```
203
+
204
+ `includePaths` works as an allowlist for automatic `http_request` and `http_error` logs. It uses the same wildcard matching as `ignorePaths`. When both are configured, Blyp logs only included paths and then removes any path that also matches `ignorePaths`.
205
+
165
206
  For other frameworks, client logging, advanced configuration, and utilities, see [Full documentation](docs/README.md).
166
207
 
167
208
  ### Expo
@@ -178,6 +219,125 @@ logger.info('app mounted');
178
219
 
179
220
  Expo uses the runtime `fetch` implementation for delivery and `expo-network` for connectivity metadata. Install `expo-network` in your app and use an absolute ingestion URL.
180
221
 
222
+ ### Durable connector retries
223
+
224
+ Server-side connector delivery can be queued and retried with an internal Blyp-managed SQLite file. This is opt-in, uses at-least-once delivery semantics, and currently applies to server connector log forwarding only.
225
+
226
+ ```typescript
227
+ import { createStandaloneLogger } from '@blyp/core/standalone';
228
+
229
+ const logger = createStandaloneLogger({
230
+ connectors: {
231
+ betterstack: {
232
+ enabled: true,
233
+ sourceToken: process.env.BETTERSTACK_TOKEN,
234
+ ingestingHost: 'https://in.logs.betterstack.com',
235
+ },
236
+ delivery: {
237
+ enabled: true,
238
+ durableQueuePath: '.blyp/connectors.sqlite',
239
+ retry: {
240
+ maxAttempts: 8,
241
+ initialBackoffMs: 500,
242
+ maxBackoffMs: 30000,
243
+ },
244
+ },
245
+ },
246
+ });
247
+ ```
248
+
249
+ Notes:
250
+
251
+ - Blyp stores the durable queue in its own SQLite file, not your app database.
252
+ - Blyp uses an in-memory hot buffer first, then persists retryable connector failures to SQLite.
253
+ - Older runtimes without built-in SQLite support fall back to memory-only retries with a warning.
254
+ - Exception capture remains best-effort direct delivery in this first version.
255
+
256
+ ### AI tracing
257
+
258
+ Use `@blyp/core/ai/vercel` for Vercel AI SDK middleware, or the provider wrappers when you want direct SDK instrumentation without a universal LLM abstraction.
259
+
260
+ Common case:
261
+
262
+ ```typescript
263
+ import { streamText } from 'ai';
264
+ import { anthropic } from '@ai-sdk/anthropic';
265
+ import { blypModel } from '@blyp/core/ai/vercel';
266
+
267
+ const model = blypModel(anthropic('claude-sonnet-4-5'), {
268
+ operation: 'support_chat',
269
+ });
270
+
271
+ const result = streamText({
272
+ model,
273
+ prompt: 'Write a refund reply for this customer',
274
+ });
275
+ ```
276
+
277
+ Advanced middleware usage:
278
+
279
+ ```typescript
280
+ import { wrapLanguageModel } from 'ai';
281
+ import { anthropic } from '@ai-sdk/anthropic';
282
+ import { blypMiddleware } from '@blyp/core/ai/vercel';
283
+
284
+ const model = wrapLanguageModel({
285
+ model: anthropic('claude-sonnet-4-5'),
286
+ middleware: blypMiddleware({
287
+ operation: 'support_chat',
288
+ }),
289
+ });
290
+ ```
291
+
292
+ By default Blyp logs one structured `ai_trace` record per AI SDK call with provider, model, operation, token usage, finish reason, timing, and best-effort tool events. Prompt, response, reasoning, tool input, tool output, and stream chunk capture are off by default. When Blyp request context is active, AI traces inherit the active request-scoped logger automatically.
293
+
294
+ Direct provider wrappers:
295
+
296
+ ```typescript
297
+ import OpenAI from 'openai';
298
+ import Anthropic from '@anthropic-ai/sdk';
299
+ import { wrapOpenAI } from '@blyp/core/ai/openai';
300
+ import { wrapAnthropic } from '@blyp/core/ai/anthropic';
301
+
302
+ const openai = wrapOpenAI(new OpenAI({ apiKey: process.env.OPENAI_API_KEY }), {
303
+ operation: 'draft_blog_intro',
304
+ });
305
+
306
+ const anthropic = wrapAnthropic(new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY }), {
307
+ operation: 'summarize_ticket',
308
+ });
309
+ ```
310
+
311
+ OpenRouter is supported through the OpenAI-compatible path:
312
+
313
+ ```typescript
314
+ import OpenAI from 'openai';
315
+ import { wrapOpenAI } from '@blyp/core/ai/openai';
316
+
317
+ const client = wrapOpenAI(
318
+ new OpenAI({
319
+ apiKey: process.env.OPENROUTER_API_KEY,
320
+ baseURL: 'https://openrouter.ai/api/v1',
321
+ }),
322
+ {
323
+ provider: 'openrouter',
324
+ operation: 'route_experiment',
325
+ }
326
+ );
327
+ ```
328
+
329
+ Optional transport tracing:
330
+
331
+ ```typescript
332
+ import OpenAI from 'openai';
333
+ import { blypFetch } from '@blyp/core/ai/fetch';
334
+
335
+ const client = new OpenAI({
336
+ apiKey: process.env.OPENAI_API_KEY,
337
+ fetch: blypFetch(fetch),
338
+ });
339
+ ```
340
+
181
341
  ### Database logging
182
342
 
183
343
  Use `destination: 'database'` when you cannot rely on filesystem writes, such as serverless deployments. Database mode requires an executable config file like `blyp.config.ts` because Prisma and Drizzle adapters are runtime objects.
@@ -221,7 +381,7 @@ export default {
221
381
  };
222
382
  ```
223
383
 
224
- In database mode, Blyp keeps connectors working as usual and replaces only the primary local persistence backend. Promise-based framework integrations flush database writes before the request finishes. In callback-style servers, call `await logger.flush()` at your own boundary when you need a hard durability point.
384
+ In database mode, Blyp keeps connectors working as usual and replaces only the primary local persistence backend. Promise-based and hook-driven framework integrations such as Hono, Elysia, Next.js, React Router, Astro, Nitro, Nuxt, SvelteKit, and TanStack Start flush database writes before the request finishes. In callback-style servers, call `await logger.flush()` at your own boundary when you need a hard durability point.
225
385
 
226
386
  Use the Blyp CLI to scaffold the schema and migrations:
227
387
 
@@ -234,6 +394,12 @@ blyp logs init --adapter drizzle --dialect mysql
234
394
 
235
395
  Use `connectors.betterstack` when you want Blyp logs forwarded into Better Stack through `@logtail/node`:
236
396
 
397
+ Install the optional peer dependencies for this connector when you enable it:
398
+
399
+ ```bash
400
+ bun add @logtail/node @sentry/node
401
+ ```
402
+
237
403
  ```typescript
238
404
  export default {
239
405
  connectors: {
@@ -302,6 +468,12 @@ The browser and Expo connector flow still posts to Blyp first. Blyp forwards to
302
468
 
303
469
  Use `blyp.config.ts` when you want to read the PostHog project key from the environment:
304
470
 
471
+ Install the optional peer dependencies for this connector when you enable it:
472
+
473
+ ```bash
474
+ bun add posthog-node @opentelemetry/api-logs @opentelemetry/exporter-logs-otlp-http @opentelemetry/resources @opentelemetry/sdk-logs
475
+ ```
476
+
305
477
  ```typescript
306
478
  export default {
307
479
  connectors: {
@@ -354,10 +526,74 @@ Client `error` and `critical` logs requested through the PostHog connector are p
354
526
 
355
527
  The client and Expo connector flow still posts to Blyp first. Blyp forwards to PostHog only when the server connector is configured, and browser or Expo apps do not use `posthog-node` directly. Workers remain out of scope for this connector.
356
528
 
529
+ ### Databuddy
530
+
531
+ Use `connectors.databuddy` when you want Blyp logs and handled errors forwarded into Databuddy:
532
+
533
+ Install the optional peer dependency for this connector when you enable it:
534
+
535
+ ```bash
536
+ bun add @databuddy/sdk
537
+ ```
538
+
539
+ ```typescript
540
+ export default {
541
+ connectors: {
542
+ databuddy: {
543
+ enabled: true,
544
+ mode: 'auto',
545
+ apiKey: process.env.DATABUDDY_API_KEY,
546
+ websiteId: process.env.DATABUDDY_WEBSITE_ID,
547
+ enableBatching: true,
548
+ },
549
+ },
550
+ };
551
+ ```
552
+
553
+ Databuddy requires both `apiKey` and `websiteId`. Blyp treats the connector as unavailable until both are configured.
554
+
555
+ In `auto` mode, normal Blyp server loggers forward to Databuddy automatically and handled errors are captured as Databuddy `error` events. In `manual` mode, use `@blyp/core/databuddy`:
556
+
557
+ ```typescript
558
+ import {
559
+ captureDatabuddyException,
560
+ createDatabuddyErrorTracker,
561
+ createDatabuddyLogger,
562
+ createStructuredDatabuddyLogger,
563
+ } from '@blyp/core/databuddy';
564
+
565
+ createDatabuddyLogger().info('manual databuddy log');
566
+ createDatabuddyErrorTracker().capture(new Error('manual databuddy exception'));
567
+ captureDatabuddyException(new Error('wrapped databuddy exception'));
568
+
569
+ const structured = createStructuredDatabuddyLogger('checkout', { orderId: 'ord_123' });
570
+ structured.info('manual start');
571
+ structured.emit({ status: 200 });
572
+ ```
573
+
574
+ Browser and Expo loggers can request server-side Databuddy forwarding through the existing ingestion endpoint:
575
+
576
+ ```typescript
577
+ import { createClientLogger } from '@blyp/core/client';
578
+
579
+ const logger = createClientLogger({
580
+ endpoint: '/inngest',
581
+ connector: 'databuddy',
582
+ });
583
+ ```
584
+
585
+ Client `error` and `critical` logs requested through the Databuddy connector are promoted to Databuddy `error` events only when server-side Databuddy is enabled in `auto` mode. The client and Expo connector flow still posts to Blyp first. Blyp forwards to Databuddy only when the server connector is configured.
586
+
357
587
  ### Sentry
358
588
 
359
589
  Use `connectors.sentry` when you want Blyp logs forwarded into Sentry Logs:
360
590
 
591
+ Install the optional peer dependency for this connector when you enable it:
592
+
593
+ ```bash
594
+ bun add @sentry/node
595
+ ```
596
+
361
597
  ```typescript
362
598
  export default {
363
599
  connectors: {
@@ -412,6 +648,12 @@ The browser and Expo Sentry flow still posts to Blyp first. Blyp forwards to Sen
412
648
 
413
649
  Use `connectors.otlp` when you want to send logs to named OTLP-compatible backends such as Grafana Cloud, Datadog, Honeycomb, or a self-hosted OpenTelemetry Collector:
414
650
 
651
+ Install the optional peer dependencies for this connector when you enable it:
652
+
653
+ ```bash
654
+ bun add @opentelemetry/api-logs @opentelemetry/exporter-logs-otlp-http @opentelemetry/resources @opentelemetry/sdk-logs
655
+ ```
656
+
415
657
  ```typescript
416
658
  export default {
417
659
  connectors: {
@@ -507,7 +749,23 @@ bun run type-check
507
749
 
508
750
  ## Publishing
509
751
 
510
- GitHub Actions publishes the package to npm when a GitHub Release is published. Add an `NPM_TOKEN` repository secret before using the workflow.
752
+ GitHub Actions publishes the package to npm when a GitHub Release is published. Add an `NPM_TOKEN` repository secret before using the workflow. The publish workflow uses npm provenance attestation, and maintainers should rotate `NPM_TOKEN` every 90 days.
753
+
754
+ ## Security
755
+
756
+ Security issues should be reported through GitHub's private advisory flow for this repository. Public issue reports are not the right channel for suspected vulnerabilities. Security details and disclosure expectations are in [SECURITY.md](SECURITY.md).
757
+
758
+ ## Runtime dependencies
759
+
760
+ Blyp keeps its shipped runtime dependency surface small and documents each direct dependency:
761
+
762
+ - `pino`: core structured logger engine
763
+ - `pino-pretty`: human-readable local and development console output when `pretty` mode is enabled
764
+ - `jiti`: runtime loading for `blyp.config.*` files and optional first-party subpath modules
765
+ - `fflate`: gzip compression and decompression for archived log files and log reading
766
+ - `zod`: runtime validation for shared and client payloads
767
+
768
+ Optional connectors stay in `peerDependencies` so regular installs do not pull large connector-specific transitive trees by default.
511
769
 
512
770
  ## Contributing
513
771
 
@@ -526,6 +784,7 @@ This project is licensed under the MIT License — see the [LICENSE](LICENSE) fi
526
784
  - [GitHub Repository](https://github.com/Blyphq/blyp)
527
785
  - [NPM Package](https://www.npmjs.com/package/@blyp/core)
528
786
  - [Documentation](docs/README.md)
787
+ - [Security Policy](SECURITY.md)
529
788
  - [Issues](https://github.com/Blyphq/blyp/issues)
530
789
 
531
790
  ---
package/STABILITY.md ADDED
@@ -0,0 +1,56 @@
1
+ # Stability
2
+
3
+ This document is Blyp's canonical compatibility contract for production adopters.
4
+
5
+ ## Why this exists
6
+
7
+ During Blyp's early releases, the npm package name changed from `blyp-js` to `@blyp/core`, the CLI executable changed from `blyphq` to `blyp`, and TypeScript subpath declaration shims were fixed after release. Those changes created uncertainty about what production users can rely on.
8
+
9
+ This file defines the stability guarantees for Blyp's public surfaces going forward.
10
+
11
+ ## Stability tiers
12
+
13
+ | Area | Tier | Guarantee |
14
+ | --- | --- | --- |
15
+ | Core logger API (`logger.*`, `createStructuredLog`, `createError`) | Stable | No breaking changes without a major version bump |
16
+ | Framework adapters (`@blyp/core/hono`, `/nextjs`, etc.) | Stable | Same guarantee |
17
+ | Connector APIs | Stable | Same guarantee |
18
+ | Studio UI | Beta | May change between minor versions |
19
+ | CLI commands | Beta | Commands may be added/changed with minor version |
20
+ | Internal APIs / unexported symbols | Unstable | No guarantees |
21
+
22
+ ## Deprecation policy
23
+
24
+ - Stable APIs are deprecated before removal.
25
+ - Deprecations are called out in GitHub release notes and changelog entries.
26
+ - Deprecated Stable APIs remain available for at least one minor release before removal.
27
+ - Removing a Stable API is a breaking change and therefore requires a major version bump.
28
+ - Beta surfaces may change in a minor release without a deprecation window.
29
+ - Unstable and internal surfaces may change at any time.
30
+
31
+ ## How breaking changes are communicated
32
+
33
+ Blyp communicates breaking changes through these channels:
34
+
35
+ - GitHub Releases in `Blyphq/blyp` are the authoritative release-note channel for package changes.
36
+ - Changelog entries, including the docs changelog, provide the human-readable running history.
37
+ - Migration notes are included when a release changes common adoption paths or requires user action.
38
+
39
+ ## Bun vs Node support
40
+
41
+ "Blyp-first" means Blyp is designed around Bun as the primary optimization target while maintaining feature parity for Stable documented APIs on Bun and supported Node versions.
42
+
43
+ - Stable documented APIs are intended to work on Bun and supported Node versions.
44
+ - Bun may receive earlier runtime-specific optimizations or validation when runtime behavior differs.
45
+ - Node support is not best effort for Stable surfaces.
46
+ - If a documented capability cannot ship with Stable parity on Node, it must be documented as Beta or explicitly scoped to Bun before release.
47
+
48
+ ## Out of scope
49
+
50
+ This contract does not cover:
51
+
52
+ - private helpers
53
+ - unexported symbols
54
+ - internal file layout
55
+ - undocumented implementation details
56
+ - behavior that is present in source but not documented as part of a public API
@@ -0,0 +1,3 @@
1
+ export { wrapAnthropic } from './wrap';
2
+ export { blypFetch } from '../shared/fetch';
3
+ export type { AIToolCallRecord, BlypLLMEventPart, BlypLLMTrace, BlypProviderOptions, BlypSDKContext, } from '../shared/types';
@@ -0,0 +1,9 @@
1
+ import { normalizeTokenUsage } from '../shared/normalize';
2
+ import type { AIToolCallRecord } from '../shared/types';
3
+ export declare function normalizeAnthropicResponse(response: unknown): {
4
+ model?: string;
5
+ usage?: ReturnType<typeof normalizeTokenUsage>;
6
+ finishReason?: string;
7
+ output?: unknown;
8
+ toolCalls: AIToolCallRecord[];
9
+ };
@@ -0,0 +1,3 @@
1
+ import { markSDKFirstChunk } from '../shared/trace';
2
+ import type { BlypSDKContext } from '../shared/types';
3
+ export declare function consumeAnthropicStreamChunk(state: Parameters<typeof markSDKFirstChunk>[0], context: BlypSDKContext, chunk: unknown): Promise<void>;
@@ -0,0 +1,13 @@
1
+ import type { BlypProviderOptions } from '../shared/types';
2
+ type AnthropicMessagesCreateParams = {
3
+ model?: string;
4
+ messages?: unknown;
5
+ stream?: boolean;
6
+ };
7
+ type WrappedAnthropicClient = {
8
+ messages?: {
9
+ create?: (params: AnthropicMessagesCreateParams, ...rest: unknown[]) => Promise<unknown>;
10
+ };
11
+ };
12
+ export declare function wrapAnthropic<TClient extends WrappedAnthropicClient>(client: TClient, options?: BlypProviderOptions): TClient;
13
+ export {};