@principal-ai/principal-view-core 0.6.4 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/ConfigurationLoader.js +2 -1
  2. package/dist/ConfigurationLoader.js.map +1 -1
  3. package/dist/ConfigurationValidator.js.map +1 -1
  4. package/dist/EventProcessor.js.map +1 -1
  5. package/dist/EventRecorderService.js.map +1 -1
  6. package/dist/LibraryLoader.js.map +1 -1
  7. package/dist/PathBasedEventProcessor.js.map +1 -1
  8. package/dist/SessionManager.js +1 -1
  9. package/dist/SessionManager.js.map +1 -1
  10. package/dist/ValidationEngine.js.map +1 -1
  11. package/dist/cli/codegen.js.map +1 -1
  12. package/dist/codegen/type-generator.js.map +1 -1
  13. package/dist/codegen/usage-example.js.map +1 -1
  14. package/dist/helpers/GraphInstrumentationHelper.js +2 -2
  15. package/dist/helpers/GraphInstrumentationHelper.js.map +1 -1
  16. package/dist/index.d.ts +2 -2
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +2 -2
  19. package/dist/index.js.map +1 -1
  20. package/dist/narrative/example.d.ts +11 -0
  21. package/dist/narrative/example.d.ts.map +1 -0
  22. package/dist/narrative/example.js +331 -0
  23. package/dist/narrative/example.js.map +1 -0
  24. package/dist/narrative/index.d.ts +12 -0
  25. package/dist/narrative/index.d.ts.map +1 -0
  26. package/dist/narrative/index.js +14 -0
  27. package/dist/narrative/index.js.map +1 -0
  28. package/dist/narrative/scenario-matcher.d.ts +87 -0
  29. package/dist/narrative/scenario-matcher.d.ts.map +1 -0
  30. package/dist/narrative/scenario-matcher.js +269 -0
  31. package/dist/narrative/scenario-matcher.js.map +1 -0
  32. package/dist/narrative/template-parser.d.ts +33 -0
  33. package/dist/narrative/template-parser.d.ts.map +1 -0
  34. package/dist/narrative/template-parser.js +288 -0
  35. package/dist/narrative/template-parser.js.map +1 -0
  36. package/dist/narrative/template-renderer.d.ts +18 -0
  37. package/dist/narrative/template-renderer.d.ts.map +1 -0
  38. package/dist/narrative/template-renderer.js +367 -0
  39. package/dist/narrative/template-renderer.js.map +1 -0
  40. package/dist/narrative/types.d.ts +268 -0
  41. package/dist/narrative/types.d.ts.map +1 -0
  42. package/dist/narrative/types.js +10 -0
  43. package/dist/narrative/types.js.map +1 -0
  44. package/dist/rules/config.js.map +1 -1
  45. package/dist/rules/engine.js.map +1 -1
  46. package/dist/rules/implementations/connection-type-references.js.map +1 -1
  47. package/dist/rules/implementations/dead-end-states.js.map +1 -1
  48. package/dist/rules/implementations/library-node-type-match.js.map +1 -1
  49. package/dist/rules/implementations/minimum-node-sources.js.map +1 -1
  50. package/dist/rules/implementations/no-unknown-fields.js.map +1 -1
  51. package/dist/rules/implementations/orphaned-edge-types.js.map +1 -1
  52. package/dist/rules/implementations/orphaned-node-types.js.map +1 -1
  53. package/dist/rules/implementations/required-metadata.js.map +1 -1
  54. package/dist/rules/implementations/state-transition-references.js.map +1 -1
  55. package/dist/rules/implementations/unreachable-states.js.map +1 -1
  56. package/dist/rules/implementations/valid-action-patterns.js.map +1 -1
  57. package/dist/rules/implementations/valid-color-format.js.map +1 -1
  58. package/dist/rules/implementations/valid-edge-types.js.map +1 -1
  59. package/dist/rules/implementations/valid-node-types.js.map +1 -1
  60. package/dist/rules/types.js.map +1 -1
  61. package/dist/telemetry/coverage.js.map +1 -1
  62. package/dist/telemetry/event-validator.js.map +1 -1
  63. package/dist/types/audit.js.map +1 -1
  64. package/dist/types/canvas.js +5 -5
  65. package/dist/types/canvas.js.map +1 -1
  66. package/dist/types/otel.js.map +1 -1
  67. package/dist/types/resource-match.js.map +1 -1
  68. package/dist/utils/CanvasConverter.js.map +1 -1
  69. package/dist/utils/GraphConverter.js.map +1 -1
  70. package/dist/utils/LibraryConverter.js.map +1 -1
  71. package/dist/utils/PathMatcher.js.map +1 -1
  72. package/dist/utils/TraceToCanvas.js +7 -7
  73. package/dist/utils/TraceToCanvas.js.map +1 -1
  74. package/dist/utils/YamlParser.js.map +1 -1
  75. package/package.json +15 -15
  76. package/src/index.ts +31 -13
  77. package/src/narrative/README.md +381 -0
  78. package/src/narrative/__tests__/scenario-matcher.test.ts +368 -0
  79. package/src/narrative/__tests__/template-parser.test.ts +235 -0
  80. package/src/narrative/__tests__/template-renderer.test.ts +377 -0
  81. package/src/narrative/example.ts +349 -0
  82. package/src/narrative/index.ts +35 -0
  83. package/src/narrative/scenario-matcher.ts +331 -0
  84. package/src/narrative/template-parser.ts +298 -0
  85. package/src/narrative/template-renderer.ts +423 -0
  86. package/src/narrative/types.ts +368 -0
  87. package/src/utils/GraphConverter.test.ts +0 -79
  88. package/dist/utils/ExecutionFileDiscovery.d.ts +0 -206
  89. package/dist/utils/ExecutionFileDiscovery.d.ts.map +0 -1
  90. package/dist/utils/ExecutionFileDiscovery.js +0 -340
  91. package/dist/utils/ExecutionFileDiscovery.js.map +0 -1
  92. package/src/utils/ExecutionFileDiscovery.ts +0 -522
