@blyp/core 0.1.21 → 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.
- package/README.md +217 -11
- package/STABILITY.md +56 -0
- package/dist/ai/anthropic/index.d.ts +3 -0
- package/dist/ai/anthropic/normalize.d.ts +9 -0
- package/dist/ai/anthropic/stream.d.ts +3 -0
- package/dist/ai/anthropic/wrap.d.ts +13 -0
- package/dist/ai/anthropic.js +701 -0
- package/dist/ai/anthropic.mjs +701 -0
- package/dist/ai/fetch.js +701 -0
- package/dist/ai/fetch.mjs +701 -0
- package/dist/ai/openai/index.d.ts +3 -0
- package/dist/ai/openai/normalize.d.ts +10 -0
- package/dist/ai/openai/stream.d.ts +3 -0
- package/dist/ai/openai/wrap.d.ts +24 -0
- package/dist/ai/openai.js +701 -0
- package/dist/ai/openai.mjs +701 -0
- package/dist/ai/shared/fetch.d.ts +5 -0
- package/dist/ai/shared/index.d.ts +2 -0
- package/dist/ai/shared/normalize.d.ts +17 -0
- package/dist/ai/shared/redaction.d.ts +6 -0
- package/dist/ai/shared/stream.d.ts +7 -0
- package/dist/ai/shared/trace.d.ts +116 -0
- package/dist/ai/shared/types.d.ts +161 -0
- package/dist/ai/shared.js +701 -0
- package/dist/ai/shared.mjs +701 -0
- package/dist/ai/vercel/index.d.ts +3 -0
- package/dist/ai/vercel/middleware.d.ts +3 -0
- package/dist/ai/vercel/model.d.ts +3 -0
- package/dist/ai/vercel.js +701 -0
- package/dist/ai/vercel.mjs +701 -0
- package/dist/astro.js +618 -4519
- package/dist/astro.mjs +618 -4491
- package/dist/client.js +1 -1139
- package/dist/client.mjs +1 -1132
- package/dist/connectors/betterstack.js +9 -1532
- package/dist/connectors/betterstack.mjs +9 -1507
- package/dist/connectors/databuddy.js +9 -1456
- package/dist/connectors/databuddy.mjs +9 -1451
- package/dist/connectors/delivery/backoff.d.ts +2 -0
- package/dist/connectors/delivery/manager.d.ts +44 -0
- package/dist/connectors/delivery/queue-path.d.ts +1 -0
- package/dist/connectors/delivery/sqlite-adapter-bun.d.ts +1 -0
- package/dist/connectors/delivery/sqlite-adapter-node.d.ts +1 -0
- package/dist/connectors/delivery/sqlite-client.d.ts +37 -0
- package/dist/connectors/delivery/sqlite-worker.d.ts +1 -0
- package/dist/connectors/delivery/studio-queue.d.ts +12 -0
- package/dist/connectors/delivery/types.d.ts +98 -0
- package/dist/connectors/otlp/index.d.ts +1 -0
- package/dist/connectors/otlp.js +9 -1371
- package/dist/connectors/otlp.mjs +9 -1368
- package/dist/connectors/posthog/properties.d.ts +4 -0
- package/dist/connectors/posthog/sender.d.ts +0 -1
- package/dist/connectors/posthog.js +10 -1527
- package/dist/connectors/posthog.mjs +10 -1522
- package/dist/connectors/sentry.js +9 -1380
- package/dist/connectors/sentry.mjs +9 -1357
- package/dist/core/config.d.ts +7 -2
- package/dist/core/log-record.d.ts +5 -4
- package/dist/core/logger.d.ts +2 -0
- package/dist/core/optional-module.d.ts +1 -0
- package/dist/core/pino-pretty-loader.d.ts +4 -0
- package/dist/database.js +1 -24
- package/dist/database.mjs +1 -21
- package/dist/elysia.js +613 -4517
- package/dist/elysia.mjs +615 -4491
- package/dist/expo.js +1 -726
- package/dist/expo.mjs +1 -724
- package/dist/express.js +613 -4507
- package/dist/express.mjs +615 -4480
- package/dist/fastify.js +615 -4526
- package/dist/fastify.mjs +617 -4499
- package/dist/frameworks/elysia/index.d.ts +1 -1
- package/dist/frameworks/elysia/logger.d.ts +2 -35
- package/dist/frameworks/nestjs/helpers.d.ts +2 -0
- package/dist/frameworks/shared/http.d.ts +3 -2
- package/dist/frameworks/shared/index.d.ts +2 -1
- package/dist/frameworks/shared/logger.d.ts +2 -0
- package/dist/frameworks/shared/request-context.d.ts +2 -0
- package/dist/frameworks/shared/trace.d.ts +6 -0
- package/dist/hono.js +616 -4496
- package/dist/hono.mjs +618 -4470
- package/dist/index.d.ts +49 -19
- package/dist/index.js +615 -7557
- package/dist/index.mjs +618 -7465
- package/dist/nestjs.js +626 -4999
- package/dist/nestjs.mjs +621 -4966
- package/dist/nextjs.js +618 -4525
- package/dist/nextjs.mjs +620 -4499
- package/dist/nitro.js +617 -4642
- package/dist/nitro.mjs +619 -4616
- package/dist/nuxt.js +617 -4649
- package/dist/nuxt.mjs +619 -4623
- package/dist/react-router.js +616 -4559
- package/dist/react-router.mjs +618 -4533
- package/dist/shared/redaction.d.ts +17 -0
- package/dist/standalone.js +606 -3628
- package/dist/standalone.mjs +610 -3603
- package/dist/sveltekit.js +617 -4523
- package/dist/sveltekit.mjs +619 -4497
- package/dist/tanstack-start.js +616 -4522
- package/dist/tanstack-start.mjs +618 -4496
- package/dist/types/core/config.d.ts +57 -0
- package/dist/types/core/logger.d.ts +3 -0
- package/dist/types/core/structured-log.d.ts +2 -0
- package/dist/types/database.d.ts +1 -0
- package/dist/types/frameworks/astro.d.ts +1 -0
- package/dist/types/frameworks/client.d.ts +2 -0
- package/dist/types/frameworks/elysia.d.ts +2 -0
- package/dist/types/frameworks/express.d.ts +1 -0
- package/dist/types/frameworks/fastify.d.ts +1 -0
- package/dist/types/frameworks/hono.d.ts +1 -0
- package/dist/types/frameworks/http.d.ts +1 -0
- package/dist/types/frameworks/nestjs.d.ts +2 -0
- package/dist/types/frameworks/nextjs.d.ts +1 -0
- package/dist/types/frameworks/nitro.d.ts +1 -0
- package/dist/types/frameworks/react-router.d.ts +2 -0
- package/dist/types/frameworks/request-context.d.ts +1 -0
- package/dist/types/frameworks/shared.d.ts +4 -1
- package/dist/types/frameworks/standalone.d.ts +3 -2
- package/dist/types/frameworks/sveltekit.d.ts +1 -0
- package/dist/types/frameworks/tanstack-start.d.ts +9 -3
- package/dist/types/frameworks/workers.d.ts +3 -0
- package/dist/types/shared/client-log.d.ts +1 -0
- package/dist/workers.js +2 -626
- package/dist/workers.mjs +2 -623
- package/package.json +246 -173
- package/dist/astro.js.map +0 -1
- package/dist/astro.mjs.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/client.mjs.map +0 -1
- package/dist/connectors/betterstack.js.map +0 -1
- package/dist/connectors/betterstack.mjs.map +0 -1
- package/dist/connectors/databuddy.js.map +0 -1
- package/dist/connectors/databuddy.mjs.map +0 -1
- package/dist/connectors/otlp.js.map +0 -1
- package/dist/connectors/otlp.mjs.map +0 -1
- package/dist/connectors/posthog.js.map +0 -1
- package/dist/connectors/posthog.mjs.map +0 -1
- package/dist/connectors/sentry.js.map +0 -1
- package/dist/connectors/sentry.mjs.map +0 -1
- package/dist/database.js.map +0 -1
- package/dist/database.mjs.map +0 -1
- package/dist/elysia.js.map +0 -1
- package/dist/elysia.mjs.map +0 -1
- package/dist/expo.js.map +0 -1
- package/dist/expo.mjs.map +0 -1
- package/dist/express.js.map +0 -1
- package/dist/express.mjs.map +0 -1
- package/dist/fastify.js.map +0 -1
- package/dist/fastify.mjs.map +0 -1
- package/dist/hono.js.map +0 -1
- package/dist/hono.mjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/nestjs.js.map +0 -1
- package/dist/nestjs.mjs.map +0 -1
- package/dist/nextjs.js.map +0 -1
- package/dist/nextjs.mjs.map +0 -1
- package/dist/nitro.js.map +0 -1
- package/dist/nitro.mjs.map +0 -1
- package/dist/nuxt.js.map +0 -1
- package/dist/nuxt.mjs.map +0 -1
- package/dist/react-router.js.map +0 -1
- package/dist/react-router.mjs.map +0 -1
- package/dist/standalone.js.map +0 -1
- package/dist/standalone.mjs.map +0 -1
- package/dist/sveltekit.js.map +0 -1
- package/dist/sveltekit.mjs.map +0 -1
- package/dist/tanstack-start.js.map +0 -1
- package/dist/tanstack-start.mjs.map +0 -1
- package/dist/workers.js.map +0 -1
- package/dist/workers.mjs.map +0 -1
- package/exports/client.js +0 -3
- package/exports/client.mjs +0 -3
- package/exports/connectors/betterstack.js +0 -1
- package/exports/connectors/betterstack.mjs +0 -1
- package/exports/connectors/databuddy.js +0 -1
- package/exports/connectors/databuddy.mjs +0 -1
- package/exports/connectors/otlp.js +0 -1
- package/exports/connectors/otlp.mjs +0 -1
- package/exports/connectors/posthog.js +0 -1
- package/exports/connectors/posthog.mjs +0 -1
- package/exports/connectors/sentry.js +0 -1
- package/exports/connectors/sentry.mjs +0 -1
- package/exports/database.js +0 -1
- package/exports/database.mjs +0 -1
- package/exports/expo.js +0 -1
- package/exports/expo.mjs +0 -1
- package/exports/frameworks/astro.js +0 -1
- package/exports/frameworks/astro.mjs +0 -1
- package/exports/frameworks/elysia.js +0 -1
- package/exports/frameworks/elysia.mjs +0 -1
- package/exports/frameworks/express.js +0 -1
- package/exports/frameworks/express.mjs +0 -1
- package/exports/frameworks/fastify.js +0 -1
- package/exports/frameworks/fastify.mjs +0 -1
- package/exports/frameworks/hono.js +0 -1
- package/exports/frameworks/hono.mjs +0 -1
- package/exports/frameworks/nestjs.js +0 -1
- package/exports/frameworks/nestjs.mjs +0 -1
- package/exports/frameworks/nextjs.js +0 -1
- package/exports/frameworks/nextjs.mjs +0 -1
- package/exports/frameworks/nitro.js +0 -1
- package/exports/frameworks/nitro.mjs +0 -1
- package/exports/frameworks/nuxt.js +0 -1
- package/exports/frameworks/nuxt.mjs +0 -1
- package/exports/frameworks/react-router.js +0 -1
- package/exports/frameworks/react-router.mjs +0 -1
- package/exports/frameworks/standalone.js +0 -1
- package/exports/frameworks/standalone.mjs +0 -1
- package/exports/frameworks/sveltekit.js +0 -1
- package/exports/frameworks/sveltekit.mjs +0 -1
- package/exports/frameworks/tanstack-start.js +0 -1
- package/exports/frameworks/tanstack-start.mjs +0 -1
- package/exports/workers.js +0 -1
- package/exports/workers.mjs +0 -1
- package/types/client.d.ts +0 -34
- package/types/connectors/betterstack.d.ts +0 -1
- package/types/connectors/databuddy.d.ts +0 -1
- package/types/connectors/otlp.d.ts +0 -1
- package/types/connectors/posthog.d.ts +0 -1
- package/types/connectors/sentry.d.ts +0 -1
- package/types/database.d.ts +0 -1
- package/types/expo.d.ts +0 -17
- package/types/frameworks/astro.d.ts +0 -1
- package/types/frameworks/client.d.ts +0 -160
- package/types/frameworks/elysia.d.ts +0 -1
- package/types/frameworks/expo.d.ts +0 -50
- package/types/frameworks/express.d.ts +0 -1
- package/types/frameworks/fastify.d.ts +0 -1
- package/types/frameworks/hono.d.ts +0 -1
- package/types/frameworks/nestjs.d.ts +0 -1
- package/types/frameworks/nextjs.d.ts +0 -1
- package/types/frameworks/nitro.d.ts +0 -1
- package/types/frameworks/nuxt.d.ts +0 -1
- package/types/frameworks/react-router.d.ts +0 -1
- package/types/frameworks/standalone.d.ts +0 -1
- package/types/frameworks/sveltekit.d.ts +0 -1
- package/types/frameworks/tanstack-start.d.ts +0 -1
- package/types/frameworks/workers.d.ts +0 -115
- package/types/index.d.ts +0 -1
- package/types/workers.d.ts +0 -13
package/README.md
CHANGED
|
@@ -19,21 +19,22 @@
|
|
|
19
19
|
- **PostHog connector** — Automatic or manual PostHog log forwarding for server, browser, and Expo flows
|
|
20
20
|
- **Databuddy connector** — Automatic or manual Databuddy log forwarding and handled-error tracking for server, browser, and Expo flows
|
|
21
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
|
|
22
23
|
- **Standalone usage** — Use without any framework
|
|
23
24
|
- **Structured file logging** — NDJSON with size-based rotation and gzip archives
|
|
24
25
|
- **Database logging** — Serverless-friendly persistence with Prisma and Drizzle adapters for Postgres and MySQL
|
|
25
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
|
|
26
28
|
|
|
27
29
|
## Project structure
|
|
28
30
|
|
|
29
31
|
```
|
|
30
32
|
blyp/
|
|
31
|
-
├──
|
|
32
|
-
│ ├── client.js # Public client entry shim
|
|
33
|
+
├── dist/ # Published JS and declaration output
|
|
33
34
|
│ ├── connectors/
|
|
34
|
-
│ │ └── posthog.js # Public connector
|
|
35
|
+
│ │ └── posthog.js # Public connector build output
|
|
35
36
|
│ └── frameworks/
|
|
36
|
-
│ └── elysia.js # Public framework
|
|
37
|
+
│ └── elysia.js # Public framework build output
|
|
37
38
|
├── index.ts # Main source export bridge
|
|
38
39
|
├── src/
|
|
39
40
|
│ ├── core/ # Logger runtime and file logging internals
|
|
@@ -46,12 +47,6 @@ blyp/
|
|
|
46
47
|
│ │ └── posthog.ts # Connector-specific source types
|
|
47
48
|
│ └── frameworks/
|
|
48
49
|
│ └── elysia.ts # Framework-specific source types
|
|
49
|
-
├── types/
|
|
50
|
-
│ ├── index.d.ts # Public type entry shim
|
|
51
|
-
│ ├── connectors/
|
|
52
|
-
│ │ └── posthog.d.ts # Public connector type shims
|
|
53
|
-
│ └── frameworks/
|
|
54
|
-
│ └── elysia.d.ts # Public framework type shims
|
|
55
50
|
├── tests/
|
|
56
51
|
│ ├── frameworks/ # One test file per server integration
|
|
57
52
|
│ ├── helpers/ # Shared test utilities
|
|
@@ -69,6 +64,10 @@ npx expo install expo-network
|
|
|
69
64
|
|
|
70
65
|
Also: `npm install @blyp/core` | `yarn add @blyp/core` | `pnpm add @blyp/core`
|
|
71
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
|
+
|
|
72
71
|
## Usage
|
|
73
72
|
|
|
74
73
|
### Basic logger
|
|
@@ -139,6 +138,34 @@ const app = new Elysia()
|
|
|
139
138
|
|
|
140
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.
|
|
141
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
|
+
|
|
142
169
|
### Errors
|
|
143
170
|
|
|
144
171
|
```typescript
|
|
@@ -163,6 +190,19 @@ const app = new Elysia()
|
|
|
163
190
|
.listen(3000);
|
|
164
191
|
```
|
|
165
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
|
+
|
|
166
206
|
For other frameworks, client logging, advanced configuration, and utilities, see [Full documentation](docs/README.md).
|
|
167
207
|
|
|
168
208
|
### Expo
|
|
@@ -179,6 +219,125 @@ logger.info('app mounted');
|
|
|
179
219
|
|
|
180
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.
|
|
181
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
|
+
|
|
182
341
|
### Database logging
|
|
183
342
|
|
|
184
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.
|
|
@@ -235,6 +394,12 @@ blyp logs init --adapter drizzle --dialect mysql
|
|
|
235
394
|
|
|
236
395
|
Use `connectors.betterstack` when you want Blyp logs forwarded into Better Stack through `@logtail/node`:
|
|
237
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
|
+
|
|
238
403
|
```typescript
|
|
239
404
|
export default {
|
|
240
405
|
connectors: {
|
|
@@ -303,6 +468,12 @@ The browser and Expo connector flow still posts to Blyp first. Blyp forwards to
|
|
|
303
468
|
|
|
304
469
|
Use `blyp.config.ts` when you want to read the PostHog project key from the environment:
|
|
305
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
|
+
|
|
306
477
|
```typescript
|
|
307
478
|
export default {
|
|
308
479
|
connectors: {
|
|
@@ -359,6 +530,12 @@ The client and Expo connector flow still posts to Blyp first. Blyp forwards to P
|
|
|
359
530
|
|
|
360
531
|
Use `connectors.databuddy` when you want Blyp logs and handled errors forwarded into Databuddy:
|
|
361
532
|
|
|
533
|
+
Install the optional peer dependency for this connector when you enable it:
|
|
534
|
+
|
|
535
|
+
```bash
|
|
536
|
+
bun add @databuddy/sdk
|
|
537
|
+
```
|
|
538
|
+
|
|
362
539
|
```typescript
|
|
363
540
|
export default {
|
|
364
541
|
connectors: {
|
|
@@ -411,6 +588,12 @@ Client `error` and `critical` logs requested through the Databuddy connector are
|
|
|
411
588
|
|
|
412
589
|
Use `connectors.sentry` when you want Blyp logs forwarded into Sentry Logs:
|
|
413
590
|
|
|
591
|
+
Install the optional peer dependency for this connector when you enable it:
|
|
592
|
+
|
|
593
|
+
```bash
|
|
594
|
+
bun add @sentry/node
|
|
595
|
+
```
|
|
596
|
+
|
|
414
597
|
```typescript
|
|
415
598
|
export default {
|
|
416
599
|
connectors: {
|
|
@@ -465,6 +648,12 @@ The browser and Expo Sentry flow still posts to Blyp first. Blyp forwards to Sen
|
|
|
465
648
|
|
|
466
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:
|
|
467
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
|
+
|
|
468
657
|
```typescript
|
|
469
658
|
export default {
|
|
470
659
|
connectors: {
|
|
@@ -560,7 +749,23 @@ bun run type-check
|
|
|
560
749
|
|
|
561
750
|
## Publishing
|
|
562
751
|
|
|
563
|
-
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.
|
|
564
769
|
|
|
565
770
|
## Contributing
|
|
566
771
|
|
|
@@ -579,6 +784,7 @@ This project is licensed under the MIT License — see the [LICENSE](LICENSE) fi
|
|
|
579
784
|
- [GitHub Repository](https://github.com/Blyphq/blyp)
|
|
580
785
|
- [NPM Package](https://www.npmjs.com/package/@blyp/core)
|
|
581
786
|
- [Documentation](docs/README.md)
|
|
787
|
+
- [Security Policy](SECURITY.md)
|
|
582
788
|
- [Issues](https://github.com/Blyphq/blyp/issues)
|
|
583
789
|
|
|
584
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,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,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 {};
|