monora-ai 2.1.0 → 2.1.3

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 (184) hide show
  1. package/README.md +333 -159
  2. package/dist/aims_governance.d.ts +238 -0
  3. package/dist/aims_governance.d.ts.map +1 -0
  4. package/dist/aims_governance.js +922 -0
  5. package/dist/alerts.d.ts +16 -0
  6. package/dist/alerts.d.ts.map +1 -1
  7. package/dist/alerts.js +16 -0
  8. package/dist/api.d.ts +6 -0
  9. package/dist/api.d.ts.map +1 -1
  10. package/dist/api.js +6 -0
  11. package/dist/assessment.d.ts +85 -0
  12. package/dist/assessment.d.ts.map +1 -1
  13. package/dist/assessment.js +506 -13
  14. package/dist/attribution.d.ts +44 -3
  15. package/dist/attribution.d.ts.map +1 -1
  16. package/dist/attribution.js +197 -10
  17. package/dist/autodetect.d.ts +68 -0
  18. package/dist/autodetect.d.ts.map +1 -1
  19. package/dist/autodetect.js +639 -0
  20. package/dist/bias.d.ts +130 -0
  21. package/dist/bias.d.ts.map +1 -0
  22. package/dist/bias.js +223 -0
  23. package/dist/cli/diagnostics.d.ts +5 -1
  24. package/dist/cli/diagnostics.d.ts.map +1 -1
  25. package/dist/cli/diagnostics.js +23 -6
  26. package/dist/cli/doctor.d.ts +25 -0
  27. package/dist/cli/doctor.d.ts.map +1 -0
  28. package/dist/cli/doctor.js +381 -0
  29. package/dist/cli/fix.d.ts +16 -0
  30. package/dist/cli/fix.d.ts.map +1 -0
  31. package/dist/cli/fix.js +284 -0
  32. package/dist/cli/init.d.ts +57 -0
  33. package/dist/cli/init.d.ts.map +1 -0
  34. package/dist/cli/init.js +205 -0
  35. package/dist/cli.js +1550 -176
  36. package/dist/complianceTargets.d.ts +111 -0
  37. package/dist/complianceTargets.d.ts.map +1 -0
  38. package/dist/complianceTargets.js +521 -0
  39. package/dist/config.d.ts +261 -16
  40. package/dist/config.d.ts.map +1 -1
  41. package/dist/config.js +381 -32
  42. package/dist/config_migrations.d.ts.map +1 -1
  43. package/dist/config_migrations.js +38 -1
  44. package/dist/config_schema.d.ts +2490 -1035
  45. package/dist/config_schema.d.ts.map +1 -1
  46. package/dist/config_schema.js +233 -64
  47. package/dist/context.d.ts +34 -0
  48. package/dist/context.d.ts.map +1 -1
  49. package/dist/context.js +118 -7
  50. package/dist/control_backbone.d.ts +122 -0
  51. package/dist/control_backbone.d.ts.map +1 -0
  52. package/dist/control_backbone.js +698 -0
  53. package/dist/data-governance.d.ts +187 -0
  54. package/dist/data-governance.d.ts.map +1 -0
  55. package/dist/data-governance.js +424 -0
  56. package/dist/dataResidency.d.ts +44 -0
  57. package/dist/dataResidency.d.ts.map +1 -0
  58. package/dist/dataResidency.js +203 -0
  59. package/dist/dispatcher.d.ts.map +1 -1
  60. package/dist/dispatcher.js +17 -5
  61. package/dist/evidence_store.d.ts +103 -0
  62. package/dist/evidence_store.d.ts.map +1 -0
  63. package/dist/evidence_store.js +459 -0
  64. package/dist/executiveSummary.d.ts +15 -0
  65. package/dist/executiveSummary.d.ts.map +1 -1
  66. package/dist/executiveSummary.js +135 -22
  67. package/dist/identity.d.ts +143 -0
  68. package/dist/identity.d.ts.map +1 -0
  69. package/dist/identity.js +231 -0
  70. package/dist/impact-assessment.d.ts +350 -0
  71. package/dist/impact-assessment.d.ts.map +1 -0
  72. package/dist/impact-assessment.js +580 -0
  73. package/dist/index.d.ts +20 -4
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +247 -5
  76. package/dist/instrumentation.d.ts +1 -1
  77. package/dist/instrumentation.d.ts.map +1 -1
  78. package/dist/instrumentation.js +123 -22
  79. package/dist/integrations/anthropic.d.ts +3 -0
  80. package/dist/integrations/anthropic.d.ts.map +1 -1
  81. package/dist/integrations/anthropic.js +282 -80
  82. package/dist/integrations/governance.d.ts +33 -0
  83. package/dist/integrations/governance.d.ts.map +1 -0
  84. package/dist/integrations/governance.js +208 -0
  85. package/dist/integrations/langchain.d.ts +4 -0
  86. package/dist/integrations/langchain.d.ts.map +1 -1
  87. package/dist/integrations/langchain.js +362 -142
  88. package/dist/integrations/openai.d.ts +9 -0
  89. package/dist/integrations/openai.d.ts.map +1 -1
  90. package/dist/integrations/openai.js +673 -73
  91. package/dist/iso42001_consolidation.d.ts +16 -0
  92. package/dist/iso42001_consolidation.d.ts.map +1 -0
  93. package/dist/iso42001_consolidation.js +413 -0
  94. package/dist/iso42001_workflows.d.ts +263 -0
  95. package/dist/iso42001_workflows.d.ts.map +1 -0
  96. package/dist/iso42001_workflows.js +781 -0
  97. package/dist/lifecycle.d.ts +299 -0
  98. package/dist/lifecycle.d.ts.map +1 -0
  99. package/dist/lifecycle.js +624 -0
  100. package/dist/lineage.d.ts +2 -2
  101. package/dist/lineage.d.ts.map +1 -1
  102. package/dist/lineage.js +9 -16
  103. package/dist/middleware/express.d.ts.map +1 -1
  104. package/dist/middleware/express.js +18 -3
  105. package/dist/middleware/nextjs.js +2 -2
  106. package/dist/model.d.ts +143 -0
  107. package/dist/model.d.ts.map +1 -0
  108. package/dist/model.js +371 -0
  109. package/dist/onboarding.d.ts +42 -0
  110. package/dist/onboarding.d.ts.map +1 -0
  111. package/dist/onboarding.js +1022 -0
  112. package/dist/oversight.d.ts +264 -0
  113. package/dist/oversight.d.ts.map +1 -0
  114. package/dist/oversight.js +497 -0
  115. package/dist/presets.js +7 -7
  116. package/dist/quotas.d.ts +171 -0
  117. package/dist/quotas.d.ts.map +1 -0
  118. package/dist/quotas.js +259 -0
  119. package/dist/register.d.ts +13 -0
  120. package/dist/register.d.ts.map +1 -0
  121. package/dist/register.js +99 -0
  122. package/dist/registry.d.ts +1 -0
  123. package/dist/registry.d.ts.map +1 -1
  124. package/dist/registry.js +7 -0
  125. package/dist/registryData.json +43 -6
  126. package/dist/report.d.ts +2 -1
  127. package/dist/report.d.ts.map +1 -1
  128. package/dist/report.js +189 -2
  129. package/dist/reporting.d.ts +125 -0
  130. package/dist/reporting.d.ts.map +1 -1
  131. package/dist/reporting.js +192 -2
  132. package/dist/resources.d.ts +285 -0
  133. package/dist/resources.d.ts.map +1 -0
  134. package/dist/resources.js +643 -0
  135. package/dist/risk.d.ts +120 -0
  136. package/dist/risk.d.ts.map +1 -0
  137. package/dist/risk.js +220 -0
  138. package/dist/runtime.d.ts +73 -0
  139. package/dist/runtime.d.ts.map +1 -1
  140. package/dist/runtime.js +415 -18
  141. package/dist/schemaInference.d.ts +92 -0
  142. package/dist/schemaInference.d.ts.map +1 -0
  143. package/dist/schemaInference.js +466 -0
  144. package/dist/schema_validation.js +2 -2
  145. package/dist/schemas/config.schema.json +118 -4
  146. package/dist/security_report.js +4 -4
  147. package/dist/signing.d.ts +1 -1
  148. package/dist/signing.d.ts.map +1 -1
  149. package/dist/signing.js +4 -0
  150. package/dist/sinks/file.d.ts +19 -1
  151. package/dist/sinks/file.d.ts.map +1 -1
  152. package/dist/sinks/file.js +82 -13
  153. package/dist/sinks/https.d.ts +10 -0
  154. package/dist/sinks/https.d.ts.map +1 -1
  155. package/dist/sinks/https.js +76 -16
  156. package/dist/sinks/stdout.d.ts +1 -0
  157. package/dist/sinks/stdout.d.ts.map +1 -1
  158. package/dist/sinks/stdout.js +12 -1
  159. package/dist/spec.d.ts +159 -0
  160. package/dist/spec.d.ts.map +1 -0
  161. package/dist/spec.js +391 -0
  162. package/dist/stakeholders.d.ts +199 -0
  163. package/dist/stakeholders.d.ts.map +1 -0
  164. package/dist/stakeholders.js +398 -0
  165. package/dist/standards.d.ts.map +1 -1
  166. package/dist/standards.js +160 -2
  167. package/dist/standards_ingest.d.ts.map +1 -1
  168. package/dist/standards_ingest.js +1 -4
  169. package/dist/telemetry.d.ts +16 -2
  170. package/dist/telemetry.d.ts.map +1 -1
  171. package/dist/telemetry.js +77 -14
  172. package/dist/templates/controls/iso42001_control_catalog.json +1443 -0
  173. package/dist/traced_emitter.d.ts.map +1 -1
  174. package/dist/traced_emitter.js +19 -9
  175. package/dist/trust_package.d.ts +19 -1
  176. package/dist/trust_package.d.ts.map +1 -1
  177. package/dist/trust_package.js +89 -2
  178. package/dist/verify.d.ts.map +1 -1
  179. package/dist/verify.js +9 -2
  180. package/dist/wal.d.ts.map +1 -1
  181. package/dist/wal.js +2 -1
  182. package/package.json +14 -1
  183. package/scripts/postinstall.js +105 -210
  184. package/templates/controls/iso42001_control_catalog.json +1443 -0
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Resource quotas for controlling LLM usage and costs.
3
+ *
4
+ * Provides per-trace limits on tokens, LLM calls, and duration
5
+ * to prevent runaway costs and resource exhaustion.
6
+ */
7
+ /**
8
+ * Quota enforcement action when limits are exceeded.
9
+ */
10
+ export type QuotaAction = 'warn' | 'block';
11
+ /**
12
+ * Configuration for resource quotas.
13
+ */
14
+ export interface QuotasConfig {
15
+ /** Enable quota enforcement (default: false) */
16
+ enabled?: boolean;
17
+ /** Maximum tokens per trace (input + output combined) */
18
+ max_tokens_per_trace?: number;
19
+ /** Maximum LLM calls per trace */
20
+ max_llm_calls_per_trace?: number;
21
+ /** Maximum trace duration in seconds */
22
+ max_trace_duration_sec?: number;
23
+ /** Maximum cost per trace in USD (requires cost tracking) */
24
+ max_cost_per_trace?: number;
25
+ /** Action when quota exceeded: 'warn' logs warning, 'block' throws error */
26
+ action?: QuotaAction;
27
+ }
28
+ /**
29
+ * Default quota configuration values.
30
+ */
31
+ export declare const DEFAULT_QUOTAS: Required<QuotasConfig>;
32
+ /**
33
+ * Result of a quota check.
34
+ */
35
+ export interface QuotaCheckResult {
36
+ /** Whether the quota check passed */
37
+ allowed: boolean;
38
+ /** Which quota was exceeded (if any) */
39
+ exceededQuota?: 'tokens' | 'calls' | 'duration' | 'cost';
40
+ /** Current value */
41
+ currentValue?: number;
42
+ /** Limit value */
43
+ limitValue?: number;
44
+ /** Human-readable message */
45
+ message: string;
46
+ }
47
+ /**
48
+ * Quota violation error thrown when action is 'block'.
49
+ */
50
+ export declare class QuotaExceededError extends Error {
51
+ readonly quota: string;
52
+ readonly currentValue: number;
53
+ readonly limitValue: number;
54
+ /** Policy type for metrics (e.g., "quota.tokens"). Matches Python SDK's policy_type. */
55
+ readonly policyType: string;
56
+ readonly model: string;
57
+ constructor(quota: string, currentValue: number, limitValue: number, model?: string);
58
+ }
59
+ /**
60
+ * Usage statistics for a trace.
61
+ */
62
+ export interface TraceUsage {
63
+ /** Total tokens used (input + output) */
64
+ totalTokens: number;
65
+ /** Number of LLM calls made */
66
+ llmCalls: number;
67
+ /** Trace start time (epoch ms) */
68
+ startTime: number;
69
+ /** Estimated cost in USD */
70
+ estimatedCost: number;
71
+ }
72
+ /**
73
+ * Resource quota tracker for a single trace.
74
+ */
75
+ export declare class TraceQuotaTracker {
76
+ private readonly config;
77
+ private usage;
78
+ constructor(config?: QuotasConfig);
79
+ /**
80
+ * Check if quotas are enabled.
81
+ */
82
+ isEnabled(): boolean;
83
+ /**
84
+ * Get current usage statistics.
85
+ */
86
+ getUsage(): TraceUsage;
87
+ /**
88
+ * Get the quota configuration.
89
+ */
90
+ getConfig(): Required<QuotasConfig>;
91
+ /**
92
+ * Update trace start time if the provided time is earlier.
93
+ */
94
+ setStartTime(startTime?: number): void;
95
+ /**
96
+ * Record token usage from an LLM call.
97
+ *
98
+ * @param inputTokens - Number of input/prompt tokens
99
+ * @param outputTokens - Number of output/completion tokens
100
+ * @param cost - Optional cost in USD for this call
101
+ */
102
+ recordTokenUsage(inputTokens: number, outputTokens: number, cost?: number): void;
103
+ /**
104
+ * Check all quotas and return the result.
105
+ * Does not modify state or throw errors.
106
+ */
107
+ checkQuotas(): QuotaCheckResult;
108
+ /**
109
+ * Enforce quotas based on configured action.
110
+ * Logs warning or throws error depending on config.
111
+ *
112
+ * @throws QuotaExceededError if action is 'block' and quota exceeded
113
+ */
114
+ enforceQuotas(): QuotaCheckResult;
115
+ /**
116
+ * Reset usage statistics (for reuse).
117
+ */
118
+ reset(): void;
119
+ }
120
+ /**
121
+ * Global quota manager that tracks quotas per trace.
122
+ */
123
+ export declare class QuotaManager {
124
+ private readonly defaultConfig;
125
+ private readonly trackers;
126
+ constructor(config?: QuotasConfig);
127
+ /**
128
+ * Check if quotas are enabled.
129
+ */
130
+ isEnabled(): boolean;
131
+ /**
132
+ * Get or create a quota tracker for a trace.
133
+ */
134
+ getTracker(traceId: string): TraceQuotaTracker;
135
+ /**
136
+ * Check if a quota tracker exists for a trace without creating one.
137
+ */
138
+ hasTracker(traceId: string): boolean;
139
+ /**
140
+ * Record token usage for a trace.
141
+ */
142
+ recordUsage(traceId: string, inputTokens: number, outputTokens: number, cost?: number): void;
143
+ /**
144
+ * Check quotas for a trace (creates a tracker if missing).
145
+ */
146
+ checkQuotas(traceId: string): QuotaCheckResult;
147
+ /**
148
+ * Enforce quotas for a trace (creates a tracker if missing).
149
+ *
150
+ * @throws QuotaExceededError if action is 'block' and quota exceeded
151
+ */
152
+ enforceQuotas(traceId: string): QuotaCheckResult;
153
+ /**
154
+ * Get usage statistics for a trace without creating a tracker.
155
+ * Returns null if the trace is unknown.
156
+ */
157
+ getUsage(traceId: string): TraceUsage | null;
158
+ /**
159
+ * Remove tracker for a completed trace.
160
+ */
161
+ removeTrace(traceId: string): void;
162
+ /**
163
+ * Get all tracked trace IDs.
164
+ */
165
+ getTrackedTraces(): string[];
166
+ /**
167
+ * Clear all trackers.
168
+ */
169
+ clear(): void;
170
+ }
171
+ //# sourceMappingURL=quotas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quotas.d.ts","sourceRoot":"","sources":["../src/quotas.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,gDAAgD;IAChD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yDAAyD;IACzD,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,kCAAkC;IAClC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,wCAAwC;IACxC,sBAAs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ACH,gBAAgB,IAAI,MAAM,EAAE;IAI5B;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd"}
package/dist/quotas.js ADDED
@@ -0,0 +1,259 @@
1
+ "use strict";
2
+ /**
3
+ * Resource quotas for controlling LLM usage and costs.
4
+ *
5
+ * Provides per-trace limits on tokens, LLM calls, and duration
6
+ * to prevent runaway costs and resource exhaustion.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.QuotaManager = exports.TraceQuotaTracker = exports.QuotaExceededError = exports.DEFAULT_QUOTAS = void 0;
10
+ const logger_1 = require("./logger");
11
+ const context_1 = require("./context");
12
+ /**
13
+ * Default quota configuration values.
14
+ */
15
+ exports.DEFAULT_QUOTAS = {
16
+ enabled: false,
17
+ max_tokens_per_trace: 100000,
18
+ max_llm_calls_per_trace: 50,
19
+ max_trace_duration_sec: 3600,
20
+ max_cost_per_trace: 10.0,
21
+ action: 'warn',
22
+ };
23
+ /**
24
+ * Quota violation error thrown when action is 'block'.
25
+ */
26
+ class QuotaExceededError extends Error {
27
+ constructor(quota, currentValue, limitValue, model) {
28
+ super(`Quota exceeded: ${quota} (${currentValue} > ${limitValue})`);
29
+ this.name = 'QuotaExceededError';
30
+ this.quota = quota;
31
+ this.currentValue = currentValue;
32
+ this.limitValue = limitValue;
33
+ this.policyType = `quota.${quota}`;
34
+ this.model = model || 'unknown';
35
+ }
36
+ }
37
+ exports.QuotaExceededError = QuotaExceededError;
38
+ /**
39
+ * Resource quota tracker for a single trace.
40
+ */
41
+ class TraceQuotaTracker {
42
+ constructor(config = {}) {
43
+ this.config = { ...exports.DEFAULT_QUOTAS, ...config };
44
+ this.usage = {
45
+ totalTokens: 0,
46
+ llmCalls: 0,
47
+ startTime: Date.now(),
48
+ estimatedCost: 0,
49
+ };
50
+ }
51
+ /**
52
+ * Check if quotas are enabled.
53
+ */
54
+ isEnabled() {
55
+ return this.config.enabled;
56
+ }
57
+ /**
58
+ * Get current usage statistics.
59
+ */
60
+ getUsage() {
61
+ return { ...this.usage };
62
+ }
63
+ /**
64
+ * Get the quota configuration.
65
+ */
66
+ getConfig() {
67
+ return { ...this.config };
68
+ }
69
+ /**
70
+ * Update trace start time if the provided time is earlier.
71
+ */
72
+ setStartTime(startTime) {
73
+ if (startTime === undefined || startTime === null) {
74
+ return;
75
+ }
76
+ if (startTime < this.usage.startTime) {
77
+ this.usage.startTime = startTime;
78
+ }
79
+ }
80
+ /**
81
+ * Record token usage from an LLM call.
82
+ *
83
+ * @param inputTokens - Number of input/prompt tokens
84
+ * @param outputTokens - Number of output/completion tokens
85
+ * @param cost - Optional cost in USD for this call
86
+ */
87
+ recordTokenUsage(inputTokens, outputTokens, cost) {
88
+ this.usage.totalTokens += inputTokens + outputTokens;
89
+ this.usage.llmCalls += 1;
90
+ if (cost !== undefined) {
91
+ this.usage.estimatedCost += cost;
92
+ }
93
+ }
94
+ /**
95
+ * Check all quotas and return the result.
96
+ * Does not modify state or throw errors.
97
+ */
98
+ checkQuotas() {
99
+ if (!this.config.enabled) {
100
+ return { allowed: true, message: 'Quotas disabled' };
101
+ }
102
+ // Check token quota
103
+ if (this.usage.totalTokens > this.config.max_tokens_per_trace) {
104
+ return {
105
+ allowed: false,
106
+ exceededQuota: 'tokens',
107
+ currentValue: this.usage.totalTokens,
108
+ limitValue: this.config.max_tokens_per_trace,
109
+ message: `Token quota exceeded: ${this.usage.totalTokens} > ${this.config.max_tokens_per_trace}`,
110
+ };
111
+ }
112
+ // Check call quota
113
+ if (this.usage.llmCalls > this.config.max_llm_calls_per_trace) {
114
+ return {
115
+ allowed: false,
116
+ exceededQuota: 'calls',
117
+ currentValue: this.usage.llmCalls,
118
+ limitValue: this.config.max_llm_calls_per_trace,
119
+ message: `LLM call quota exceeded: ${this.usage.llmCalls} > ${this.config.max_llm_calls_per_trace}`,
120
+ };
121
+ }
122
+ // Check duration quota
123
+ const durationSec = (Date.now() - this.usage.startTime) / 1000;
124
+ if (durationSec > this.config.max_trace_duration_sec) {
125
+ return {
126
+ allowed: false,
127
+ exceededQuota: 'duration',
128
+ currentValue: durationSec,
129
+ limitValue: this.config.max_trace_duration_sec,
130
+ message: `Trace duration quota exceeded: ${durationSec.toFixed(1)}s > ${this.config.max_trace_duration_sec}s`,
131
+ };
132
+ }
133
+ // Check cost quota
134
+ if (this.usage.estimatedCost > this.config.max_cost_per_trace) {
135
+ return {
136
+ allowed: false,
137
+ exceededQuota: 'cost',
138
+ currentValue: this.usage.estimatedCost,
139
+ limitValue: this.config.max_cost_per_trace,
140
+ message: `Cost quota exceeded: $${this.usage.estimatedCost.toFixed(4)} > $${this.config.max_cost_per_trace}`,
141
+ };
142
+ }
143
+ return { allowed: true, message: 'All quotas within limits' };
144
+ }
145
+ /**
146
+ * Enforce quotas based on configured action.
147
+ * Logs warning or throws error depending on config.
148
+ *
149
+ * @throws QuotaExceededError if action is 'block' and quota exceeded
150
+ */
151
+ enforceQuotas() {
152
+ const result = this.checkQuotas();
153
+ if (!result.allowed) {
154
+ if (this.config.action === 'block') {
155
+ throw new QuotaExceededError(result.exceededQuota, result.currentValue, result.limitValue);
156
+ }
157
+ else {
158
+ logger_1.logger.warning('Quota warning: %s', result.message);
159
+ }
160
+ }
161
+ return result;
162
+ }
163
+ /**
164
+ * Reset usage statistics (for reuse).
165
+ */
166
+ reset() {
167
+ this.usage = {
168
+ totalTokens: 0,
169
+ llmCalls: 0,
170
+ startTime: Date.now(),
171
+ estimatedCost: 0,
172
+ };
173
+ }
174
+ }
175
+ exports.TraceQuotaTracker = TraceQuotaTracker;
176
+ /**
177
+ * Global quota manager that tracks quotas per trace.
178
+ */
179
+ class QuotaManager {
180
+ constructor(config = {}) {
181
+ this.trackers = new Map();
182
+ this.defaultConfig = { ...exports.DEFAULT_QUOTAS, ...config };
183
+ }
184
+ /**
185
+ * Check if quotas are enabled.
186
+ */
187
+ isEnabled() {
188
+ return this.defaultConfig.enabled;
189
+ }
190
+ /**
191
+ * Get or create a quota tracker for a trace.
192
+ */
193
+ getTracker(traceId) {
194
+ let tracker = this.trackers.get(traceId);
195
+ if (!tracker) {
196
+ tracker = new TraceQuotaTracker(this.defaultConfig);
197
+ this.trackers.set(traceId, tracker);
198
+ }
199
+ const startTime = (0, context_1.getTraceStartTime)(traceId);
200
+ tracker.setStartTime(startTime);
201
+ return tracker;
202
+ }
203
+ /**
204
+ * Check if a quota tracker exists for a trace without creating one.
205
+ */
206
+ hasTracker(traceId) {
207
+ return this.trackers.has(traceId);
208
+ }
209
+ /**
210
+ * Record token usage for a trace.
211
+ */
212
+ recordUsage(traceId, inputTokens, outputTokens, cost) {
213
+ const tracker = this.getTracker(traceId);
214
+ tracker.recordTokenUsage(inputTokens, outputTokens, cost);
215
+ }
216
+ /**
217
+ * Check quotas for a trace (creates a tracker if missing).
218
+ */
219
+ checkQuotas(traceId) {
220
+ const tracker = this.getTracker(traceId);
221
+ return tracker.checkQuotas();
222
+ }
223
+ /**
224
+ * Enforce quotas for a trace (creates a tracker if missing).
225
+ *
226
+ * @throws QuotaExceededError if action is 'block' and quota exceeded
227
+ */
228
+ enforceQuotas(traceId) {
229
+ const tracker = this.getTracker(traceId);
230
+ return tracker.enforceQuotas();
231
+ }
232
+ /**
233
+ * Get usage statistics for a trace without creating a tracker.
234
+ * Returns null if the trace is unknown.
235
+ */
236
+ getUsage(traceId) {
237
+ const tracker = this.trackers.get(traceId);
238
+ return tracker ? tracker.getUsage() : null;
239
+ }
240
+ /**
241
+ * Remove tracker for a completed trace.
242
+ */
243
+ removeTrace(traceId) {
244
+ this.trackers.delete(traceId);
245
+ }
246
+ /**
247
+ * Get all tracked trace IDs.
248
+ */
249
+ getTrackedTraces() {
250
+ return Array.from(this.trackers.keys());
251
+ }
252
+ /**
253
+ * Clear all trackers.
254
+ */
255
+ clear() {
256
+ this.trackers.clear();
257
+ }
258
+ }
259
+ exports.QuotaManager = QuotaManager;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Auto-init hook for zero-code instrumentation.
3
+ *
4
+ * This module is designed to be loaded via NODE_OPTIONS="--require monora-ai/register"
5
+ * It automatically initializes Monora and instruments detected AI SDKs.
6
+ *
7
+ * Usage:
8
+ * npx monora start -- node server.js
9
+ * NODE_OPTIONS="--require monora-ai/register" node server.js
10
+ */
11
+ import { init, shutdown } from './runtime';
12
+ export { init, shutdown };
13
+ //# sourceMappingURL=register.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAe,MAAM,WAAW,CAAC;AAgGxD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ /**
3
+ * Auto-init hook for zero-code instrumentation.
4
+ *
5
+ * This module is designed to be loaded via NODE_OPTIONS="--require monora-ai/register"
6
+ * It automatically initializes Monora and instruments detected AI SDKs.
7
+ *
8
+ * Usage:
9
+ * npx monora start -- node server.js
10
+ * NODE_OPTIONS="--require monora-ai/register" node server.js
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.shutdown = exports.init = void 0;
14
+ const runtime_1 = require("./runtime");
15
+ Object.defineProperty(exports, "init", { enumerable: true, get: function () { return runtime_1.init; } });
16
+ Object.defineProperty(exports, "shutdown", { enumerable: true, get: function () { return runtime_1.shutdown; } });
17
+ const autodetect_1 = require("./autodetect");
18
+ const integrations_1 = require("./integrations");
19
+ const logger_1 = require("./logger");
20
+ let isShuttingDown = false;
21
+ // Only auto-init if explicitly enabled
22
+ if (process.env.MONORA_AUTO_INIT === 'true') {
23
+ const configPath = process.env.MONORA_CONFIG_PATH;
24
+ try {
25
+ // Build init options
26
+ const initOptions = {};
27
+ if (configPath) {
28
+ initOptions.configPath = configPath;
29
+ logger_1.logger.debug('Monora: using config from %s', configPath);
30
+ }
31
+ else {
32
+ // Auto-detect configuration
33
+ const detection = (0, autodetect_1.detectFramework)();
34
+ const env = (0, autodetect_1.detectEnvironment)();
35
+ const preset = (0, autodetect_1.selectPresetForEnvironment)(env);
36
+ initOptions.preset = preset;
37
+ // Apply detected model allowlist
38
+ if (detection.suggestedModels.length > 0) {
39
+ initOptions.policies = detection.suggestedModels;
40
+ }
41
+ logger_1.logger.debug('Monora: using auto-detected config (preset=%s, env=%s)', preset, env);
42
+ }
43
+ // Initialize Monora
44
+ (0, runtime_1.init)(initOptions);
45
+ logger_1.logger.info('Monora: initialized with auto-instrumentation');
46
+ // Auto-patch detected SDKs
47
+ const detection = (0, autodetect_1.detectFramework)();
48
+ const sdkNames = new Set(detection.aiSdks.map(sdk => sdk.name));
49
+ if (sdkNames.has('openai') || sdkNames.has('vercel-ai-openai') || sdkNames.has('langchain-openai')) {
50
+ try {
51
+ // Check if OpenAI is actually importable
52
+ require.resolve('openai');
53
+ (0, integrations_1.patchOpenAI)({});
54
+ logger_1.logger.debug('Monora: patched OpenAI SDK');
55
+ }
56
+ catch {
57
+ // OpenAI not installed, skip
58
+ }
59
+ }
60
+ if (sdkNames.has('anthropic') || sdkNames.has('vercel-ai-anthropic') || sdkNames.has('langchain-anthropic')) {
61
+ try {
62
+ // Check if Anthropic is actually importable
63
+ require.resolve('@anthropic-ai/sdk');
64
+ (0, integrations_1.patchAnthropic)({});
65
+ logger_1.logger.debug('Monora: patched Anthropic SDK');
66
+ }
67
+ catch {
68
+ // Anthropic not installed, skip
69
+ }
70
+ }
71
+ // Graceful shutdown on process exit
72
+ const handleExit = async () => {
73
+ if (isShuttingDown) {
74
+ return;
75
+ }
76
+ isShuttingDown = true;
77
+ try {
78
+ await (0, runtime_1.shutdown)();
79
+ }
80
+ catch {
81
+ // Ignore shutdown errors
82
+ }
83
+ };
84
+ process.on('SIGINT', async () => {
85
+ await handleExit();
86
+ process.exit(130);
87
+ });
88
+ process.on('SIGTERM', async () => {
89
+ await handleExit();
90
+ process.exit(143);
91
+ });
92
+ process.on('beforeExit', async () => {
93
+ await handleExit();
94
+ });
95
+ }
96
+ catch (error) {
97
+ logger_1.logger.error('Monora: failed to auto-init: %s', error);
98
+ }
99
+ }
@@ -79,6 +79,7 @@ export declare class ModelRegistry {
79
79
  private loadCustomRegistry;
80
80
  private loadModels;
81
81
  private canonicalizeModel;
82
+ getModelMetadata(model: string | null | undefined): Record<string, any> | null;
82
83
  }
