monora-ai 1.4.0 → 1.6.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.
- package/dist/autodetect.d.ts +24 -0
- package/dist/autodetect.d.ts.map +1 -0
- package/dist/autodetect.js +207 -0
- package/dist/cli.js +64 -20
- package/dist/config.d.ts +51 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +168 -2
- package/dist/executiveSummary.d.ts +33 -0
- package/dist/executiveSummary.d.ts.map +1 -0
- package/dist/executiveSummary.js +364 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -3
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +12 -6
- package/dist/runtime.d.ts +36 -3
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +71 -2
- package/dist/streaming.d.ts +108 -0
- package/dist/streaming.d.ts.map +1 -0
- package/dist/streaming.js +222 -0
- package/package.json +1 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-detection utilities for zero-config initialization.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Detect which LLM SDKs are installed.
|
|
6
|
+
*/
|
|
7
|
+
export declare function detectInstalledSdks(): string[];
|
|
8
|
+
/**
|
|
9
|
+
* Detect the current environment (dev, staging, production).
|
|
10
|
+
*/
|
|
11
|
+
export declare function detectEnvironment(): string;
|
|
12
|
+
/**
|
|
13
|
+
* Detect the service name from project files.
|
|
14
|
+
*/
|
|
15
|
+
export declare function detectServiceName(): string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Auto-detect configuration based on environment.
|
|
18
|
+
*/
|
|
19
|
+
export declare function autoDetectConfig(): Record<string, any>;
|
|
20
|
+
/**
|
|
21
|
+
* Select the appropriate preset based on environment.
|
|
22
|
+
*/
|
|
23
|
+
export declare function selectPresetForEnvironment(env: string): string;
|
|
24
|
+
//# sourceMappingURL=autodetect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autodetect.d.ts","sourceRoot":"","sources":["../src/autodetect.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,EAAE,CAmB9C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CA0D1C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,GAAG,SAAS,CA2CtD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAwBtD;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAa9D"}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Auto-detection utilities for zero-config initialization.
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.detectInstalledSdks = detectInstalledSdks;
|
|
40
|
+
exports.detectEnvironment = detectEnvironment;
|
|
41
|
+
exports.detectServiceName = detectServiceName;
|
|
42
|
+
exports.autoDetectConfig = autoDetectConfig;
|
|
43
|
+
exports.selectPresetForEnvironment = selectPresetForEnvironment;
|
|
44
|
+
const fs = __importStar(require("fs"));
|
|
45
|
+
const path = __importStar(require("path"));
|
|
46
|
+
/**
|
|
47
|
+
* Detect which LLM SDKs are installed.
|
|
48
|
+
*/
|
|
49
|
+
function detectInstalledSdks() {
|
|
50
|
+
const sdks = [];
|
|
51
|
+
const sdkModules = {
|
|
52
|
+
openai: 'openai',
|
|
53
|
+
anthropic: '@anthropic-ai/sdk',
|
|
54
|
+
langchain: 'langchain',
|
|
55
|
+
};
|
|
56
|
+
for (const [sdkName, moduleName] of Object.entries(sdkModules)) {
|
|
57
|
+
try {
|
|
58
|
+
require.resolve(moduleName);
|
|
59
|
+
sdks.push(sdkName);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// Module not installed
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return sdks;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Detect the current environment (dev, staging, production).
|
|
69
|
+
*/
|
|
70
|
+
function detectEnvironment() {
|
|
71
|
+
// Check explicit environment variables
|
|
72
|
+
const envVars = [
|
|
73
|
+
'MONORA_ENV',
|
|
74
|
+
'ENVIRONMENT',
|
|
75
|
+
'ENV',
|
|
76
|
+
'NODE_ENV',
|
|
77
|
+
'PYTHON_ENV',
|
|
78
|
+
'FLASK_ENV',
|
|
79
|
+
'DJANGO_ENV',
|
|
80
|
+
'RAILS_ENV',
|
|
81
|
+
];
|
|
82
|
+
for (const varName of envVars) {
|
|
83
|
+
const value = (process.env[varName] || '').toLowerCase();
|
|
84
|
+
if (['production', 'prod'].includes(value)) {
|
|
85
|
+
return 'production';
|
|
86
|
+
}
|
|
87
|
+
if (['staging', 'stage', 'stg'].includes(value)) {
|
|
88
|
+
return 'staging';
|
|
89
|
+
}
|
|
90
|
+
if (['development', 'dev', 'local'].includes(value)) {
|
|
91
|
+
return 'dev';
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Check CI/CD indicators
|
|
95
|
+
const ciIndicators = [
|
|
96
|
+
'CI',
|
|
97
|
+
'CONTINUOUS_INTEGRATION',
|
|
98
|
+
'GITHUB_ACTIONS',
|
|
99
|
+
'GITLAB_CI',
|
|
100
|
+
'CIRCLECI',
|
|
101
|
+
'JENKINS_URL',
|
|
102
|
+
'TRAVIS',
|
|
103
|
+
'BUILDKITE',
|
|
104
|
+
];
|
|
105
|
+
for (const indicator of ciIndicators) {
|
|
106
|
+
if (process.env[indicator]) {
|
|
107
|
+
return 'staging';
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// Check for production indicators
|
|
111
|
+
const productionIndicators = [
|
|
112
|
+
'KUBERNETES_SERVICE_HOST',
|
|
113
|
+
'ECS_CONTAINER_METADATA_URI',
|
|
114
|
+
'DYNO',
|
|
115
|
+
];
|
|
116
|
+
for (const indicator of productionIndicators) {
|
|
117
|
+
if (process.env[indicator]) {
|
|
118
|
+
return 'production';
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return 'dev';
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Detect the service name from project files.
|
|
125
|
+
*/
|
|
126
|
+
function detectServiceName() {
|
|
127
|
+
const cwd = process.cwd();
|
|
128
|
+
// Try package.json
|
|
129
|
+
const packageJsonPath = path.join(cwd, 'package.json');
|
|
130
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
131
|
+
try {
|
|
132
|
+
const content = fs.readFileSync(packageJsonPath, 'utf-8');
|
|
133
|
+
const data = JSON.parse(content);
|
|
134
|
+
if (data.name && typeof data.name === 'string') {
|
|
135
|
+
let name = data.name;
|
|
136
|
+
// Strip scope from scoped packages
|
|
137
|
+
if (name.startsWith('@') && name.includes('/')) {
|
|
138
|
+
name = name.split('/')[1];
|
|
139
|
+
}
|
|
140
|
+
return name;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
// Parse error, continue
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// Try pyproject.toml (for monorepos with Python)
|
|
148
|
+
const pyprojectPath = path.join(cwd, 'pyproject.toml');
|
|
149
|
+
if (fs.existsSync(pyprojectPath)) {
|
|
150
|
+
try {
|
|
151
|
+
const content = fs.readFileSync(pyprojectPath, 'utf-8');
|
|
152
|
+
const match = content.match(/^name\s*=\s*["']([^"']+)["']/m);
|
|
153
|
+
if (match) {
|
|
154
|
+
return match[1];
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
// Parse error, continue
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
// Fall back to directory name
|
|
162
|
+
const dirName = path.basename(cwd);
|
|
163
|
+
if (dirName && dirName !== '.' && dirName !== '..') {
|
|
164
|
+
return dirName;
|
|
165
|
+
}
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Auto-detect configuration based on environment.
|
|
170
|
+
*/
|
|
171
|
+
function autoDetectConfig() {
|
|
172
|
+
const env = detectEnvironment();
|
|
173
|
+
const serviceName = detectServiceName();
|
|
174
|
+
const installedSdks = detectInstalledSdks();
|
|
175
|
+
const config = {
|
|
176
|
+
defaults: {
|
|
177
|
+
environment: env,
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
if (serviceName) {
|
|
181
|
+
config.defaults.service_name = serviceName;
|
|
182
|
+
}
|
|
183
|
+
// Enable auto-instrumentation if SDKs are detected
|
|
184
|
+
if (installedSdks.length > 0) {
|
|
185
|
+
config.instrumentation = {
|
|
186
|
+
enabled: true,
|
|
187
|
+
targets: installedSdks,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
return config;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Select the appropriate preset based on environment.
|
|
194
|
+
*/
|
|
195
|
+
function selectPresetForEnvironment(env) {
|
|
196
|
+
const presetMap = {
|
|
197
|
+
dev: 'development',
|
|
198
|
+
development: 'development',
|
|
199
|
+
local: 'development',
|
|
200
|
+
staging: 'production',
|
|
201
|
+
stage: 'production',
|
|
202
|
+
stg: 'production',
|
|
203
|
+
production: 'production',
|
|
204
|
+
prod: 'production',
|
|
205
|
+
};
|
|
206
|
+
return presetMap[env.toLowerCase()] || 'development';
|
|
207
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -42,6 +42,7 @@ const path = __importStar(require("path"));
|
|
|
42
42
|
const readline = __importStar(require("readline"));
|
|
43
43
|
const yaml = __importStar(require("js-yaml"));
|
|
44
44
|
const config_1 = require("./config");
|
|
45
|
+
const autodetect_1 = require("./autodetect");
|
|
45
46
|
const report_1 = require("./report");
|
|
46
47
|
const ai_act_report_1 = require("./ai_act_report");
|
|
47
48
|
const security_report_1 = require("./security_report");
|
|
@@ -195,19 +196,44 @@ async function runInitWizard(configPath, format, assumeYes, force) {
|
|
|
195
196
|
process.exit(1);
|
|
196
197
|
}
|
|
197
198
|
}
|
|
198
|
-
|
|
199
|
+
// Auto-detect project info
|
|
200
|
+
const detectedService = (0, autodetect_1.detectServiceName)() || path.basename(process.cwd()) || 'monora-app';
|
|
201
|
+
const detectedEnv = (0, autodetect_1.detectEnvironment)();
|
|
202
|
+
const detectedSdks = (0, autodetect_1.detectInstalledSdks)();
|
|
203
|
+
// Show auto-detection results
|
|
204
|
+
console.log('\n=== Monora Setup Wizard ===\n');
|
|
205
|
+
console.log('Auto-detected configuration:');
|
|
206
|
+
console.log(` Service name: ${detectedService}`);
|
|
207
|
+
console.log(` Environment: ${detectedEnv}`);
|
|
208
|
+
if (detectedSdks.length > 0) {
|
|
209
|
+
console.log(` AI SDKs: ${detectedSdks.join(', ')}`);
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
console.log(' AI SDKs: (none detected)');
|
|
213
|
+
}
|
|
214
|
+
console.log('');
|
|
215
|
+
// Generate smart defaults based on detection
|
|
216
|
+
const smartAllowlist = detectedSdks.includes('openai') && detectedSdks.includes('anthropic')
|
|
217
|
+
? ['gpt-4*', 'gpt-4o*', 'claude-3-*']
|
|
218
|
+
: detectedSdks.includes('openai')
|
|
219
|
+
? ['gpt-4*', 'gpt-4o*', 'o1-*']
|
|
220
|
+
: detectedSdks.includes('anthropic')
|
|
221
|
+
? ['claude-3-*', 'claude-sonnet-4-*', 'claude-opus-4-*']
|
|
222
|
+
: [];
|
|
199
223
|
let answers;
|
|
200
224
|
if (assumeYes) {
|
|
225
|
+
// Smart defaults for --yes mode
|
|
201
226
|
answers = {
|
|
202
|
-
service_name:
|
|
203
|
-
environment:
|
|
204
|
-
stdout_sink:
|
|
205
|
-
file_sink:
|
|
227
|
+
service_name: detectedService,
|
|
228
|
+
environment: detectedEnv,
|
|
229
|
+
stdout_sink: detectedEnv === 'dev',
|
|
230
|
+
file_sink: true,
|
|
231
|
+
file_path: detectedEnv === 'production' ? './logs/monora_events.jsonl' : './monora_events.jsonl',
|
|
206
232
|
https_sink: false,
|
|
207
|
-
enable_policies:
|
|
208
|
-
allowlist:
|
|
233
|
+
enable_policies: smartAllowlist.length > 0,
|
|
234
|
+
allowlist: smartAllowlist,
|
|
209
235
|
denylist: [],
|
|
210
|
-
enable_instrumentation:
|
|
236
|
+
enable_instrumentation: detectedSdks.length > 0,
|
|
211
237
|
instrumentation_purpose: 'general',
|
|
212
238
|
enable_data_handling: false,
|
|
213
239
|
data_handling_mode: 'redact',
|
|
@@ -215,25 +241,29 @@ async function runInitWizard(configPath, format, assumeYes, force) {
|
|
|
215
241
|
queue_full_mode: 'warn',
|
|
216
242
|
queue_full_timeout_sec: null,
|
|
217
243
|
};
|
|
244
|
+
console.log('Using smart defaults based on auto-detection...\n');
|
|
218
245
|
}
|
|
219
246
|
else {
|
|
220
247
|
const rl = createInterface();
|
|
221
248
|
try {
|
|
222
249
|
answers = {
|
|
223
|
-
service_name: await ask(rl, 'Service name',
|
|
224
|
-
environment: await ask(rl, 'Environment (dev/staging/production)',
|
|
225
|
-
stdout_sink: await confirm(rl, 'Enable stdout sink?',
|
|
250
|
+
service_name: await ask(rl, 'Service name', detectedService),
|
|
251
|
+
environment: await ask(rl, 'Environment (dev/staging/production)', detectedEnv),
|
|
252
|
+
stdout_sink: await confirm(rl, 'Enable stdout sink?', detectedEnv === 'dev'),
|
|
226
253
|
file_sink: await confirm(rl, 'Enable file sink?', true),
|
|
227
254
|
https_sink: await confirm(rl, 'Enable HTTPS sink?', false),
|
|
228
|
-
enable_policies: await confirm(rl, 'Configure model allowlist
|
|
255
|
+
enable_policies: await confirm(rl, 'Configure model allowlist?', smartAllowlist.length > 0),
|
|
229
256
|
allowlist: [],
|
|
230
257
|
denylist: [],
|
|
231
|
-
enable_instrumentation: await confirm(rl, 'Enable auto-instrumentation?',
|
|
258
|
+
enable_instrumentation: await confirm(rl, 'Enable auto-instrumentation?', detectedSdks.length > 0),
|
|
232
259
|
enable_data_handling: await confirm(rl, 'Enable data redaction rules?', false),
|
|
233
260
|
queue_full_mode: await ask(rl, 'Queue overflow mode (warn/raise/block)', 'warn'),
|
|
234
261
|
};
|
|
235
262
|
if (answers.file_sink) {
|
|
236
|
-
|
|
263
|
+
const defaultPath = answers.environment === 'production'
|
|
264
|
+
? './logs/monora_events.jsonl'
|
|
265
|
+
: './monora_events.jsonl';
|
|
266
|
+
answers.file_path = await ask(rl, 'File sink path', defaultPath);
|
|
237
267
|
}
|
|
238
268
|
if (answers.https_sink) {
|
|
239
269
|
answers.https_endpoint = await ask(rl, 'HTTPS endpoint URL');
|
|
@@ -243,8 +273,11 @@ async function runInitWizard(configPath, format, assumeYes, force) {
|
|
|
243
273
|
}
|
|
244
274
|
}
|
|
245
275
|
if (answers.enable_policies) {
|
|
246
|
-
|
|
247
|
-
|
|
276
|
+
const defaultAllowlist = smartAllowlist.length > 0
|
|
277
|
+
? smartAllowlist.join(',')
|
|
278
|
+
: 'gpt-4*,claude-3-*';
|
|
279
|
+
answers.allowlist = parseList(await ask(rl, 'Allowlist patterns (comma-separated)', defaultAllowlist));
|
|
280
|
+
answers.denylist = parseList(await ask(rl, 'Denylist patterns (comma-separated)', ''));
|
|
248
281
|
}
|
|
249
282
|
if (answers.enable_instrumentation) {
|
|
250
283
|
answers.instrumentation_purpose = await ask(rl, 'Default purpose for instrumentation', 'general');
|
|
@@ -285,10 +318,21 @@ async function runInitWizard(configPath, format, assumeYes, force) {
|
|
|
285
318
|
? JSON.stringify(config, null, 2)
|
|
286
319
|
: yaml.dump(config, { sortKeys: false, noRefs: true });
|
|
287
320
|
fs.writeFileSync(configPath, output, 'utf-8');
|
|
288
|
-
console.log(
|
|
289
|
-
console.log('Next
|
|
290
|
-
console.log('
|
|
291
|
-
console.log('
|
|
321
|
+
console.log(`\nMonora config written to ${configPath}`);
|
|
322
|
+
console.log('\n=== Next Steps ===\n');
|
|
323
|
+
console.log('Option 1: Zero-config (recommended)');
|
|
324
|
+
console.log(' Just call init() - Monora auto-detects everything:');
|
|
325
|
+
console.log('');
|
|
326
|
+
console.log(" import { init } from 'monora-ai';");
|
|
327
|
+
console.log(' init();');
|
|
328
|
+
console.log('');
|
|
329
|
+
console.log('Option 2: Use generated config file');
|
|
330
|
+
console.log(` import { init } from 'monora-ai';`);
|
|
331
|
+
console.log(` init({ configPath: '${configPath}' });`);
|
|
332
|
+
console.log('');
|
|
333
|
+
if (detectedSdks.length > 0) {
|
|
334
|
+
console.log(`Detected SDKs (${detectedSdks.join(', ')}) will be auto-instrumented.`);
|
|
335
|
+
}
|
|
292
336
|
}
|
|
293
337
|
function parseInitOptions(args) {
|
|
294
338
|
const configPath = getFlagValue(args, '--path') || 'monora.yml';
|
package/dist/config.d.ts
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Configuration loading and normalization.
|
|
3
3
|
*/
|
|
4
|
+
export type PresetName = 'minimal' | 'development' | 'production' | 'compliance' | 'poc';
|
|
5
|
+
export interface SinkConfig {
|
|
6
|
+
type: string;
|
|
7
|
+
format?: string;
|
|
8
|
+
path?: string;
|
|
9
|
+
endpoint?: string;
|
|
10
|
+
headers?: Record<string, string>;
|
|
11
|
+
api_key?: string;
|
|
12
|
+
batch_size?: number;
|
|
13
|
+
timeout_sec?: number;
|
|
14
|
+
retry_attempts?: number;
|
|
15
|
+
rotation?: string;
|
|
16
|
+
max_size_mb?: number;
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Preset configurations for quick setup.
|
|
21
|
+
*/
|
|
22
|
+
export declare const PRESETS: Record<PresetName, Partial<MonoraConfig>>;
|
|
4
23
|
export interface MonoraConfig {
|
|
5
24
|
defaults?: {
|
|
6
25
|
data_classification?: string;
|
|
@@ -32,6 +51,7 @@ export interface MonoraConfig {
|
|
|
32
51
|
registry?: any;
|
|
33
52
|
instrumentation?: {
|
|
34
53
|
enabled?: boolean;
|
|
54
|
+
auto_patch?: boolean;
|
|
35
55
|
targets?: string[];
|
|
36
56
|
default_purpose?: string;
|
|
37
57
|
data_classification?: string;
|
|
@@ -45,6 +65,7 @@ export interface MonoraConfig {
|
|
|
45
65
|
output_dir?: string;
|
|
46
66
|
formats?: string[];
|
|
47
67
|
include_security_report?: boolean;
|
|
68
|
+
include_executive_summary?: boolean;
|
|
48
69
|
max_events_per_trace?: number;
|
|
49
70
|
redact_host?: boolean;
|
|
50
71
|
};
|
|
@@ -109,4 +130,34 @@ export declare function loadConfig(options?: {
|
|
|
109
130
|
configDict?: MonoraConfig;
|
|
110
131
|
envPrefix?: string;
|
|
111
132
|
}): MonoraConfig;
|
|
133
|
+
/**
|
|
134
|
+
* Parse simplified sink configuration into full sink config.
|
|
135
|
+
*
|
|
136
|
+
* Supports:
|
|
137
|
+
* - "stdout" -> stdout sink
|
|
138
|
+
* - "./path/to/file.jsonl" -> file sink
|
|
139
|
+
* - "https://endpoint.com" -> https sink
|
|
140
|
+
* - { type: "...", ... } -> full sink config (passthrough)
|
|
141
|
+
* - undefined -> default stdout sink
|
|
142
|
+
*/
|
|
143
|
+
export declare function parseSinkConfig(sink: string | SinkConfig | undefined): SinkConfig[];
|
|
144
|
+
/**
|
|
145
|
+
* Get configuration for a named preset.
|
|
146
|
+
*/
|
|
147
|
+
export declare function getPresetConfig(preset: PresetName): Partial<MonoraConfig>;
|
|
148
|
+
/**
|
|
149
|
+
* Options for simplified init() configuration.
|
|
150
|
+
*/
|
|
151
|
+
export interface SimplifiedInitOptions {
|
|
152
|
+
preset?: 'auto' | PresetName;
|
|
153
|
+
serviceName?: string;
|
|
154
|
+
sink?: string | SinkConfig;
|
|
155
|
+
policies?: string[];
|
|
156
|
+
configPath?: string;
|
|
157
|
+
configDict?: MonoraConfig;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Build configuration from simplified options.
|
|
161
|
+
*/
|
|
162
|
+
export declare function buildConfigFromOptions(options?: SimplifiedInitOptions): MonoraConfig;
|
|
112
163
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config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ACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,qBAA0B,GAAG,YAAY,CA6CxF"}
|
package/dist/config.js
CHANGED
|
@@ -36,9 +36,78 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.PRESETS = void 0;
|
|
39
40
|
exports.loadConfig = loadConfig;
|
|
41
|
+
exports.parseSinkConfig = parseSinkConfig;
|
|
42
|
+
exports.getPresetConfig = getPresetConfig;
|
|
43
|
+
exports.buildConfigFromOptions = buildConfigFromOptions;
|
|
40
44
|
const fs = __importStar(require("fs"));
|
|
41
45
|
const yaml = __importStar(require("js-yaml"));
|
|
46
|
+
/**
|
|
47
|
+
* Preset configurations for quick setup.
|
|
48
|
+
*/
|
|
49
|
+
exports.PRESETS = {
|
|
50
|
+
minimal: {
|
|
51
|
+
sinks: [{ type: 'stdout', format: 'json' }],
|
|
52
|
+
immutability: { enabled: false },
|
|
53
|
+
reporting: { enabled: false },
|
|
54
|
+
instrumentation: { enabled: false },
|
|
55
|
+
},
|
|
56
|
+
development: {
|
|
57
|
+
defaults: { environment: 'dev' },
|
|
58
|
+
sinks: [
|
|
59
|
+
{ type: 'stdout', format: 'json' },
|
|
60
|
+
{ type: 'file', path: './monora_events.jsonl' },
|
|
61
|
+
],
|
|
62
|
+
immutability: { enabled: true, verify_on_emit: false },
|
|
63
|
+
reporting: { enabled: true, output_dir: './monora_reports' },
|
|
64
|
+
instrumentation: { enabled: true, auto_patch: true },
|
|
65
|
+
},
|
|
66
|
+
production: {
|
|
67
|
+
defaults: { environment: 'production' },
|
|
68
|
+
sinks: [{ type: 'file', path: './logs/monora_events.jsonl' }],
|
|
69
|
+
immutability: { enabled: true, verify_on_shutdown: true },
|
|
70
|
+
reporting: { enabled: true, output_dir: './monora_reports' },
|
|
71
|
+
wal: { enabled: true, path: './monora_wal' },
|
|
72
|
+
instrumentation: { enabled: true, auto_patch: true },
|
|
73
|
+
error_handling: { sink_failure_mode: 'warn' },
|
|
74
|
+
},
|
|
75
|
+
compliance: {
|
|
76
|
+
defaults: { environment: 'production' },
|
|
77
|
+
sinks: [{ type: 'file', path: './logs/monora_events.jsonl' }],
|
|
78
|
+
immutability: { enabled: true, verify_on_emit: true, verify_on_shutdown: true },
|
|
79
|
+
reporting: {
|
|
80
|
+
enabled: true,
|
|
81
|
+
output_dir: './monora_reports',
|
|
82
|
+
include_security_report: true,
|
|
83
|
+
include_executive_summary: true,
|
|
84
|
+
},
|
|
85
|
+
wal: { enabled: true, path: './monora_wal', sync_mode: 'fsync' },
|
|
86
|
+
signing: { enabled: true, algorithm: 'ed25519' },
|
|
87
|
+
attestation: { enabled: true },
|
|
88
|
+
ai_act: { enabled: true, generate_transparency_report: true },
|
|
89
|
+
instrumentation: { enabled: true, auto_patch: true },
|
|
90
|
+
},
|
|
91
|
+
poc: {
|
|
92
|
+
defaults: { environment: 'production' },
|
|
93
|
+
sinks: [
|
|
94
|
+
{ type: 'stdout', format: 'json' },
|
|
95
|
+
{ type: 'file', path: './monora_poc_events.jsonl' },
|
|
96
|
+
],
|
|
97
|
+
immutability: { enabled: true, verify_on_shutdown: true },
|
|
98
|
+
reporting: {
|
|
99
|
+
enabled: true,
|
|
100
|
+
output_dir: './monora_poc_reports',
|
|
101
|
+
formats: ['json', 'markdown'],
|
|
102
|
+
include_security_report: true,
|
|
103
|
+
include_executive_summary: true,
|
|
104
|
+
},
|
|
105
|
+
wal: { enabled: true, path: './monora_wal' },
|
|
106
|
+
signing: { enabled: true, algorithm: 'ed25519' },
|
|
107
|
+
ai_act: { enabled: true, generate_transparency_report: true },
|
|
108
|
+
instrumentation: { enabled: true, auto_patch: true },
|
|
109
|
+
},
|
|
110
|
+
};
|
|
42
111
|
const DEFAULT_CONFIG = {
|
|
43
112
|
defaults: {
|
|
44
113
|
data_classification: 'internal',
|
|
@@ -65,6 +134,7 @@ const DEFAULT_CONFIG = {
|
|
|
65
134
|
},
|
|
66
135
|
instrumentation: {
|
|
67
136
|
enabled: false,
|
|
137
|
+
auto_patch: false,
|
|
68
138
|
targets: ['openai', 'anthropic'],
|
|
69
139
|
default_purpose: undefined,
|
|
70
140
|
data_classification: undefined,
|
|
@@ -164,9 +234,12 @@ function loadConfig(options) {
|
|
|
164
234
|
normalizeDataHandlingMode(config);
|
|
165
235
|
return config;
|
|
166
236
|
}
|
|
167
|
-
function loadConfigFile(configPath) {
|
|
237
|
+
function loadConfigFile(configPath, silent = false) {
|
|
168
238
|
if (!fs.existsSync(configPath)) {
|
|
169
|
-
|
|
239
|
+
if (!silent) {
|
|
240
|
+
console.warn(`Monora: Config file not found: ${configPath}. Using defaults.`);
|
|
241
|
+
}
|
|
242
|
+
return {};
|
|
170
243
|
}
|
|
171
244
|
const raw = fs.readFileSync(configPath, 'utf-8');
|
|
172
245
|
if (configPath.endsWith('.json')) {
|
|
@@ -411,3 +484,96 @@ function expandEnvString(value) {
|
|
|
411
484
|
});
|
|
412
485
|
return result;
|
|
413
486
|
}
|
|
487
|
+
/**
|
|
488
|
+
* Parse simplified sink configuration into full sink config.
|
|
489
|
+
*
|
|
490
|
+
* Supports:
|
|
491
|
+
* - "stdout" -> stdout sink
|
|
492
|
+
* - "./path/to/file.jsonl" -> file sink
|
|
493
|
+
* - "https://endpoint.com" -> https sink
|
|
494
|
+
* - { type: "...", ... } -> full sink config (passthrough)
|
|
495
|
+
* - undefined -> default stdout sink
|
|
496
|
+
*/
|
|
497
|
+
function parseSinkConfig(sink) {
|
|
498
|
+
if (sink === undefined) {
|
|
499
|
+
return [{ type: 'stdout', format: 'json' }];
|
|
500
|
+
}
|
|
501
|
+
if (typeof sink === 'object') {
|
|
502
|
+
return [sink];
|
|
503
|
+
}
|
|
504
|
+
if (typeof sink !== 'string') {
|
|
505
|
+
return [{ type: 'stdout', format: 'json' }];
|
|
506
|
+
}
|
|
507
|
+
const sinkStr = sink.trim();
|
|
508
|
+
// stdout sink
|
|
509
|
+
if (sinkStr.toLowerCase() === 'stdout') {
|
|
510
|
+
return [{ type: 'stdout', format: 'json' }];
|
|
511
|
+
}
|
|
512
|
+
// HTTPS sink
|
|
513
|
+
if (sinkStr.startsWith('https://') || sinkStr.startsWith('http://')) {
|
|
514
|
+
return [{
|
|
515
|
+
type: 'https',
|
|
516
|
+
endpoint: sinkStr,
|
|
517
|
+
batch_size: 50,
|
|
518
|
+
timeout_sec: 10,
|
|
519
|
+
retry_attempts: 3,
|
|
520
|
+
}];
|
|
521
|
+
}
|
|
522
|
+
// File sink (anything else is treated as a file path)
|
|
523
|
+
return [{
|
|
524
|
+
type: 'file',
|
|
525
|
+
path: sinkStr,
|
|
526
|
+
rotation: 'daily',
|
|
527
|
+
max_size_mb: 100,
|
|
528
|
+
}];
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Get configuration for a named preset.
|
|
532
|
+
*/
|
|
533
|
+
function getPresetConfig(preset) {
|
|
534
|
+
if (!(preset in exports.PRESETS)) {
|
|
535
|
+
const valid = Object.keys(exports.PRESETS).join(', ');
|
|
536
|
+
throw new Error(`Unknown preset '${preset}'. Valid presets: ${valid}`);
|
|
537
|
+
}
|
|
538
|
+
return deepCopy(exports.PRESETS[preset]);
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Build configuration from simplified options.
|
|
542
|
+
*/
|
|
543
|
+
function buildConfigFromOptions(options = {}) {
|
|
544
|
+
const { preset, serviceName, sink, policies, configPath, configDict } = options;
|
|
545
|
+
// Start with defaults
|
|
546
|
+
let config = deepCopy(DEFAULT_CONFIG);
|
|
547
|
+
// Apply preset if specified
|
|
548
|
+
if (preset && preset !== 'auto') {
|
|
549
|
+
const presetConfig = getPresetConfig(preset);
|
|
550
|
+
mergeDicts(config, presetConfig);
|
|
551
|
+
}
|
|
552
|
+
// Load from file if specified
|
|
553
|
+
if (configPath) {
|
|
554
|
+
const fileConfig = loadConfigFile(configPath);
|
|
555
|
+
mergeDicts(config, fileConfig);
|
|
556
|
+
}
|
|
557
|
+
// Merge explicit config dict
|
|
558
|
+
if (configDict) {
|
|
559
|
+
mergeDicts(config, configDict);
|
|
560
|
+
}
|
|
561
|
+
// Apply service name
|
|
562
|
+
if (serviceName) {
|
|
563
|
+
config.defaults = config.defaults || {};
|
|
564
|
+
config.defaults.service_name = serviceName;
|
|
565
|
+
}
|
|
566
|
+
// Apply sink configuration
|
|
567
|
+
if (sink !== undefined) {
|
|
568
|
+
config.sinks = parseSinkConfig(sink);
|
|
569
|
+
}
|
|
570
|
+
// Apply policies
|
|
571
|
+
if (policies && policies.length > 0) {
|
|
572
|
+
config.policies = config.policies || {};
|
|
573
|
+
config.policies.model_allowlist = policies;
|
|
574
|
+
config.policies.enforce = true;
|
|
575
|
+
}
|
|
576
|
+
// Expand environment variables
|
|
577
|
+
expandEnvVars(config);
|
|
578
|
+
return config;
|
|
579
|
+
}
|