@lssm/lib.observability 0.0.0-canary-20251120192244 → 0.2.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 (70) hide show
  1. package/.turbo/turbo-build.log +92 -29
  2. package/.turbo/turbo-lint.log +20 -0
  3. package/CHANGELOG.md +12 -1
  4. package/README.md +6 -0
  5. package/dist/anomaly/alert-manager.d.mts +21 -0
  6. package/dist/anomaly/alert-manager.d.mts.map +1 -0
  7. package/dist/anomaly/alert-manager.mjs +2 -0
  8. package/dist/anomaly/alert-manager.mjs.map +1 -0
  9. package/dist/anomaly/anomaly-detector.d.mts +26 -0
  10. package/dist/anomaly/anomaly-detector.d.mts.map +1 -0
  11. package/dist/anomaly/anomaly-detector.mjs +2 -0
  12. package/dist/anomaly/anomaly-detector.mjs.map +1 -0
  13. package/dist/anomaly/baseline-calculator.d.mts +26 -0
  14. package/dist/anomaly/baseline-calculator.d.mts.map +1 -0
  15. package/dist/anomaly/baseline-calculator.mjs +2 -0
  16. package/dist/anomaly/baseline-calculator.mjs.map +1 -0
  17. package/dist/anomaly/root-cause-analyzer.d.mts +23 -0
  18. package/dist/anomaly/root-cause-analyzer.d.mts.map +1 -0
  19. package/dist/anomaly/root-cause-analyzer.mjs +2 -0
  20. package/dist/anomaly/root-cause-analyzer.mjs.map +1 -0
  21. package/dist/index.d.mts +10 -2
  22. package/dist/index.mjs +1 -1
  23. package/dist/intent/aggregator.d.mts +60 -0
  24. package/dist/intent/aggregator.d.mts.map +1 -0
  25. package/dist/intent/aggregator.mjs +2 -0
  26. package/dist/intent/aggregator.mjs.map +1 -0
  27. package/dist/intent/detector.d.mts +32 -0
  28. package/dist/intent/detector.d.mts.map +1 -0
  29. package/dist/intent/detector.mjs +2 -0
  30. package/dist/intent/detector.mjs.map +1 -0
  31. package/dist/lifecycle/dist/index.mjs +1 -0
  32. package/dist/lifecycle/dist/types/axes.mjs +2 -0
  33. package/dist/lifecycle/dist/types/axes.mjs.map +1 -0
  34. package/dist/lifecycle/dist/types/milestones.mjs +1 -0
  35. package/dist/lifecycle/dist/types/signals.mjs +1 -0
  36. package/dist/lifecycle/dist/types/stages.mjs +2 -0
  37. package/dist/lifecycle/dist/types/stages.mjs.map +1 -0
  38. package/dist/lifecycle/dist/utils/formatters.mjs +2 -0
  39. package/dist/lifecycle/dist/utils/formatters.mjs.map +1 -0
  40. package/dist/logging/index.mjs.map +1 -1
  41. package/dist/metrics/index.mjs.map +1 -1
  42. package/dist/pipeline/evolution-pipeline.d.mts +40 -0
  43. package/dist/pipeline/evolution-pipeline.d.mts.map +1 -0
  44. package/dist/pipeline/evolution-pipeline.mjs +2 -0
  45. package/dist/pipeline/evolution-pipeline.mjs.map +1 -0
  46. package/dist/pipeline/lifecycle-pipeline.d.mts +44 -0
  47. package/dist/pipeline/lifecycle-pipeline.d.mts.map +1 -0
  48. package/dist/pipeline/lifecycle-pipeline.mjs +2 -0
  49. package/dist/pipeline/lifecycle-pipeline.mjs.map +1 -0
  50. package/dist/tracing/index.mjs.map +1 -1
  51. package/dist/tracing/middleware.d.mts +16 -2
  52. package/dist/tracing/middleware.d.mts.map +1 -1
  53. package/dist/tracing/middleware.mjs +1 -1
  54. package/dist/tracing/middleware.mjs.map +1 -1
  55. package/package.json +12 -1
  56. package/src/anomaly/alert-manager.ts +31 -0
  57. package/src/anomaly/anomaly-detector.ts +94 -0
  58. package/src/anomaly/baseline-calculator.ts +54 -0
  59. package/src/anomaly/root-cause-analyzer.ts +55 -0
  60. package/src/index.ts +35 -1
  61. package/src/intent/aggregator.ts +161 -0
  62. package/src/intent/detector.ts +187 -0
  63. package/src/logging/index.ts +0 -1
  64. package/src/metrics/index.ts +0 -1
  65. package/src/pipeline/evolution-pipeline.ts +90 -0
  66. package/src/pipeline/lifecycle-pipeline.ts +105 -0
  67. package/src/tracing/index.ts +0 -1
  68. package/src/tracing/middleware.ts +76 -1
  69. package/tsconfig.json +6 -0
  70. package/tsconfig.tsbuildinfo +1 -1