83
84
  export {};
84
85
  //# sourceMappingURL=registry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EAAmB,WAAW,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,WAAW,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B,YAAY,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,cAAc,CAAC;IAC9D,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,UAAU,YAAY;IACpB,MAAM,CAAC,EAAE;QACP,CAAC,OAAO,EAAE,MAAM,GAAG;YACjB,QAAQ,EAAE,MAAM,CAAC;YACjB,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,YAAY,CAAC,EAAE,MAAM,CAAC;YACtB,YAAY,CAAC,EAAE,MAAM,CAAC;YACtB,cAAc,CAAC,EAAE,MAAM,CAAC;YACxB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;YACxB,OAAO,CAAC,EAAE,MAAM,EAAE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;QAChE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;QACxB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;KAC/B,CAAC,CAAC;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;CACjC;AAsCD,qBAAa,aAAa;IACxB,SAAgB,OAAO,EAAE,MAAM,CAAC;IAChC,SAAgB,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAChD,SAAgB,eAAe,EAAE,MAAM,CAAC;IACxC,SAAgB,YAAY,EAAE,OAAO,CAAC;IACtC,SAAgB,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3C,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,OAAO,CAAC,OAAO,CAAmC;IAClD,OAAO,CAAC,iBAAiB,CAAsB;gBAEnC,MAAM,EAAE,mBAAmB;IAwCvC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAK5D,YAAY,CACV,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC/B,CAAC,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;IAkB1C,OAAO,CAAC,WAAW;IAgCnB,OAAO,CAAC,mBAAmB;IAW3B,OAAO,CAAC,kBAAkB;IAS1B,OAAO,CAAC,UAAU;IAoClB,OAAO,CAAC,iBAAiB;IAOzB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;CAO/E"}
