@runflow-ai/sdk 1.0.32 → 1.0.33
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/README.md +354 -19
- package/dist/core/agent.d.ts.map +1 -1
- package/dist/core/agent.js +59 -14
- package/dist/core/agent.js.map +1 -1
- package/dist/core/helpers/agent-memory.d.ts +2 -2
- package/dist/core/helpers/agent-memory.d.ts.map +1 -1
- package/dist/core/helpers/agent-memory.js +17 -4
- package/dist/core/helpers/agent-memory.js.map +1 -1
- package/dist/core/helpers/observability-helpers.d.ts +33 -0
- package/dist/core/helpers/observability-helpers.d.ts.map +1 -0
- package/dist/core/helpers/observability-helpers.js +108 -0
- package/dist/core/helpers/observability-helpers.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -6
- package/dist/index.js.map +1 -1
- package/dist/observability/execution.d.ts +44 -0
- package/dist/observability/execution.d.ts.map +1 -0
- package/dist/observability/execution.js +147 -0
- package/dist/observability/execution.js.map +1 -0
- package/dist/observability/identify.d.ts +37 -0
- package/dist/observability/identify.d.ts.map +1 -0
- package/dist/observability/identify.js +124 -0
- package/dist/observability/identify.js.map +1 -0
- package/dist/observability/index.d.ts +7 -0
- package/dist/observability/index.d.ts.map +1 -1
- package/dist/observability/index.js +20 -2
- package/dist/observability/index.js.map +1 -1
- package/dist/observability/logging.d.ts +52 -0
- package/dist/observability/logging.d.ts.map +1 -0
- package/dist/observability/logging.js +140 -0
- package/dist/observability/logging.js.map +1 -0
- package/dist/observability/trace-collector.d.ts +14 -2
- package/dist/observability/trace-collector.d.ts.map +1 -1
- package/dist/observability/trace-collector.js +151 -3
- package/dist/observability/trace-collector.js.map +1 -1
- package/dist/types/all-types.d.ts +11 -0
- package/dist/types/all-types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ============================================================================
|
|
4
|
+
* EXECUTION MANAGEMENT - For Custom Flows
|
|
5
|
+
* ============================================================================
|
|
6
|
+
*
|
|
7
|
+
* Allows developers to create custom executions for non-agent flows
|
|
8
|
+
* (document analysis, batch processing, etc.)
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.startExecution = startExecution;
|
|
12
|
+
const context_1 = require("../core/context");
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// HELPERS
|
|
15
|
+
// ============================================================================
|
|
16
|
+
function generateExecutionId() {
|
|
17
|
+
return `exec_${Date.now()}_${Math.random().toString(36).substring(2, 8)}`;
|
|
18
|
+
}
|
|
19
|
+
function getTraceCollector() {
|
|
20
|
+
// Get trace collector from Agent or create new one
|
|
21
|
+
// This will be set by the agent or workflow
|
|
22
|
+
return global.__runflowTraceCollector;
|
|
23
|
+
}
|
|
24
|
+
// ============================================================================
|
|
25
|
+
// PUBLIC API
|
|
26
|
+
// ============================================================================
|
|
27
|
+
/**
|
|
28
|
+
* Start a custom execution for non-agent flows
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* const exec = startExecution({
|
|
32
|
+
* name: 'document-analysis',
|
|
33
|
+
* input: { documentId: 'doc_456' }
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* try {
|
|
37
|
+
* const result = await analyzeDocument();
|
|
38
|
+
* exec.setOutput(result);
|
|
39
|
+
* } catch (error) {
|
|
40
|
+
* exec.setError(error);
|
|
41
|
+
* } finally {
|
|
42
|
+
* await exec.end();
|
|
43
|
+
* }
|
|
44
|
+
*/
|
|
45
|
+
function startExecution(config) {
|
|
46
|
+
const executionId = generateExecutionId();
|
|
47
|
+
const state = context_1.Runflow.getState();
|
|
48
|
+
const traceCollector = getTraceCollector();
|
|
49
|
+
if (!traceCollector) {
|
|
50
|
+
console.warn('⚠️ TraceCollector not available, execution will not be tracked');
|
|
51
|
+
return new NoOpExecutionController(executionId);
|
|
52
|
+
}
|
|
53
|
+
// Create execution_summary trace when started
|
|
54
|
+
const span = traceCollector.startSpan('execution_summary', {
|
|
55
|
+
executionId,
|
|
56
|
+
custom: {
|
|
57
|
+
executionName: config.name,
|
|
58
|
+
executionType: config.type || 'custom',
|
|
59
|
+
manualExecution: true
|
|
60
|
+
},
|
|
61
|
+
...state
|
|
62
|
+
});
|
|
63
|
+
span?.setInput(config.input);
|
|
64
|
+
span?.setMetadata(config.metadata);
|
|
65
|
+
return new ExecutionControllerImpl(executionId, span, traceCollector);
|
|
66
|
+
}
|
|
67
|
+
// ============================================================================
|
|
68
|
+
// IMPLEMENTATION
|
|
69
|
+
// ============================================================================
|
|
70
|
+
class ExecutionControllerImpl {
|
|
71
|
+
constructor(id, span, traceCollector) {
|
|
72
|
+
this.id = id;
|
|
73
|
+
this.span = span;
|
|
74
|
+
this.traceCollector = traceCollector;
|
|
75
|
+
this.finalized = false;
|
|
76
|
+
// Auto-cleanup after 60s if not ended manually
|
|
77
|
+
this.cleanupTimer = setTimeout(() => {
|
|
78
|
+
if (!this.finalized) {
|
|
79
|
+
console.warn(`⚠️ [ExecutionController] Execution ${this.id} not ended after 60s, auto-flushing traces`);
|
|
80
|
+
this.end({
|
|
81
|
+
output: {
|
|
82
|
+
autoCompleted: true,
|
|
83
|
+
warning: 'Execution was not manually ended, auto-cleanup triggered'
|
|
84
|
+
}
|
|
85
|
+
}).catch(err => {
|
|
86
|
+
console.error('Failed to auto-cleanup execution:', err);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}, 60000);
|
|
90
|
+
}
|
|
91
|
+
setOutput(output) {
|
|
92
|
+
this.span?.setOutput(output);
|
|
93
|
+
}
|
|
94
|
+
setError(error) {
|
|
95
|
+
this.span?.setError(error);
|
|
96
|
+
}
|
|
97
|
+
log(name, data) {
|
|
98
|
+
if (this.finalized) {
|
|
99
|
+
console.warn(`⚠️ Cannot log to finalized execution ${this.id}`);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const logSpan = this.traceCollector?.startSpan('custom_event', {
|
|
103
|
+
executionId: this.id,
|
|
104
|
+
operation: name,
|
|
105
|
+
custom: {
|
|
106
|
+
customLog: true
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
if (typeof data === 'object' && data !== null) {
|
|
110
|
+
logSpan?.setInput(data.input);
|
|
111
|
+
logSpan?.setOutput(data.output);
|
|
112
|
+
logSpan?.setMetadata(data.metadata);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
logSpan?.setOutput(data);
|
|
116
|
+
}
|
|
117
|
+
logSpan?.finish();
|
|
118
|
+
}
|
|
119
|
+
async end(summary) {
|
|
120
|
+
if (this.finalized) {
|
|
121
|
+
return; // Already ended
|
|
122
|
+
}
|
|
123
|
+
this.finalized = true;
|
|
124
|
+
clearTimeout(this.cleanupTimer);
|
|
125
|
+
if (summary?.input) {
|
|
126
|
+
this.span?.setInput(summary.input);
|
|
127
|
+
}
|
|
128
|
+
if (summary?.output) {
|
|
129
|
+
this.span?.setOutput(summary.output);
|
|
130
|
+
}
|
|
131
|
+
this.span?.finish();
|
|
132
|
+
await this.traceCollector?.flush();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* No-op implementation when TraceCollector is not available
|
|
137
|
+
*/
|
|
138
|
+
class NoOpExecutionController {
|
|
139
|
+
constructor(id) {
|
|
140
|
+
this.id = id;
|
|
141
|
+
}
|
|
142
|
+
setOutput(output) { }
|
|
143
|
+
setError(error) { }
|
|
144
|
+
log(name, data) { }
|
|
145
|
+
async end(summary) { }
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=execution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution.js","sourceRoot":"","sources":["../../src/observability/execution.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AA4DH,wCAyBC;AAnFD,6CAA0C;AAsB1C,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AAE/E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,IAAkB,CAAC;CACrE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ============================================================================
|
|
3
|
+
* SMART IDENTIFY - Auto-detection of Entity Types
|
|
4
|
+
* ============================================================================
|
|
5
|
+
*
|
|
6
|
+
* Automatically detects entity type from value (email, phone, URL, UUID).
|
|
7
|
+
* Supports both simple string input and explicit config.
|
|
8
|
+
*/
|
|
9
|
+
export interface IdentifyConfig {
|
|
10
|
+
type: string;
|
|
11
|
+
value: string;
|
|
12
|
+
userId?: string;
|
|
13
|
+
threadId?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Identify execution context
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Auto-detect from email
|
|
20
|
+
* identify('user@example.com');
|
|
21
|
+
*
|
|
22
|
+
* // Auto-detect from phone
|
|
23
|
+
* identify('+5511999999999');
|
|
24
|
+
*
|
|
25
|
+
* // Explicit type
|
|
26
|
+
* identify({ type: 'order', value: 'ORD-123' });
|
|
27
|
+
*/
|
|
28
|
+
export declare function identify(valueOrConfig: string | IdentifyConfig): void;
|
|
29
|
+
/**
|
|
30
|
+
* Detect entity type from value
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* detectIdentityType('user@example.com') // 'email'
|
|
34
|
+
* detectIdentityType('+5511999999999') // 'phone'
|
|
35
|
+
*/
|
|
36
|
+
export declare function detectIdentityType(value: string): string;
|
|
37
|
+
//# sourceMappingURL=identify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identify.d.ts","sourceRoot":"","sources":["../../src/observability/identify.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAQH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAarE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAExD"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ============================================================================
|
|
4
|
+
* SMART IDENTIFY - Auto-detection of Entity Types
|
|
5
|
+
* ============================================================================
|
|
6
|
+
*
|
|
7
|
+
* Automatically detects entity type from value (email, phone, URL, UUID).
|
|
8
|
+
* Supports both simple string input and explicit config.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.identify = identify;
|
|
12
|
+
exports.detectIdentityType = detectIdentityType;
|
|
13
|
+
const context_1 = require("../core/context");
|
|
14
|
+
// ============================================================================
|
|
15
|
+
// PUBLIC API
|
|
16
|
+
// ============================================================================
|
|
17
|
+
/**
|
|
18
|
+
* Identify execution context
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Auto-detect from email
|
|
22
|
+
* identify('user@example.com');
|
|
23
|
+
*
|
|
24
|
+
* // Auto-detect from phone
|
|
25
|
+
* identify('+5511999999999');
|
|
26
|
+
*
|
|
27
|
+
* // Explicit type
|
|
28
|
+
* identify({ type: 'order', value: 'ORD-123' });
|
|
29
|
+
*/
|
|
30
|
+
function identify(valueOrConfig) {
|
|
31
|
+
if (typeof valueOrConfig === 'string') {
|
|
32
|
+
const value = valueOrConfig;
|
|
33
|
+
const type = detectType(value);
|
|
34
|
+
context_1.Runflow.identify({
|
|
35
|
+
type,
|
|
36
|
+
value,
|
|
37
|
+
userId: value
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
context_1.Runflow.identify(valueOrConfig);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Detect entity type from value
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* detectIdentityType('user@example.com') // 'email'
|
|
49
|
+
* detectIdentityType('+5511999999999') // 'phone'
|
|
50
|
+
*/
|
|
51
|
+
function detectIdentityType(value) {
|
|
52
|
+
return detectType(value);
|
|
53
|
+
}
|
|
54
|
+
// ============================================================================
|
|
55
|
+
// TYPE DETECTION
|
|
56
|
+
// ============================================================================
|
|
57
|
+
function detectType(value) {
|
|
58
|
+
const trimmed = value.trim();
|
|
59
|
+
// ============================================================================
|
|
60
|
+
// EMAIL - RFC 5322 simplified
|
|
61
|
+
// ============================================================================
|
|
62
|
+
// Covers: user@example.com, user+tag@domain.co.uk, user.name@sub.domain.com
|
|
63
|
+
if (/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(trimmed)) {
|
|
64
|
+
return 'email';
|
|
65
|
+
}
|
|
66
|
+
// ============================================================================
|
|
67
|
+
// PHONE - International and local formats
|
|
68
|
+
// ============================================================================
|
|
69
|
+
// Remove common formatting characters to validate
|
|
70
|
+
const phoneDigits = trimmed.replace(/[\s\-\(\)\.\+]/g, '');
|
|
71
|
+
// Must have 8-15 digits (E.164 standard)
|
|
72
|
+
// Covers:
|
|
73
|
+
// - +5511999999999 (international with +)
|
|
74
|
+
// - 5511999999999 (international without +)
|
|
75
|
+
// - 11999999999 (local with area code)
|
|
76
|
+
// - (11) 99999-9999 (formatted)
|
|
77
|
+
// - +1 (415) 555-2671 (US formatted)
|
|
78
|
+
// - +44 20 7946 0958 (UK)
|
|
79
|
+
if (/^\d{8,15}$/.test(phoneDigits)) {
|
|
80
|
+
// International format (starts with +)
|
|
81
|
+
if (trimmed.startsWith('+')) {
|
|
82
|
+
return 'phone';
|
|
83
|
+
}
|
|
84
|
+
// 10+ digits without + is likely a phone
|
|
85
|
+
if (phoneDigits.length >= 10) {
|
|
86
|
+
return 'phone';
|
|
87
|
+
}
|
|
88
|
+
// Has formatting (spaces, dashes, parentheses) - likely phone
|
|
89
|
+
if (/[\s\-\(\)]/.test(trimmed)) {
|
|
90
|
+
return 'phone';
|
|
91
|
+
}
|
|
92
|
+
// 8-9 digits without formatting - ambiguous, default to 'id'
|
|
93
|
+
// User should be explicit for these cases
|
|
94
|
+
}
|
|
95
|
+
// ============================================================================
|
|
96
|
+
// URL - With or without protocol
|
|
97
|
+
// ============================================================================
|
|
98
|
+
// Covers:
|
|
99
|
+
// - https://example.com
|
|
100
|
+
// - http://localhost:3000
|
|
101
|
+
// - example.com
|
|
102
|
+
// - www.example.com
|
|
103
|
+
// - example.com/path/to/page
|
|
104
|
+
// With protocol
|
|
105
|
+
if (/^https?:\/\/.+/.test(trimmed)) {
|
|
106
|
+
return 'url';
|
|
107
|
+
}
|
|
108
|
+
// Without protocol (domain pattern)
|
|
109
|
+
if (/^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]?\.([a-zA-Z]{2,}|localhost)(:\d+)?(\/.*)?$/.test(trimmed)) {
|
|
110
|
+
return 'url';
|
|
111
|
+
}
|
|
112
|
+
// ============================================================================
|
|
113
|
+
// UUID - Standard format
|
|
114
|
+
// ============================================================================
|
|
115
|
+
// Covers: 550e8400-e29b-41d4-a716-446655440000
|
|
116
|
+
if (/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(trimmed)) {
|
|
117
|
+
return 'uuid';
|
|
118
|
+
}
|
|
119
|
+
// ============================================================================
|
|
120
|
+
// FALLBACK - Generic identifier
|
|
121
|
+
// ============================================================================
|
|
122
|
+
return 'id';
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=identify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identify.js","sourceRoot":"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CAAC,EAAE,CAAC;QACnC,uCAAuC;QACvC,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC5B,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,yCAAyC;QACzC,IAAI,WAAW,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;YAC7B,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,8DAA8D;QAC9D,IAAI,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/B,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,6DAA6D;QAC7D,0CAA0C;IAC5C,CAAC;IAED,+EAA+E;IAC/E,iCAAiC;IACjC,+EAA+E;IAC/E,UAAU;IACV,wBAAwB;IACxB,0BAA0B;IAC1B,gBAAgB;IAChB,oBAAoB;IACpB,6BAA6B;IAE7B,gBAAgB;IAChB,IAAI,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,oCAAoC;IACpC,IAAI,qFAAqF,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACxG,OAAO,KAAK,CAAC;IACf,CAAC;IAED,+EAA+E;IAC/E,yBAAyB;IACzB,+EAA+E;IAC/E,+CAA+C;IAC/C,IAAI,4EAA4E,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/F,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,+EAA+E;IAC/E,gCAAgC;IAChC,+EAA+E;IAC/E,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
export { identify, detectIdentityType } from './identify';
|
|
2
|
+
export type { IdentifyConfig } from './identify';
|
|
3
|
+
export { startExecution } from './execution';
|
|
4
|
+
export type { ExecutionConfig, ExecutionController } from './execution';
|
|
5
|
+
export { log, logEvent, logError } from './logging';
|
|
6
|
+
export type { LogData } from './logging';
|
|
1
7
|
export { RunflowTraceCollector, RunflowTraceSpan, createTraceCollector, traced, } from './trace-collector';
|
|
2
8
|
export type { TraceData, TraceMetadata, TraceCosts, TraceCollector, TraceSpan } from '../types';
|
|
9
|
+
export { Runflow } from '../core/context';
|
|
3
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/observability/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/observability/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC1D,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGxE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpD,YAAY,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,oBAAoB,EACpB,MAAM,GACP,MAAM,mBAAmB,CAAC;AAG3B,YAAY,EACV,SAAS,EACT,aAAa,EACb,UAAU,EACV,cAAc,EACd,SAAS,EACV,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// ============================================================================
|
|
3
|
+
// OBSERVABILITY API - Public Exports
|
|
4
|
+
// ============================================================================
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.traced = exports.createTraceCollector = exports.RunflowTraceSpan = exports.RunflowTraceCollector = void 0;
|
|
4
|
-
//
|
|
6
|
+
exports.Runflow = exports.traced = exports.createTraceCollector = exports.RunflowTraceSpan = exports.RunflowTraceCollector = exports.logError = exports.logEvent = exports.log = exports.startExecution = exports.detectIdentityType = exports.identify = void 0;
|
|
7
|
+
// Identification (smart identify with auto-detection)
|
|
8
|
+
var identify_1 = require("./identify");
|
|
9
|
+
Object.defineProperty(exports, "identify", { enumerable: true, get: function () { return identify_1.identify; } });
|
|
10
|
+
Object.defineProperty(exports, "detectIdentityType", { enumerable: true, get: function () { return identify_1.detectIdentityType; } });
|
|
11
|
+
// Execution Management (for custom flows)
|
|
12
|
+
var execution_1 = require("./execution");
|
|
13
|
+
Object.defineProperty(exports, "startExecution", { enumerable: true, get: function () { return execution_1.startExecution; } });
|
|
14
|
+
// Custom Logging
|
|
15
|
+
var logging_1 = require("./logging");
|
|
16
|
+
Object.defineProperty(exports, "log", { enumerable: true, get: function () { return logging_1.log; } });
|
|
17
|
+
Object.defineProperty(exports, "logEvent", { enumerable: true, get: function () { return logging_1.logEvent; } });
|
|
18
|
+
Object.defineProperty(exports, "logError", { enumerable: true, get: function () { return logging_1.logError; } });
|
|
19
|
+
// Advanced Tracing (for framework developers)
|
|
5
20
|
var trace_collector_1 = require("./trace-collector");
|
|
6
21
|
Object.defineProperty(exports, "RunflowTraceCollector", { enumerable: true, get: function () { return trace_collector_1.RunflowTraceCollector; } });
|
|
7
22
|
Object.defineProperty(exports, "RunflowTraceSpan", { enumerable: true, get: function () { return trace_collector_1.RunflowTraceSpan; } });
|
|
8
23
|
Object.defineProperty(exports, "createTraceCollector", { enumerable: true, get: function () { return trace_collector_1.createTraceCollector; } });
|
|
9
24
|
Object.defineProperty(exports, "traced", { enumerable: true, get: function () { return trace_collector_1.traced; } });
|
|
25
|
+
// Re-export Runflow context for backward compatibility
|
|
26
|
+
var context_1 = require("../core/context");
|
|
27
|
+
Object.defineProperty(exports, "Runflow", { enumerable: true, get: function () { return context_1.Runflow; } });
|
|
10
28
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/observability/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/observability/index.ts"],"names":[],"mappings":";AAAA,+EAA+E;AAC/E,qCAAqC;AACrC,+EAA+E;;;AAE/E,sDAAsD;AACtD,uCAA0D;AAAjD,oGAAA,QAAQ,OAAA;AAAE,8GAAA,kBAAkB,OAAA;AAGrC,0CAA0C;AAC1C,yCAA6C;AAApC,2GAAA,cAAc,OAAA;AAGvB,iBAAiB;AACjB,qCAAoD;AAA3C,8FAAA,GAAG,OAAA;AAAE,mGAAA,QAAQ,OAAA;AAAE,mGAAA,QAAQ,OAAA;AAGhC,8CAA8C;AAC9C,qDAK2B;AAJzB,wHAAA,qBAAqB,OAAA;AACrB,mHAAA,gBAAgB,OAAA;AAChB,uHAAA,oBAAoB,OAAA;AACpB,yGAAA,MAAM,OAAA;AAYR,uDAAuD;AACvD,2CAA0C;AAAjC,kGAAA,OAAO,OAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ============================================================================
|
|
3
|
+
* CUSTOM LOGGING - Event and Error Tracking
|
|
4
|
+
* ============================================================================
|
|
5
|
+
*
|
|
6
|
+
* Provides simple API for logging custom events, validations, and errors
|
|
7
|
+
* within the current execution context.
|
|
8
|
+
*/
|
|
9
|
+
export interface LogData {
|
|
10
|
+
input?: any;
|
|
11
|
+
output?: any;
|
|
12
|
+
metadata?: any;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Log a custom event or operation
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Simple log
|
|
19
|
+
* log('cache_hit', { key: 'user_123' });
|
|
20
|
+
*
|
|
21
|
+
* // Detailed log
|
|
22
|
+
* log('validation', {
|
|
23
|
+
* input: { orderId: '123', amount: 100 },
|
|
24
|
+
* output: { valid: true, score: 0.95 },
|
|
25
|
+
* metadata: { rule: 'fraud_detection' }
|
|
26
|
+
* });
|
|
27
|
+
*/
|
|
28
|
+
export declare function log(name: string, data?: any): void;
|
|
29
|
+
/**
|
|
30
|
+
* Log an event with structured input/output
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* logEvent('validation', {
|
|
34
|
+
* input: { orderId: '123' },
|
|
35
|
+
* output: { valid: true },
|
|
36
|
+
* metadata: { rule: 'fraud_check' }
|
|
37
|
+
* });
|
|
38
|
+
*/
|
|
39
|
+
export declare function logEvent(name: string, data: LogData): void;
|
|
40
|
+
/**
|
|
41
|
+
* Log an error
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* try {
|
|
45
|
+
* await riskyOperation();
|
|
46
|
+
* } catch (error) {
|
|
47
|
+
* logError('operation_failed', error);
|
|
48
|
+
* throw error;
|
|
49
|
+
* }
|
|
50
|
+
*/
|
|
51
|
+
export declare function logError(name: string, error: Error | string): void;
|
|
52
|
+
//# sourceMappingURL=logging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../src/observability/logging.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AASH,MAAM,WAAW,OAAO;IACtB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB;AAqCD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI,CAyClD;AAED;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAE1D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,CA0BlE"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ============================================================================
|
|
4
|
+
* CUSTOM LOGGING - Event and Error Tracking
|
|
5
|
+
* ============================================================================
|
|
6
|
+
*
|
|
7
|
+
* Provides simple API for logging custom events, validations, and errors
|
|
8
|
+
* within the current execution context.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.log = log;
|
|
12
|
+
exports.logEvent = logEvent;
|
|
13
|
+
exports.logError = logError;
|
|
14
|
+
const context_1 = require("../core/context");
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// HELPERS
|
|
17
|
+
// ============================================================================
|
|
18
|
+
function getTraceCollector() {
|
|
19
|
+
return global.__runflowTraceCollector;
|
|
20
|
+
}
|
|
21
|
+
function generateExecutionId() {
|
|
22
|
+
return `exec_${Date.now()}_${Math.random().toString(36).substring(2, 8)}`;
|
|
23
|
+
}
|
|
24
|
+
let autoFlushTimer;
|
|
25
|
+
function scheduleAutoFlush() {
|
|
26
|
+
const traceCollector = getTraceCollector();
|
|
27
|
+
if (!traceCollector)
|
|
28
|
+
return;
|
|
29
|
+
// Clear existing timer
|
|
30
|
+
if (autoFlushTimer) {
|
|
31
|
+
clearTimeout(autoFlushTimer);
|
|
32
|
+
}
|
|
33
|
+
// Schedule flush after 5s of inactivity
|
|
34
|
+
autoFlushTimer = setTimeout(() => {
|
|
35
|
+
traceCollector.flush().catch(err => {
|
|
36
|
+
console.error('Auto-flush failed:', err);
|
|
37
|
+
});
|
|
38
|
+
}, 5000);
|
|
39
|
+
}
|
|
40
|
+
// ============================================================================
|
|
41
|
+
// PUBLIC API
|
|
42
|
+
// ============================================================================
|
|
43
|
+
/**
|
|
44
|
+
* Log a custom event or operation
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* // Simple log
|
|
48
|
+
* log('cache_hit', { key: 'user_123' });
|
|
49
|
+
*
|
|
50
|
+
* // Detailed log
|
|
51
|
+
* log('validation', {
|
|
52
|
+
* input: { orderId: '123', amount: 100 },
|
|
53
|
+
* output: { valid: true, score: 0.95 },
|
|
54
|
+
* metadata: { rule: 'fraud_detection' }
|
|
55
|
+
* });
|
|
56
|
+
*/
|
|
57
|
+
function log(name, data) {
|
|
58
|
+
const state = context_1.Runflow.getState();
|
|
59
|
+
const traceCollector = getTraceCollector();
|
|
60
|
+
if (!traceCollector) {
|
|
61
|
+
console.warn('⚠️ TraceCollector not available, log will not be tracked');
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const executionId = state.executionId || generateExecutionId();
|
|
65
|
+
const span = traceCollector.startSpan('custom_event', {
|
|
66
|
+
executionId,
|
|
67
|
+
operation: name,
|
|
68
|
+
custom: {
|
|
69
|
+
customLog: true
|
|
70
|
+
},
|
|
71
|
+
...state
|
|
72
|
+
});
|
|
73
|
+
if (typeof data === 'object' && data !== null) {
|
|
74
|
+
if (data.input !== undefined) {
|
|
75
|
+
span?.setInput(data.input);
|
|
76
|
+
}
|
|
77
|
+
if (data.output !== undefined) {
|
|
78
|
+
span?.setOutput(data.output);
|
|
79
|
+
}
|
|
80
|
+
if (data.metadata !== undefined) {
|
|
81
|
+
span?.setMetadata(data.metadata);
|
|
82
|
+
}
|
|
83
|
+
// If none of the special fields, treat whole object as output
|
|
84
|
+
if (data.input === undefined && data.output === undefined && data.metadata === undefined) {
|
|
85
|
+
span?.setOutput(data);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else if (data !== undefined) {
|
|
89
|
+
span?.setOutput(data);
|
|
90
|
+
}
|
|
91
|
+
span?.finish();
|
|
92
|
+
scheduleAutoFlush();
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Log an event with structured input/output
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* logEvent('validation', {
|
|
99
|
+
* input: { orderId: '123' },
|
|
100
|
+
* output: { valid: true },
|
|
101
|
+
* metadata: { rule: 'fraud_check' }
|
|
102
|
+
* });
|
|
103
|
+
*/
|
|
104
|
+
function logEvent(name, data) {
|
|
105
|
+
log(name, data);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Log an error
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* try {
|
|
112
|
+
* await riskyOperation();
|
|
113
|
+
* } catch (error) {
|
|
114
|
+
* logError('operation_failed', error);
|
|
115
|
+
* throw error;
|
|
116
|
+
* }
|
|
117
|
+
*/
|
|
118
|
+
function logError(name, error) {
|
|
119
|
+
const state = context_1.Runflow.getState();
|
|
120
|
+
const traceCollector = getTraceCollector();
|
|
121
|
+
if (!traceCollector) {
|
|
122
|
+
console.warn('⚠️ TraceCollector not available, error will not be tracked');
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const executionId = state.executionId || generateExecutionId();
|
|
126
|
+
const span = traceCollector.startSpan('error_event', {
|
|
127
|
+
executionId,
|
|
128
|
+
operation: name,
|
|
129
|
+
custom: {
|
|
130
|
+
customError: true,
|
|
131
|
+
errorType: error instanceof Error ? error.name : 'Error',
|
|
132
|
+
errorMessage: error instanceof Error ? error.message : String(error)
|
|
133
|
+
},
|
|
134
|
+
...state
|
|
135
|
+
});
|
|
136
|
+
span?.setError(error);
|
|
137
|
+
span?.finish();
|
|
138
|
+
scheduleAutoFlush();
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=logging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../../src/observability/logging.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AAgEH,kBAyCC;AAYD,4BAEC;AAaD,4BA0BC;AA5JD,6CAA0C;AAa1C,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AAE/E,SAAS,iBAAiB;IACxB,OAAQ,MAAc,CAAC,uBAAuB,CAAC;AACjD,CAAC;AAED,SAAS,mBAAmB;IAC1B,OAAO,QAAQ,IAAI,CAAC,GAAG,EAAE,IAAI,IAA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AAmB,EAAE,CAAC;IAE/D,MAAM,IAAI,GAAG,cAAc,CAAC,SAAS,CAAC,aAAa,EAAE;QACnD,WAAW;QACX,SAAS,EAAE,IAAI;QACf,MAAM,EAAE;YACN,WAAW,EAAE,IAAI;YACjB,SAAS,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO;YACxD,YAAY,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SACrE;QACD,GAAG,KAAK;KACT,CAAC,CAAC;IAEH,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEtB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,iBAAiB,EAAE,CAAC;AACtB,CAAC"}
|
|
@@ -6,8 +6,10 @@ export declare class RunflowTraceCollector implements TraceCollector {
|
|
|
6
6
|
private options;
|
|
7
7
|
private flushTimer?;
|
|
8
8
|
private sequenceCounter;
|
|
9
|
+
private exitHandlersRegistered;
|
|
10
|
+
private onTraceCallback?;
|
|
9
11
|
private context;
|
|
10
|
-
constructor(apiClient: RunflowAPIClient, projectId: string, options?: TraceCollectorOptions);
|
|
12
|
+
constructor(apiClient: RunflowAPIClient, projectId: string, options?: TraceCollectorOptions, onTraceCallback?: (trace: TraceData) => TraceData | null | void);
|
|
11
13
|
trace(data: Omit<TraceData, 'traceId' | 'startTime' | 'endTime' | 'duration'>): string;
|
|
12
14
|
/**
|
|
13
15
|
* Set execution context (called by Agent.process)
|
|
@@ -36,6 +38,16 @@ export declare class RunflowTraceCollector implements TraceCollector {
|
|
|
36
38
|
private startFlushTimer;
|
|
37
39
|
private stopFlushTimer;
|
|
38
40
|
destroy(): void;
|
|
41
|
+
private registerExitHandlers;
|
|
42
|
+
/**
|
|
43
|
+
* Synchronous flush for process.exit handler
|
|
44
|
+
* Only works for local traces (remote traces may be lost)
|
|
45
|
+
*/
|
|
46
|
+
private flushSync;
|
|
47
|
+
/**
|
|
48
|
+
* Synchronous version of saveTracesToFile for exit handlers
|
|
49
|
+
*/
|
|
50
|
+
private saveTracesToFileSync;
|
|
39
51
|
}
|
|
40
52
|
export declare class RunflowTraceSpan implements TraceSpan {
|
|
41
53
|
readonly traceId: string;
|
|
@@ -59,6 +71,6 @@ export declare class RunflowTraceSpan implements TraceSpan {
|
|
|
59
71
|
finish(): void;
|
|
60
72
|
private inferTraceType;
|
|
61
73
|
}
|
|
62
|
-
export declare function createTraceCollector(apiClient: RunflowAPIClient, projectId: string, options?: TraceCollectorOptions): TraceCollector;
|
|
74
|
+
export declare function createTraceCollector(apiClient: RunflowAPIClient, projectId: string, options?: TraceCollectorOptions, onTraceCallback?: (trace: TraceData) => TraceData | null | void): TraceCollector;
|
|
63
75
|
export declare function traced(operation: string, metadata?: Partial<TraceMetadata>): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
64
76
|
//# sourceMappingURL=trace-collector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace-collector.d.ts","sourceRoot":"","sources":["../../src/observability/trace-collector.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,SAAS,EACT,SAAS,EACT,aAAa,EACb,UAAU,EACV,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAQlB,qBAAa,qBAAsB,YAAW,cAAc;IAC1D,OAAO,CAAC,SAAS,CAAmB;IACpC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,aAAa,CAAmB;IACxC,OAAO,CAAC,OAAO,CAAkC;IACjD,OAAO,CAAC,UAAU,CAAC,CAAiB;IACpC,OAAO,CAAC,eAAe,CAAa;IACpC,OAAO,CAAC,OAAO,CAMR;
|
|
1
|
+
{"version":3,"file":"trace-collector.d.ts","sourceRoot":"","sources":["../../src/observability/trace-collector.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,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