@@ -1,29 +1,92 @@
1
- $ bun build:bundle && bun build:types
2
- $ tsdown
3
- ℹ tsdown v0.15.12 powered by rolldown v1.0.0-beta.45
4
- ℹ Using tsdown config: /home/runner/work/contractspec/contractspec/packages/libs/observability/tsdown.config.js
5
- ℹ entry: src/index.ts, src/logging/index.ts, src/metrics/index.ts, src/tracing/index.ts, src/tracing/middleware.ts
6
- ℹ target: esnext
7
- ℹ tsconfig: tsconfig.json
8
- ℹ Build start
9
- ℹ dist/metrics/index.mjs 0.73 kB │ gzip: 0.36 kB
10
- ℹ dist/tracing/index.mjs 0.71 kB │ gzip: 0.34 kB
11
- ℹ dist/tracing/middleware.mjs 0.65 kB │ gzip: 0.39 kB
12
- ℹ dist/logging/index.mjs 0.59 kB │ gzip: 0.38 kB
13
- ℹ dist/index.mjs 0.54 kB │ gzip: 0.24 kB
14
- ℹ dist/tracing/index.mjs.map 2.34 kB │ gzip: 0.77 kB
15
- ℹ dist/logging/index.mjs.map 2.10 kB │ gzip: 0.85 kB
16
- ℹ dist/metrics/index.mjs.map 1.87 kB │ gzip: 0.68 kB
17
- ℹ dist/tracing/middleware.mjs.map 1.75 kB │ gzip: 0.80 kB
18
- ℹ dist/metrics/index.d.mts.map 0.42 kB │ gzip: 0.26 kB
19
- ℹ dist/logging/index.d.mts.map 0.36 kB │ gzip: 0.24 kB
20
- ℹ dist/tracing/index.d.mts.map 0.33 kB │ gzip: 0.23 kB
21
- ℹ dist/tracing/middleware.d.mts.map 0.17 kB │ gzip: 0.15 kB
22
- ℹ dist/metrics/index.d.mts 0.94 kB │ gzip: 0.34 kB
23
- ℹ dist/logging/index.d.mts 0.66 kB │ gzip: 0.31 kB
24
- ℹ dist/index.d.mts 0.53 kB │ gzip: 0.22 kB
25
- ℹ dist/tracing/index.d.mts 0.43 kB │ gzip: 0.23 kB
26
- ℹ dist/tracing/middleware.d.mts 0.24 kB │ gzip: 0.17 kB
27
- ℹ 18 files, total: 15.38 kB
28
- ✔ Build complete in 35694ms
29
- $ tsc --noEmit
1
+
2
+ $ bun build:bundle && bun build:types
3
+ $ tsdown
4
+ ℹ tsdown v0.16.6 powered by rolldown v1.0.0-beta.51
5
+ ℹ Using tsdown config: /Users/tboutron/Documents/clients/lssm/monorepo-lssm/packages/contractspec/packages/libs/observability/tsdown.config.js
6
+ ℹ entry: src/index.ts, src/anomaly/alert-manager.ts, src/anomaly/anomaly-detector.ts, src/anomaly/baseline-calculator.ts, src/anomaly/root-cause-analyzer.ts, src/logging/index.ts, src/intent/aggregator.ts, src/intent/detector.ts, src/tracing/index.ts, src/tracing/middleware.ts, src/pipeline/evolution-pipeline.ts, src/pipeline/lifecycle-pipeline.ts, src/metrics/index.ts
7
+ ℹ target: esnext
8
+ ℹ tsconfig: tsconfig.json
9
+ ℹ Build start
10
+ ℹ Cleaning 69 files
11
+ ℹ dist/intent/detector.mjs 2.49 kB │ gzip: 0.88 kB
12
+ ℹ dist/intent/aggregator.mjs 1.88 kB │ gzip: 0.86 kB
13
+ ℹ dist/pipeline/lifecycle-pipeline.mjs 1.67 kB │ gzip: 0.66 kB
14
+ ℹ dist/tracing/middleware.mjs 1.26 kB │ gzip: 0.65 kB
15
+ ℹ dist/index.mjs 1.24 kB │ gzip: 0.45 kB
16
+ ℹ dist/pipeline/evolution-pipeline.mjs 1.18 kB │ gzip: 0.55 kB
17
+ ℹ dist/anomaly/anomaly-detector.mjs 0.95 kB │ gzip: 0.45 kB
18
+ ℹ dist/metrics/index.mjs 0.73 kB │ gzip: 0.36 kB
19
+ ℹ dist/tracing/index.mjs 0.71 kB │ gzip: 0.34 kB
20
+ ℹ dist/anomaly/root-cause-analyzer.mjs 0.69 kB │ gzip: 0.45 kB
21
+ ℹ dist/anomaly/baseline-calculator.mjs 0.66 kB │ gzip: 0.31 kB
22
+ ℹ dist/logging/index.mjs 0.59 kB │ gzip: 0.38 kB
23
+ ℹ dist/anomaly/alert-manager.mjs 0.37 kB │ gzip: 0.26 kB
24
+ ℹ dist/intent/detector.mjs.map 7.77 kB │ gzip: 2.12 kB
25
+ ℹ dist/intent/aggregator.mjs.map 7.69 kB │ gzip: 2.41 kB
26
+ ℹ dist/lifecycle/dist/types/stages.mjs.map 4.93 kB │ gzip: 1.94 kB
27
+ ℹ dist/pipeline/lifecycle-pipeline.mjs.map 4.76 kB │ gzip: 1.46 kB
28
+ ℹ dist/tracing/middleware.mjs.map 4.31 kB │ gzip: 1.58 kB
29
+ ℹ dist/pipeline/evolution-pipeline.mjs.map 3.91 kB │ gzip: 1.37 kB
30
+ ℹ dist/anomaly/anomaly-detector.mjs.map 3.48 kB │ gzip: 1.12 kB
31
+ ℹ dist/lifecycle/dist/types/stages.mjs 2.95 kB │ gzip: 1.30 kB
32
+ ℹ dist/tracing/index.mjs.map 2.33 kB │ gzip: 0.77 kB
33
+ ℹ dist/anomaly/root-cause-analyzer.mjs.map 2.29 kB │ gzip: 1.05 kB
34
+ ℹ dist/anomaly/baseline-calculator.mjs.map 2.12 kB │ gzip: 0.76 kB
35
+ ℹ dist/logging/index.mjs.map 2.10 kB │ gzip: 0.85 kB
36
+ ℹ dist/metrics/index.mjs.map 1.87 kB │ gzip: 0.68 kB
37
+ ℹ dist/anomaly/alert-manager.mjs.map 1.44 kB │ gzip: 0.70 kB
38
+ ℹ dist/lifecycle/dist/utils/formatters.mjs.map 1.11 kB │ gzip: 0.68 kB
39
+ ℹ dist/lifecycle/dist/types/axes.mjs.map 1.00 kB │ gzip: 0.48 kB
40
+ ℹ dist/intent/aggregator.d.mts.map 0.67 kB │ gzip: 0.33 kB
41
+ ℹ dist/intent/detector.d.mts.map 0.63 kB │ gzip: 0.33 kB
42
+ ℹ dist/pipeline/evolution-pipeline.d.mts.map 0.62 kB │ gzip: 0.35 kB
43
+ ℹ dist/tracing/middleware.d.mts.map 0.61 kB │ gzip: 0.30 kB
44
+ ℹ dist/anomaly/alert-manager.d.mts.map 0.46 kB │ gzip: 0.25 kB
45
+ ℹ dist/lifecycle/dist/types/axes.mjs 0.44 kB │ gzip: 0.25 kB
46
+ ℹ dist/anomaly/anomaly-detector.d.mts.map 0.44 kB │ gzip: 0.27 kB
47
+ ℹ dist/pipeline/lifecycle-pipeline.d.mts.map 0.43 kB │ gzip: 0.27 kB
48
+ ℹ dist/metrics/index.d.mts.map 0.42 kB │ gzip: 0.26 kB
49
+ ℹ dist/logging/index.d.mts.map 0.36 kB │ gzip: 0.24 kB
50
+ ℹ dist/anomaly/root-cause-analyzer.d.mts.map 0.35 kB │ gzip: 0.24 kB
51
+ ℹ dist/tracing/index.d.mts.map 0.33 kB │ gzip: 0.23 kB
52
+ ℹ dist/anomaly/baseline-calculator.d.mts.map 0.33 kB │ gzip: 0.22 kB
53
+ ℹ dist/lifecycle/dist/utils/formatters.mjs 0.20 kB │ gzip: 0.17 kB
54
+ ℹ dist/lifecycle/dist/index.mjs 0.18 kB │ gzip: 0.12 kB
55
+ ℹ dist/lifecycle/dist/types/milestones.mjs 0.02 kB │ gzip: 0.04 kB
56
+ ℹ dist/lifecycle/dist/types/signals.mjs 0.02 kB │ gzip: 0.04 kB
57
+ ℹ dist/index.d.mts 1.78 kB │ gzip: 0.51 kB
58
+ ℹ dist/intent/aggregator.d.mts 1.53 kB │ gzip: 0.55 kB
59
+ ℹ dist/pipeline/evolution-pipeline.d.mts 1.32 kB │ gzip: 0.52 kB
60
+ ℹ dist/pipeline/lifecycle-pipeline.d.mts 1.30 kB │ gzip: 0.51 kB
61
+ ℹ dist/intent/detector.d.mts 1.16 kB │ gzip: 0.52 kB
62
+ ℹ dist/metrics/index.d.mts 0.94 kB │ gzip: 0.34 kB
63
+ ℹ dist/anomaly/anomaly-detector.d.mts 0.81 kB │ gzip: 0.40 kB
64
+ ℹ dist/tracing/middleware.d.mts 0.70 kB │ gzip: 0.34 kB
65
+ ℹ dist/anomaly/root-cause-analyzer.d.mts 0.68 kB │ gzip: 0.37 kB
66
+ ℹ dist/anomaly/alert-manager.d.mts 0.68 kB │ gzip: 0.34 kB
67
+ ℹ dist/logging/index.d.mts 0.66 kB │ gzip: 0.31 kB
68
+ ℹ dist/anomaly/baseline-calculator.d.mts 0.66 kB │ gzip: 0.30 kB
69
+ ℹ dist/tracing/index.d.mts 0.43 kB │ gzip: 0.23 kB
70
+ ℹ 59 files, total: 87.66 kB
71
+ [UNRESOLVED_IMPORT] Warning: Could not resolve 'node:events' in src/pipeline/evolution-pipeline.ts
72
+ ╭─[ src/pipeline/evolution-pipeline.ts:1:30 ]
73
+ │
74
+ 1 │ import { EventEmitter } from 'node:events';
75
+  │ ──────┬──────
76
+  │ ╰──────── Module not found, treating it as an external dependency
77
+  │
78
+  │ Help: The "main" field here was ignored. Main fields must be configured explicitly when using the "neutral" platform.
79
+ ───╯
80
+
81
+ [UNRESOLVED_IMPORT] Warning: Could not resolve 'node:events' in src/pipeline/lifecycle-pipeline.ts
82
+ ╭─[ src/pipeline/lifecycle-pipeline.ts:1:30 ]
83
+ │
84
+ 1 │ import { EventEmitter } from 'node:events';
85
+  │ ──────┬──────
86
+  │ ╰──────── Module not found, treating it as an external dependency
87
+  │
88
+  │ Help: The "main" field here was ignored. Main fields must be configured explicitly when using the "neutral" platform.
89
+ ───╯
90
+
91
+ ✔ Build complete in 6428ms
92
+ $ tsc --noEmit
@@ -0,0 +1,20 @@
1
+
2
+ $ bun lint:fix
3
+ $ eslint src --fix
4
+ 
5
+ /Users/tboutron/Documents/clients/lssm/monorepo-lssm/packages/contractspec/packages/libs/observability/src/anomaly/root-cause-analyzer.ts
6
+  35:17 error Forbidden non-null assertion @typescript-eslint/no-non-null-assertion
7
+ 
8
+ /Users/tboutron/Documents/clients/lssm/monorepo-lssm/packages/contractspec/packages/libs/observability/src/intent/aggregator.ts
9
+  107:20 error Forbidden non-null assertion @typescript-eslint/no-non-null-assertion
10
+  133:17 error 'traceId' is assigned a value but never used. Allowed unused elements of array destructuring must match /^_/u @typescript-eslint/no-unused-vars
11
+  158:35 error Forbidden non-null assertion @typescript-eslint/no-non-null-assertion
12
+  160:10 error Forbidden non-null assertion @typescript-eslint/no-non-null-assertion
13
+ 
14
+ /Users/tboutron/Documents/clients/lssm/monorepo-lssm/packages/contractspec/packages/libs/observability/src/tracing/index.ts
15
+  3:3 error 'context' is defined but never used. Allowed unused vars must match /^_/u @typescript-eslint/no-unused-vars
16
+ 
17
+ ✖ 6 problems (6 errors, 0 warnings)
18
+ 
19
+ error: script "lint:fix" exited with code 1
20
+ error: script "lint" exited with code 1
package/CHANGELOG.md CHANGED
@@ -1,6 +1,17 @@
1
1
  # @lssm/lib.observability
2
2
 
3
- ## 0.0.0-canary-20251120192244
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b1d0876: Managed platform
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [b1d0876]
12
+ - @lssm/lib.lifecycle@0.1.0
13
+
14
+ ## 0.1.0
4
15
 
5
16
  ### Minor Changes
6
17
 
package/README.md CHANGED
@@ -48,3 +48,9 @@ app.use(createTracingMiddleware());
48
48
 
49
49
  Full docs: https://contractspec.chaman.ventures/docs/libraries/observability
50
50
 
