@rasputin-ai/node 0.13.0 → 0.14.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.
Files changed (72) hide show
  1. package/dist/auto-instrumentation/bun-plugin.d.ts.map +1 -1
  2. package/dist/auto-instrumentation/instrument-compiled-esm.d.ts.map +1 -1
  3. package/dist/auto-instrumentation/instrumentation-manifest-registry.d.ts.map +1 -1
  4. package/dist/auto-instrumentation/node-hooks.d.ts.map +1 -1
  5. package/dist/auto-instrumentation/transform-disk-cache.d.ts.map +1 -1
  6. package/dist/execution-metrics/bind-execution-metrics.d.ts +20 -0
  7. package/dist/execution-metrics/bind-execution-metrics.d.ts.map +1 -0
  8. package/dist/execution-metrics/encode-execution-metrics-upload.d.ts +14 -0
  9. package/dist/execution-metrics/encode-execution-metrics-upload.d.ts.map +1 -0
  10. package/dist/execution-metrics/execution-metrics-batches.d.ts +34 -0
  11. package/dist/execution-metrics/execution-metrics-batches.d.ts.map +1 -0
  12. package/dist/execution-metrics/execution-metrics-collector.d.ts +44 -0
  13. package/dist/execution-metrics/execution-metrics-collector.d.ts.map +1 -0
  14. package/dist/execution-metrics/execution-metrics-exporter.d.ts +23 -0
  15. package/dist/execution-metrics/execution-metrics-exporter.d.ts.map +1 -0
  16. package/dist/execution-recorder/adaptive-recording-options.d.ts +0 -2
  17. package/dist/execution-recorder/adaptive-recording-options.d.ts.map +1 -1
  18. package/dist/execution-recorder/bind-adaptive-recorder.d.ts +8 -2
  19. package/dist/execution-recorder/bind-adaptive-recorder.d.ts.map +1 -1
  20. package/dist/execution-recorder/execution-identity.d.ts +6 -0
  21. package/dist/execution-recorder/execution-identity.d.ts.map +1 -1
  22. package/dist/execution-recorder/execution-journal.d.ts +1 -0
  23. package/dist/execution-recorder/execution-journal.d.ts.map +1 -1
  24. package/dist/execution-recorder/execution-recorder-hooks.d.ts +9 -0
  25. package/dist/execution-recorder/execution-recorder-hooks.d.ts.map +1 -1
  26. package/dist/execution-recorder/execution-recorder-types.d.ts +1 -12
  27. package/dist/execution-recorder/execution-recorder-types.d.ts.map +1 -1
  28. package/dist/execution-recorder/execution-recorder.d.ts.map +1 -1
  29. package/dist/execution-recorder/execution-recording-sync.d.ts +2 -2
  30. package/dist/execution-recorder/execution-recording-sync.d.ts.map +1 -1
  31. package/dist/execution-recorder/function-plan.d.ts +3 -1
  32. package/dist/execution-recorder/function-plan.d.ts.map +1 -1
  33. package/dist/function-metrics/bind-function-metrics.d.ts +20 -0
  34. package/dist/function-metrics/bind-function-metrics.d.ts.map +1 -0
  35. package/dist/function-metrics/create-metrics-only-runtime.d.ts +10 -0
  36. package/dist/function-metrics/create-metrics-only-runtime.d.ts.map +1 -0
  37. package/dist/function-metrics/encode-function-metrics-upload.d.ts +14 -0
  38. package/dist/function-metrics/encode-function-metrics-upload.d.ts.map +1 -0
  39. package/dist/function-metrics/function-metric-declaration-registry.d.ts +9 -0
  40. package/dist/function-metrics/function-metric-declaration-registry.d.ts.map +1 -0
  41. package/dist/function-metrics/function-metrics-batches.d.ts +36 -0
  42. package/dist/function-metrics/function-metrics-batches.d.ts.map +1 -0
  43. package/dist/function-metrics/function-metrics-collector.d.ts +60 -0
  44. package/dist/function-metrics/function-metrics-collector.d.ts.map +1 -0
  45. package/dist/function-metrics/function-metrics-exporter.d.ts +23 -0
  46. package/dist/function-metrics/function-metrics-exporter.d.ts.map +1 -0
  47. package/dist/function-metrics/install-function-metric-declaration-sink.d.ts +2 -0
  48. package/dist/function-metrics/install-function-metric-declaration-sink.d.ts.map +1 -0
  49. package/dist/function-metrics/intern-prepared-metrics.d.ts +6 -0
  50. package/dist/function-metrics/intern-prepared-metrics.d.ts.map +1 -0
  51. package/dist/function-metrics/send-function-metrics-batch.d.ts +25 -0
  52. package/dist/function-metrics/send-function-metrics-batch.d.ts.map +1 -0
  53. package/dist/function-metrics/settle-function-metrics.d.ts +8 -0
  54. package/dist/function-metrics/settle-function-metrics.d.ts.map +1 -0
  55. package/dist/index.js +3530 -671
  56. package/dist/instrument/build.js +450 -140
  57. package/dist/instrument/bun.js +454 -132
  58. package/dist/instrument/node.js +452 -132
  59. package/dist/internal.d.ts +5 -0
  60. package/dist/internal.d.ts.map +1 -1
  61. package/dist/internal.js +3836 -1009
  62. package/dist/rasputin-init.d.ts +37 -4
  63. package/dist/rasputin-init.d.ts.map +1 -1
  64. package/dist/runtime-timing/call-duration.d.ts +13 -0
  65. package/dist/runtime-timing/call-duration.d.ts.map +1 -0
  66. package/dist/{execution-recorder → runtime-timing}/dynamic-duration-sampling.d.ts +6 -4
  67. package/dist/runtime-timing/dynamic-duration-sampling.d.ts.map +1 -0
  68. package/dist/runtime-timing/execution-duration.d.ts +5 -0
  69. package/dist/runtime-timing/execution-duration.d.ts.map +1 -0
  70. package/dist/sdk-meta.d.ts +1 -1
  71. package/package.json +2 -2
  72. package/dist/execution-recorder/dynamic-duration-sampling.d.ts.map +0 -1
