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
@@ -1,17 +1,29 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * Postinstall script for Monora SDK
4
- * Automatically runs the setup wizard after npm install
5
- * Optionally collects registration data for telemetry
4
+ *
5
+ * Shows a non-blocking welcome message with setup instructions.
6
+ * Opt-in only - no interactive prompts or data collection during install.
7
+ *
8
+ * Users can register later via: npx monora-ai init
6
9
  */
7
10
 
8
- const { spawn } = require('child_process');
9
11
  const fs = require('fs');
10
12
  const path = require('path');
11
- const readline = require('readline');
12
13
  const crypto = require('crypto');
13
14
 
14
- // Check if we're in a CI environment or non-interactive terminal
15
+ // ANSI color codes for terminal output
16
+ const colors = {
17
+ reset: '\x1b[0m',
18
+ bold: '\x1b[1m',
19
+ dim: '\x1b[2m',
20
+ cyan: '\x1b[36m',
21
+ green: '\x1b[32m',
22
+ yellow: '\x1b[33m',
23
+ blue: '\x1b[34m',
24
+ };
25
+
26
+ // Check if we're in a CI environment
15
27
  function isCI() {
16
28
  return !!(
17
29
  process.env.CI ||
@@ -22,61 +34,29 @@ function isCI() {
22
34
  process.env.CIRCLECI ||
23
35
  process.env.TRAVIS ||
24
36
  process.env.JENKINS_URL ||
37
+ process.env.BUILDKITE ||
38
+ process.env.TF_BUILD ||
25
39
  process.env.MONORA_SKIP_POSTINSTALL
26
40
  );
27
41
  }
28
42
 
29
- // Generate a stable install ID (SHA256 of random UUID)
30
- function generateInstallId() {
31
- const uuid = crypto.randomUUID();
32
- return crypto.createHash('sha256').update(uuid).digest('hex').slice(0, 32);
33
- }
34
-
35
- function isTTY() {
36
- return process.stdout.isTTY && process.stdin.isTTY;
37
- }
38
-
39
- function findProjectRoot() {
40
- // Walk up from current directory to find package.json (the user's project)
41
- let dir = process.cwd();
42
- const maxLevels = 10;
43
-
44
- for (let i = 0; i < maxLevels; i++) {
45
- const pkgPath = path.join(dir, 'package.json');
46
- if (fs.existsSync(pkgPath)) {
47
- try {
48
- const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
49
- // Skip if this is the monora-ai package itself
50
- if (pkg.name !== 'monora-ai') {
51
- return dir;
52
- }
53
- } catch (e) {
54
- // Continue searching
55
- }
56
- }
57
- const parent = path.dirname(dir);
58
- if (parent === dir) break;
59
- dir = parent;
43
+ // Check if terminal supports colors
44
+ function supportsColor() {
45
+ if (process.env.NO_COLOR || process.env.TERM === 'dumb') {
46
+ return false;
60
47
  }
61
- return process.cwd();
48
+ return process.stdout.isTTY;
62
49
  }
63
50
 
64
- function configExists(projectRoot) {
65
- const configFiles = [
66
- 'monora.yml',
67
- 'monora.yaml',
68
- 'monora.json',
69
- '.monora.yml',
70
- '.monora.yaml',
71
- '.monora.json',
72
- ];
73
-
74
- return configFiles.some(file =>
75
- fs.existsSync(path.join(projectRoot, file))
76
- );
51
+ // Colorize text if supported
52
+ function colorize(text, color) {
53
+ if (!supportsColor()) {
54
+ return text;
55
+ }
56
+ return `${color}${text}${colors.reset}`;
77
57
  }
78
58
 
79
- // Get the Monora data directory for storing registration
59
+ // Get the Monora data directory
80
60
  function getMonoraDataDir() {
81
61
  const home = process.env.HOME || process.env.USERPROFILE;
82
62
  if (!home) {
@@ -85,189 +65,104 @@ function getMonoraDataDir() {
85
65
  return path.join(home, '.monora');
86
66
  }
87
67
 
88
- // Load existing registration data
89
- function loadRegistration() {
68
+ // Record install timestamp for analytics (local only)
69
+ function recordInstallTimestamp() {
90
70
  const dataDir = getMonoraDataDir();
91
71
  if (!dataDir) {
92
- console.warn('Monora: HOME/USERPROFILE not set; skipping registration load');
93
- return null;
94
- }
95
- const regPath = path.join(dataDir, 'registration.json');
96
- try {
97
- if (fs.existsSync(regPath)) {
98
- return JSON.parse(fs.readFileSync(regPath, 'utf8'));
99
- }
100
- } catch (e) {
101
- // Ignore errors
72
+ return;
102
73
  }
103
- return null;
104
- }
105
74
 
106
- // Save registration data
107
- function saveRegistration(data) {
108
- const dataDir = getMonoraDataDir();
109
- if (!dataDir) {
110
- console.warn('Monora: HOME/USERPROFILE not set; skipping registration save');
111
- return false;
112
- }
113
75
  try {
114
76
  if (!fs.existsSync(dataDir)) {
115
77
  fs.mkdirSync(dataDir, { recursive: true });
116
78
  }
117
- const regPath = path.join(dataDir, 'registration.json');
118
- fs.writeFileSync(regPath, JSON.stringify(data, null, 2));
119
- return true;
120
- } catch (e) {
121
- return false;
122
- }
123
- }
124
79
 
125
- // Prompt user for input
126
- function prompt(rl, question, defaultValue = '') {
127
- const displayDefault = defaultValue ? ` [${defaultValue}]` : '';
128
- return new Promise((resolve) => {
129
- rl.question(`${question}${displayDefault}: `, (answer) => {
130
- resolve(answer.trim() || defaultValue);
131
- });
132
- });
133
- }
134
-
135
- // Collect optional registration data
136
- async function collectRegistration() {
137
- const existing = loadRegistration();
138
- if (existing && existing.install_id) {
139
- // Already registered, don't ask again
140
- return existing;
80
+ const installPath = path.join(dataDir, 'install_info.json');
81
+ const existingData = fs.existsSync(installPath)
82
+ ? JSON.parse(fs.readFileSync(installPath, 'utf8'))
83
+ : {};
84
+
85
+ const installInfo = {
86
+ ...existingData,
87
+ install_id: existingData.install_id || crypto.randomUUID().replace(/-/g, '').slice(0, 32),
88
+ sdk: 'node',
89
+ first_installed_at: existingData.first_installed_at || new Date().toISOString(),
90
+ last_installed_at: new Date().toISOString(),
91
+ install_count: (existingData.install_count || 0) + 1,
92
+ };
93
+
94
+ fs.writeFileSync(installPath, JSON.stringify(installInfo, null, 2));
95
+ } catch {
96
+ // Silent fail - never break install
141
97
  }
98
+ }
142
99
 
143
- console.log('');
144
- console.log('šŸ“‹ Optional: Help us improve Monora by sharing some info');
145
- console.log(' (Press Enter to skip any question)\n');
146
-
147
- const rl = readline.createInterface({
148
- input: process.stdin,
149
- output: process.stdout,
150
- });
151
-
152
- try {
153
- const company = await prompt(rl, ' Company/Organization');
154
- const role = await prompt(rl, ' Your role (e.g., Developer, ML Engineer)');
155
- const email = await prompt(rl, ' Email (for product updates, optional)');
156
-
157
- rl.close();
100
+ // Check if config already exists in project
101
+ function configExists() {
102
+ const configFiles = [
103
+ 'monora.yml',
104
+ 'monora.yaml',
105
+ 'monora.json',
106
+ '.monora.yml',
107
+ '.monora.yaml',
108
+ '.monora.json',
109
+ ];
158
110
 
159
- // Only save if at least one field is provided
160
- if (company || role || email) {
161
- const registration = {
162
- install_id: generateInstallId(),
163
- company: company || undefined,
164
- role: role || undefined,
165
- email: email || undefined,
166
- sdk_type: 'node',
167
- source: 'npm',
168
- registered_at: new Date().toISOString(),
169
- };
170
- if (saveRegistration(registration)) {
171
- console.log('\n āœ“ Thanks! Your info has been saved locally.\n');
172
- }
173
- return registration;
174
- } else {
175
- // Create minimal registration with just install_id
176
- const registration = {
177
- install_id: generateInstallId(),
178
- sdk_type: 'node',
179
- source: 'npm',
180
- registered_at: new Date().toISOString(),
181
- };
182
- saveRegistration(registration);
183
- return registration;
184
- }
185
- } catch (e) {
186
- rl.close();
187
- return null;
188
- }
111
+ return configFiles.some(file => fs.existsSync(path.join(process.cwd(), file)));
189
112
  }
190
113
 
191
- async function main() {
192
- // Skip in CI environments
193
- if (isCI()) {
194
- console.log('\nšŸ“¦ Monora SDK installed successfully.');
195
- console.log(' Run "npx monora init" to configure.\n');
196
- return;
197
- }
198
-
199
- const projectRoot = findProjectRoot();
114
+ // Display welcome message
115
+ function showWelcomeMessage() {
116
+ const hasConfig = configExists();
200
117
 
201
- // Check if config already exists
202
- if (configExists(projectRoot)) {
203
- console.log('\nāœ… Monora SDK installed. Existing configuration detected.\n');
204
- return;
205
- }
118
+ console.log('');
119
+ console.log(colorize(' Monora AI Governance SDK', colors.bold + colors.cyan));
120
+ console.log('');
206
121
 
207
- // Non-interactive terminal - show quick start
208
- if (!isTTY()) {
209
- console.log('\nšŸ“¦ Monora SDK installed successfully!');
122
+ if (hasConfig) {
123
+ console.log(colorize(' āœ“ Existing configuration detected', colors.green));
210
124
  console.log('');
211
- console.log('Quick Start:');
212
- console.log(' 1. Run: npx monora init');
213
- console.log(' 2. Or use zero-config:');
214
- console.log(' import { init } from "monora-ai";');
215
- console.log(' init();');
125
+ } else {
126
+ console.log(colorize(' Quick Start:', colors.bold));
127
+ console.log('');
128
+ console.log(' ' + colorize('Option 1:', colors.yellow) + ' Zero-config (recommended)');
129
+ console.log(colorize(' import { init } from "monora-ai";', colors.dim));
130
+ console.log(colorize(' init();', colors.dim));
131
+ console.log('');
132
+ console.log(' ' + colorize('Option 2:', colors.yellow) + ' Run setup wizard');
133
+ console.log(colorize(' npx monora-ai init', colors.dim));
216
134
  console.log('');
217
- return;
218
- }
219
-
220
- // Interactive terminal - run setup wizard
221
- console.log('\nšŸš€ Monora SDK installed!');
222
-
223
- // Collect optional registration data
224
- try {
225
- await collectRegistration();
226
- } catch {
227
- // Intentionally ignore - registration is optional and should never break install
228
135
  }
229
136
 
230
- try {
231
- // Run the wizard with --yes for smart defaults
232
- // Users can run `npx monora init` later for full interactive mode
233
- const cliPath = path.join(__dirname, '..', 'dist', 'cli.js');
137
+ console.log(colorize(' Documentation:', colors.bold) + ' https://docs.monora.ai');
138
+ console.log(colorize(' GitHub:', colors.bold) + ' https://github.com/monora-ai/monora');
139
+ console.log('');
140
+ }
234
141
 
235
- if (fs.existsSync(cliPath)) {
236
- console.log('Starting setup wizard...\n');
237
- // Run the CLI init command
238
- const child = spawn('node', [cliPath, 'init', '--yes'], {
239
- cwd: projectRoot,
240
- stdio: 'inherit',
241
- shell: process.platform === 'win32',
242
- });
142
+ // Display minimal CI message
143
+ function showCIMessage() {
144
+ console.log('');
145
+ console.log('Monora SDK installed. Use init() for zero-config or run "npx monora-ai init".');
146
+ console.log('');
147
+ }
243
148
 
244
- child.on('error', () => {
245
- console.log('\nšŸ“¦ Monora SDK installed.');
246
- console.log(' Run "npx monora init" to configure manually.\n');
247
- });
149
+ // Main function
150
+ function main() {
151
+ // Record install timestamp (local only, non-blocking)
152
+ recordInstallTimestamp();
248
153
 
249
- child.on('close', (code) => {
250
- if (code !== 0) {
251
- console.log('\n Run "npx monora init" to configure manually.\n');
252
- }
253
- });
254
- } else {
255
- // CLI not built yet (fresh install), show manual instructions
256
- console.log('Quick Start:');
257
- console.log(' Option 1: Run "npx monora init" to configure');
258
- console.log(' Option 2: Use zero-config in your code:');
259
- console.log(' import { init } from "monora-ai";');
260
- console.log(' init();');
261
- console.log('');
262
- }
263
- } catch (err) {
264
- // Silent fail - don't break npm install
265
- console.log('\nšŸ“¦ Monora SDK installed.');
266
- console.log(' Run "npx monora init" to configure.\n');
154
+ // Show appropriate message based on environment
155
+ if (isCI()) {
156
+ showCIMessage();
157
+ } else {
158
+ showWelcomeMessage();
267
159
  }
268
160
  }
269
161
 
270
- main().catch(() => {
162
+ // Execute
163
+ try {
164
+ main();
165
+ } catch {
271
166
  // Never fail the install
272
- console.log('\nšŸ“¦ Monora SDK installed.\n');
273
- });
167
+ console.log('\nMonora SDK installed.\n');
168
+ }