monora-ai 2.0.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 (202) hide show
  1. package/README.md +441 -150
  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 +269 -0
  12. package/dist/assessment.d.ts.map +1 -0
  13. package/dist/assessment.js +1232 -0
  14. package/dist/attestation.js +23 -1
  15. package/dist/attribution.d.ts +349 -0
  16. package/dist/attribution.d.ts.map +1 -0
  17. package/dist/attribution.js +987 -0
  18. package/dist/autodetect.d.ts +69 -1
  19. package/dist/autodetect.d.ts.map +1 -1
  20. package/dist/autodetect.js +644 -1
  21. package/dist/bias.d.ts +130 -0
  22. package/dist/bias.d.ts.map +1 -0
  23. package/dist/bias.js +223 -0
  24. package/dist/circuit_breaker.js +3 -3
  25. package/dist/cli/diagnostics.d.ts +5 -1
  26. package/dist/cli/diagnostics.d.ts.map +1 -1
  27. package/dist/cli/diagnostics.js +31 -8
  28. package/dist/cli/doctor.d.ts +25 -0
  29. package/dist/cli/doctor.d.ts.map +1 -0
  30. package/dist/cli/doctor.js +381 -0
  31. package/dist/cli/fix.d.ts +16 -0
  32. package/dist/cli/fix.d.ts.map +1 -0
  33. package/dist/cli/fix.js +284 -0
  34. package/dist/cli/init.d.ts +57 -0
  35. package/dist/cli/init.d.ts.map +1 -0
  36. package/dist/cli/init.js +205 -0
  37. package/dist/cli.js +1611 -126
  38. package/dist/complianceTargets.d.ts +111 -0
  39. package/dist/complianceTargets.d.ts.map +1 -0
  40. package/dist/complianceTargets.js +521 -0
  41. package/dist/config.d.ts +301 -17
  42. package/dist/config.d.ts.map +1 -1
  43. package/dist/config.js +428 -36
  44. package/dist/config_migrations.d.ts +41 -0
  45. package/dist/config_migrations.d.ts.map +1 -1
  46. package/dist/config_migrations.js +205 -0
  47. package/dist/config_schema.d.ts +2900 -731
  48. package/dist/config_schema.d.ts.map +1 -1
  49. package/dist/config_schema.js +257 -55
  50. package/dist/context.d.ts +34 -0
  51. package/dist/context.d.ts.map +1 -1
  52. package/dist/context.js +118 -7
  53. package/dist/control_backbone.d.ts +122 -0
  54. package/dist/control_backbone.d.ts.map +1 -0
  55. package/dist/control_backbone.js +698 -0
  56. package/dist/data-governance.d.ts +187 -0
  57. package/dist/data-governance.d.ts.map +1 -0
  58. package/dist/data-governance.js +424 -0
  59. package/dist/dataResidency.d.ts +44 -0
  60. package/dist/dataResidency.d.ts.map +1 -0
  61. package/dist/dataResidency.js +203 -0
  62. package/dist/dispatcher.d.ts +32 -0
  63. package/dist/dispatcher.d.ts.map +1 -1
  64. package/dist/dispatcher.js +91 -4
  65. package/dist/events.d.ts.map +1 -1
  66. package/dist/events.js +38 -0
  67. package/dist/evidence_store.d.ts +103 -0
  68. package/dist/evidence_store.d.ts.map +1 -0
  69. package/dist/evidence_store.js +459 -0
  70. package/dist/executiveSummary.d.ts +65 -8
  71. package/dist/executiveSummary.d.ts.map +1 -1
  72. package/dist/executiveSummary.js +289 -26
  73. package/dist/identity.d.ts +143 -0
  74. package/dist/identity.d.ts.map +1 -0
  75. package/dist/identity.js +231 -0
  76. package/dist/impact-assessment.d.ts +350 -0
  77. package/dist/impact-assessment.d.ts.map +1 -0
  78. package/dist/impact-assessment.js +580 -0
  79. package/dist/index.d.ts +25 -5
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +300 -4
  82. package/dist/instrumentation.d.ts +1 -1
  83. package/dist/instrumentation.d.ts.map +1 -1
  84. package/dist/instrumentation.js +243 -27
  85. package/dist/integrations/anthropic.d.ts +3 -0
  86. package/dist/integrations/anthropic.d.ts.map +1 -1
  87. package/dist/integrations/anthropic.js +284 -79
  88. package/dist/integrations/governance.d.ts +33 -0
  89. package/dist/integrations/governance.d.ts.map +1 -0
  90. package/dist/integrations/governance.js +208 -0
  91. package/dist/integrations/langchain.d.ts +7 -0
  92. package/dist/integrations/langchain.d.ts.map +1 -1
  93. package/dist/integrations/langchain.js +387 -143
  94. package/dist/integrations/openai.d.ts +9 -0
  95. package/dist/integrations/openai.d.ts.map +1 -1
  96. package/dist/integrations/openai.js +673 -73
  97. package/dist/iso42001_consolidation.d.ts +16 -0
  98. package/dist/iso42001_consolidation.d.ts.map +1 -0
  99. package/dist/iso42001_consolidation.js +413 -0
  100. package/dist/iso42001_workflows.d.ts +263 -0
  101. package/dist/iso42001_workflows.d.ts.map +1 -0
  102. package/dist/iso42001_workflows.js +781 -0
  103. package/dist/lifecycle.d.ts +299 -0
  104. package/dist/lifecycle.d.ts.map +1 -0
  105. package/dist/lifecycle.js +624 -0
  106. package/dist/lineage.d.ts +2 -2
  107. package/dist/lineage.d.ts.map +1 -1
  108. package/dist/lineage.js +12 -17
  109. package/dist/middleware/express.d.ts.map +1 -1
  110. package/dist/middleware/express.js +33 -3
  111. package/dist/middleware/nextjs.d.ts.map +1 -1
  112. package/dist/middleware/nextjs.js +42 -68
  113. package/dist/model.d.ts +143 -0
  114. package/dist/model.d.ts.map +1 -0
  115. package/dist/model.js +371 -0
  116. package/dist/onboarding.d.ts +42 -0
  117. package/dist/onboarding.d.ts.map +1 -0
  118. package/dist/onboarding.js +1022 -0
  119. package/dist/oversight.d.ts +264 -0
  120. package/dist/oversight.d.ts.map +1 -0
  121. package/dist/oversight.js +497 -0
  122. package/dist/pdf_report.d.ts.map +1 -1
  123. package/dist/pdf_report.js +42 -21
  124. package/dist/presets.d.ts +88 -0
  125. package/dist/presets.d.ts.map +1 -0
  126. package/dist/presets.js +520 -0
  127. package/dist/propagation.d.ts.map +1 -1
  128. package/dist/propagation.js +34 -2
  129. package/dist/quotas.d.ts +171 -0
  130. package/dist/quotas.d.ts.map +1 -0
  131. package/dist/quotas.js +259 -0
  132. package/dist/register.d.ts +13 -0
  133. package/dist/register.d.ts.map +1 -0
  134. package/dist/register.js +99 -0
  135. package/dist/registry.d.ts +1 -0
  136. package/dist/registry.d.ts.map +1 -1
  137. package/dist/registry.js +7 -0
  138. package/dist/registryData.json +43 -6
  139. package/dist/report.d.ts +2 -1
  140. package/dist/report.d.ts.map +1 -1
  141. package/dist/report.js +189 -2
  142. package/dist/reporting.d.ts +125 -0
  143. package/dist/reporting.d.ts.map +1 -1
  144. package/dist/reporting.js +196 -5
  145. package/dist/resources.d.ts +285 -0
  146. package/dist/resources.d.ts.map +1 -0
  147. package/dist/resources.js +643 -0
  148. package/dist/risk.d.ts +120 -0
  149. package/dist/risk.d.ts.map +1 -0
  150. package/dist/risk.js +220 -0
  151. package/dist/runtime.d.ts +74 -1
  152. package/dist/runtime.d.ts.map +1 -1
  153. package/dist/runtime.js +598 -22
  154. package/dist/schemaInference.d.ts +92 -0
  155. package/dist/schemaInference.d.ts.map +1 -0
  156. package/dist/schemaInference.js +466 -0
  157. package/dist/schema_validation.js +2 -2
  158. package/dist/schemas/config.schema.json +169 -6
  159. package/dist/schemas/event.schema.json +4 -0
  160. package/dist/security_report.js +4 -4
  161. package/dist/signing.d.ts +1 -1
  162. package/dist/signing.d.ts.map +1 -1
  163. package/dist/signing.js +4 -0
  164. package/dist/sinks/file.d.ts +19 -1
  165. package/dist/sinks/file.d.ts.map +1 -1
  166. package/dist/sinks/file.js +82 -13
  167. package/dist/sinks/https.d.ts +10 -0
  168. package/dist/sinks/https.d.ts.map +1 -1
  169. package/dist/sinks/https.js +76 -16
  170. package/dist/sinks/stdout.d.ts +1 -0
  171. package/dist/sinks/stdout.d.ts.map +1 -1
  172. package/dist/sinks/stdout.js +12 -1
  173. package/dist/spec.d.ts +159 -0
  174. package/dist/spec.d.ts.map +1 -0
  175. package/dist/spec.js +391 -0
  176. package/dist/stakeholders.d.ts +199 -0
  177. package/dist/stakeholders.d.ts.map +1 -0
  178. package/dist/stakeholders.js +398 -0
  179. package/dist/standards.d.ts.map +1 -1
  180. package/dist/standards.js +160 -2
  181. package/dist/standards_ingest.d.ts +2 -2
  182. package/dist/standards_ingest.d.ts.map +1 -1
  183. package/dist/standards_ingest.js +105 -23
  184. package/dist/streaming.d.ts.map +1 -1
  185. package/dist/streaming.js +7 -2
  186. package/dist/telemetry.d.ts +16 -2
  187. package/dist/telemetry.d.ts.map +1 -1
  188. package/dist/telemetry.js +79 -14
  189. package/dist/templates/controls/iso42001_control_catalog.json +1443 -0
  190. package/dist/traced_emitter.d.ts +3 -0
  191. package/dist/traced_emitter.d.ts.map +1 -1
  192. package/dist/traced_emitter.js +142 -25
  193. package/dist/trust_package.d.ts +21 -1
  194. package/dist/trust_package.d.ts.map +1 -1
  195. package/dist/trust_package.js +101 -4
  196. package/dist/verify.d.ts.map +1 -1
  197. package/dist/verify.js +9 -2
  198. package/dist/wal.d.ts.map +1 -1
  199. package/dist/wal.js +2 -1
  200. package/package.json +14 -1
  201. package/scripts/postinstall.js +119 -97
  202. package/templates/controls/iso42001_control_catalog.json +1443 -0