@@ -1,4 +1,4 @@
1
- import { type RasputinClient, type RasputinClientStats, type RasputinOptions, type SourceVerification } from '@rasputin-ai/core';
1
+ import { type ExecutionMetricsOptions, type FunctionMetricsOptions, type RasputinClient, type RasputinClientStats, type RasputinOptions, type SourceVerification, type TransportFetch } from '@rasputin-ai/core';
2
2
  import { type ExecutionRecorderOptions, type ExecutionRecorderStats, type RasputinExecution } from './execution-recorder';
3
3
  export type RasputinNodeOptions = RasputinOptions & {
4
4
  /**
@@ -24,6 +24,37 @@ export type RasputinNodeOptions = RasputinOptions & {
24
24
  * Set false when the host owns process shutdown.
25
25
  */
26
26
  installTransportSignalHandlers?: boolean;
27
+ /**
28
+ * Measure durations on a progressive schedule shared by function metrics,
29
+ * execution metrics, and lightweight execution recording. Default false
30
+ * times every eligible call and execution. True counts every call,
31
+ * execution, and failure, and times a subset. Function durations are
32
+ * keyed by function, direct caller, and execution type. Execution
33
+ * durations use a separate counter per execution type so they cannot
34
+ * move function sampling. Counters reset hourly. After 5,000 samples
35
+ * the tail rate still samples. Selected sessions, activations, and full
36
+ * capture still record every duration; metric duration statistics follow
37
+ * this schedule so incident traffic does not bias aggregates. Invalid
38
+ * values are treated as false.
39
+ */
40
+ dynamicDurationSampling?: boolean;
41
+ /**
42
+ * Function-level counts, failures, and duration histograms. On with a
43
+ * valid client. Set `enabled: false` to turn them off. Independent of
44
+ * `executionRecorder`. A build key is optional; omit it to use the server
45
+ * artifact id or a process fallback.
46
+ */
47
+ functionMetrics?: FunctionMetricsOptions;
48
+ /**
49
+ * Execution-level counts, failures, and duration histograms. On with a
50
+ * valid client. Set `enabled: false` to turn them off. Independent of
51
+ * `executionRecorder` and `functionMetrics`.
52
+ */
53
+ executionMetrics?: ExecutionMetricsOptions;
54
+ };
55
+ /** @internal Test seams omitted from the published declaration surface. */
56
+ type RasputinNodeHooks = {
57
+ fetch?: TransportFetch;
27
58
  };
28
59
  export type RasputinNodeClientStats = RasputinClientStats & {
29
60
  /** What this process has recorded since it started. See `ExecutionRecorderStats`. */
@@ -48,9 +79,11 @@ export type RasputinNodeClient = Omit<RasputinClient, 'getStats'> & {
48
79
  * dsn: process.env.RASPUTIN_DSN!,
49
80
  * projectApiKey: process.env.RASPUTIN_PROJECT_API_KEY!,
50
81
  * release: process.env.RASPUTIN_RELEASE!,
51
- * environment: process.env.NODE_ENV ?? 'development',
52
- * enabled: ['staging', 'production'].includes(process.env.NODE_ENV ?? 'development'),
82
+ * environment: 'production',
53
83
  * });
54
84
  */
55
- export declare const RasputinInit: (options: RasputinNodeOptions) => RasputinNodeClient;
85
+ export declare function RasputinInit(options: RasputinNodeOptions): RasputinNodeClient;
86
+ /** @internal Test overload; omitted from the published declaration surface. */
87
+ export declare function RasputinInit(options: RasputinNodeOptions, hooks: RasputinNodeHooks): RasputinNodeClient;
88
+ export {};
56
89
  //# sourceMappingURL=rasputin-init.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rasputin-init.d.ts","sourceRoot":"","sources":["../src/rasputin-init.ts"],"names":[],"mappings":"AAMA,OAAO,EAKN,KAAK,cA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 measure: boolean;