51
+
52
+
53
+
54
+
55
+
56
+
@@ -0,0 +1,21 @@
1
+ import { AnomalySignal } from "./anomaly-detector.mjs";
2
+ import { RootCauseAnalysis } from "./root-cause-analyzer.mjs";
3
+
4
+ //#region src/anomaly/alert-manager.d.ts
5
+ interface AlertManagerOptions {
6
+ cooldownMs?: number;
7
+ transport: (payload: {
8
+ signal: AnomalySignal;
9
+ analysis: RootCauseAnalysis;
10
+ }) => Promise<void> | void;
11
+ }
12
+ declare class AlertManager {
13
+ private readonly options;
14
+ private readonly cooldownMs;
15
+ private readonly lastAlert;
16
+ constructor(options: AlertManagerOptions);
17
+ notify(signal: AnomalySignal, analysis: RootCauseAnalysis): Promise<void>;
18
+ }
19
+ //#endregion
20
+ export { AlertManager, AlertManagerOptions };
21
+ //# sourceMappingURL=alert-manager.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert-manager.d.mts","names":[],"sources":["../../src/anomaly/alert-manager.ts"],"sourcesContent":[],"mappings":";;;;UAGiB,mBAAA;;EAAA,SAAA,EAAA,CAAA,OAAA,EAAA;IAGL,MAAA,EAAA,aAAA;IACE,QAAA,EAAA,iBAAA;EACN,CAAA,EAAA,GAAA,OAAA,CAAA,IAAA,CAAA,GAAA,IAAA;;AAGK,cAAA,YAAA,CAAY;EAIe,iBAAA,OAAA;EAIjB,iBAAA,UAAA;EAAyB,iBAAA,SAAA;EAAiB,WAAA,CAAA,OAAA,EAJzB,mBAIyB;EAAA,MAAA,CAAA,MAAA,EAA1C,aAA0C,EAAA,QAAA,EAAjB,iBAAiB,CAAA,EAAA,OAAA,CAAA,IAAA,CAAA"}
@@ -0,0 +1,2 @@
1
+ var e=class{cooldownMs;lastAlert=new Map;constructor(e){this.options=e,this.cooldownMs=e.cooldownMs??6e4}async notify(e,t){let n=`${e.type}:${t.culprit?.id??`none`}`,r=Date.now();r-(this.lastAlert.get(n)??0)<this.cooldownMs||(await this.options.transport({signal:e,analysis:t}),this.lastAlert.set(n,r))}};export{e as AlertManager};
2
+ //# sourceMappingURL=alert-manager.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert-manager.mjs","names":["options: AlertManagerOptions"],"sources":["../../src/anomaly/alert-manager.ts"],"sourcesContent":["import type { AnomalySignal } from './anomaly-detector';\nimport type { RootCauseAnalysis } from './root-cause-analyzer';\n\nexport interface AlertManagerOptions {\n cooldownMs?: number;\n transport: (payload: {\n signal: AnomalySignal;\n analysis: RootCauseAnalysis;\n }) => Promise<void> | void;\n}\n\nexport class AlertManager {\n private readonly cooldownMs: number;\n private readonly lastAlert = new Map<string, number>();\n\n constructor(private readonly options: AlertManagerOptions) {\n this.cooldownMs = options.cooldownMs ?? 60_000;\n }\n\n async notify(signal: AnomalySignal, analysis: RootCauseAnalysis) {\n const key = `${signal.type}:${analysis.culprit?.id ?? 'none'}`;\n const now = Date.now();\n const last = this.lastAlert.get(key) ?? 0;\n if (now - last < this.cooldownMs) {\n return;\n }\n\n await this.options.transport({ signal, analysis });\n this.lastAlert.set(key, now);\n }\n}\n"],"mappings":"AAWA,IAAa,EAAb,KAA0B,CACxB,WACA,UAA6B,IAAI,IAEjC,YAAY,EAA+C,CAA9B,KAAA,QAAA,EAC3B,KAAK,WAAa,EAAQ,YAAc,IAG1C,MAAM,OAAO,EAAuB,EAA6B,CAC/D,IAAM,EAAM,GAAG,EAAO,KAAK,GAAG,EAAS,SAAS,IAAM,SAChD,EAAM,KAAK,KAAK,CAElB,GADS,KAAK,UAAU,IAAI,EAAI,EAAI,GACvB,KAAK,aAItB,MAAM,KAAK,QAAQ,UAAU,CAAE,SAAQ,WAAU,CAAC,CAClD,KAAK,UAAU,IAAI,EAAK,EAAI"}
@@ -0,0 +1,26 @@
1
+ import { BaselineCalculator, MetricPoint } from "./baseline-calculator.mjs";
2
+
3
+ //#region src/anomaly/anomaly-detector.d.ts
4
+ interface AnomalyThresholds {
5
+ errorRateDelta?: number;
6
+ latencyDelta?: number;
7
+ throughputDrop?: number;
8
+ minSamples?: number;
9
+ }
10
+ interface AnomalySignal {
11
+ type: 'error_rate_spike' | 'latency_regression' | 'throughput_drop';
12
+ delta: number;
13
+ point: MetricPoint;
14
+ baseline: ReturnType<BaselineCalculator['getSnapshot']>;
15
+ }
16
+ declare class AnomalyDetector {
17
+ private readonly baseline;
18
+ private readonly thresholds;
19
+ constructor(options?: AnomalyThresholds);
20
+ evaluate(point: MetricPoint): AnomalySignal[];
21
+ private relativeDelta;
22
+ private relativeDrop;
23
+ }
24
+ //#endregion
25
+ export { AnomalyDetector, AnomalySignal, AnomalyThresholds };
26
+ //# sourceMappingURL=anomaly-detector.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anomaly-detector.d.mts","names":[],"sources":["../../src/anomaly/anomaly-detector.ts"],"sourcesContent":[],"mappings":";;;UAEiB,iBAAA;;EAAA,YAAA,CAAA,EAAA,MAAiB;EAOjB,cAAA,CAAA,EAAa,MAAA;EAGrB,UAAA,CAAA,EAAA,MAAA;;AACG,UAJK,aAAA,CAIL;EAAU,IAAA,EAAA,kBAAA,GAAA,oBAAA,GAAA,iBAAA;EAGT,KAAA,EAAA,MAAA;EASU,KAAA,EAbd,WAac;EAKL,QAAA,EAjBN,UAiBM,CAjBK,kBAiBL,CAAA,aAAA,CAAA,CAAA;;AAA2B,cAdhC,eAAA,CAcgC;;;wBALtB;kBAKL,cAAc"}
@@ -0,0 +1,2 @@
1
+ import{BaselineCalculator as e}from"./baseline-calculator.mjs";var t=class{baseline;thresholds={errorRateDelta:.5,latencyDelta:.35,throughputDrop:.4,minSamples:10};constructor(t={}){this.baseline=new e,this.thresholds={...this.thresholds,...t}}evaluate(e){let t=this.baseline.update(e);if(t.sampleCount<this.thresholds.minSamples)return[];let n=[],r=this.relativeDelta(e.errorRate,t.errorRate);r>this.thresholds.errorRateDelta&&n.push({type:`error_rate_spike`,delta:r,point:e,baseline:t});let i=this.relativeDelta(e.latencyP99,t.latencyP99);i>this.thresholds.latencyDelta&&n.push({type:`latency_regression`,delta:i,point:e,baseline:t});let a=this.relativeDrop(e.throughput,t.throughput);return a>this.thresholds.throughputDrop&&n.push({type:`throughput_drop`,delta:a,point:e,baseline:t}),n}relativeDelta(e,t){return t===0?0:(e-t)/t}relativeDrop(e,t){return t===0?0:(t-e)/t}};export{t as AnomalyDetector};
2
+ //# sourceMappingURL=anomaly-detector.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anomaly-detector.mjs","names":["signals: AnomalySignal[]"],"sources":["../../src/anomaly/anomaly-detector.ts"],"sourcesContent":["import { BaselineCalculator, type MetricPoint } from './baseline-calculator';\n\nexport interface AnomalyThresholds {\n errorRateDelta?: number;\n latencyDelta?: number;\n throughputDrop?: number;\n minSamples?: number;\n}\n\nexport interface AnomalySignal {\n type: 'error_rate_spike' | 'latency_regression' | 'throughput_drop';\n delta: number;\n point: MetricPoint;\n baseline: ReturnType<BaselineCalculator['getSnapshot']>;\n}\n\nexport class AnomalyDetector {\n private readonly baseline: BaselineCalculator;\n private readonly thresholds: Required<AnomalyThresholds> = {\n errorRateDelta: 0.5,\n latencyDelta: 0.35,\n throughputDrop: 0.4,\n minSamples: 10,\n } as Required<AnomalyThresholds>;\n\n constructor(options: AnomalyThresholds = {}) {\n this.baseline = new BaselineCalculator();\n this.thresholds = { ...this.thresholds, ...options };\n }\n\n evaluate(point: MetricPoint): AnomalySignal[] {\n const baselineSnapshot = this.baseline.update(point);\n if (baselineSnapshot.sampleCount < this.thresholds.minSamples) {\n return [];\n }\n\n const signals: AnomalySignal[] = [];\n\n const errorDelta = this.relativeDelta(\n point.errorRate,\n baselineSnapshot.errorRate\n );\n if (errorDelta > this.thresholds.errorRateDelta) {\n signals.push({\n type: 'error_rate_spike',\n delta: errorDelta,\n point,\n baseline: baselineSnapshot,\n });\n }\n\n const latencyDelta = this.relativeDelta(\n point.latencyP99,\n baselineSnapshot.latencyP99\n );\n if (latencyDelta > this.thresholds.latencyDelta) {\n signals.push({\n type: 'latency_regression',\n delta: latencyDelta,\n point,\n baseline: baselineSnapshot,\n });\n }\n\n const throughputDelta = this.relativeDrop(\n point.throughput,\n baselineSnapshot.throughput\n );\n if (throughputDelta > this.thresholds.throughputDrop) {\n signals.push({\n type: 'throughput_drop',\n delta: throughputDelta,\n point,\n baseline: baselineSnapshot,\n });\n }\n\n return signals;\n }\n\n private relativeDelta(value: number, baseline: number) {\n if (baseline === 0) {\n return 0;\n }\n return (value - baseline) / baseline;\n }\n\n private relativeDrop(value: number, baseline: number) {\n if (baseline === 0) {\n return 0;\n }\n return (baseline - value) / baseline;\n }\n}\n"],"mappings":"+DAgBA,IAAa,EAAb,KAA6B,CAC3B,SACA,WAA2D,CACzD,eAAgB,GAChB,aAAc,IACd,eAAgB,GAChB,WAAY,GACb,CAED,YAAY,EAA6B,EAAE,CAAE,CAC3C,KAAK,SAAW,IAAI,EACpB,KAAK,WAAa,CAAE,GAAG,KAAK,WAAY,GAAG,EAAS,CAGtD,SAAS,EAAqC,CAC5C,IAAM,EAAmB,KAAK,SAAS,OAAO,EAAM,CACpD,GAAI,EAAiB,YAAc,KAAK,WAAW,WACjD,MAAO,EAAE,CAGX,IAAMA,EAA2B,EAAE,CAE7B,EAAa,KAAK,cACtB,EAAM,UACN,EAAiB,UAClB,CACG,EAAa,KAAK,WAAW,gBAC/B,EAAQ,KAAK,CACX,KAAM,mBACN,MAAO,EACP,QACA,SAAU,EACX,CAAC,CAGJ,IAAM,EAAe,KAAK,cACxB,EAAM,WACN,EAAiB,WAClB,CACG,EAAe,KAAK,WAAW,cACjC,EAAQ,KAAK,CACX,KAAM,qBACN,MAAO,EACP,QACA,SAAU,EACX,CAAC,CAGJ,IAAM,EAAkB,KAAK,aAC3B,EAAM,WACN,EAAiB,WAClB,CAUD,OATI,EAAkB,KAAK,WAAW,gBACpC,EAAQ,KAAK,CACX,KAAM,kBACN,MAAO,EACP,QACA,SAAU,EACX,CAAC,CAGG,EAGT,cAAsB,EAAe,EAAkB,CAIrD,OAHI,IAAa,EACR,GAED,EAAQ,GAAY,EAG9B,aAAqB,EAAe,EAAkB,CAIpD,OAHI,IAAa,EACR,GAED,EAAW,GAAS"}
@@ -0,0 +1,26 @@
1
+ //#region src/anomaly/baseline-calculator.d.ts
2
+ interface MetricPoint {
3
+ latencyP99: number;
4
+ latencyP95: number;
5
+ errorRate: number;
6
+ throughput: number;
7
+ timestamp: Date;
8
+ }
9
+ interface BaselineSnapshot {
10
+ latencyP99: number;
11
+ latencyP95: number;
12
+ errorRate: number;
13
+ throughput: number;
14
+ sampleCount: number;
15
+ }
16
+ declare class BaselineCalculator {
17
+ private readonly alpha;
18
+ private snapshot;
19
+ constructor(alpha?: number);
20
+ update(point: MetricPoint): BaselineSnapshot;
21
+ getSnapshot(): BaselineSnapshot;
22
+ private mix;
23
+ }
24
+ //#endregion
25
+ export { BaselineCalculator, BaselineSnapshot, MetricPoint };
26
+ //# sourceMappingURL=baseline-calculator.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseline-calculator.d.mts","names":[],"sources":["../../src/anomaly/baseline-calculator.ts"],"sourcesContent":[],"mappings":";UAAiB,WAAA;EAAA,UAAA,EAAA,MAAW;EAQX,UAAA,EAAA,MAAA;EAQJ,SAAA,EAAA,MAAA;EAWG,UAAA,EAAA,MAAA;EAAc,SAAA,EAtBjB,IAsBiB;;AAgBjB,UAnCI,gBAAA,CAmCJ;;;;;;;cA3BA,kBAAA;;;;gBAWG,cAAc;iBAgBjB"}
@@ -0,0 +1,2 @@
1
+ var e=class{snapshot={latencyP99:0,latencyP95:0,errorRate:0,throughput:0,sampleCount:0};constructor(e=.2){this.alpha=e}update(e){let{sampleCount:t}=this.snapshot,n=t+1,r=t===0?1:this.alpha;return this.snapshot={latencyP99:this.mix(this.snapshot.latencyP99,e.latencyP99,r),latencyP95:this.mix(this.snapshot.latencyP95,e.latencyP95,r),errorRate:this.mix(this.snapshot.errorRate,e.errorRate,r),throughput:this.mix(this.snapshot.throughput,e.throughput,r),sampleCount:n},this.snapshot}getSnapshot(){return this.snapshot}mix(e,t,n){return this.snapshot.sampleCount===0?t:e*(1-n)+t*n}};export{e as BaselineCalculator};
2
+ //# sourceMappingURL=baseline-calculator.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseline-calculator.mjs","names":[],"sources":["../../src/anomaly/baseline-calculator.ts"],"sourcesContent":["export interface MetricPoint {\n latencyP99: number;\n latencyP95: number;\n errorRate: number;\n throughput: number;\n timestamp: Date;\n}\n\nexport interface BaselineSnapshot {\n latencyP99: number;\n latencyP95: number;\n errorRate: number;\n throughput: number;\n sampleCount: number;\n}\n\nexport class BaselineCalculator {\n private snapshot: BaselineSnapshot = {\n latencyP99: 0,\n latencyP95: 0,\n errorRate: 0,\n throughput: 0,\n sampleCount: 0,\n };\n\n constructor(private readonly alpha = 0.2) {}\n\n update(point: MetricPoint): BaselineSnapshot {\n const { sampleCount } = this.snapshot;\n const nextCount = sampleCount + 1;\n const weight = sampleCount === 0 ? 1 : this.alpha;\n\n this.snapshot = {\n latencyP99: this.mix(this.snapshot.latencyP99, point.latencyP99, weight),\n latencyP95: this.mix(this.snapshot.latencyP95, point.latencyP95, weight),\n errorRate: this.mix(this.snapshot.errorRate, point.errorRate, weight),\n throughput: this.mix(this.snapshot.throughput, point.throughput, weight),\n sampleCount: nextCount,\n };\n\n return this.snapshot;\n }\n\n getSnapshot() {\n return this.snapshot;\n }\n\n private mix(current: number, next: number, weight: number) {\n if (this.snapshot.sampleCount === 0) {\n return next;\n }\n return current * (1 - weight) + next * weight;\n }\n}\n"],"mappings":"AAgBA,IAAa,EAAb,KAAgC,CAC9B,SAAqC,CACnC,WAAY,EACZ,WAAY,EACZ,UAAW,EACX,WAAY,EACZ,YAAa,EACd,CAED,YAAY,EAAyB,GAAK,CAAb,KAAA,MAAA,EAE7B,OAAO,EAAsC,CAC3C,GAAM,CAAE,eAAgB,KAAK,SACvB,EAAY,EAAc,EAC1B,EAAS,IAAgB,EAAI,EAAI,KAAK,MAU5C,MARA,MAAK,SAAW,CACd,WAAY,KAAK,IAAI,KAAK,SAAS,WAAY,EAAM,WAAY,EAAO,CACxE,WAAY,KAAK,IAAI,KAAK,SAAS,WAAY,EAAM,WAAY,EAAO,CACxE,UAAW,KAAK,IAAI,KAAK,SAAS,UAAW,EAAM,UAAW,EAAO,CACrE,WAAY,KAAK,IAAI,KAAK,SAAS,WAAY,EAAM,WAAY,EAAO,CACxE,YAAa,EACd,CAEM,KAAK,SAGd,aAAc,CACZ,OAAO,KAAK,SAGd,IAAY,EAAiB,EAAc,EAAgB,CAIzD,OAHI,KAAK,SAAS,cAAgB,EACzB,EAEF,GAAW,EAAI,GAAU,EAAO"}
@@ -0,0 +1,23 @@
1
+ import { AnomalySignal } from "./anomaly-detector.mjs";
2
+
3
+ //#region src/anomaly/root-cause-analyzer.d.ts
4
+ interface DeploymentEvent {
5
+ id: string;
6
+ operation: string;
7
+ deployedAt: Date;
8
+ stage?: string;
9
+ status: 'in_progress' | 'completed' | 'rolled_back';
10
+ }
11
+ interface RootCauseAnalysis {
12
+ signal: AnomalySignal;
13
+ culprit?: DeploymentEvent;
14
+ notes: string[];
15
+ }
16
+ declare class RootCauseAnalyzer {
17
+ private readonly lookbackMs;
18
+ constructor(lookbackMs?: number);
19
+ analyze(signal: AnomalySignal, deployments: DeploymentEvent[]): RootCauseAnalysis;
20
+ }
21
+ //#endregion
22
+ export { DeploymentEvent, RootCauseAnalysis, RootCauseAnalyzer };
23
+ //# sourceMappingURL=root-cause-analyzer.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root-cause-analyzer.d.mts","names":[],"sources":["../../src/anomaly/root-cause-analyzer.ts"],"sourcesContent":[],"mappings":";;;UAEiB,eAAA;;EAAA,SAAA,EAAA,MAAA;EAQA,UAAA,EALH,IAKG;EAMJ,KAAA,CAAA,EAAA,MAAA;EAID,MAAA,EAAA,aAAA,GAAA,WAAA,GAAA,aAAA;;AAEP,UAZY,iBAAA,CAYZ;EAAiB,MAAA,EAXZ,aAWY;YAVV;;;cAIC,iBAAA;;;kBAID,4BACK,oBACZ"}
@@ -0,0 +1,2 @@
1
+ var e=class{constructor(e=900*1e3){this.lookbackMs=e}analyze(e,t){let n=new Date(e.point.timestamp.getTime()-this.lookbackMs),r=t.filter(e=>e.deployedAt>=n).sort((e,t)=>t.deployedAt.getTime()-e.deployedAt.getTime()),i=[],a;return r.length>0?(a=r[0],i.push(`Closest deployment ${a.id} (${a.operation}) at ${a.deployedAt.toISOString()}`)):i.push(`No deployments found within lookback window.`),e.type===`latency_regression`&&i.push(`Verify recent schema changes and external dependency latency.`),e.type===`error_rate_spike`&&i.push(`Check SLO monitor for correlated incidents.`),{signal:e,culprit:a,notes:i}}};export{e as RootCauseAnalyzer};
2
+ //# sourceMappingURL=root-cause-analyzer.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root-cause-analyzer.mjs","names":["lookbackMs: number","notes: string[]","culprit: DeploymentEvent | undefined"],"sources":["../../src/anomaly/root-cause-analyzer.ts"],"sourcesContent":["import type { AnomalySignal } from './anomaly-detector';\n\nexport interface DeploymentEvent {\n id: string;\n operation: string;\n deployedAt: Date;\n stage?: string;\n status: 'in_progress' | 'completed' | 'rolled_back';\n}\n\nexport interface RootCauseAnalysis {\n signal: AnomalySignal;\n culprit?: DeploymentEvent;\n notes: string[];\n}\n\nexport class RootCauseAnalyzer {\n constructor(private readonly lookbackMs: number = 15 * 60 * 1000) {}\n\n analyze(\n signal: AnomalySignal,\n deployments: DeploymentEvent[]\n ): RootCauseAnalysis {\n const windowStart = new Date(\n signal.point.timestamp.getTime() - this.lookbackMs\n );\n const candidates = deployments\n .filter((deployment) => deployment.deployedAt >= windowStart)\n .sort((a, b) => b.deployedAt.getTime() - a.deployedAt.getTime());\n\n const notes: string[] = [];\n let culprit: DeploymentEvent | undefined;\n\n if (candidates.length > 0) {\n culprit = candidates[0]!;\n notes.push(\n `Closest deployment ${culprit.id} (${culprit.operation}) at ${culprit.deployedAt.toISOString()}`\n );\n } else {\n notes.push('No deployments found within lookback window.');\n }\n\n if (signal.type === 'latency_regression') {\n notes.push(\n 'Verify recent schema changes and external dependency latency.'\n );\n }\n\n if (signal.type === 'error_rate_spike') {\n notes.push('Check SLO monitor for correlated incidents.');\n }\n\n return { signal, culprit, notes };\n }\n}\n"],"mappings":"AAgBA,IAAa,EAAb,KAA+B,CAC7B,YAAY,EAAsC,IAAU,IAAM,CAArC,KAAA,WAAA,EAE7B,QACE,EACA,EACmB,CACnB,IAAM,EAAc,IAAI,KACtB,EAAO,MAAM,UAAU,SAAS,CAAG,KAAK,WACzC,CACK,EAAa,EAChB,OAAQ,GAAe,EAAW,YAAc,EAAY,CAC5D,MAAM,EAAG,IAAM,EAAE,WAAW,SAAS,CAAG,EAAE,WAAW,SAAS,CAAC,CAE5DC,EAAkB,EAAE,CACtBC,EAqBJ,OAnBI,EAAW,OAAS,GACtB,EAAU,EAAW,GACrB,EAAM,KACJ,sBAAsB,EAAQ,GAAG,IAAI,EAAQ,UAAU,OAAO,EAAQ,WAAW,aAAa,GAC/F,EAED,EAAM,KAAK,+CAA+C,CAGxD,EAAO,OAAS,sBAClB,EAAM,KACJ,gEACD,CAGC,EAAO,OAAS,oBAClB,EAAM,KAAK,8CAA8C,CAGpD,CAAE,SAAQ,UAAS,QAAO"}
package/dist/index.d.mts CHANGED
@@ -1,5 +1,13 @@
1
+ import { BaselineCalculator } from "./anomaly/baseline-calculator.mjs";
2
+ import { AnomalyDetector, AnomalySignal, AnomalyThresholds } from "./anomaly/anomaly-detector.mjs";
3
+ import { RootCauseAnalysis, RootCauseAnalyzer } from "./anomaly/root-cause-analyzer.mjs";
4
+ import { AlertManager } from "./anomaly/alert-manager.mjs";
1
5
  import { getTracer, traceAsync, traceSync } from "./tracing/index.mjs";
