@rasputin-ai/node 0.1.2

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,5 @@
1
+ export type { CaptureContext, RasputinClient, RasputinOptions } from '@rasputin-ai/core';
2
+ export type { InstallGlobalHandlersOptions } from './install-global-handlers';
3
+ export { installGlobalHandlers } from './install-global-handlers';
4
+ export { RasputinInit } from './rasputin-init';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzF,YAAY,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,73 @@
1
+ // src/install-global-handlers.ts
2
+ var installGlobalHandlers = (client, options = {}) => {
3
+ const exitOnUncaught = options.exitOnUncaughtException ?? true;
4
+ const flushTimeoutMs = options.flushTimeoutMs ?? 2e3;
5
+ let handlingUncaught = false;
6
+ const onUnhandledRejection = (reason) => {
7
+ try {
8
+ client.captureException(reason);
9
+ } catch {
10
+ }
11
+ };
12
+ const onUncaughtException = (error) => {
13
+ if (handlingUncaught) {
14
+ process.exit(1);
15
+ return;
16
+ }
17
+ handlingUncaught = true;
18
+ try {
19
+ client.captureException(error);
20
+ } catch {
21
+ }
22
+ const soleListener = process.listenerCount("uncaughtException") <= 1;
23
+ const shutdown = async () => {
24
+ try {
25
+ await client.flush(flushTimeoutMs);
26
+ } catch {
27
+ }
28
+ if (exitOnUncaught && soleListener) process.exit(1);
29
+ };
30
+ void shutdown();
31
+ };
32
+ try {
33
+ process.on("uncaughtException", onUncaughtException);
34
+ process.on("unhandledRejection", onUnhandledRejection);
35
+ } catch {
36
+ return () => {
37
+ };
38
+ }
39
+ return () => {
40
+ try {
41
+ process.off("uncaughtException", onUncaughtException);
42
+ process.off("unhandledRejection", onUnhandledRejection);
43
+ } catch {
44
+ }
45
+ };
46
+ };
47
+
48
+ // src/rasputin-init.ts
49
+ import {
50
+ createClient,
51
+ isClientEnabled
52
+ } from "@rasputin-ai/core";
53
+
54
+ // src/sdk-meta.ts
55
+ var SDK_NAME = "@rasputin-ai/node";
56
+ var SDK_VERSION = "0.1.2";
57
+
58
+ // src/rasputin-init.ts
59
+ var RasputinInit = (options) => {
60
+ try {
61
+ const client = createClient(options, { sdkVersion: SDK_VERSION, sdkName: SDK_NAME });
62
+ if (isClientEnabled(options)) {
63
+ installGlobalHandlers(client);
64
+ }
65
+ return client;
66
+ } catch {
67
+ return createClient({ ...options, enabled: false });
68
+ }
69
+ };
70
+ export {
71
+ RasputinInit,
72
+ installGlobalHandlers
73
+ };
@@ -0,0 +1,18 @@
1
+ import type { RasputinClient } from '@rasputin-ai/core';
2
+ export type InstallGlobalHandlersOptions = {
3
+ /**
4
+ * When we are the only `uncaughtException` listener, flush then `process.exit(1)`
5
+ * (Node's default is suppressed by any listener). When other listeners exist,
6
+ * capture + flush only — they own graceful shutdown / exit.
7
+ */
8
+ exitOnUncaughtException?: boolean;
9
+ /** Flush budget before exit. Default 2000ms. */
10
+ flushTimeoutMs?: number;
11
+ };
12
+ /**
13
+ * Capture process-level failures outside any request handler.
14
+ * `uncaughtException`: capture → flush → exit only if we are the sole listener.
15
+ * `unhandledRejection`: capture only (do not exit).
16
+ */
17
+ export declare const installGlobalHandlers: (client: Pick<RasputinClient, "captureException" | "flush">, options?: InstallGlobalHandlersOptions) => (() => void);
18
+ //# sourceMappingURL=install-global-handlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-global-handlers.d.ts","sourceRoot":"","sources":["../src/install-global-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,MAAM,MAAM,4BAA4B,GAAG;IAC1C;;;;OAIG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,gDAAgD;IAChD,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GACjC,QAAQ,IAAI,CAAC,cAAc,EAAE,kBAAkB,GAAG,OAAO,CAAC,EAC1D,UAAS,4BAAiC,KACxC,CAAC,MAAM,IAAI,CAuDb,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { type RasputinClient, type RasputinOptions } from '@rasputin-ai/core';
2
+ /**
3
+ * Boot the Node/Bun SDK: client + process global handlers.
4
+ * Call once at process start. Never throws into the host app.
5
+ */
6
+ export declare const RasputinInit: (options: RasputinOptions) => RasputinClient;
7
+ //# sourceMappingURL=rasputin-init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rasputin-init.d.ts","sourceRoot":"","sources":["../src/rasputin-init.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,MAAM,mBAAmB,CAAC;AAI3B;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,eAAe,KAAG,cAUvD,CAAC"}
@@ -0,0 +1,4 @@
1
+ /** Generated by packages/sdk/scripts/generate-sdk-meta.ts — do not edit. */
2
+ export declare const SDK_NAME = "@rasputin-ai/node";
3
+ export declare const SDK_VERSION = "0.1.2";
4
+ //# sourceMappingURL=sdk-meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk-meta.d.ts","sourceRoot":"","sources":["../src/sdk-meta.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,eAAO,MAAM,QAAQ,sBAAsB,CAAC;AAC5C,eAAO,MAAM,WAAW,UAAU,CAAC"}
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@rasputin-ai/node",
3
+ "version": "0.1.2",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": {
7
+ "bun": "./src/index.ts",
8
+ "types": "./dist/index.d.ts",
9
+ "import": "./dist/index.js",
10
+ "default": "./dist/index.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "scripts": {
17
+ "build": "bun ../scripts/build-package.ts .",
18
+ "prepublishOnly": "npm run build && bun ../scripts/check-lockstep-versions.ts",
19
+ "pack:check": "npm run build && npm pack --dry-run",
20
+ "typecheck": "bun ../scripts/build-package.ts ../core && bun ../scripts/generate-sdk-meta.ts . && bunx tsc --noEmit",
21
+ "lint": "biome check .",
22
+ "test": "bun test"
23
+ },
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "dependencies": {
28
+ "@rasputin-ai/core": "0.1.2"
29
+ },
30
+ "devDependencies": {
31
+ "@rasputin-ai/core": "workspace:*",
32
+ "@types/bun": "latest",
33
+ "@types/node": "22.13.10",
34
+ "esbuild": "0.25.12",
35
+ "typescript": "5"
36
+ }
37
+ }