package/dist/registry.js CHANGED
@@ -207,5 +207,12 @@ class ModelRegistry {
207
207
  }
208
208
  return this._aliasToCanonical.get(model.toLowerCase()) || model;
209
209
  }
210
+ getModelMetadata(model) {
211
+ if (!model) {
212
+ return null;
213
+ }
214
+ const canonical = this.canonicalizeModel(model);
215
+ return this._models.get(canonical) || null;
216
+ }
210
217
  }
211
218
  exports.ModelRegistry = ModelRegistry;
@@ -28,7 +28,13 @@
28
28
  "context_window": 128000,
29
29
  "capabilities": ["chat", "function_calling", "vision"],
30
30
  "aliases": ["gpt-4o-2024-05-13"],
31
- "deprecated": false
31
+ "deprecated": false,
32
+ "pricing": {
33
+ "currency": "USD",
34
+ "unit": "1m_tokens",
35
+ "prompt_cost_per_1m": 2.5,
36
+ "completion_cost_per_1m": 10.0
37
+ }
32
38
  },
33
39
  "gpt-4o-mini": {
34
40
  "provider": "openai",
@@ -38,7 +44,13 @@
38
44
  "context_window": 128000,
39
45
  "capabilities": ["chat", "function_calling", "vision"],
40
46
  "aliases": ["gpt-4o-mini-2024-07-18"],
41
- "deprecated": false
47
+ "deprecated": false,
48
+ "pricing": {
49
+ "currency": "USD",
50
+ "unit": "1m_tokens",
51
+ "prompt_cost_per_1m": 0.15,
52
+ "completion_cost_per_1m": 0.6
53
+ }
42
54
  },
