@rasputin-ai/elysia 0.5.3 → 0.6.1

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 CHANGED
@@ -1,215 +1,5 @@
1
1
  # Official Rasputin AI SDK for Elysia
2
2
 
3
- Report application errors to Rasputin.
3
+ Report application errors to Rasputin from Elysia services.
4
4
 
5
- ## Setup
6
-
7
- Initialize once and register the plugin early in your app:
8
-
9
- ```ts
10
- import { Elysia } from 'elysia';
11
- import { RasputinInit } from '@rasputin-ai/elysia';
12
-
13
- const { client, plugin } = RasputinInit({
14
- projectApiKey: process.env.RASPUTIN_PROJECT_API_KEY!,
15
- release: process.env.RASPUTIN_RELEASE!,
16
- environment: process.env.NODE_ENV ?? 'development',
17
- enabled: ['staging', 'production'].includes(process.env.NODE_ENV ?? 'development'),
18
- });
19
-
20
- const app = new Elysia()
21
- .use(plugin) // Register Rasputin before other plugins when possible.
22
- .use(otherPlugins)
23
- .listen(3000);
24
- ```
25
-
26
- Route errors, uncaught exceptions, and unhandled rejections are reported automatically.
27
-
28
- ## Capture handled errors
29
-
30
- ```ts
31
- try {
32
- await processPayment();
33
- } catch (error) {
34
- client.captureException(error);
35
- }
36
- ```
37
-
38
- ## Configuration
39
-
40
- | Field | Required | Description |
41
- | --- | --- | --- |
42
- | `projectApiKey` | yes | Project API key from the Rasputin dashboard |
43
- | `environment` | yes | Environment such as `production`, `staging`, or `preview` |
44
- | `release` | yes | Git commit SHA for the deployed version |
45
- | `enabled` | no | Enables or disables the SDK; defaults to `true` |
46
- | `logSuccess` | no | Prints a configuration summary when setup succeeds; defaults to `true`. Failures always log. |
47
- | `moduleUrl` | no | `import.meta.url` from the initialization file; helps normalize local stack paths |
48
- | `sourceRoot` | no | Git repository folder for a single-package service, such as `apps/api` |
49
- | `sourceRoots` | no | Package-name to Git-folder mappings for ambiguous monorepos |
50
- | `repoRoot` | no | Local filesystem display root; it does not control instrumentation or Git identity |
51
-
52
- Rasputin normally identifies source from the nearest `package.json` and verifies it against the exact release on the server. Filesystem paths such as `/container` are never used as source identity.
53
-
54
- For deployment checks, call:
55
-
56
- ```ts
57
- const verification = await client.verifyConfiguration();
58
- ```
59
-
60
- `verified` means every instrumented source file maps uniquely to the configured Git release. If a monorepo is ambiguous, set `sourceRoot` or `sourceRoots` using repository-relative folders, never Docker paths.
61
-
62
- Rasputin also prints a configuration summary after the instrumentation manifest is uploaded. Set `logSuccess: false` if you do not want that banner in production logs. Mapping failures still warn.
63
-
64
- ## Shutdown
65
-
66
- Events are sent in the background. Flush before a short-lived process exits:
67
-
68
- ```ts
69
- await client.flush();
70
- ```
71
-
72
- Call `await client.close()` during graceful shutdown when the process stays alive afterward.
73
-
74
- ---
75
-
76
- # Runtime recorder
77
-
78
- Optionally attach the runtime state that led to an error — arguments, return values, and call history from the failing execution.
79
-
80
- The Elysia plugin scopes each HTTP request as an execution automatically. For background jobs and other non-HTTP work, wrap them manually (see below).
81
-
82
- ## Automatic instrumentation
83
-
84
- Rasputin wraps your functions so it can show what ran when an error happened.
85
-
86
- **Compiled JavaScript (use this in production)**
87
-
88
- Build as you already do, then run `rasputin-instrument` on the output. Start the process normally — no extra flags:
89
-
90
- ```json
91
- {
92
- "scripts": {
93
- "build": "tsc && rasputin-instrument dist",
94
- "start:node": "node dist/app.js",
95
- "start:bun": "bun dist/app.js"
96
- }
97
- }
98
- ```
99
-
100
- Have TypeScript write `.js.map` files next to the output so recorded functions still point at your `.ts` sources. The instrumenter writes `.rasputin/instrumentation-manifest.json` beside `dist`, and `RasputinInit` loads it automatically.
101
-
102
- **Running TypeScript directly**
103
-
104
- `rasputin-instrument` rewrites compiled `.js` files on disk. It does not run when you start TypeScript with Bun (`bun src/app.ts`, `bun run src/app.ts`, and similar). Use `--preload` so Bun wraps files as they load:
105
-
106
- ```json
107
- {
108
- "scripts": {
109
- "start:bun": "bun --preload @rasputin-ai/elysia/instrument/bun src/app.ts"
110
- }
111
- }
112
- ```
113
-
114
- On Node you can wrap compiled files as they load instead of instrumenting at build time:
115
-
116
- ```json
117
- {
118
- "scripts": {
119
- "start:node": "node --import @rasputin-ai/elysia/instrument/node dist/app.js"
120
- }
121
- }
122
- ```
123
-
124
- Use `--preload` / `--import` while you run TypeScript locally. In production, instrument at build time instead — wrapping files at startup is slower and uses more memory.
125
-
126
- Runtime state is kept only while a request or job is running, and is attached when that work throws.
127
-
128
- ## Manual capture
129
-
130
- For background jobs, scheduled tasks, or worker iterations, define an execution:
131
-
132
- ```ts
133
- const scope = client.execution.createScope({
134
- kind: 'job',
135
- name: 'sync-invoices',
136
- })
137
-
138
- try {
139
- return await scope.run(() => syncInvoices())
140
- } catch (error) {
141
- scope.associateError(error)
142
- throw error
143
- } finally {
144
- scope.finish()
145
- }
146
- ```
147
-
148
- `scope.run()` executes the callback under this recording's async context and returns exactly what the callback returned. It does not wrap, replace, or observe Promises.
149
-
150
- When automatic instrumentation is unavailable, mark individual functions explicitly:
151
-
152
- ```ts
153
- const syncInvoices = client.execution.trace(
154
- 'src/jobs/sync-invoices.ts:syncInvoices',
155
- async () => {
156
- // ...
157
- },
158
- );
159
- ```
160
-
161
- ## Runtime support
162
-
163
- | Environment | Support |
164
- | --- | --- |
165
- | TypeScript compiled to multiple JavaScript files | Use `rasputin-instrument dist` after `tsc`, with adjacent source maps |
166
- | Elysia 1.4+ on Bun 1.3.x, running `.ts` or `.js` files directly | Use `--preload @rasputin-ai/elysia/instrument/bun` |
167
- | Elysia 1.4+ on Node.js 22.15 or newer, unbundled ESM/CJS | Use `rasputin-instrument`, or `--import @rasputin-ai/elysia/instrument/node`; Node 22 and 24 are the supported LTS lines |
168
-
169
- On Node.js 22, start the process with `--experimental-async-context-frame` (or set `NODE_OPTIONS`) so `AsyncLocalStorage` uses the faster implementation that Node.js 24 enables by default. Rasputin logs this once when the flag is missing; set `RASPUTIN_SUPPRESS_ASYNC_CONTEXT_FRAME_WARNING=1` to hide it.
170
- | Single-file bundles (esbuild, tsup, webpack, Vite SSR, Next.js) | Automatic instrumentation is not supported |
171
- | `tsx`, custom Node loader stacks, and Node's native TypeScript execution | Automatic instrumentation is not supported |
172
- | Deno and edge runtimes | Not supported |
173
-
174
- Tested on Bun 1.3.13, Node.js 24.19.0, and Elysia 1.4.28. Node.js 22.15.0 is the minimum for automatic instrumentation. Use `execution.createScope()` and `execution.trace()` when automatic instrumentation is not available.
175
-
176
- ## Recorder configuration
177
-
178
- Defaults work for most apps. Customize to exclude noisy sources, redact fields, or retain less state:
179
-
180
- | Field | Default | Description |
181
- | --- | ---: | --- |
182
- | `enabled` | `true` | Enables runtime-state capture |
183
- | `maxEventsPerExecution` | `500` | Maximum events retained for one execution |
184
- | `maxCapturedCallsPerFunction` | `3` | Detailed successful calls retained before similar calls are summarized |
185
- | `maxActiveMemoryBytes` | `64 MiB` | Maximum recorder memory shared across active executions |
186
- | `maxDepth` | `3` | Maximum captured value depth |
187
- | `maxObjectKeys` | `30` | Maximum properties retained from one object |
188
- | `maxArrayElements` | `20` | Maximum items retained from one array, map, or set |
189
- | `maxStringLength` | `500` | Maximum characters retained from one string |
190
- | `maxSerializedValueBytes` | `16 KiB` | Maximum retained size of one captured value |
191
- | `runtimeStateTargetBytes` | `256 KiB` | Soft size goal for the snapshot sent with an error; extra reconstruction data is dropped first |
192
- | `maxRuntimeStateBytes` | `512 KiB` | Hard size limit for that snapshot; values are dropped before call history |
193
- | `redactKeys` | `[]` | Additional property names to redact (case- and separator-insensitive) |
194
- | `excludeSources` | `[]` | Source globs or function-name patterns to exclude |
195
-
196
- ```ts
197
- const { client, plugin } = RasputinInit({
198
- // ...required options
199
- executionRecorder: {
200
- excludeSources: ['src/logger/**', 'packages/shared-logger/**'],
201
- redactKeys: ['customerEmail'],
202
- maxEventsPerExecution: 200,
203
- },
204
- });
205
- ```
206
-
207
- Runtime state can include application data. Use `redactKeys` for sensitive fields.
208
-
209
- ## Diagnostics
210
-
211
- ```ts
212
- const { recorder, transport } = client.getStats();
213
- ```
214
-
215
- These counters describe what this process has recorded and sent since it started. They reset on restart. Compare two snapshots if you want activity over a window, rather than dividing lifetime totals by one request.
5
+ See the [Elysia documentation](https://rasputinai.dev/docs/elysia/installation).
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import { Elysia } from "elysia";
13
13
 
14
14
  // src/sdk-meta.ts
15
15
  var SDK_NAME = "@rasputin-ai/elysia";
16
- var SDK_VERSION = "0.5.3";
16
+ var SDK_VERSION = "0.6.1";
17
17
 
18
18
  // src/rasputin-init.ts
19
19
  var publicExecution = (runtime) => ({
@@ -168,7 +168,7 @@ function RasputinInit(options, hooks = {}) {
168
168
  runtime,
169
169
  recorderEnabled,
170
170
  {
171
- projectApiKey: options.projectApiKey ?? "",
171
+ projectApiKey: options.projectApiKey,
172
172
  release: options.release,
173
173
  apiUrl: options.apiUrl,
174
174
  fetch,
@@ -190,7 +190,7 @@ function RasputinInit(options, hooks = {}) {
190
190
  const client = createClient({ ...options, enabled: false });
191
191
  const runtime = createExecutionRecorder({ enabled: false });
192
192
  const wrappedClient = withExecution(client, runtime, false, {
193
- projectApiKey: options.projectApiKey ?? "",
193
+ projectApiKey: options.projectApiKey,
194
194
  release: options.release,
195
195
  apiUrl: options.apiUrl,
196
196
  enabled: false,
@@ -69,6 +69,7 @@ declare const buildPlugin: (client: RasputinNodeClient, execution: Pick<Rasputin
69
69
  *
70
70
  * @example
71
71
  * const { client, plugin } = RasputinInit({
72
+ * dsn: process.env.RASPUTIN_DSN!,
72
73
  * projectApiKey: process.env.RASPUTIN_PROJECT_API_KEY!,
73
74
  * release: process.env.RASPUTIN_RELEASE!,
74
75
  * environment: process.env.NODE_ENV ?? 'development',
@@ -1 +1 @@
1
- {"version":3,"file":"rasputin-init.d.ts","sourceRoot":"","sources":["../src/rasputin-init.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAKN,KAAK,eAAe,EACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACX,wBAAwB,EAExB,iBAAiB,EACjB,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BAAkB,CAAC;IAC3B,2EAA2E;IAC3E,MAAM,EAAE,oBAAoB,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,eAAe,GAAG;IACrD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,wBAAwB,CAAC;IAC7C;;;;;OAKG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;OAGG;IACH,8BAA8B,CAAC,EAAE,OAAO,CAAC;CACzC,CAAC;AA+GF,QAAA,MAAM,WAAW,GAChB,QAAQ,kBAAkB,EAC1B,WAAW,IAAI,CAAC,iBAAiB,EAAE,aAAa,CAAC,EACjD,iBAAiB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsDxB,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,qBAAqB,GAAG,cAAc,CAAC"}
@@ -1,4 +1,4 @@
1
1
  /** Generated by scripts/generate-sdk-meta.ts — do not edit. */
2
2
  export declare const SDK_NAME = "@rasputin-ai/elysia";
3
- export declare const SDK_VERSION = "0.5.3";
3
+ export declare const SDK_VERSION = "0.6.1";
4
4
  //# sourceMappingURL=sdk-meta.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rasputin-ai/elysia",
3
- "version": "0.5.3",
3
+ "version": "0.6.1",
4
4
  "description": "Official Rasputin AI SDK for Elysia.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -35,8 +35,8 @@
35
35
  "access": "public"
36
36
  },
37
37
  "dependencies": {
38
- "@rasputin-ai/core": "0.5.3",
39
- "@rasputin-ai/node": "0.5.3"
38
+ "@rasputin-ai/core": "0.6.1",
39
+ "@rasputin-ai/node": "0.6.1"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "elysia": ">=1.4.0 <2"
@@ -46,7 +46,6 @@
46
46
  "@rasputin-ai/node": "workspace:*",
47
47
  "@types/bun": "1.3.14",
48
48
  "@types/node": "22.13.10",
49
- "esbuild": "0.25.12",
50
49
  "elysia": "1.4.28",
51
50
  "typescript": "5"
52
51
  }