@@ -0,0 +1,231 @@
1
+ "use strict";
2
+ /**
3
+ * User/identity tracking for SOC 2 CC6 access control compliance.
4
+ *
5
+ * This module provides identity context management for tracking who invoked
6
+ * each AI call, supporting SOC 2 access control audit trails.
7
+ *
8
+ * Cross-SDK Parity:
9
+ * Both Python and Node.js SDKs provide identical identity tracking APIs:
10
+ * - setIdentity() / set_identity()
11
+ * - getIdentity() / get_identity()
12
+ * - clearIdentity() / clear_identity()
13
+ * - withIdentity() / identity_context()
14
+ */
15
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ var desc = Object.getOwnPropertyDescriptor(m, k);
18
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
19
+ desc = { enumerable: true, get: function() { return m[k]; } };
20
+ }
21
+ Object.defineProperty(o, k2, desc);
22
+ }) : (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ o[k2] = m[k];
25
+ }));
26
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
27
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
28
+ }) : function(o, v) {
29
+ o["default"] = v;
30
+ });
31
+ var __importStar = (this && this.__importStar) || (function () {
32
+ var ownKeys = function(o) {
33
+ ownKeys = Object.getOwnPropertyNames || function (o) {
34
+ var ar = [];
35
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
36
+ return ar;
37
+ };
38
+ return ownKeys(o);
39
+ };
40
+ return function (mod) {
41
+ if (mod && mod.__esModule) return mod;
42
+ var result = {};
43
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
44
+ __setModuleDefault(result, mod);
45
+ return result;
46
+ };
47
+ })();
48
+ Object.defineProperty(exports, "__esModule", { value: true });
49
+ exports.identityToDict = identityToDict;
50
+ exports.setIdentity = setIdentity;
51
+ exports.getIdentity = getIdentity;
52
+ exports.clearIdentity = clearIdentity;
53
+ exports.withIdentity = withIdentity;
54
+ exports.withIdentityAsync = withIdentityAsync;
55
+ exports.bindIdentity = bindIdentity;
56
+ exports.getIdentityForEvent = getIdentityForEvent;
57
+ exports.validateIdentityRequirement = validateIdentityRequirement;
58
+ const async_hooks_1 = require("async_hooks");
59
+ const crypto = __importStar(require("crypto"));
60
+ /**
61
+ * Convert identity to dictionary for event inclusion.
62
+ *
63
+ * @param identity - The identity object.
64
+ * @param options - Conversion options.
65
+ * @returns Dictionary representation of identity.
66
+ */
67
+ function identityToDict(identity, options = {}) {
68
+ const { includeRoles = true, includeOrg = true, redactUserId = false } = options;
69
+ let userIdValue = identity.userId;
70
+ if (redactUserId && userIdValue) {
71
+ const hash = crypto.createHash('sha256').update(userIdValue).digest('hex');
72
+ userIdValue = `sha256:${hash.slice(0, 16)}`;
73
+ }
74
+ const result = { user_id: userIdValue };
75
+ if (identity.sessionId) {
76
+ result.session_id = identity.sessionId;
77
+ }
78
+ if (identity.authMethod) {
79
+ result.auth_method = identity.authMethod;
80
+ }
81
+ if (includeRoles && identity.roles && identity.roles.length > 0) {
82
+ result.roles = identity.roles;
83
+ }
84
+ if (includeOrg && identity.orgId) {
85
+ result.org_id = identity.orgId;
86
+ }
87
+ if (identity.metadata && Object.keys(identity.metadata).length > 0) {
88
+ result.metadata = identity.metadata;
89
+ }
90
+ return result;
91
+ }
92
+ // AsyncLocalStorage for identity context propagation
93
+ const identityStorage = new async_hooks_1.AsyncLocalStorage();
94
+ /**
95
+ * Set the current identity context.
96
+ *
97
+ * All subsequent events will include this identity information until
98
+ * clearIdentity() is called or the context exits.
99
+ *
100
+ * Note: This sets identity in the current async context. For scoped identity,
101
+ * use withIdentity() instead.
102
+ *
103
+ * @param identity - The identity to set.
104
+ * @returns The identity object.
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * setIdentity({ userId: 'usr_123', sessionId: 'sess_456', roles: ['admin'] });
109
+ * // All subsequent AI calls will include identity
110
+ * await llmCall(...);
111
+ * ```
112
+ */
113
+ function setIdentity(identity) {
114
+ // Note: AsyncLocalStorage.enterWith() sets the store for the current execution context
115
+ identityStorage.enterWith(identity);
116
+ return identity;
117
+ }
118
+ /**
119
+ * Get the current identity from context.
120
+ *
121
+ * @returns The current Identity object, or undefined if not set.
122
+ */
123
+ function getIdentity() {
124
+ return identityStorage.getStore();
125
+ }
126
+ /**
127
+ * Clear the current identity context.
128
+ */
129
+ function clearIdentity() {
130
+ identityStorage.enterWith(undefined);
131
+ }
132
+ /**
133
+ * Run a function within a specific identity context.
134
+ *
135
+ * The identity is automatically cleared when the function completes.
136
+ *
137
+ * @param identity - The identity to use.
138
+ * @param fn - The function to execute.
139
+ * @returns The result of the function.
140
+ *
141
+ * @example
142
+ * ```typescript
143
+ * await withIdentity({ userId: 'usr_789', roles: ['analyst'] }, async () => {
144
+ * await llmCall(...); // Includes identity
145
+ * });
146
+ * // Identity cleared after function completes
147
+ * ```
148
+ */
149
+ function withIdentity(identity, fn) {
150
+ return identityStorage.run(identity, fn);
151
+ }
152
+ /**
153
+ * Async version of withIdentity for async functions.
154
+ *
155
+ * @param identity - The identity to use.
156
+ * @param fn - The async function to execute.
157
+ * @returns Promise resolving to the result of the function.
158
+ */
159
+ async function withIdentityAsync(identity, fn) {
160
+ return identityStorage.run(identity, fn);
161
+ }
162
+ /**
163
+ * Bind a function to the current identity context.
164
+ *
165
+ * The returned function, when called, will execute with the captured
166
+ * identity context regardless of where it's called from.
167
+ *
168
+ * @param fn - The function to bind to the current identity.
169
+ * @returns A wrapped function that will execute with the captured identity.
170
+ *
171
+ * @example
172
+ * ```typescript
173
+ * setIdentity({ userId: 'usr_123' });
174
+ * const boundCallback = bindIdentity(myCallback);
175
+ * // Call from anywhere - identity is preserved
176
+ * boundCallback();
177
+ * ```
178
+ */
179
+ function bindIdentity(fn) {
180
+ const captured = identityStorage.getStore();
181
+ if (!captured) {
182
+ return fn;
183
+ }
184
+ return ((...args) => {
185
+ return identityStorage.run(captured, () => fn(...args));
186
+ });
187
+ }
188
+ /**
189
+ * Get identity dict for event inclusion based on config.
190
+ *
191
+ * This is called internally when building events to include identity
192
+ * information according to the configuration settings.
193
+ *
194
+ * @param config - The Monora configuration.
195
+ * @returns Identity dict for event inclusion, or undefined if identity not set
196
+ * or identity tracking is disabled.
197
+ */
198
+ function getIdentityForEvent(config) {
199
+ const identityConfig = config.identity;
200
+ if (!identityConfig?.enabled) {
201
+ return undefined;
202
+ }
203
+ const identity = getIdentity();
204
+ if (!identity) {
205
+ return undefined;
206
+ }
207
+ return identityToDict(identity, {
208
+ includeRoles: identityConfig.capture_roles ?? false,
209
+ includeOrg: identityConfig.capture_org ?? false,
210
+ redactUserId: identityConfig.redact_user_id ?? false,
211
+ });
212
+ }
213
+ /**
214
+ * Validate that identity is set if required by config.
215
+ *
216
+ * @param config - The Monora configuration.
217
+ * @throws Error if require_user_id is true but no identity is set.
218
+ */
219
+ function validateIdentityRequirement(config) {
220
+ const identityConfig = config.identity;
221
+ if (!identityConfig?.enabled) {
222
+ return;
223
+ }
224
+ if (identityConfig.require_user_id) {
225
+ const identity = getIdentity();
226
+ if (!identity) {
227
+ throw new Error('Identity is required but not set. ' +
228
+ 'Use setIdentity() or withIdentity() before making AI calls.');
229
+ }
230
+ }
231
+ }
@@ -0,0 +1,350 @@
1
+ /**
2
+ * AI Impact Assessment for ISO 42001 A.5 compliance.
3
+ *
4
+ * This module provides AI Impact Assessment (AIIA) management supporting
5
+ * ISO 42001 controls A.5.2 (process), A.5.3 (documentation), A.5.4 (individual
6
+ * impacts), and A.5.5 (societal impacts).
7
+ *
8
+ * Cross-SDK Parity:
9
+ * Both Python and Node.js SDKs provide identical impact assessment APIs:
10
+ * - createImpactAssessment() / create_impact_assessment()
11
+ * - addImpactRecord() / add_impact_record()
12
+ * - addMitigation() / add_mitigation()
13
+ * - submitForApproval() / submit_for_approval()
14
+ * - recordApproval() / record_approval()
15
+ * - finalizeAssessment() / finalize_assessment()
16
+ */
17
+ import { MonoraConfig } from './config';
18
+ export type Likelihood = 'rare' | 'unlikely' | 'possible' | 'likely' | 'certain';
19
+ export type Severity = 'minimal' | 'minor' | 'moderate' | 'major' | 'catastrophic';
20
+ export type ImpactCategory = 'fairness' | 'privacy' | 'safety' | 'autonomy' | 'economic' | 'environmental';
21
+ export type AssessmentStatus = 'draft' | 'review' | 'approved' | 'archived';
22
+ export type MitigationEffectiveness = 'partial' | 'substantial' | 'complete';
23
+ export type MitigationStatus = 'planned' | 'in_progress' | 'implemented' | 'verified';
24
+ export type ImpactType = 'individual' | 'societal';
25
+ /**
26
+ * A single impact assessment record (individual or societal).
27
+ */
28
+ export interface ImpactRecord {
29
+ /** Unique identifier for this impact record */
30
+ impactId: string;
31
+ /** Impact category */
32
+ category: ImpactCategory;
33
+ /** Detailed description of the potential impact */
34
+ description: string;
35
+ /** Probability of occurrence */
36
+ likelihood: Likelihood;
37
+ /** Severity if the impact occurs */
38
+ severity: Severity;
39
+ /** Computed risk score (likelihood * severity, 1-25) */
40
+ riskScore: number;
41
+ /** Groups or individuals who may be affected */
42
+ affectedParties: string[];
43
+ /** Whether this is an individual or societal impact */
44
+ impactType: ImpactType;
45
+ }
46
+ /**
47
+ * Convert impact record to dictionary for serialization.
48
+ */
49
+ export declare function impactRecordToDict(record: ImpactRecord): Record<string, any>;
50
+ /**
51
+ * A risk mitigation measure.
52
+ */
53
+ export interface Mitigation {
54
+ /** Unique identifier */
55
+ mitigationId: string;
56
+ /** Category of risk being mitigated */
57
+ riskCategory: string;
58
+ /** Description of the mitigation measure */
59
+ description: string;
60
+ /** Expected effectiveness of the mitigation */
61
+ effectiveness: MitigationEffectiveness;
62
+ /** Current implementation status */
63
+ implementationStatus: MitigationStatus;
64
+ /** Person/team responsible for implementation */
65
+ owner: string;
66
+ /** List of impact_ids this mitigation addresses */
67
+ targetImpacts: string[];
68
+ }
69
+ /**
70
+ * Convert mitigation to dictionary for serialization.
71
+ */
72
+ export declare function mitigationToDict(mitigation: Mitigation): Record<string, any>;
73
+ /**
74
+ * An approval sign-off on the assessment.
75
+ */
76
+ export interface Approval {
77
+ /** Role of the approver (ai_governance, legal, ethics_board) */
78
+ approverRole: string;
79
+ /** Name of the person approving */
80
+ approverName: string;
81
+ /** Timestamp of approval */
82
+ approvedAt: string;
83
+ /** Optional approval comments */
84
+ comments?: string;
85
+ }
86
+ /**
87
+ * Convert approval to dictionary for serialization.
88
+ */
89
+ export declare function approvalToDict(approval: Approval): Record<string, any>;
90
+ /**
91
+ * Complete AI Impact Assessment (AIIA) for ISO 42001 A.5.
92
+ */
93
+ export interface AIImpactAssessment {
94
+ /** Unique identifier for this assessment */
95
+ assessmentId: string;
96
+ /** ID of the AI system being assessed */
97
+ systemId: string;
98
+ /** Date assessment was created */
99
+ assessmentDate: string;
100
+ /** Person conducting the assessment */
101
+ assessor: string;
102
+ /** Version of this assessment */
103
+ version: string;
104
+ /** Current status */
105
+ status: AssessmentStatus;
106
+ /** Purpose of the AI system */
107
+ intendedPurpose: string;
108
+ /** Context in which the system will be deployed */
109
+ deploymentContext: string;
110
+ /** Groups that may be affected by the system */
111
+ affectedGroups: string[];
112
+ /** List of individual impact assessments (A.5.4) */
113
+ individualImpacts: ImpactRecord[];
114
+ /** List of societal impact assessments (A.5.5) */
115
+ societalImpacts: ImpactRecord[];
116
+ /** Mitigation measures for identified risks */
117
+ riskMitigations: Mitigation[];
118
+ /** Risks remaining after mitigation */
119
+ residualRisks: string[];
120
+ /** Sign-offs from required approvers */
121
+ approvals: Approval[];
122
+ /** Timestamp of creation */
123
+ createdAt: string;
124
+ /** Timestamp of last update */
125
+ updatedAt: string;
126
+ }
127
+ /**
128
+ * Convert assessment to dictionary for serialization.
129
+ */
130
+ export declare function assessmentToDict(assessment: AIImpactAssessment): Record<string, any>;
131
+ /**
132
+ * Calculate risk score from likelihood and severity.
133
+ *
134
+ * Uses a 5x5 risk matrix where score = likelihood_weight * severity_weight.
135
+ *
136
+ * @param likelihood - Probability of occurrence
137
+ * @param severity - Severity if impact occurs
138
+ * @returns Risk score from 1 (rare/minimal) to 25 (certain/catastrophic)
139
+ */
140
+ export declare function calculateRiskScore(likelihood: Likelihood, severity: Severity): number;
141
+ /**
142
+ * Options for creating an impact assessment.
143
+ */
144
+ export interface CreateImpactAssessmentOptions {
145
+ /** ID of the AI system being assessed */
146
+ systemId: string;
147
+ /** Person conducting the assessment */
148
+ assessor: string;
149
+ /** Purpose of the AI system */
150
+ intendedPurpose: string;
151
+ /** Context of deployment */
152
+ deploymentContext: string;
153
+ /** Groups that may be affected */
154
+ affectedGroups?: string[];
155
+ /** Assessment version */
156
+ version?: string;
157
+ /** Optional config */
158
+ config?: MonoraConfig;
159
+ }
160
+ /**
161
+ * Create a new AI Impact Assessment.
162
+ *
163
+ * @param options - Assessment creation options
164
+ * @returns A new AIImpactAssessment in draft status
165
+ *
166
+ * @example
167
+ * ```typescript
168
+ * const assessment = createImpactAssessment({
169
+ * systemId: 'chatbot-v2',
170
+ * assessor: 'Jane Doe',
171
+ * intendedPurpose: 'Customer support automation',
172
+ * deploymentContext: 'Web and mobile applications',
173
+ * affectedGroups: ['customers', 'support_staff']
174
+ * });
175
+ * ```
176
+ */
177
+ export declare function createImpactAssessment(options: CreateImpactAssessmentOptions): AIImpactAssessment;
178
+ /**
179
+ * Options for adding an impact record.
180
+ */
181
+ export interface AddImpactRecordOptions {
182
+ /** ID of the assessment to update */
183
+ assessmentId: string;
184
+ /** Impact category */
185
+ category: ImpactCategory;
186
+ /** Description of the potential impact */
187
+ description: string;
188
+ /** Probability of occurrence */
189
+ likelihood: Likelihood;
190
+ /** Severity if impact occurs */
191
+ severity: Severity;
192
+ /** Groups/individuals affected */
193
+ affectedParties?: string[];
194
+ /** Whether individual or societal impact */
195
+ impactType?: ImpactType;
196
+ }
197
+ /**
198
+ * Add an impact record to an assessment.
199
+ *
200
+ * @param options - Impact record options
201
+ * @returns The created ImpactRecord
202
+ * @throws Error if assessment not found or not in draft status
203
+ */
204
+ export declare function addImpactRecord(options: AddImpactRecordOptions): ImpactRecord;
205
+ /**
206
+ * Options for adding a mitigation.
207
+ */
208
+ export interface AddMitigationOptions {
209
+ /** ID of the assessment to update */
210
+ assessmentId: string;
211
+ /** Category of risk being mitigated */
212
+ riskCategory: string;
213
+ /** Description of the mitigation measure */
214
+ description: string;
215
+ /** Expected effectiveness */
216
+ effectiveness: MitigationEffectiveness;
217
+ /** Current implementation status */
218
+ implementationStatus: MitigationStatus;
219
+ /** Person/team responsible */
220
+ owner: string;
221
+ /** List of impact_ids this addresses */
222
+ targetImpacts?: string[];
223
+ }
224
+ /**
225
+ * Add a risk mitigation to an assessment.
226
+ *
227
+ * @param options - Mitigation options
228
+ * @returns The created Mitigation
229
+ * @throws Error if assessment not found or not in draft status
230
+ */
231
+ export declare function addMitigation(options: AddMitigationOptions): Mitigation;
232
+ /**
233
+ * Add a residual risk to an assessment.
234
+ *
235
+ * @param assessmentId - ID of the assessment to update
236
+ * @param riskDescription - Description of the residual risk
237
+ * @throws Error if assessment not found or not in draft status
238
+ */
239
+ export declare function addResidualRisk(assessmentId: string, riskDescription: string): void;
240
+ /**
241
+ * Validate that an assessment has all required fields.
242
+ *
243
+ * @param assessment - The assessment to validate
244
+ * @returns List of validation errors (empty if valid)
245
+ */
246
+ export declare function validateAssessmentCompleteness(assessment: AIImpactAssessment): string[];
247
+ /**
248
+ * Submit an assessment for approval review.
249
+ *
250
+ * Changes status from 'draft' to 'review'.
251
+ *
252
+ * @param assessmentId - ID of the assessment to submit
253
+ * @returns The updated assessment
254
+ * @throws Error if assessment not found or not in draft status
255
+ */
256
+ export declare function submitForApproval(assessmentId: string): AIImpactAssessment;
257
+ /**
258
+ * Options for recording an approval.
259
+ */
260
+ export interface RecordApprovalOptions {
261
+ /** ID of the assessment */
262
+ assessmentId: string;
263
+ /** Role of the approver */
264
+ approverRole: string;
265
+ /** Name of the person approving */
266
+ approverName: string;
267
+ /** Optional comments */
268
+ comments?: string;
269
+ }
270
+ /**
271
+ * Record an approval sign-off on an assessment.
272
+ *
273
+ * @param options - Approval options
274
+ * @returns The created Approval
275
+ * @throws Error if assessment not found or not in review status
276
+ */
277
+ export declare function recordApproval(options: RecordApprovalOptions): Approval;
278
+ /**
279
+ * Finalize an assessment, marking it as approved.
280
+ *
281
+ * Validates that all required approvals are present.
282
+ *
283
+ * @param assessmentId - ID of the assessment to finalize
284
+ * @param config - Optional config for required approvals
285
+ * @returns The finalized assessment
286
+ * @throws Error if assessment not found, not in review, or missing approvals
287
+ */
288
+ export declare function finalizeAssessment(assessmentId: string, config?: MonoraConfig): AIImpactAssessment;
289
+ /**
290
+ * Archive an approved assessment.
291
+ *
292
+ * @param assessmentId - ID of the assessment to archive
293
+ * @returns The archived assessment
294
+ * @throws Error if assessment not found or not approved
295
+ */
296
+ export declare function archiveAssessment(assessmentId: string): AIImpactAssessment;
297
+ /**
298
+ * Get an assessment by ID.
299
+ *
300
+ * @param assessmentId - ID of the assessment
301
+ * @returns The assessment if found, undefined otherwise
302
+ */
303
+ export declare function getAssessment(assessmentId: string): AIImpactAssessment | undefined;
304
+ /**
305
+ * Get all assessments for a system.
306
+ *
307
+ * @param systemId - ID of the AI system
308
+ * @returns List of assessments for the system
309
+ */
310
+ export declare function getAssessmentsForSystem(systemId: string): AIImpactAssessment[];
311
+ /**
312
+ * Get all registered assessments.
313
+ *
314
+ * @returns List of all assessments
315
+ */
316
+ export declare function getAllAssessments(): AIImpactAssessment[];
317
+ /**
318
+ * Clear all assessments from the registry.
319
+ */
320
+ export declare function clearAssessments(): void;
321
+ /**
322
+ * Get a summary of an assessment for reporting.
323
+ *
324
+ * @param assessmentId - ID of the assessment
325
+ * @returns Summary dict with key metrics
326
+ */
327
+ export declare function getAssessmentSummary(assessmentId: string): Record<string, any>;
328
+ /**
329
+ * Get aggregate report of all impact assessments.
330
+ *
331
+ * @param config - Optional config
332
+ * @returns Report dict for compliance reporting
333
+ */
334
+ export declare function getImpactAssessmentReport(config?: MonoraConfig): Record<string, any>;
335
+ /**
336
+ * Check if a system has approved impact assessment for production.
337
+ *
338
+ * @param systemId - ID of the AI system
339
+ * @param config - Optional config
340
+ * @returns Object with readiness status and details
341
+ */
342
+ export declare function checkProductionReadiness(systemId: string, config?: MonoraConfig): Record<string, any>;
343
+ /**
344
+ * Emit the current state of an assessment as an event.
345
+ *
346
+ * @param assessmentId - ID of the assessment to emit
347
+ * @param config - Optional config
348
+ */
349
+ export declare function emitImpactAssessment(assessmentId: string, config?: MonoraConfig): void;
350
+ //# sourceMappingURL=impact-assessment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"impact-assessment.d.ts","sourceRoot":"","sources":["../src/impact-assessment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAIxC,MAAM,MAAM,UAAU,GA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