2
6
  import { createCounter, createHistogram, createUpDownCounter, getMeter, standardMetrics } from "./metrics/index.mjs";
3
7
  import { LogEntry, LogLevel, Logger, logger } from "./logging/index.mjs";
4
- import { createTracingMiddleware } from "./tracing/middleware.mjs";
5
- export { type LogEntry, type LogLevel, Logger, createCounter, createHistogram, createTracingMiddleware, createUpDownCounter, getMeter, getTracer, logger, standardMetrics, traceAsync, traceSync };
8
+ import { IntentAggregator, IntentAggregatorSnapshot, TelemetrySample } from "./intent/aggregator.mjs";
9
+ import { TracingMiddlewareOptions, createTracingMiddleware } from "./tracing/middleware.mjs";
10
+ import { IntentDetector, IntentSignal, IntentSignalType } from "./intent/detector.mjs";
11
+ import { EvolutionPipeline, EvolutionPipelineEvent, EvolutionPipelineOptions } from "./pipeline/evolution-pipeline.mjs";
12
+ import { LifecycleKpiPipeline, LifecycleKpiPipelineOptions, LifecyclePipelineEvent } from "./pipeline/lifecycle-pipeline.mjs";
13
+ export { AlertManager, AnomalyDetector, type AnomalySignal, type AnomalyThresholds, BaselineCalculator, EvolutionPipeline, type EvolutionPipelineEvent, type EvolutionPipelineOptions, IntentAggregator, type IntentAggregatorSnapshot, IntentDetector, type IntentSignal, type IntentSignalType, LifecycleKpiPipeline, type LifecycleKpiPipelineOptions, type LifecyclePipelineEvent, type LogEntry, type LogLevel, Logger, type RootCauseAnalysis, RootCauseAnalyzer, type TelemetrySample, type TracingMiddlewareOptions, createCounter, createHistogram, createTracingMiddleware, createUpDownCounter, getMeter, getTracer, logger, standardMetrics, traceAsync, traceSync };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{getTracer as e,traceAsync as t,traceSync as n}from"./tracing/index.mjs";import{createCounter as r,createHistogram as i,createUpDownCounter as a,getMeter as o,standardMetrics as s}from"./metrics/index.mjs";import{Logger as c,logger as l}from"./logging/index.mjs";import{createTracingMiddleware as u}from"./tracing/middleware.mjs";export{c as Logger,r as createCounter,i as createHistogram,u as createTracingMiddleware,a as createUpDownCounter,o as getMeter,e as getTracer,l as logger,s as standardMetrics,t as traceAsync,n as traceSync};
1
+ import{getTracer as e,traceAsync as t,traceSync as n}from"./tracing/index.mjs";import{createCounter as r,createHistogram as i,createUpDownCounter as a,getMeter as o,standardMetrics as s}from"./metrics/index.mjs";import{Logger as c,logger as l}from"./logging/index.mjs";import{createTracingMiddleware as u}from"./tracing/middleware.mjs";import{IntentAggregator as d}from"./intent/aggregator.mjs";import{IntentDetector as f}from"./intent/detector.mjs";import{EvolutionPipeline as p}from"./pipeline/evolution-pipeline.mjs";import{LifecycleKpiPipeline as m}from"./pipeline/lifecycle-pipeline.mjs";import{BaselineCalculator as h}from"./anomaly/baseline-calculator.mjs";import{AnomalyDetector as g}from"./anomaly/anomaly-detector.mjs";import{RootCauseAnalyzer as _}from"./anomaly/root-cause-analyzer.mjs";import{AlertManager as v}from"./anomaly/alert-manager.mjs";export{v as AlertManager,g as AnomalyDetector,h as BaselineCalculator,p as EvolutionPipeline,d as IntentAggregator,f as IntentDetector,m as LifecycleKpiPipeline,c as Logger,_ as RootCauseAnalyzer,r as createCounter,i as createHistogram,u as createTracingMiddleware,a as createUpDownCounter,o as getMeter,e as getTracer,l as logger,s as standardMetrics,t as traceAsync,n as traceSync};
@@ -0,0 +1,60 @@
1
+ //#region src/intent/aggregator.d.ts
2
+ interface TelemetrySample {
3
+ operation: {
4
+ name: string;
5
+ version: number;
6
+ };
7
+ durationMs: number;
8
+ success: boolean;
9
+ timestamp: Date;
10
+ errorCode?: string;
11
+ tenantId?: string;
12
+ traceId?: string;
13
+ actorId?: string;
14
+ metadata?: Record<string, unknown>;
15
+ }
16
+ interface AggregatedOperationMetrics {
17
+ operation: {
18
+ name: string;
19
+ version: number;
20
+ };
21
+ totalCalls: number;
22
+ successRate: number;
23
+ errorRate: number;
24
+ averageLatencyMs: number;
25
+ p95LatencyMs: number;
26
+ p99LatencyMs: number;
27
+ maxLatencyMs: number;
28
+ windowStart: Date;
29
+ windowEnd: Date;
30
+ topErrors: Record<string, number>;
31
+ }
32
+ interface OperationSequence {
33
+ steps: string[];
34
+ tenantId?: string;
35
+ count: number;
36
+ }
37
+ interface IntentAggregatorSnapshot {
38
+ metrics: AggregatedOperationMetrics[];
39
+ sequences: OperationSequence[];
40
+ sampleCount: number;
41
+ windowStart?: Date;
42
+ windowEnd?: Date;
43
+ }
44
+ interface IntentAggregatorOptions {
45
+ windowMs?: number;
46
+ sequenceSampleSize?: number;
47
+ }
48
+ declare class IntentAggregator {
49
+ private readonly windowMs;
50
+ private readonly sequenceSampleSize;
51
+ private readonly samples;
52
+ constructor(options?: IntentAggregatorOptions);
53
+ add(sample: TelemetrySample): void;
54
+ flush(now?: Date): IntentAggregatorSnapshot;
55
+ private aggregateMetrics;
56
+ private buildSequences;
57
+ }
58
+ //#endregion
59
+ export { AggregatedOperationMetrics, IntentAggregator, IntentAggregatorOptions, IntentAggregatorSnapshot, OperationSequence, TelemetrySample };
60
+ //# sourceMappingURL=aggregator.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aggregator.d.mts","names":[],"sources":["../../src/intent/aggregator.ts"],"sourcesContent":[],"mappings":";UAAiB,eAAA;EAAA,SAAA,EAAA;IAYA,IAAA,EAAA,MAAA;IASF,OAAA,EAAA,MAAA;EACF,CAAA;EACA,UAAA,EAAA,MAAA;EAAM,OAAA,EAAA,OAAA;EAGF,SAAA,EAtBJ,IAsBI;EAMA,SAAA,CAAA,EAAA,MAAA;EACN,QAAA,CAAA,EAAA,MAAA;EACE,OAAA,CAAA,EAAA,MAAA;EAEG,OAAA,CAAA,EAAA,MAAA;EACF,QAAA,CAAA,EA5BD,MA4BC,CAAA,MAAA,EAAA,OAAA,CAAA;;AAGG,UA5BA,0BAAA,CA4BuB;EAO3B,SAAA,EAAA;IAKU,IAAA,EAAA,MAAA;IAKT,OAAA,EAAA,MAAA;EAIH,CAAA;EAAgB,UAAA,EAAA,MAAA;EAAwB,WAAA,EAAA,MAAA;;;;;;eAxCpC;aACF;aACA;;UAGI,iBAAA;;;;;UAMA,wBAAA;WACN;aACE;;gBAEG;cACF;;UAGG,uBAAA;;;;cAOJ,gBAAA;;;;wBAKU;cAKT;cAIH,OAAgB"}
@@ -0,0 +1,2 @@
1
+ var e=class{windowMs;sequenceSampleSize;samples=[];constructor(e={}){this.windowMs=e.windowMs??9e5,this.sequenceSampleSize=e.sequenceSampleSize??1e3}add(e){this.samples.push(e)}flush(e=new Date){let t=e.getTime()-this.windowMs,n=this.samples.filter(e=>e.timestamp.getTime()>=t);this.samples.length=0;let r=this.aggregateMetrics(n),i=this.buildSequences(n),a=n.map(e=>e.timestamp.getTime());return{metrics:r,sequences:i,sampleCount:n.length,windowStart:a.length?new Date(Math.min(...a)):void 0,windowEnd:a.length?new Date(Math.max(...a)):void 0}}aggregateMetrics(e){if(!e.length)return[];let n=new Map;for(let t of e){let e=`${t.operation.name}.v${t.operation.version}`,r=n.get(e)??[];r.push(t),n.set(e,r)}return[...n.values()].map(e=>{let n=e.map(e=>e.durationMs).sort((e,t)=>e-t),r=e.filter(e=>!e.success),i=e.length,a=r.reduce((e,t)=>(t.errorCode&&(e[t.errorCode]=(e[t.errorCode]??0)+1),e),{}),o=e.map(e=>e.timestamp.getTime());return{operation:e[0].operation,totalCalls:i,successRate:(i-r.length)/i,errorRate:r.length/i,averageLatencyMs:n.reduce((e,t)=>e+t,0)/i,p95LatencyMs:t(n,.95),p99LatencyMs:t(n,.99),maxLatencyMs:Math.max(...n),windowStart:new Date(Math.min(...o)),windowEnd:new Date(Math.max(...o)),topErrors:a}})}buildSequences(e){let t=new Map;for(let n of e.slice(-this.sequenceSampleSize)){if(!n.traceId)continue;let e=t.get(n.traceId)??[];e.push(n),t.set(n.traceId,e)}let n={};for(let[e,r]of t.entries()){let e=r.sort((e,t)=>e.timestamp.getTime()-t.timestamp.getTime()),t=e.map(e=>e.operation.name);if(t.length<2)continue;let i=`${t.join(`>`)}@${e[0]?.tenantId??`global`}`,a=n[i];a?a.count+=1:n[i]={steps:t,tenantId:e[0]?.tenantId,count:1}}return Object.values(n).sort((e,t)=>t.count-e.count)}};function t(e,t){return e.length?e.length===1?e[0]:e[Math.min(e.length-1,Math.floor(t*e.length))]:0}export{e as IntentAggregator};
2
+ //# sourceMappingURL=aggregator.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aggregator.mjs","names":["sequences: Record<string, OperationSequence>"],"sources":["../../src/intent/aggregator.ts"],"sourcesContent":["export interface TelemetrySample {\n operation: { name: string; version: number };\n durationMs: number;\n success: boolean;\n timestamp: Date;\n errorCode?: string;\n tenantId?: string;\n traceId?: string;\n actorId?: string;\n metadata?: Record<string, unknown>;\n}\n\nexport interface AggregatedOperationMetrics {\n operation: { name: string; version: number };\n totalCalls: number;\n successRate: number;\n errorRate: number;\n averageLatencyMs: number;\n p95LatencyMs: number;\n p99LatencyMs: number;\n maxLatencyMs: number;\n windowStart: Date;\n windowEnd: Date;\n topErrors: Record<string, number>;\n}\n\nexport interface OperationSequence {\n steps: string[];\n tenantId?: string;\n count: number;\n}\n\nexport interface IntentAggregatorSnapshot {\n metrics: AggregatedOperationMetrics[];\n sequences: OperationSequence[];\n sampleCount: number;\n windowStart?: Date;\n windowEnd?: Date;\n}\n\nexport interface IntentAggregatorOptions {\n windowMs?: number;\n sequenceSampleSize?: number;\n}\n\nconst DEFAULT_WINDOW_MS = 15 * 60 * 1000; // 15 minutes\n\nexport class IntentAggregator {\n private readonly windowMs: number;\n private readonly sequenceSampleSize: number;\n private readonly samples: TelemetrySample[] = [];\n\n constructor(options: IntentAggregatorOptions = {}) {\n this.windowMs = options.windowMs ?? DEFAULT_WINDOW_MS;\n this.sequenceSampleSize = options.sequenceSampleSize ?? 1000;\n }\n\n add(sample: TelemetrySample) {\n this.samples.push(sample);\n }\n\n flush(now = new Date()): IntentAggregatorSnapshot {\n const minTimestamp = now.getTime() - this.windowMs;\n const windowSamples = this.samples.filter(\n (sample) => sample.timestamp.getTime() >= minTimestamp\n );\n this.samples.length = 0;\n const metrics = this.aggregateMetrics(windowSamples);\n const sequences = this.buildSequences(windowSamples);\n const timestamps = windowSamples.map((sample) =>\n sample.timestamp.getTime()\n );\n return {\n metrics,\n sequences,\n sampleCount: windowSamples.length,\n windowStart: timestamps.length\n ? new Date(Math.min(...timestamps))\n : undefined,\n windowEnd: timestamps.length\n ? new Date(Math.max(...timestamps))\n : undefined,\n };\n }\n\n private aggregateMetrics(samples: TelemetrySample[]) {\n if (!samples.length) return [] as AggregatedOperationMetrics[];\n const groups = new Map<string, TelemetrySample[]>();\n for (const sample of samples) {\n const key = `${sample.operation.name}.v${sample.operation.version}`;\n const arr = groups.get(key) ?? [];\n arr.push(sample);\n groups.set(key, arr);\n }\n\n return [...groups.values()].map((group) => {\n const durations = group.map((s) => s.durationMs).sort((a, b) => a - b);\n const errors = group.filter((s) => !s.success);\n const totalCalls = group.length;\n const topErrors = errors.reduce<Record<string, number>>((acc, sample) => {\n if (!sample.errorCode) return acc;\n acc[sample.errorCode] = (acc[sample.errorCode] ?? 0) + 1;\n return acc;\n }, {});\n const timestamps = group.map((s) => s.timestamp.getTime());\n return {\n operation: group[0]!.operation,\n totalCalls,\n successRate: (totalCalls - errors.length) / totalCalls,\n errorRate: errors.length / totalCalls,\n averageLatencyMs:\n durations.reduce((sum, value) => sum + value, 0) / totalCalls,\n p95LatencyMs: percentile(durations, 0.95),\n p99LatencyMs: percentile(durations, 0.99),\n maxLatencyMs: Math.max(...durations),\n windowStart: new Date(Math.min(...timestamps)),\n windowEnd: new Date(Math.max(...timestamps)),\n topErrors,\n } satisfies AggregatedOperationMetrics;\n });\n }\n\n private buildSequences(samples: TelemetrySample[]): OperationSequence[] {\n const byTrace = new Map<string, TelemetrySample[]>();\n for (const sample of samples.slice(-this.sequenceSampleSize)) {\n if (!sample.traceId) continue;\n const arr = byTrace.get(sample.traceId) ?? [];\n arr.push(sample);\n byTrace.set(sample.traceId, arr);\n }\n\n const sequences: Record<string, OperationSequence> = {};\n for (const [traceId, events] of byTrace.entries()) {\n const ordered = events.sort(\n (a, b) => a.timestamp.getTime() - b.timestamp.getTime()\n );\n const steps = ordered.map((event) => event.operation.name);\n if (steps.length < 2) continue;\n const key = `${steps.join('>')}@${ordered[0]?.tenantId ?? 'global'}`;\n const existing = sequences[key];\n if (existing) {\n existing.count += 1;\n } else {\n sequences[key] = {\n steps,\n tenantId: ordered[0]?.tenantId,\n count: 1,\n };\n }\n }\n\n return Object.values(sequences).sort((a, b) => b.count - a.count);\n }\n}\n\nfunction percentile(values: number[], ratio: number) {\n if (!values.length) return 0;\n if (values.length === 1) return values[0]!;\n const index = Math.min(values.length - 1, Math.floor(ratio * values.length));\n return values[index]!;\n}\n"],"mappings":"AA+CA,IAAa,EAAb,KAA8B,CAC5B,SACA,mBACA,QAA8C,EAAE,CAEhD,YAAY,EAAmC,EAAE,CAAE,CACjD,KAAK,SAAW,EAAQ,UAAY,IACpC,KAAK,mBAAqB,EAAQ,oBAAsB,IAG1D,IAAI,EAAyB,CAC3B,KAAK,QAAQ,KAAK,EAAO,CAG3B,MAAM,EAAM,IAAI,KAAkC,CAChD,IAAM,EAAe,EAAI,SAAS,CAAG,KAAK,SACpC,EAAgB,KAAK,QAAQ,OAChC,GAAW,EAAO,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entSignalType = 'latency-regression' | 'error-spike' | 'throughput-drop' | 'missing-workflow-step';
5
+ interface IntentSignal {
6
+ id: string;
7
+ type: IntentSignalType;
8
+ operation?: AggregatedOperationMetrics['operation'];
9
+ confidence: number;
10
+ description: string;
11
+ metadata?: Record<string, unknown>;
12
+ evidence: {
13
+ type: 'metric' | 'sequence' | 'anomaly';
14
+ description: string;
15
+ data?: Record<string, unknown>;
16
+ }[];
17
+ }
18
+ interface IntentDetectorOptions {
19
+ errorRateThreshold?: number;
20
+ latencyP99ThresholdMs?: number;
21
+ throughputDropThreshold?: number;
22
+ minSequenceLength?: number;
23
+ }
24
+ declare class IntentDetector {
25
+ private readonly options;
26
+ constructor(options?: IntentDetectorOptions);
27
+ detectFromMetrics(current: AggregatedOperationMetrics[], previous?: AggregatedOperationMetrics[]): IntentSignal[];
28
+ detectSequentialIntents(sequences: OperationSequence[]): IntentSignal[];
29
+ }
30
+ //#endregion
31
+ export { IntentDetector, IntentDetectorOptions, IntentSignal, IntentSignalType };
32
+ //# sourceMappingURL=detector.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detector.d.mts","names":[],"sources":["../../src/intent/detector.ts"],"sourcesContent":[],"mappings":";;;KAMY,gBAAA;UAMK,YAAA;EANL,EAAA,EAAA,MAAA;EAMK,IAAA,EAET,gBAFqB;EAErB,SAAA,CAAA,EACM,0BADN,CAAA,WAAA,CAAA;EACM,UAAA,EAAA,MAAA;EAGD,WAAA,EAAA,MAAA;EAIF,QAAA,CAAA,EAJE,MAIF,CAAA,MAAA,EAAA,OAAA,CAAA;EAAM,QAAA,EAAA;IAIA,IAAA,EAAA,QAAA,GAAA,UAAqB,GAAA,SAAA;IAczB,WAAA,EAAc,MAAA;IAGJ,IAAA,CAAA,EArBZ,MAqBY,CAAA,MAAA,EAAA,OAAA,CAAA;EAcV,CAAA,EAAA;;AAER,UAjCY,qBAAA,CAiCZ;EAqGgC,kBAAA,CAAA,EAAA,MAAA;EAAsB,qBAAA,CAAA,EAAA,MAAA;EAAY,uBAAA,CAAA,EAAA,MAAA;;;cAxH1D,cAAA;;wBAGU;6BAcV,yCACE,+BACV;qCAqGgC,sBAAsB"}
@@ -0,0 +1,2 @@
1
+ import{randomUUID as e}from"node:crypto";const t={errorRateThreshold:.05,latencyP99ThresholdMs:750,throughputDropThreshold:.3,minSequenceLength:3};var n=class{options;constructor(e={}){this.options={errorRateThreshold:e.errorRateThreshold??t.errorRateThreshold,latencyP99ThresholdMs:e.latencyP99ThresholdMs??t.latencyP99ThresholdMs,throughputDropThreshold:e.throughputDropThreshold??t.throughputDropThreshold,minSequenceLength:e.minSequenceLength??t.minSequenceLength}}detectFromMetrics(t,n){let r=[],i=new Map((n??[]).map(e=>[`${e.operation.name}.v${e.operation.version}`,e]));for(let n of t){if(n.errorRate>=this.options.errorRateThreshold){r.push({id:e(),type:`error-spike`,operation:n.operation,confidence:Math.min(1,n.errorRate/this.options.errorRateThreshold),description:`Error rate ${n.errorRate.toFixed(2)} exceeded threshold`,metadata:{errorRate:n.errorRate,topErrors:n.topErrors},evidence:[{type:`metric`,description:`error-rate`,data:{errorRate:n.errorRate,threshold:this.options.errorRateThreshold}}]});continue}if(n.p99LatencyMs>=this.options.latencyP99ThresholdMs){r.push({id:e(),type:`latency-regression`,operation:n.operation,confidence:Math.min(1,n.p99LatencyMs/this.options.latencyP99ThresholdMs),description:`P99 latency ${n.p99LatencyMs}ms exceeded threshold`,metadata:{p99LatencyMs:n.p99LatencyMs},evidence:[{type:`metric`,description:`p99-latency`,data:{p99LatencyMs:n.p99LatencyMs,threshold:this.options.latencyP99ThresholdMs}}]});continue}let t=i.get(`${n.operation.name}.v${n.operation.version}`);if(t){let i=(t.totalCalls-n.totalCalls)/Math.max(t.totalCalls,1);i>=this.options.throughputDropThreshold&&r.push({id:e(),type:`throughput-drop`,operation:n.operation,confidence:Math.min(1,i/this.options.throughputDropThreshold),description:`Throughput dropped ${(i*100).toFixed(1)}% vs baseline`,metadata:{baselineCalls:t.totalCalls,currentCalls:n.totalCalls},evidence:[{type:`metric`,description:`throughput-drop`,data:{baselineCalls:t.totalCalls,currentCalls:n.totalCalls}}]})}}return r}detectSequentialIntents(t){let n=[];for(let r of t){if(r.steps.length<this.options.minSequenceLength)continue;let t=r.steps.join(` → `);n.push({id:e(),type:`missing-workflow-step`,confidence:.6,description:`Repeated workflow detected: ${t}`,metadata:{steps:r.steps,tenantId:r.tenantId,occurrences:r.count},evidence:[{type:`sequence`,description:`sequential-calls`,data:{steps:r.steps,count:r.count}}]})}return n}};export{n as IntentDetector};
2
+ //# sourceMappingURL=detector.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detector.mjs","names":["signals: IntentSignal[]"],"sources":["../../src/intent/detector.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport type {\n AggregatedOperationMetrics,\n OperationSequence,\n} from './aggregator';\n\nexport type IntentSignalType =\n | 'latency-regression'\n | 'error-spike'\n | 'throughput-drop'\n | 'missing-workflow-step';\n\nexport interface IntentSignal {\n id: string;\n type: IntentSignalType;\n operation?: AggregatedOperationMetrics['operation'];\n confidence: number;\n description: string;\n metadata?: Record<string, unknown>;\n evidence: {\n type: 'metric' | 'sequence' | 'anomaly';\n description: string;\n data?: Record<string, unknown>;\n }[];\n}\n\nexport interface IntentDetectorOptions {\n errorRateThreshold?: number;\n latencyP99ThresholdMs?: number;\n throughputDropThreshold?: number;\n minSequenceLength?: number;\n}\n\nconst DEFAULTS = {\n errorRateThreshold: 0.05,\n latencyP99ThresholdMs: 750,\n throughputDropThreshold: 0.3,\n minSequenceLength: 3,\n};\n\nexport class IntentDetector {\n private readonly options: Required<IntentDetectorOptions>;\n\n constructor(options: IntentDetectorOptions = {}) {\n this.options = {\n errorRateThreshold:\n options.errorRateThreshold ?? DEFAULTS.errorRateThreshold,\n latencyP99ThresholdMs:\n options.latencyP99ThresholdMs ?? DEFAULTS.latencyP99ThresholdMs,\n throughputDropThreshold:\n options.throughputDropThreshold ?? DEFAULTS.throughputDropThreshold,\n minSequenceLength:\n options.minSequenceLength ?? DEFAULTS.minSequenceLength,\n };\n }\n\n detectFromMetrics(\n current: AggregatedOperationMetrics[],\n previous?: AggregatedOperationMetrics[]\n ): IntentSignal[] {\n const signals: IntentSignal[] = [];\n const baseline = new Map(\n (previous ?? []).map((metric) => [\n `${metric.operation.name}.v${metric.operation.version}`,\n metric,\n ])\n );\n\n for (const metric of current) {\n if (metric.errorRate >= this.options.errorRateThreshold) {\n signals.push({\n id: randomUUID(),\n type: 'error-spike',\n operation: metric.operation,\n confidence: Math.min(\n 1,\n metric.errorRate / this.options.errorRateThreshold\n ),\n description: `Error rate ${metric.errorRate.toFixed(2)} exceeded threshold`,\n metadata: {\n errorRate: metric.errorRate,\n topErrors: metric.topErrors,\n },\n evidence: [\n {\n type: 'metric',\n description: 'error-rate',\n data: {\n errorRate: metric.errorRate,\n threshold: this.options.errorRateThreshold,\n },\n },\n ],\n });\n continue;\n }\n\n if (metric.p99LatencyMs >= this.options.latencyP99ThresholdMs) {\n signals.push({\n id: randomUUID(),\n type: 'latency-regression',\n operation: metric.operation,\n confidence: Math.min(\n 1,\n metric.p99LatencyMs / this.options.latencyP99ThresholdMs\n ),\n description: `P99 latency ${metric.p99LatencyMs}ms exceeded threshold`,\n metadata: { p99LatencyMs: metric.p99LatencyMs },\n evidence: [\n {\n type: 'metric',\n description: 'p99-latency',\n data: {\n p99LatencyMs: metric.p99LatencyMs,\n threshold: this.options.latencyP99ThresholdMs,\n },\n },\n ],\n });\n continue;\n }\n\n const base = baseline.get(\n `${metric.operation.name}.v${metric.operation.version}`\n );\n if (base) {\n const drop =\n (base.totalCalls - metric.totalCalls) / Math.max(base.totalCalls, 1);\n if (drop >= this.options.throughputDropThreshold) {\n signals.push({\n id: randomUUID(),\n type: 'throughput-drop',\n operation: metric.operation,\n confidence: Math.min(\n 1,\n drop / this.options.throughputDropThreshold\n ),\n description: `Throughput dropped ${(drop * 100).toFixed(1)}% vs baseline`,\n metadata: {\n baselineCalls: base.totalCalls,\n currentCalls: metric.totalCalls,\n },\n evidence: [\n {\n type: 'metric',\n description: 'throughput-drop',\n data: {\n baselineCalls: base.totalCalls,\n currentCalls: metric.totalCalls,\n },\n },\n ],\n });\n }\n }\n }\n\n return signals;\n }\n\n detectSequentialIntents(sequences: OperationSequence[]): IntentSignal[] {\n const signals: IntentSignal[] = [];\n for (const sequence of sequences) {\n if (sequence.steps.length < this.options.minSequenceLength) continue;\n const description = sequence.steps.join(' → ');\n signals.push({\n id: randomUUID(),\n type: 'missing-workflow-step',\n confidence: 0.6,\n description: `Repeated workflow detected: ${description}`,\n metadata: {\n steps: sequence.steps,\n tenantId: sequence.tenantId,\n occurrences: sequence.count,\n },\n evidence: [\n {\n type: 'sequence',\n description: 'sequential-calls',\n data: { steps: sequence.steps, count: sequence.count },\n },\n ],\n });\n }\n return signals;\n }\n}\n"],"mappings":"yCAiCA,MAAM,EAAW,CACf,mBAAoB,IACpB,sBAAuB,IACvB,wBAAyB,GACzB,kBAAmB,EACpB,CAED,IAAa,EAAb,KAA4B,CAC1B,QAEA,YAAY,EAAiC,EAAE,CAAE,CAC/C,KAAK,QAAU,CACb,mBACE,EAAQ,oBAAsB,EAAS,mBACzC,sBACE,EAAQ,uBAAyB,EAAS,sBAC5C,wBACE,EAAQ,yBAA2B,EAAS,wBAC9C,kBACE,EAAQ,mBAAqB,EAAS,kBACzC,CAGH,kBACE,EACA,EACgB,CAChB,IAAMA,EAA0B,EAAE,CAC5B,EAAW,IAAI,KAClB,GAAY,EAAE,EAAE,IAAK,GAAW,CAC/B,GAAG,EAAO,UAAU,KAAK,IAAI,EAAO,UAAU,UAC9C,EACD,CAAC,CACH,CAED,IAAK,IAAM,KAAU,EAAS,CAC5B,GAAI,EAAO,WAAa,KAAK,QAAQ,mBAAoB,CACvD,EAAQ,KAAK,CACX,GAAI,GAAY,CAChB,KAAM,cACN,UAAW,EAAO,UAClB,WAAY,KAAK,IACf,EACA,EAAO,UAAY,KAAK,QAAQ,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,EAAS,MAAM,OAAS,KAAK,QAAQ,kBAAmB,SAC5D,IAAM,EAAc,EAAS,MAAM,KAAK,MAAM,CAC9C,EAAQ,KAAK,CACX,GAAI,GAAY,CAChB,KAAM,wBACN,WAAY,GACZ,YAAa,+BAA+B,IAC5C,SAAU,CACR,MAAO,EAAS,MAChB,SAAU,EAAS,SACnB,YAAa,EAAS,MACvB,CACD,SAAU,CACR,CACE,KAAM,WACN,YAAa,mBACb,KAAM,CAAE,MAAO,EAAS,MAAO,MAAO,EAAS,MAAO,CACvD,CACF,CACF,CAAC,CAEJ,OAAO"}
@@ -0,0 +1 @@
1
+ import{e,n as t,t as n}from"./types/stages.mjs";import"./types/axes.mjs";import"./types/signals.mjs";import"./types/milestones.mjs";import{o as r,r as i}from"./utils/formatters.mjs";
@@ -0,0 +1,2 @@
1
+ (function(e){return e.Sketch=`Sketch`,e.Prototype=`Prototype`,e.Mvp=`MVP`,e.V1=`V1`,e.Ecosystem=`Ecosystem`,e})({}),function(e){return e.Solo=`Solo`,e.TinyTeam=`TinyTeam`,e.FunctionalOrg=`FunctionalOrg`,e.MultiTeam=`MultiTeam`,e.Bureaucratic=`Bureaucratic`,e}({}),function(e){return e.Bootstrapped=`Bootstrapped`,e.PreSeed=`PreSeed`,e.Seed=`Seed`,e.SeriesAorB=`SeriesAorB`,e.LateStage=`LateStage`,e}({});
2
+ //# sourceMappingURL=axes.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axes.mjs","names":["e"],"sources":["../../../../../lifecycle/dist/types/axes.js"],"sourcesContent":["let e=function(e){return e.Sketch=`Sketch`,e.Prototype=`Prototype`,e.Mvp=`MVP`,e.V1=`V1`,e.Ecosystem=`Ecosystem`,e}({}),t=function(e){return e.Solo=`Solo`,e.TinyTeam=`TinyTeam`,e.FunctionalOrg=`FunctionalOrg`,e.MultiTeam=`MultiTeam`,e.Bureaucratic=`Bureaucratic`,e}({}),n=function(e){return e.Bootstrapped=`Bootstrapped`,e.PreSeed=`PreSeed`,e.Seed=`Seed`,e.SeriesAorB=`SeriesAorB`,e.LateStage=`LateStage`,e}({});export{n as CapitalPhase,t as CompanyPhase,e as ProductPhase};\n//# sourceMappingURL=axes.js.map"],"mappings":"CAAM,SAAS,EAAE,CAAC,MAAO,GAAE,OAAO,SAAS,EAAE,UAAU,YAAY,EAAE,IAAI,MAAM,EAAE,GAAG,KAAK,EAAE,UAAU,YAAYA,IAAG,EAAE,CAAC,CAAG,SAAS,EAAE,CAAC,MAAO,GAAE,KAAK,OAAO,EAAE,SAAS,WAAW,EAAE,cAAc,gBAAgB,EAAE,UAAU,YAAY,EAAE,aAAa,eAAeA,GAAG,EAAE,CAAC,CAAG,SAAS,EAAE,CAAC,MAAO,GAAE,aAAa,eAAe,EAAE,QAAQ,UAAU,EAAE,KAAK,OAAO,EAAE,WAAW,aAAa,EAAE,UAAU,YAAYA,GAAG,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ import"./stages.mjs";
@@ -0,0 +1 @@
1
+ import"./stages.mjs";
@@ -0,0 +1,2 @@
1
+ let e=function(e){return e[e.Exploration=0]=`Exploration`,e[e.ProblemSolutionFit=1]=`ProblemSolutionFit`,e[e.MvpEarlyTraction=2]=`MvpEarlyTraction`,e[e.ProductMarketFit=3]=`ProductMarketFit`,e[e.GrowthScaleUp=4]=`GrowthScaleUp`,e[e.ExpansionPlatform=5]=`ExpansionPlatform`,e[e.MaturityRenewal=6]=`MaturityRenewal`,e}({});const t=[e.Exploration,e.ProblemSolutionFit,e.MvpEarlyTraction,e.ProductMarketFit,e.GrowthScaleUp,e.ExpansionPlatform,e.MaturityRenewal],n={[e.Exploration]:{id:e.Exploration,order:0,slug:`exploration`,name:`Exploration / Ideation`,question:`Is there a problem worth my time?`,signals:[`20+ discovery interviews`,`Clear problem statement`,`Named ICP`],traps:[`Branding before discovery`,`Premature tooling decisions`],focusAreas:[`Customer discovery`,`Problem definition`,`Segment clarity`]},[e.ProblemSolutionFit]:{id:e.ProblemSolutionFit,order:1,slug:`problem-solution-fit`,name:`Problem–Solution Fit`,question:`Do people care enough about this solution?`,signals:[`Prototype reuse`,`Referral energy`,`Pre-pay interest`],traps:[`“Market is huge” without users`,`Skipping qualitative loops`],focusAreas:[`Solution hypothesis`,`Value messaging`,`Feedback capture`]},[e.MvpEarlyTraction]:{id:e.MvpEarlyTraction,order:2,slug:`mvp-early-traction`,name:`MVP & Early Traction`,question:`Can we get real usage and learn fast?`,signals:[`20–50 named active users`,`Weekly releases`,`Noisy feedback`],traps:[`Overbuilt infra for 10 users`,`Undefined retention metric`],focusAreas:[`Activation`,`Cohort tracking`,`Feedback rituals`]},[e.ProductMarketFit]:{id:e.ProductMarketFit,order:3,slug:`product-market-fit`,name:`Product–Market Fit`,question:`Is this pulling us forward?`,signals:[`Retention without heroics`,`Organic word-of-mouth`,`Value stories`],traps:[`Hero growth that does not scale`,`Ignoring churn signals`],focusAreas:[`Retention`,`Reliability`,`ICP clarity`]},[e.GrowthScaleUp]:{id:e.GrowthScaleUp,order:4,slug:`growth-scale-up`,name:`Growth / Scale-up`,question:`Can we grow this repeatably?`,signals:[`Predictable channels`,`Specialized hires`,`Unit economics on track`],traps:[`Paid spend masking retention gaps`,`Infra debt blocking launches`],focusAreas:[`Ops systems`,`Growth loops`,`Reliability engineering`]},[e.ExpansionPlatform]:{id:e.ExpansionPlatform,order:5,slug:`expansion-platform`,name:`Expansion / Platform`,question:`What is the next growth curve?`,signals:[`Stable core metrics`,`Partner/API demand`,`Ecosystem pull`],traps:[`Platform theater before wedge is solid`],focusAreas:[`Partnerships`,`APIs`,`New market validation`]},[e.MaturityRenewal]:{id:e.MaturityRenewal,order:6,slug:`maturity-renewal`,name:`Maturity / Renewal`,question:`Optimize, reinvent, or sunset?`,signals:[`Margin focus`,`Portfolio bets`,`Narrative refresh`],traps:[`Assuming past success is enough`],focusAreas:[`Cost optimization`,`Reinvention bets`,`Sunset planning`]}};export{e,n,t};
2
+ //# sourceMappingURL=stages.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stages.mjs","names":["e","t"],"sources":["../../../../../lifecycle/dist/types/stages.js"],"sourcesContent":["let e=function(e){return e[e.Exploration=0]=`Exploration`,e[e.ProblemSolutionFit=1]=`ProblemSolutionFit`,e[e.MvpEarlyTraction=2]=`MvpEarlyTraction`,e[e.ProductMarketFit=3]=`ProductMarketFit`,e[e.GrowthScaleUp=4]=`GrowthScaleUp`,e[e.ExpansionPlatform=5]=`ExpansionPlatform`,e[e.MaturityRenewal=6]=`MaturityRenewal`,e}({});const t=[e.Exploration,e.ProblemSolutionFit,e.MvpEarlyTraction,e.ProductMarketFit,e.GrowthScaleUp,e.ExpansionPlatform,e.MaturityRenewal],n={[e.Exploration]:{id:e.Exploration,order:0,slug:`exploration`,name:`Exploration / Ideation`,question:`Is there a problem worth my time?`,signals:[`20+ discovery interviews`,`Clear problem statement`,`Named ICP`],traps:[`Branding before discovery`,`Premature tooling decisions`],focusAreas:[`Customer discovery`,`Problem definition`,`Segment clarity`]},[e.ProblemSolutionFit]:{id:e.ProblemSolutionFit,order:1,slug:`problem-solution-fit`,name:`Problem–Solution Fit`,question:`Do people care enough about this solution?`,signals:[`Prototype reuse`,`Referral energy`,`Pre-pay interest`],traps:[`“Market is huge” without users`,`Skipping qualitative loops`],focusAreas:[`Solution hypothesis`,`Value messaging`,`Feedback capture`]},[e.MvpEarlyTraction]:{id:e.MvpEarlyTraction,order:2,slug:`mvp-early-traction`,name:`MVP & Early Traction`,question:`Can we get real usage and learn fast?`,signals:[`20–50 named active users`,`Weekly releases`,`Noisy feedback`],traps:[`Overbuilt infra for 10 users`,`Undefined retention metric`],focusAreas:[`Activation`,`Cohort tracking`,`Feedback rituals`]},[e.ProductMarketFit]:{id:e.ProductMarketFit,order:3,slug:`product-market-fit`,name:`Product–Market Fit`,question:`Is this pulling us forward?`,signals:[`Retention without heroics`,`Organic word-of-mouth`,`Value stories`],traps:[`Hero growth that does not scale`,`Ignoring churn signals`],focusAreas:[`Retention`,`Reliability`,`ICP clarity`]},[e.GrowthScaleUp]:{id:e.GrowthScaleUp,order:4,slug:`growth-scale-up`,name:`Growth / Scale-up`,question:`Can we grow this repeatably?`,signals:[`Predictable channels`,`Specialized hires`,`Unit economics on track`],traps:[`Paid spend masking retention gaps`,`Infra debt blocking launches`],focusAreas:[`Ops systems`,`Growth loops`,`Reliability engineering`]},[e.ExpansionPlatform]:{id:e.ExpansionPlatform,order:5,slug:`expansion-platform`,name:`Expansion / Platform`,question:`What is the next growth curve?`,signals:[`Stable core metrics`,`Partner/API demand`,`Ecosystem pull`],traps:[`Platform theater before wedge is solid`],focusAreas:[`Partnerships`,`APIs`,`New market validation`]},[e.MaturityRenewal]:{id:e.MaturityRenewal,order:6,slug:`maturity-renewal`,name:`Maturity / Renewal`,question:`Optimize, reinvent, or sunset?`,signals:[`Margin focus`,`Portfolio bets`,`Narrative refresh`],traps:[`Assuming past success is enough`],focusAreas:[`Cost optimization`,`Reinvention bets`,`Sunset planning`]}},r=e=>{let t=Object.values(n).find(t=>t.slug===e);if(!t)throw Error(`Unknown lifecycle stage slug: ${e}`);return t.id};export{n as LIFECYCLE_STAGE_META,t as LIFECYCLE_STAGE_ORDER,e as LifecycleStage,r as getLifecycleStageBySlug};\n//# sourceMappingURL=stages.js.map"],"mappings":"AAAA,IAAI,EAAE,SAAS,EAAE,CAAC,MAAO,GAAE,EAAE,YAAY,GAAG,cAAc,EAAE,EAAE,mBAAmB,GAAG,qBAAqB,EAAE,EAAE,iBAAiB,GAAG,mBAAmB,EAAE,EAAE,iBAAiB,GAAG,mBAAmB,EAAE,EAAE,cAAc,GAAG,gBAAgB,EAAE,EAAE,kBAAkB,GAAG,oBAAoB,EAAE,EAAE,gBAAgB,GAAG,kBAAkBA,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,YAAY,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAE,kBAAkB,EAAE,gBAAgB,CAAC,EAAE,EAAE,EA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C,MAAM,CAAC,yCAAyC,CAAC,WAAW,CAAC,eAAe,OAAO,wBAAwB,CAAC,EAAE,EAAE,iBAAiB,CAAC,GAAG,EAAE,gBAAgB,MAAM,EAAE,KAAK,mBAAmB,KAAK,qBAAqB,SAAS,iCAAiC,QAAQ,CAAC,eAAe,iBAAiB,oBAAoB,CAAC,MAAM,CAAC,kCAAkC,CAAC,WAAW,CAAC,oBAAoB,mBAAmB,kBAAkB,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import{n as e,t}from"../types/stages.mjs";const n=e=>[`Product: ${e.product}`,`Company: ${e.company}`,`Capital: ${e.capital}`],r=t=>e[t].name;export{r as o,n as r};
2
+ //# sourceMappingURL=formatters.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatters.mjs","names":["n","i","e","t","a","o","r"],"sources":["../../../../../lifecycle/dist/utils/formatters.js"],"sourcesContent":["import{LIFECYCLE_STAGE_META as e,LIFECYCLE_STAGE_ORDER as t}from\"../types/stages.js\";const n=(t,n)=>{let i=e[t],a=`Stage ${i.order} · ${i.name}`,o=n?r(n.axes):[];return{title:a,question:i.question,highlights:i.signals,traps:i.traps,focusAreas:n?.gaps?.length?n.gaps:i.focusAreas,axesSummary:o}},r=e=>[`Product: ${e.product}`,`Company: ${e.company}`,`Capital: ${e.capital}`],i=e=>[...e].sort((e,t)=>t.score===e.score?t.confidence-e.confidence:t.score-e.score),a=t=>{let n=e[t.stage],r=t.actions[0],i=r?`${r.title} (${r.estimatedImpact} impact)`:`Focus on upcoming milestones.`;return`Next up for ${n.name}: ${i}`},o=t=>e[t].name,s=e=>t.indexOf(e);export{a as createRecommendationDigest,n as formatStageSummary,o as getStageLabel,s as getStageOrderIndex,i as rankStageCandidates,r as summarizeAxes};\n//# sourceMappingURL=formatters.js.map"],"mappings":"0CAAqF,MAAkN,EAAE,GAAG,CAAC,YAAY,EAAE,UAAU,YAAY,EAAE,UAAU,YAAY,EAAE,UAAU,CAAgP,EAAE,GAAGE,EAAEC,GAAG"}