5
+ };
6
+ export declare const planCallDuration: (sampler: DurationSampler | undefined, input: {
7
+ forceMeasure: boolean;
8
+ executionType: string | undefined;
9
+ callerFunctionId: string;
10
+ functionId: string;
11
+ }) => CallDurationPlan;
12
+ export {};
13
+ //# sourceMappingURL=call-duration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"call-duration.d.ts","sourceRoot":"","sources":["../../src/runtime-timing/call-duration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,KAAK,gBAAgB,GAAG;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC5B,SAAS,eAAe,GAAG,SAAS,EACpC,OAAO;IACN,YAAY,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;CACnB,KACC,gBAKF,CAAC"}
@@ -1,6 +1,11 @@
1
1
  export declare const DYNAMIC_DURATION_SAMPLE_TAIL_AFTER = 5000;
2
2
  export declare const DYNAMIC_DURATION_SAMPLE_TAIL_DIVISOR = 100;
3
3
  export declare const DYNAMIC_DURATION_SAMPLE_RESET_MS: number;
4
+ export type DurationSampler = {
5
+ take: (executionType: string, callerFunctionId: string, functionId: string) => boolean;
6
+ takeExecution: (executionType: string) => boolean;
7
+ stop: () => void;
8
+ };
4
9
  export declare const dynamicDurationSampleDivisor: (index: number) => number;
5
10
  export declare const shouldSampleDynamicDuration: (index: number) => boolean;
6
11
  /** Stay in the tail stage so `% 100` remains exact after MAX_SAFE_INTEGER. */
@@ -9,8 +14,5 @@ export declare const createDynamicDurationSampleBuckets: (options: {
9
14
  nowMs: () => number;
10
15
  maxBuckets?: number;
11
16
  resetMs?: number;
12
- }) => {
13
- take: (executionType: string, callerFunctionId: string, functionId: string) => boolean;
14
- stop: () => void;
15
- };
17
+ }) => DurationSampler;
16
18
  //# sourceMappingURL=dynamic-duration-sampling.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamic-duration-sampling.d.ts","sourceRoot":"","sources":["../../src/runtime-timing/dynamic-duration-sampling.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,kCAAkC,OAAO,CAAC;AACvD,eAAO,MAAM,oCAAoC,MAAM,CAAC;AACxD,eAAO,MAAM,gCAAgC,QAAiB,CAAC;AAI/D,MAAM,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;IACvF,aAAa,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,OAAO,CAAC;IAClD,IAAI,EAAE,MAAM,IAAI,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,4BAA4B,GAAI,OAAO,MAAM,KAAG,MAM5D,CAAC;AAEF,eAAO,MAAM,2BAA2B,GAAI,OAAO,MAAM,KAAG,OAE3D,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,uBAAuB,GAAI,OAAO,MAAM,KAAG,MAOvD,CAAC;AAEF,eAAO,MAAM,kCAAkC,GAAI,SAAS;IAC3D,KAAK,EAAE,MAAM,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB,KAAG,eAoDH,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { DurationSampler } from './dynamic-duration-sampling';
2
+ export declare const planExecutionDuration: (sampler: DurationSampler | undefined, executionType: string | undefined) => {
3
+ selected: boolean;
4
+ };
5
+ //# sourceMappingURL=execution-duration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-duration.d.ts","sourceRoot":"","sources":["../../src/runtime-timing/execution-duration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,eAAO,MAAM,qBAAqB,GACjC,SAAS,eAAe,GAAG,SAAS,EACpC,eAAe,MAAM,GAAG,SAAS,KAC/B;IAAE,QAAQ,EAAE,OAAO,CAAA;CAIrB,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/node";
3
- export declare const SDK_VERSION = "0.13.0";
3
+ export declare const SDK_VERSION = "0.14.0";
4
4
  //# sourceMappingURL=sdk-meta.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rasputin-ai/node",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "Official Rasputin AI SDK for Node and Bun.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -49,7 +49,7 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@jridgewell/trace-mapping": "0.3.31",
52
- "@rasputin-ai/core": "0.13.0",
52
+ "@rasputin-ai/core": "0.14.0",
53
53
  "typescript": "5"
54
54
  },
55
55
  "devDependencies": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"dynamic-duration-sampling.d.ts","sourceRoot":"","sources":["../../src/execution-recorder/dynamic-duration-sampling.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,kCAAkC,OAAO,CAAC;AACvD,eAAO,MAAM,oCAAoC,MAAM,CAAC;AACxD,eAAO,MAAM,gCAAgC,QAAiB,CAAC;AAG/D,eAAO,MAAM,4BAA4B,GAAI,OAAO,MAAM,KAAG,MAK5D,CAAC;AAEF,eAAO,MAAM,2BAA2B,GAAI,OAAO,MAAM,KAAG,OAE3D,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,uBAAuB,GAAI,OAAO,MAAM,KAAG,MAOvD,CAAC;AAEF,eAAO,MAAM,kCAAkC,GAAI,SAAS;IAC3D,KAAK,EAAE,MAAM,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB,KAAG;IACH,IAAI,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;IACvF,IAAI,EAAE,MAAM,IAAI,CAAC;CA4CjB,CAAC"}