@@ -0,0 +1,269 @@
1
+ /**
2
+ * Scenario Matching Logic
3
+ *
4
+ * Selects the appropriate narrative scenario based on which events occurred
5
+ * during execution. Uses priority-based, first-match-wins algorithm.
6
+ */
7
+ /**
8
+ * Select the first matching scenario from a narrative template
9
+ *
10
+ * Scenarios are evaluated in priority order (lowest priority number first).
11
+ * Returns the first scenario whose conditions are met.
12
+ *
13
+ * @param template - Narrative template with scenarios
14
+ * @param events - Collected OTEL events
15
+ * @param attributes - Aggregated attributes (computed from events)
16
+ * @returns Matched scenario and metadata
17
+ * @throws Error if no scenario matches (template should have default fallback)
18
+ */
19
+ export function selectScenario(template, events, attributes = {}) {
20
+ // Sort scenarios by priority (should already be sorted in template)
21
+ const sorted = [...template.scenarios].sort((a, b) => a.priority - b.priority);
22
+ const applicableScenarios = [];
23
+ const matchReasons = {};
24
+ // Find first matching scenario
25
+ for (const scenario of sorted) {
26
+ const matchResult = matchesCondition(scenario.condition, events, attributes);
27
+ if (matchResult.matches) {
28
+ // Check if there are other applicable scenarios (for UI)
29
+ for (const other of sorted) {
30
+ if (other.id !== scenario.id && matchesCondition(other.condition, events, attributes).matches) {
31
+ applicableScenarios.push(other);
32
+ }
33
+ }
34
+ return {
35
+ scenario,
36
+ isDefault: Boolean(scenario.condition.default),
37
+ applicableScenarios: [scenario, ...applicableScenarios],
38
+ matchReasons,
39
+ };
40
+ }
41
+ matchReasons[scenario.id] = matchResult.reason || 'Unknown';
42
+ }
43
+ throw new Error(`No scenario matched for template "${template.name}". ` +
44
+ `Ensure there is a default scenario with { default: true } condition. ` +
45
+ `Events: ${events.map((e) => e.name).join(', ')}`);
46
+ }
47
+ /**
48
+ * Check if a scenario condition matches the given events and attributes
49
+ *
50
+ * @param condition - Scenario condition to evaluate
51
+ * @param events - Collected OTEL events
52
+ * @param attributes - Aggregated attributes
53
+ * @returns Match result with reason if not matched
54
+ */
55
+ export function matchesCondition(condition, events, attributes) {
56
+ // 1. Check default condition (always matches)
57
+ if (condition.default) {
58
+ return { matches: true };
59
+ }
60
+ // 2. Check required events
61
+ if (condition.requires) {
62
+ const matchMode = condition.any ? 'some' : 'every';
63
+ const hasRequired = condition.requires[matchMode]((pattern) => hasEventMatching(events, pattern));
64
+ if (!hasRequired) {
65
+ const missing = condition.requires.filter((pattern) => !hasEventMatching(events, pattern));
66
+ return {
67
+ matches: false,
68
+ reason: `Missing required event(s): ${missing.join(', ')}`,
69
+ };
70
+ }
71
+ }
72
+ // 3. Check excluded events
73
+ if (condition.excludes) {
74
+ const excluded = condition.excludes.find((pattern) => hasEventMatching(events, pattern));
75
+ if (excluded) {
76
+ return {
77
+ matches: false,
78
+ reason: `Found excluded event: ${excluded}`,
79
+ };
80
+ }
81
+ }
82
+ // 4. Check attribute assertions
83
+ if (condition.assertions) {
84
+ for (const [key, assertion] of Object.entries(condition.assertions)) {
85
+ const value = getNestedValue(attributes, key);
86
+ const assertionResult = evaluateAssertion(value, assertion);
87
+ if (!assertionResult.matches) {
88
+ return {
89
+ matches: false,
90
+ reason: `Assertion failed for "${key}": ${assertionResult.reason}`,
91
+ };
92
+ }
93
+ }
94
+ }
95
+ // All checks passed
96
+ return { matches: true };
97
+ }
98
+ /**
99
+ * Check if any event matches the given pattern (supports glob-style wildcards)
100
+ *
101
+ * Patterns:
102
+ * - Exact: "conversion.started" matches only that event
103
+ * - Wildcard suffix: "conversion.*" matches "conversion.started", "conversion.complete", etc.
104
+ * - Wildcard prefix: "*.error" matches "conversion.error", "rule.error", etc.
105
+ * - Wildcard middle: "log.*" matches any event starting with "log."
106
+ *
107
+ * @param events - Events to search
108
+ * @param pattern - Pattern to match (supports * wildcard)
109
+ * @returns True if any event matches the pattern
110
+ */
111
+ export function hasEventMatching(events, pattern) {
112
+ // Convert glob pattern to regex
113
+ const regexPattern = pattern
114
+ .replace(/\./g, '\\.') // Escape dots
115
+ .replace(/\*/g, '.*'); // Convert * to .*
116
+ const regex = new RegExp(`^${regexPattern}$`);
117
+ return events.some((event) => regex.test(event.name));
118
+ }
119
+ /**
120
+ * Evaluate an assertion against a value
121
+ *
122
+ * @param value - Value to test
123
+ * @param assertion - Assertion operators
124
+ * @returns Match result with reason if not matched
125
+ */
126
+ export function evaluateAssertion(value, assertion) {
127
+ // $exists check
128
+ if (assertion.$exists !== undefined) {
129
+ const exists = value !== undefined && value !== null;
130
+ if (exists !== assertion.$exists) {
131
+ return {
132
+ matches: false,
133
+ reason: assertion.$exists ? 'Value does not exist' : 'Value exists but should not',
134
+ };
135
+ }
136
+ // If only checking existence, we're done
137
+ if (Object.keys(assertion).length === 1) {
138
+ return { matches: true };
139
+ }
140
+ }
141
+ // If value doesn't exist and we're checking other operators, fail
142
+ if (value === undefined || value === null) {
143
+ return { matches: false, reason: 'Value is undefined or null' };
144
+ }
145
+ // Numeric comparisons
146
+ if (typeof value === 'number') {
147
+ if (assertion.$gt !== undefined && !(value > assertion.$gt)) {
148
+ return { matches: false, reason: `${value} is not > ${assertion.$gt}` };
149
+ }
150
+ if (assertion.$gte !== undefined && !(value >= assertion.$gte)) {
151
+ return { matches: false, reason: `${value} is not >= ${assertion.$gte}` };
152
+ }
153
+ if (assertion.$lt !== undefined && !(value < assertion.$lt)) {
154
+ return { matches: false, reason: `${value} is not < ${assertion.$lt}` };
155
+ }
156
+ if (assertion.$lte !== undefined && !(value <= assertion.$lte)) {
157
+ return { matches: false, reason: `${value} is not <= ${assertion.$lte}` };
158
+ }
159
+ }
160
+ // Equality checks
161
+ if (assertion.$eq !== undefined && value !== assertion.$eq) {
162
+ return { matches: false, reason: `${value} !== ${assertion.$eq}` };
163
+ }
164
+ if (assertion.$ne !== undefined && value === assertion.$ne) {
165
+ return { matches: false, reason: `${value} === ${assertion.$ne} (should not equal)` };
166
+ }
167
+ // Array membership
168
+ if (assertion.$in !== undefined) {
169
+ if (!assertion.$in.includes(value)) {
170
+ return { matches: false, reason: `${value} not in [${assertion.$in.join(', ')}]` };
171
+ }
172
+ }
173
+ if (assertion.$nin !== undefined) {
174
+ if (assertion.$nin.includes(value)) {
175
+ return { matches: false, reason: `${value} found in excluded list [${assertion.$nin.join(', ')}]` };
176
+ }
177
+ }
178
+ return { matches: true };
179
+ }
180
+ /**
181
+ * Get nested value from object using dot notation
182
+ *
183
+ * Supports both nested objects and flat keys with dots in them.
184
+ * First tries the path as a flat key, then tries nested lookup.
185
+ *
186
+ * @param obj - Object to search
187
+ * @param path - Dot-separated path (e.g., "result.violations.total")
188
+ * @returns Value at path, or undefined if not found
189
+ */
190
+ export function getNestedValue(obj, path) {
191
+ // First try as a flat key (handles attributes like 'result.violations.total')
192
+ if (path in obj) {
193
+ return obj[path];
194
+ }
195
+ // Then try as nested path
196
+ const keys = path.split('.');
197
+ let current = obj;
198
+ for (const key of keys) {
199
+ if (current === null || current === undefined) {
200
+ return undefined;
201
+ }
202
+ if (typeof current !== 'object') {
203
+ return undefined;
204
+ }
205
+ current = current[key];
206
+ }
207
+ return current;
208
+ }
209
+ /**
210
+ * Set nested value in object using dot notation
211
+ *
212
+ * @param obj - Object to modify
213
+ * @param path - Dot-separated path (e.g., "result.violations.total")
214
+ * @param value - Value to set
215
+ */
216
+ export function setNestedValue(obj, path, value) {
217
+ const keys = path.split('.');
218
+ let current = obj;
219
+ for (let i = 0; i < keys.length - 1; i++) {
220
+ const key = keys[i];
221
+ if (current[key] === undefined || typeof current[key] !== 'object') {
222
+ current[key] = {};
223
+ }
224
+ current = current[key];
225
+ }
226
+ const lastKey = keys[keys.length - 1];
227
+ current[lastKey] = value;
228
+ }
229
+ /**
230
+ * Compute aggregate values from events
231
+ *
232
+ * Provides common aggregations like counts, totals, averages, etc.
233
+ * that can be used in scenario conditions and templates.
234
+ *
235
+ * @param events - Collected OTEL events
236
+ * @returns Aggregate values
237
+ */
238
+ export function computeAggregates(events) {
239
+ const aggregates = {
240
+ // Event counts
241
+ 'events.length': events.length,
242
+ 'events.count': events.length,
243
+ // Spans
244
+ 'spans.count': events.filter((e) => e.type === 'span').length,
245
+ // Logs
246
+ 'logs.count': events.filter((e) => e.type === 'log').length,
247
+ 'errorLogs.count': events.filter((e) => e.type === 'log' && (e.severityNumber ?? 0) >= 17).length,
248
+ 'warnLogs.count': events.filter((e) => e.type === 'log' && (e.severityNumber ?? 0) >= 13 && (e.severityNumber ?? 0) <= 16).length,
249
+ 'debugLogs.count': events.filter((e) => e.type === 'log' && (e.severityNumber ?? 0) >= 5 && (e.severityNumber ?? 0) <= 8).length,
250
+ };
251
+ // Extract common attributes from events (for easy access in conditions)
252
+ for (const event of events) {
253
+ if (event.attributes) {
254
+ for (const [key, value] of Object.entries(event.attributes)) {
255
+ // Store first occurrence using nested value setter
256
+ // This handles both flat keys and dot-notation keys (e.g., "result.violations.total")
257
+ if (getNestedValue(aggregates, key) === undefined) {
258
+ // Store both as nested structure (for getNestedValue) and flat key (for direct access)
259
+ setNestedValue(aggregates, key, value);
260
+ if (key.includes('.')) {
261
+ aggregates[key] = value; // Also store flat version
262
+ }
263
+ }
264
+ }
265
+ }
266
+ }
267
+ return aggregates;
268
+ }
269
+ //# sourceMappingURL=sc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EAAwE;IACxE,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;QAC1B,IAAI,KAAK,CAAC,UAAU,EAAE;YACpB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE;gBAC3D,mDAAmD;gBACnD,sFAAsF;gBACtF,IAAI,cAAc,CAAC,UAAU,EAAE,GAAG,CAAC,KAAK,SAAS,EAAE;oBACjD,uFAAuF;oBACvF,cAAc,CAAC,UAAU,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;oBACvC,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;wBACrB,UAAU,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,0BAA0B;qBACpD;iBACF;aACF;SACF;KACF;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Template Expression Parser
3
+ *
4
+ * Parses and evaluates template expressions like:
5
+ * - Simple: "{config.nodeTypes}"
6
+ * - Conditional: "{result.violations.total > 0 ? '❌ FAILED' : '✅ PASSED'}"
7
+ * - Function calls: "{'━'.repeat(50)}"
8
+ */
9
+ /**
10
+ * Parse and evaluate a template string with embedded expressions
11
+ *
12
+ * Expressions are enclosed in curly braces: {expression}
13
+ *
14
+ * Supported syntax:
15
+ * - Property access: {config.nodeTypes}
16
+ * - Ternary: {count > 0 ? 'yes' : 'no'}
17
+ * - String methods: {'━'.repeat(50)}
18
+ * - Arithmetic: {duration.ms / 1000}
19
+ *
20
+ * @param template - Template string with {expressions}
21
+ * @param context - Data context for variable lookup
22
+ * @returns Evaluated string
23
+ */
24
+ export declare function parseTemplate(template: string, context: Record<string, unknown>): string;
25
+ /**
26
+ * Evaluate a single expression in the given context
27
+ *
28
+ * @param expression - Expression to evaluate
29
+ * @param context - Data context
30
+ * @returns Evaluated value
31
+ */
32
+ export declare function evaluateExpression(expression: string, context: Record<string, unknown>): unknown;
33
+ //# sourceMappingURL=template-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-parser.d.ts","sourceRoot":"","sources":["../../src/narrative/template-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CA6DxF;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CA4HhG"}
@@ -0,0 +1,288 @@
1
+ /**
2
+ * Template Expression Parser
3
+ *
4
+ * Parses and evaluates template expressions like:
5
+ * - Simple: "{config.nodeTypes}"
6
+ * - Conditional: "{result.violations.total > 0 ? '❌ FAILED' : '✅ PASSED'}"
7
+ * - Function calls: "{'━'.repeat(50)}"
8
+ */
9
+ import { getNestedValue } from './scenario-matcher';
10
+ /**
11
+ * Parse and evaluate a template string with embedded expressions
12
+ *
13
+ * Expressions are enclosed in curly braces: {expression}
14
+ *
15
+ * Supported syntax:
16
+ * - Property access: {config.nodeTypes}
17
+ * - Ternary: {count > 0 ? 'yes' : 'no'}
18
+ * - String methods: {'━'.repeat(50)}
19
+ * - Arithmetic: {duration.ms / 1000}
20
+ *
21
+ * @param template - Template string with {expressions}
22
+ * @param context - Data context for variable lookup
23
+ * @returns Evaluated string
24
+ */
25
+ export function parseTemplate(template, context) {
26
+ // Find all {expression} patterns, handling nested braces
27
+ let result = '';
28
+ let i = 0;
29
+ while (i < template.length) {
30
+ const start = template.indexOf('{', i);
31
+ if (start === -1) {
32
+ // No more expressions
33
+ result += template.substring(i);
34
+ break;
35
+ }
36
+ // Add text before the expression
37
+ result += template.substring(i, start);
38
+ // Find matching closing brace
39
+ let depth = 1;
40
+ let end = start + 1;
41
+ while (end < template.length && depth > 0) {
42
+ if (template[end] === '{')
43
+ depth++;
44
+ if (template[end] === '}')
45
+ depth--;
46
+ end++;
47
+ }
48
+ if (depth === 0) {
49
+ // Found matching brace
50
+ const expression = template.substring(start + 1, end - 1);
51
+ try {
52
+ const value = evaluateExpression(expression.trim(), context);
53
+ // Check if evaluation failed (returned undefined when it shouldn't)
54
+ if (value === undefined && !expression.trim().includes('undefined')) {
55
+ // If the expression doesn't contain 'undefined' but returned undefined,
56
+ // it likely failed to parse/evaluate
57
+ const isValidExpression = expression.trim() in context || // Simple variable
58
+ /^[\w.]+$/.test(expression.trim()) || // Property path
59
+ expression.includes('?') || // Ternary
60
+ /[+\-*/<>=!]/.test(expression); // Operations
61
+ if (!isValidExpression && expression.includes('(')) {
62
+ result += `{ERROR: Unable to evaluate '${expression}'}`;
63
+ }
64
+ else {
65
+ result += formatValue(value);
66
+ }
67
+ }
68
+ else {
69
+ result += formatValue(value);
70
+ }
71
+ }
72
+ catch (error) {
73
+ // Return error placeholder instead of throwing
74
+ result += `{ERROR: ${error instanceof Error ? error.message : 'unknown'}}`;
75
+ }
76
+ i = end;
77
+ }
78
+ else {
79
+ // Unmatched brace
80
+ result += '{';
81
+ i = start + 1;
82
+ }
83
+ }
84
+ return result;
85
+ }
86
+ /**
87
+ * Evaluate a single expression in the given context
88
+ *
89
+ * @param expression - Expression to evaluate
90
+ * @param context - Data context
91
+ * @returns Evaluated value
92
+ */
93
+ export function evaluateExpression(expression, context) {
94
+ // Handle literals FIRST (before operators to avoid false matches)
95
+ // Handle string literals
96
+ if ((expression.startsWith("'") && expression.endsWith("'")) || (expression.startsWith('"') && expression.endsWith('"'))) {
97
+ return expression.slice(1, -1);
98
+ }
99
+ // Handle number literals (including negative numbers)
100
+ if (/^-?\d+(\.\d+)?$/.test(expression)) {
101
+ return Number(expression);
102
+ }
103
+ // Handle boolean literals
104
+ if (expression === 'true')
105
+ return true;
106
+ if (expression === 'false')
107
+ return false;
108
+ if (expression === 'null')
109
+ return null;
110
+ if (expression === 'undefined')
111
+ return undefined;
112
+ // Handle ternary operator: condition ? true : false
113
+ const ternaryMatch = expression.match(/^(.+?)\s*\?\s*(.+?)\s*:\s*(.+)$/);
114
+ if (ternaryMatch) {
115
+ const [, condition, trueValue, falseValue] = ternaryMatch;
116
+ const conditionResult = evaluateExpression(condition, context);
117
+ const result = isTruthy(conditionResult)
118
+ ? evaluateExpression(trueValue, context)
119
+ : evaluateExpression(falseValue, context);
120
+ // If the result is a string containing {expressions}, recursively parse it
121
+ if (typeof result === 'string' && result.includes('{') && result.includes('}')) {
122
+ return parseTemplate(result, context);
123
+ }
124
+ return result;
125
+ }
126
+ // Handle comparison operators
127
+ if (expression.includes('>=')) {
128
+ const [left, right] = expression.split('>=').map((s) => s.trim());
129
+ return Number(evaluateExpression(left, context)) >= Number(evaluateExpression(right, context));
130
+ }
131
+ if (expression.includes('<=')) {
132
+ const [left, right] = expression.split('<=').map((s) => s.trim());
133
+ return Number(evaluateExpression(left, context)) <= Number(evaluateExpression(right, context));
134
+ }
135
+ if (expression.includes('>')) {
136
+ const [left, right] = expression.split('>').map((s) => s.trim());
137
+ return Number(evaluateExpression(left, context)) > Number(evaluateExpression(right, context));
138
+ }
139
+ if (expression.includes('<')) {
140
+ const [left, right] = expression.split('<').map((s) => s.trim());
141
+ return Number(evaluateExpression(left, context)) < Number(evaluateExpression(right, context));
142
+ }
143
+ if (expression.includes('===')) {
144
+ const [left, right] = expression.split('===').map((s) => s.trim());
145
+ return evaluateExpression(left, context) === evaluateExpression(right, context);
146
+ }
147
+ if (expression.includes('!==')) {
148
+ const [left, right] = expression.split('!==').map((s) => s.trim());
149
+ return evaluateExpression(left, context) !== evaluateExpression(right, context);
150
+ }
151
+ if (expression.includes('==')) {
152
+ const [left, right] = expression.split('==').map((s) => s.trim());
153
+ // eslint-disable-next-line eqeqeq
154
+ return evaluateExpression(left, context) == evaluateExpression(right, context);
155
+ }
156
+ if (expression.includes('!=')) {
157
+ const [left, right] = expression.split('!=').map((s) => s.trim());
158
+ // eslint-disable-next-line eqeqeq
159
+ return evaluateExpression(left, context) != evaluateExpression(right, context);
160
+ }
161
+ // Handle arithmetic operators (check for operators not at start to avoid matching negative numbers)
162
+ if (expression.includes('+') && !expression.includes("'") && !expression.includes('"')) {
163
+ const parts = expression.split('+');
164
+ if (parts.length > 1) {
165
+ const [left, right] = parts.map((s) => s.trim());
166
+ return Number(evaluateExpression(left, context)) + Number(evaluateExpression(right, context));
167
+ }
168
+ }
169
+ if (expression.includes('-') && !expression.includes("'") && !expression.includes('"')) {
170
+ // Only treat as subtraction if there's content before the minus (to avoid matching negative numbers)
171
+ const minusIndex = expression.indexOf('-');
172
+ if (minusIndex > 0) {
173
+ const beforeMinus = expression.substring(0, minusIndex).trim();
174
+ if (beforeMinus.length > 0) {
175
+ const [left, right] = expression.split('-').map((s) => s.trim());
176
+ return Number(evaluateExpression(left, context)) - Number(evaluateExpression(right, context));
177
+ }
178
+ }
179
+ }
180
+ if (expression.includes('*') && !expression.includes("'") && !expression.includes('"')) {
181
+ const [left, right] = expression.split('*').map((s) => s.trim());
182
+ return Number(evaluateExpression(left, context)) * Number(evaluateExpression(right, context));
183
+ }
184
+ if (expression.includes('/') && !expression.includes("'") && !expression.includes('"')) {
185
+ const [left, right] = expression.split('/').map((s) => s.trim());
186
+ return Number(evaluateExpression(left, context)) / Number(evaluateExpression(right, context));
187
+ }
188
+ // Handle method calls (limited to safe string methods)
189
+ if (expression.includes('.')) {
190
+ // Support both single and double quotes
191
+ const methodMatch = expression.match(/^(['"])(.+)\1\.(\w+)\(([^)]*)\)$/);
192
+ if (methodMatch) {
193
+ const [, , str, method, argsStr] = methodMatch;
194
+ return callStringMethod(str, method, argsStr);
195
+ }
196
+ // Property access with method call
197
+ const propMethodMatch = expression.match(/^([\w.[\]']+)\.(\w+)\(([^)]*)\)$/);
198
+ if (propMethodMatch) {
199
+ const [, propPath, method, argsStr] = propMethodMatch;
200
+ const value = evaluateExpression(propPath, context);
201
+ if (typeof value === 'string') {
202
+ return callStringMethod(value, method, argsStr);
203
+ }
204
+ }
205
+ // Simple property access
206
+ return getNestedValue(context, expression);
207
+ }
208
+ // Simple variable lookup
209
+ return context[expression];
210
+ }
211
+ /**
212
+ * Call a safe string method
213
+ *
214
+ * Only allows specific string methods to prevent code injection.
215
+ *
216
+ * @param str - String to operate on
217
+ * @param method - Method name
218
+ * @param argsStr - Arguments string
219
+ * @returns Result of method call
220
+ */
221
+ function callStringMethod(str, method, argsStr) {
222
+ const args = argsStr.split(',').map((s) => s.trim());
223
+ switch (method) {
224
+ case 'repeat': {
225
+ const count = Number(args[0]);
226
+ return str.repeat(count);
227
+ }
228
+ case 'substring': {
229
+ const start = Number(args[0]);
230
+ const end = args[1] !== undefined ? Number(args[1]) : undefined;
231
+ return str.substring(start, end);
232
+ }
233
+ case 'slice': {
234
+ const start = Number(args[0]);
235
+ const end = args[1] !== undefined ? Number(args[1]) : undefined;
236
+ return str.slice(start, end);
237
+ }
238
+ case 'toUpperCase':
239
+ return str.toUpperCase();
240
+ case 'toLowerCase':
241
+ return str.toLowerCase();
242
+ case 'trim':
243
+ return str.trim();
244
+ case 'replace': {
245
+ const search = args[0].replace(/^['"]|['"]$/g, '');
246
+ const replace = args[1].replace(/^['"]|['"]$/g, '');
247
+ return str.replace(search, replace);
248
+ }
249
+ default:
250
+ throw new Error(`Method ${method} is not allowed in templates`);
251
+ }
252
+ }
253
+ /**
254
+ * Check if a value is truthy
255
+ *
256
+ * @param value - Value to check
257
+ * @returns True if value is truthy
258
+ */
259
+ function isTruthy(value) {
260
+ if (value === null || value === undefined)
261
+ return false;
262
+ if (typeof value === 'boolean')
263
+ return value;
264
+ if (typeof value === 'number')
265
+ return value !== 0;
266
+ if (typeof value === 'string')
267
+ return value.length > 0;
268
+ return true;
269
+ }
270
+ /**
271
+ * Format a value for output
272
+ *
273
+ * @param value - Value to format
274
+ * @returns Formatted string
275
+ */
276
+ function formatValue(value) {
277
+ if (value === null || value === undefined) {
278
+ return '';
279
+ }
280
+ if (typeof value === 'boolean') {
281
+ return value ? 'true' : 'false';
282
+ }
283
+ if (typeof value === 'object') {
284
+ return JSON.stringify(value);
285
+ }
286
+ return String(value);
287
+ }
288
+ //# sourceMappingURL=template-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-parser.js","sourceRoot":"","sources":["../../src/narrative/template-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,aAAa,CAAC,QAAgB,EAAE,OAAgC;IAC9E,yDAAyD;IACzD,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,CAAC,GAAG,CAAC,CAAC;IAEV,OAAO,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE;QAC1B,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACvC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;YAChB,sBAAsB;YACtB,MAAM,IAAI,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YAChC,MAAM;SACP;QAED,iCAAiC;QACjC,MAAM,IAAI,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QAEvC,8BAA8B;QAC9B,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,IAAI,GAAG,GAAG,KAAK,GAAG,CAAC,CAAC;QACpB,OAAO,GAAG,GAAG,QAAQ,CAAC,MAAM,IAAI,KAAK,GAAG,CAAC,EAAE;YACzC,IAAI,QAAQ,CAAC,GAAG,CAAC,KAAK,GAAG;gBAAE,KAAK,EAAE,CAAC;YACnC,IAAI,QAAQ,CAAC,GAAG,CAAC,KAAK,GAAG;gBAAE,KAAK,EAAE,CAAC;YACnC,GAAG,EAAE,CAAC;SACP;QAED,IAAI,KAAK,KAAK,CAAC,EAAE;YACf,uB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,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;YACnD,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;YACpD,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;SACrC;QACD;YACE,MAAM,IAAI,KAAK,CAAC,UAAU,MAAM,8BAA8B,CAAC,CAAC;KACnE;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACxD,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,KAAK,CAAC,CAAC;IAClD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IACvD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,SAAS,WAAW,CAAC,KAAc;IACjC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;QACzC,OAAO,EAAE,CAAC;KACX;IACD,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;QAC9B,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;KACjC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;KAC9B;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Template Renderer
3
+ *
4
+ * Renders narrative templates into human-readable text using
5
+ * OTEL events, selected scenarios, and template expressions.
6
+ */
7
+ import type { NarrativeTemplate, OtelEvent, NarrativeResult } from './types';
8
+ /**
9
+ * Render a narrative from a template and events
10
+ *
11
+ * Main entry point for narrative generation.
12
+ *
13
+ * @param template - Narrative template
14
+ * @param events - Collected OTEL events
15
+ * @returns Rendered narrative
16
+ */
17
+ export declare function renderNarrative(template: NarrativeTemplate, events: OtelEvent[]): NarrativeResult;
18
+ //# sourceMappingURL=template-renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-renderer.d.ts","sourceRoot":"","sources":["../../src/narrative/template-renderer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,iBAAiB,EAEjB,SAAS,EACT,eAAe,EAKhB,MAAM,SAAS,CAAC;AAIjB;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,iBAAiB,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,eAAe,CAqDjG"}