43
55
  "gpt-3.5-turbo": {
44
56
  "provider": "openai",
@@ -48,7 +60,13 @@
48
60
  "context_window": 16385,
49
61
  "capabilities": ["chat", "function_calling"],
50
62
  "aliases": ["gpt-3.5-turbo-0125"],
51
- "deprecated": false
63
+ "deprecated": false,
64
+ "pricing": {
65
+ "currency": "USD",
66
+ "unit": "1m_tokens",
67
+ "prompt_cost_per_1m": 0.5,
68
+ "completion_cost_per_1m": 1.5
69
+ }
52
70
  },
53
71
  "claude-3-5-sonnet-20241022": {
54
72
  "provider": "anthropic",
@@ -58,7 +76,13 @@
58
76
  "context_window": 200000,
59
77
  "capabilities": ["chat", "tool_use", "vision"],
60
78
  "aliases": ["claude-3.5-sonnet"],
61
- "deprecated": false
79
+ "deprecated": false,
80
+ "pricing": {
81
+ "currency": "USD",
82
+ "unit": "1m_tokens",
83
+ "prompt_cost_per_1m": 3.0,
84
+ "completion_cost_per_1m": 15.0
85
+ }
62
86
  },
63
87
  "claude-3-opus-20240229": {
64
88
  "provider": "anthropic",
@@ -68,7 +92,13 @@
68
92
  "context_window": 200000,
69
93
  "capabilities": ["chat", "tool_use", "vision"],
70
94
  "aliases": ["claude-3-opus"],
71
- "deprecated": false
95
+ "deprecated": false,
96
+ "pricing": {
97
+ "currency": "USD",
98
+ "unit": "1m_tokens",
99
+ "prompt_cost_per_1m": 15.0,
100
+ "completion_cost_per_1m": 75.0
101
+ }
72
102
  },
73
103
  "deepseek-chat": {
74
104
  "provider": "deepseek",
@@ -78,7 +108,14 @@
78
108
  "context_window": 64000,
79
109
  "capabilities": ["chat"],
80
110
  "aliases": ["deepseek:v3"],
81
- "deprecated": false
111
+ "deprecated": false,
112
+ "pricing": {
113
+ "currency": "USD",
114
+ "unit": "1m_tokens",
115
+ "prompt_cost_per_1m": 0.28,
116
+ "completion_cost_per_1m": 0.42,
117
+ "notes": "cache_miss_pricing"
118
+ }
82
119
  }
83
120
  },
84
121
  "providers": {