@ai-setting/roy-agent-core 1.5.15-test → 1.5.17-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/index.d.ts +1250 -0
- package/dist/config/index.js +32 -0
- package/dist/env/agent/index.d.ts +2279 -0
- package/dist/env/agent/index.js +24 -0
- package/dist/env/commands/index.d.ts +1131 -0
- package/dist/env/commands/index.js +14 -0
- package/dist/env/debug/formatters/index.d.ts +236 -0
- package/dist/env/debug/formatters/index.js +11 -0
- package/dist/env/debug/index.d.ts +1652 -0
- package/dist/env/debug/index.js +26 -0
- package/dist/env/hook/index.d.ts +279 -0
- package/dist/env/hook/index.js +29 -0
- package/dist/env/index.d.ts +3481 -0
- package/dist/env/index.js +82 -0
- package/dist/env/llm/index.d.ts +1760 -0
- package/dist/env/llm/index.js +40 -0
- package/dist/env/log-trace/index.d.ts +1574 -0
- package/dist/env/log-trace/index.js +83 -0
- package/dist/env/mcp/index.d.ts +1331 -0
- package/dist/env/mcp/index.js +39 -0
- package/dist/env/mcp/tool/index.d.ts +183 -0
- package/dist/env/mcp/tool/index.js +14 -0
- package/dist/env/memory/built-in/index.d.ts +232 -0
- package/dist/env/memory/built-in/index.js +11 -0
- package/dist/env/memory/index.d.ts +1799 -0
- package/dist/env/memory/index.js +56 -0
- package/dist/env/memory/plugin/index.d.ts +747 -0
- package/dist/env/memory/plugin/index.js +36 -0
- package/dist/env/prompt/index.d.ts +1164 -0
- package/dist/env/prompt/index.js +20 -0
- package/dist/env/session/index.d.ts +1908 -0
- package/dist/env/session/index.js +25 -0
- package/dist/env/session/storage/index.d.ts +564 -0
- package/dist/env/session/storage/index.js +18 -0
- package/dist/env/skill/index.d.ts +1266 -0
- package/dist/env/skill/index.js +34 -0
- package/dist/env/skill/tool/index.d.ts +193 -0
- package/dist/env/skill/tool/index.js +9 -0
- package/dist/env/task/delegate/index.d.ts +1612 -0
- package/dist/env/task/delegate/index.js +18 -0
- package/dist/env/task/events/index.d.ts +171 -0
- package/dist/env/task/events/index.js +7 -0
- package/dist/env/task/hooks/index.d.ts +624 -0
- package/dist/env/task/hooks/index.js +7 -0
- package/dist/env/task/index.d.ts +1553 -0
- package/dist/env/task/index.js +34 -0
- package/dist/env/task/plugins/index.d.ts +466 -0
- package/dist/env/task/plugins/index.js +23 -0
- package/dist/env/task/storage/index.d.ts +241 -0
- package/dist/env/task/storage/index.js +14 -0
- package/dist/env/task/tools/index.d.ts +1485 -0
- package/dist/env/task/tools/index.js +17 -0
- package/dist/env/task/tools/operation/index.d.ts +1484 -0
- package/dist/env/task/tools/operation/index.js +15 -0
- package/dist/env/tool/built-in/index.d.ts +218 -0
- package/dist/env/tool/built-in/index.js +25 -0
- package/dist/env/tool/index.d.ts +1396 -0
- package/dist/env/tool/index.js +39 -0
- package/dist/env/workflow/decorators/index.d.ts +2161 -0
- package/dist/env/workflow/decorators/index.js +27 -0
- package/dist/env/workflow/engine/index.d.ts +3453 -0
- package/dist/env/workflow/engine/index.js +28 -0
- package/dist/env/workflow/index.d.ts +3546 -0
- package/dist/env/workflow/index.js +136 -0
- package/dist/env/workflow/nodes/index.d.ts +2092 -0
- package/dist/env/workflow/nodes/index.js +19 -0
- package/dist/env/workflow/service/index.d.ts +227 -0
- package/dist/env/workflow/service/index.js +13 -0
- package/dist/env/workflow/storage/index.d.ts +165 -0
- package/dist/env/workflow/storage/index.js +27 -0
- package/dist/env/workflow/tools/index.d.ts +416 -0
- package/dist/env/workflow/tools/index.js +159 -0
- package/dist/env/workflow/types/index.d.ts +2255 -0
- package/dist/env/workflow/types/index.js +98 -0
- package/dist/env/workflow/utils/index.d.ts +2031 -0
- package/dist/env/workflow/utils/index.js +637 -0
- package/dist/index.d.ts +7858 -0
- package/dist/index.js +399 -0
- package/dist/shared/@ai-setting/roy-agent-core-0rtxwr28.js +258 -0
- package/dist/shared/@ai-setting/roy-agent-core-0vbdz0x7.js +36 -0
- package/dist/shared/@ai-setting/roy-agent-core-1akcqxj9.js +349 -0
- package/dist/shared/@ai-setting/roy-agent-core-1ce3fqrk.js +117 -0
- package/dist/shared/@ai-setting/roy-agent-core-2dhd60aw.js +11 -0
- package/dist/shared/@ai-setting/roy-agent-core-3jywqmdd.js +393 -0
- package/dist/shared/@ai-setting/roy-agent-core-3rr5k71j.js +200 -0
- package/dist/shared/@ai-setting/roy-agent-core-44hnfb02.js +299 -0
- package/dist/shared/@ai-setting/roy-agent-core-4t40mkpv.js +206 -0
- package/dist/shared/@ai-setting/roy-agent-core-4txzpsbt.js +393 -0
- package/dist/shared/@ai-setting/roy-agent-core-5x94xmt6.js +350 -0
- package/dist/shared/@ai-setting/roy-agent-core-69jskqjg.js +180 -0
- package/dist/shared/@ai-setting/roy-agent-core-6kvtahqv.js +408 -0
- package/dist/shared/@ai-setting/roy-agent-core-7fgf85wc.js +284 -0
- package/dist/shared/@ai-setting/roy-agent-core-81w1963m.js +762 -0
- package/dist/shared/@ai-setting/roy-agent-core-8gxth0eh.js +10 -0
- package/dist/shared/@ai-setting/roy-agent-core-92z6t4he.js +14 -0
- package/dist/shared/@ai-setting/roy-agent-core-93zfb3r1.js +922 -0
- package/dist/shared/@ai-setting/roy-agent-core-9yxb3ty9.js +15 -0
- package/dist/shared/@ai-setting/roy-agent-core-b0x5dda6.js +1130 -0
- package/dist/shared/@ai-setting/roy-agent-core-bcbqy27c.js +14 -0
- package/dist/shared/@ai-setting/roy-agent-core-bvr1761x.js +653 -0
- package/dist/shared/@ai-setting/roy-agent-core-ctdhjv68.js +93 -0
- package/dist/shared/@ai-setting/roy-agent-core-d7cyjkf7.js +872 -0
- package/dist/shared/@ai-setting/roy-agent-core-dh9d7a3m.js +11 -0
- package/dist/shared/@ai-setting/roy-agent-core-e25xkv53.js +64 -0
- package/dist/shared/@ai-setting/roy-agent-core-eajcvp4e.js +378 -0
- package/dist/shared/@ai-setting/roy-agent-core-f7q2x5z6.js +492 -0
- package/dist/shared/@ai-setting/roy-agent-core-fs0mn2jk.js +52 -0
- package/dist/shared/@ai-setting/roy-agent-core-g1s2h0e5.js +171 -0
- package/dist/shared/@ai-setting/roy-agent-core-g99pxzn5.js +862 -0
- package/dist/shared/@ai-setting/roy-agent-core-gbqcyegm.js +1387 -0
- package/dist/shared/@ai-setting/roy-agent-core-gjq1yk68.js +208 -0
- package/dist/shared/@ai-setting/roy-agent-core-gq20wsgv.js +139 -0
- package/dist/shared/@ai-setting/roy-agent-core-gwc4h96n.js +534 -0
- package/dist/shared/@ai-setting/roy-agent-core-jfh9q2qh.js +204 -0
- package/dist/shared/@ai-setting/roy-agent-core-jvatggbb.js +603 -0
- package/dist/shared/@ai-setting/roy-agent-core-kkbwepqb.js +97 -0
- package/dist/shared/@ai-setting/roy-agent-core-pjr12nnd.js +587 -0
- package/dist/shared/@ai-setting/roy-agent-core-psv4v63c.js +176 -0
- package/dist/shared/@ai-setting/roy-agent-core-psvxt4c9.js +60 -0
- package/dist/shared/@ai-setting/roy-agent-core-qqceba6k.js +442 -0
- package/dist/shared/@ai-setting/roy-agent-core-qxhq8ven.js +57 -0
- package/dist/shared/@ai-setting/roy-agent-core-qxnbvgwe.js +66 -0
- package/dist/shared/@ai-setting/roy-agent-core-r9ezzemr.js +10 -0
- package/dist/shared/@ai-setting/roy-agent-core-rhmtwnw1.js +267 -0
- package/dist/shared/@ai-setting/roy-agent-core-rvv6ydff.js +584 -0
- package/dist/shared/@ai-setting/roy-agent-core-rvxg1wps.js +102 -0
- package/dist/shared/@ai-setting/roy-agent-core-satmq6sh.js +549 -0
- package/dist/shared/@ai-setting/roy-agent-core-sx7wsvnn.js +15 -0
- package/dist/shared/@ai-setting/roy-agent-core-t94ktchq.js +213 -0
- package/dist/shared/@ai-setting/roy-agent-core-vf215qfv.js +812 -0
- package/dist/shared/@ai-setting/roy-agent-core-vkz81f7v.js +1316 -0
- package/dist/shared/@ai-setting/roy-agent-core-vn2bc59q.js +1205 -0
- package/dist/shared/@ai-setting/roy-agent-core-wa1kzqky.js +328 -0
- package/dist/shared/@ai-setting/roy-agent-core-wft9ra24.js +20 -0
- package/dist/shared/@ai-setting/roy-agent-core-wrcy0h6z.js +2098 -0
- package/dist/shared/@ai-setting/roy-agent-core-xq8hhqb8.js +419 -0
- package/dist/shared/@ai-setting/roy-agent-core-xs5rsgat.js +368 -0
- package/dist/shared/@ai-setting/roy-agent-core-zbkpc41z.js +377 -0
- package/dist/shared/@ai-setting/roy-agent-core-zgypchmt.js +172 -0
- package/dist/shared/@ai-setting/roy-agent-core-zpn0bqa8.js +103 -0
- package/package.json +29 -8
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SQLiteSpanStorage,
|
|
3
|
+
init_span_storage
|
|
4
|
+
} from "./roy-agent-core-psv4v63c.js";
|
|
5
|
+
import {
|
|
6
|
+
__esm,
|
|
7
|
+
__export,
|
|
8
|
+
__require
|
|
9
|
+
} from "./roy-agent-core-fs0mn2jk.js";
|
|
10
|
+
|
|
11
|
+
// src/env/log-trace/opentelemetry/propagation.ts
|
|
12
|
+
function padLeft(str, length) {
|
|
13
|
+
return str.padStart(length, "0");
|
|
14
|
+
}
|
|
15
|
+
function isValidHex(str) {
|
|
16
|
+
return /^[0-9a-f]+$/i.test(str);
|
|
17
|
+
}
|
|
18
|
+
function serialize(context) {
|
|
19
|
+
const traceId = padLeft(context.traceId.toLowerCase(), TRACE_ID_LENGTH);
|
|
20
|
+
const spanId = padLeft(context.spanId.toLowerCase(), PARENT_SPAN_ID_LENGTH);
|
|
21
|
+
const parts = [
|
|
22
|
+
TRACE_CONTEXT_VERSION,
|
|
23
|
+
traceId,
|
|
24
|
+
spanId,
|
|
25
|
+
TRACE_FLAGS_SAMPLED
|
|
26
|
+
];
|
|
27
|
+
return parts.join("-");
|
|
28
|
+
}
|
|
29
|
+
function parse(traceparent) {
|
|
30
|
+
if (!traceparent || typeof traceparent !== "string") {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const trimmed = traceparent.trim();
|
|
34
|
+
const parts = trimmed.split("-");
|
|
35
|
+
if (parts.length !== 4) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const [version, traceId, senderSpanId, flags] = parts;
|
|
39
|
+
if (version !== TRACE_CONTEXT_VERSION) {
|
|
40
|
+
if (version > TRACE_CONTEXT_VERSION) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (traceId.length !== TRACE_ID_LENGTH || !isValidHex(traceId)) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (senderSpanId.length !== PARENT_SPAN_ID_LENGTH || !isValidHex(senderSpanId)) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (flags.length !== FLAGS_LENGTH || !isValidHex(flags)) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
traceId: traceId.toLowerCase(),
|
|
55
|
+
spanId: senderSpanId.toLowerCase()
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
var TRACE_CONTEXT_VERSION = "00", TRACE_FLAGS_SAMPLED = "01", TRACEPARENT_HEADER = "TRACEPARENT", TRACE_ID_LENGTH = 32, PARENT_SPAN_ID_LENGTH = 16, FLAGS_LENGTH = 2, propagation;
|
|
59
|
+
var init_propagation = __esm(() => {
|
|
60
|
+
propagation = {
|
|
61
|
+
inject(carrier, context) {
|
|
62
|
+
carrier[TRACEPARENT_HEADER] = serialize(context);
|
|
63
|
+
},
|
|
64
|
+
extract(carrier) {
|
|
65
|
+
const traceparent = carrier[TRACEPARENT_HEADER];
|
|
66
|
+
if (!traceparent) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
return parse(traceparent);
|
|
70
|
+
},
|
|
71
|
+
getTraceparentHeader() {
|
|
72
|
+
return TRACEPARENT_HEADER;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// src/env/log-trace/types.ts
|
|
78
|
+
var SpanKind, SpanStatus;
|
|
79
|
+
var init_types = __esm(() => {
|
|
80
|
+
((SpanKind2) => {
|
|
81
|
+
SpanKind2["CLIENT"] = "client";
|
|
82
|
+
SpanKind2["SERVER"] = "server";
|
|
83
|
+
SpanKind2["INTERNAL"] = "internal";
|
|
84
|
+
})(SpanKind ||= {});
|
|
85
|
+
((SpanStatus2) => {
|
|
86
|
+
SpanStatus2["OK"] = "ok";
|
|
87
|
+
SpanStatus2["ERROR"] = "error";
|
|
88
|
+
})(SpanStatus ||= {});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// src/env/log-trace/opentelemetry/tracer-provider.ts
|
|
92
|
+
var exports_tracer_provider = {};
|
|
93
|
+
__export(exports_tracer_provider, {
|
|
94
|
+
resetTracerProvider: () => resetTracerProvider,
|
|
95
|
+
getTracerProvider: () => getTracerProvider,
|
|
96
|
+
OTelTracerProvider: () => OTelTracerProvider
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
class OTelSpanImpl {
|
|
100
|
+
name;
|
|
101
|
+
kind;
|
|
102
|
+
spanContext;
|
|
103
|
+
attributes = {};
|
|
104
|
+
startTime;
|
|
105
|
+
endTime;
|
|
106
|
+
error;
|
|
107
|
+
storage;
|
|
108
|
+
parentSpanContext;
|
|
109
|
+
onEnd;
|
|
110
|
+
constructor(name, spanContext, storage, parentSpanContext, onEnd) {
|
|
111
|
+
this.name = name;
|
|
112
|
+
this.kind = "internal";
|
|
113
|
+
this.spanContext = spanContext;
|
|
114
|
+
this.parentSpanContext = parentSpanContext;
|
|
115
|
+
this.startTime = Date.now();
|
|
116
|
+
this.storage = storage;
|
|
117
|
+
this.onEnd = onEnd;
|
|
118
|
+
}
|
|
119
|
+
setAttribute(key, value) {
|
|
120
|
+
this.attributes[key] = value;
|
|
121
|
+
}
|
|
122
|
+
addEvent(name, attributes) {
|
|
123
|
+
const events = this.attributes._events || [];
|
|
124
|
+
events.push({ name, attributes });
|
|
125
|
+
this.attributes._events = events;
|
|
126
|
+
}
|
|
127
|
+
end(result, error) {
|
|
128
|
+
this.endTime = Date.now();
|
|
129
|
+
if (error) {
|
|
130
|
+
this.error = error.message;
|
|
131
|
+
}
|
|
132
|
+
this.storage.save({
|
|
133
|
+
traceId: this.spanContext.traceId,
|
|
134
|
+
spanId: this.spanContext.spanId,
|
|
135
|
+
parentSpanId: this.spanContext.parentSpanId,
|
|
136
|
+
name: this.name,
|
|
137
|
+
kind: this.kind,
|
|
138
|
+
status: error ? "error" /* ERROR */ : "ok" /* OK */,
|
|
139
|
+
startTime: this.startTime,
|
|
140
|
+
endTime: this.endTime,
|
|
141
|
+
attributes: this.attributes,
|
|
142
|
+
result,
|
|
143
|
+
error: this.error
|
|
144
|
+
});
|
|
145
|
+
this.onEnd?.();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
class OTelTracerImpl {
|
|
150
|
+
name;
|
|
151
|
+
version;
|
|
152
|
+
storage;
|
|
153
|
+
currentContext;
|
|
154
|
+
activeSpans = new Map;
|
|
155
|
+
onSpanEndCallback;
|
|
156
|
+
provider;
|
|
157
|
+
constructor(name, version, storage, provider) {
|
|
158
|
+
this.name = name;
|
|
159
|
+
this.version = version;
|
|
160
|
+
this.storage = storage;
|
|
161
|
+
this.provider = provider;
|
|
162
|
+
}
|
|
163
|
+
setOnSpanEndCallback(callback) {
|
|
164
|
+
this.onSpanEndCallback = callback;
|
|
165
|
+
}
|
|
166
|
+
getActiveSpanCount() {
|
|
167
|
+
return this.activeSpans.size;
|
|
168
|
+
}
|
|
169
|
+
startSpan(name, options) {
|
|
170
|
+
const parentFromOptions = options?.parent;
|
|
171
|
+
const hasExplicitParent = options && "parent" in options;
|
|
172
|
+
const globalContext = this.provider.getGlobalContext();
|
|
173
|
+
let effectiveParentContext;
|
|
174
|
+
if (hasExplicitParent) {
|
|
175
|
+
effectiveParentContext = parentFromOptions;
|
|
176
|
+
} else if (this.currentContext) {
|
|
177
|
+
effectiveParentContext = this.currentContext;
|
|
178
|
+
} else if (globalContext) {
|
|
179
|
+
effectiveParentContext = globalContext;
|
|
180
|
+
}
|
|
181
|
+
const traceId = effectiveParentContext?.traceId || this.generateTraceId();
|
|
182
|
+
const spanId = this.generateSpanId();
|
|
183
|
+
let parentSpanId;
|
|
184
|
+
if (hasExplicitParent && parentFromOptions) {
|
|
185
|
+
parentSpanId = parentFromOptions.parentSpanId || parentFromOptions.spanId;
|
|
186
|
+
} else if (this.currentContext) {
|
|
187
|
+
parentSpanId = this.currentContext.spanId;
|
|
188
|
+
} else if (globalContext) {
|
|
189
|
+
parentSpanId = globalContext.spanId;
|
|
190
|
+
}
|
|
191
|
+
const spanContext = {
|
|
192
|
+
traceId,
|
|
193
|
+
spanId,
|
|
194
|
+
parentSpanId
|
|
195
|
+
};
|
|
196
|
+
this.currentContext = {
|
|
197
|
+
traceId,
|
|
198
|
+
spanId,
|
|
199
|
+
parentSpanId
|
|
200
|
+
};
|
|
201
|
+
const span = new OTelSpanImpl(name, spanContext, this.storage, effectiveParentContext, () => this.handleSpanEnd(spanContext.spanId, effectiveParentContext?.spanId));
|
|
202
|
+
if (options?.attributes) {
|
|
203
|
+
for (const [key, value] of Object.entries(options.attributes)) {
|
|
204
|
+
span.setAttribute(key, value);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
this.activeSpans.set(spanId, span);
|
|
208
|
+
return span;
|
|
209
|
+
}
|
|
210
|
+
injectToEnv(env) {
|
|
211
|
+
if (this.currentContext) {
|
|
212
|
+
propagation.inject(env, this.currentContext);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
getCurrentContext() {
|
|
216
|
+
return this.currentContext;
|
|
217
|
+
}
|
|
218
|
+
setCurrentContext(context) {
|
|
219
|
+
this.currentContext = context;
|
|
220
|
+
}
|
|
221
|
+
endSpan(span) {
|
|
222
|
+
const spanContext = span.spanContext;
|
|
223
|
+
this.activeSpans.delete(spanContext.spanId);
|
|
224
|
+
const currentTraceId = this.currentContext?.traceId;
|
|
225
|
+
if (spanContext.parentSpanId) {
|
|
226
|
+
const parentSpan = this.activeSpans.get(spanContext.parentSpanId);
|
|
227
|
+
if (parentSpan) {
|
|
228
|
+
const parentContext = {
|
|
229
|
+
traceId: spanContext.traceId,
|
|
230
|
+
spanId: parentSpan.spanContext.spanId,
|
|
231
|
+
parentSpanId: parentSpan.spanContext.parentSpanId
|
|
232
|
+
};
|
|
233
|
+
this.currentContext = parentContext;
|
|
234
|
+
return parentContext;
|
|
235
|
+
}
|
|
236
|
+
if (currentTraceId) {
|
|
237
|
+
const parentContext = {
|
|
238
|
+
traceId: currentTraceId,
|
|
239
|
+
spanId: spanContext.parentSpanId,
|
|
240
|
+
parentSpanId: undefined
|
|
241
|
+
};
|
|
242
|
+
this.currentContext = parentContext;
|
|
243
|
+
return parentContext;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
this.currentContext = undefined;
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
generateTraceId() {
|
|
250
|
+
const timestamp = Date.now().toString(16).padStart(12, "0");
|
|
251
|
+
const random = Array.from({ length: 5 }, () => Math.floor(Math.random() * 4294967295).toString(16).padStart(8, "0")).join("");
|
|
252
|
+
return (timestamp + random).slice(0, 32).padStart(32, "0");
|
|
253
|
+
}
|
|
254
|
+
generateSpanId() {
|
|
255
|
+
return Math.floor(Math.random() * 18446744073709552000).toString(16).padStart(16, "0");
|
|
256
|
+
}
|
|
257
|
+
handleSpanEnd(spanId, parentSpanId) {
|
|
258
|
+
this.activeSpans.delete(spanId);
|
|
259
|
+
const currentTraceId = this.currentContext?.traceId;
|
|
260
|
+
if (parentSpanId) {
|
|
261
|
+
const parentSpan = this.activeSpans.get(parentSpanId);
|
|
262
|
+
if (parentSpan) {
|
|
263
|
+
this.currentContext = {
|
|
264
|
+
traceId: parentSpan.spanContext.traceId,
|
|
265
|
+
spanId: parentSpan.spanContext.spanId,
|
|
266
|
+
parentSpanId: parentSpan.spanContext.parentSpanId
|
|
267
|
+
};
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (currentTraceId) {
|
|
271
|
+
this.currentContext = {
|
|
272
|
+
traceId: currentTraceId,
|
|
273
|
+
spanId: parentSpanId,
|
|
274
|
+
parentSpanId: undefined
|
|
275
|
+
};
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
this.currentContext = undefined;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
class OTelTracerProvider {
|
|
284
|
+
tracers = new Map;
|
|
285
|
+
storage;
|
|
286
|
+
initialized = false;
|
|
287
|
+
globalContext;
|
|
288
|
+
constructor(storage, dbPath) {
|
|
289
|
+
this.storage = storage || new SQLiteSpanStorage(dbPath || getDefaultDbPath());
|
|
290
|
+
}
|
|
291
|
+
async initialize() {
|
|
292
|
+
if (this.initialized)
|
|
293
|
+
return;
|
|
294
|
+
await this.storage.initialize();
|
|
295
|
+
this.initialized = true;
|
|
296
|
+
}
|
|
297
|
+
isInitialized() {
|
|
298
|
+
return this.initialized;
|
|
299
|
+
}
|
|
300
|
+
getGlobalContext() {
|
|
301
|
+
return this.globalContext;
|
|
302
|
+
}
|
|
303
|
+
setGlobalContext(context) {
|
|
304
|
+
this.globalContext = context;
|
|
305
|
+
}
|
|
306
|
+
getTracer(name, version) {
|
|
307
|
+
const key = `${name}@${version || "0.0.0"}`;
|
|
308
|
+
let tracer = this.tracers.get(key);
|
|
309
|
+
if (!tracer) {
|
|
310
|
+
tracer = new OTelTracerImpl(name, version, this.storage, this);
|
|
311
|
+
this.tracers.set(key, tracer);
|
|
312
|
+
if (this.initialized) {
|
|
313
|
+
this.restoreFromEnv(tracer);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return tracer;
|
|
317
|
+
}
|
|
318
|
+
restoreFromEnv(tracer) {
|
|
319
|
+
const extracted = propagation.extract(process.env);
|
|
320
|
+
if (extracted) {
|
|
321
|
+
tracer.setCurrentContext({
|
|
322
|
+
traceId: extracted.traceId,
|
|
323
|
+
spanId: extracted.spanId,
|
|
324
|
+
parentSpanId: undefined
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
shutdown() {
|
|
329
|
+
for (const tracer of this.tracers.values()) {}
|
|
330
|
+
this.tracers.clear();
|
|
331
|
+
this.storage.close();
|
|
332
|
+
this.initialized = false;
|
|
333
|
+
this.globalContext = undefined;
|
|
334
|
+
delete process.env["TRACEPARENT"];
|
|
335
|
+
delete process.env["TRACE_ID"];
|
|
336
|
+
delete process.env["LOG_TRACE_REQUEST_ID"];
|
|
337
|
+
}
|
|
338
|
+
getStorage() {
|
|
339
|
+
return this.storage;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
function getTracerProvider() {
|
|
343
|
+
if (!providerInstance) {
|
|
344
|
+
providerInstance = new OTelTracerProvider;
|
|
345
|
+
}
|
|
346
|
+
return providerInstance;
|
|
347
|
+
}
|
|
348
|
+
function resetTracerProvider() {
|
|
349
|
+
if (providerInstance) {
|
|
350
|
+
providerInstance.shutdown();
|
|
351
|
+
providerInstance = null;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
function getDefaultDbPath() {
|
|
355
|
+
const os = __require("os");
|
|
356
|
+
const path = __require("path");
|
|
357
|
+
const home = os.homedir();
|
|
358
|
+
const dataHome = process.env.XDG_DATA_HOME || path.join(home, ".local", "share");
|
|
359
|
+
return path.join(dataHome, "roy-agent", "traces.db");
|
|
360
|
+
}
|
|
361
|
+
var providerInstance = null;
|
|
362
|
+
var init_tracer_provider = __esm(() => {
|
|
363
|
+
init_span_storage();
|
|
364
|
+
init_propagation();
|
|
365
|
+
init_types();
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
export { serialize, parse, propagation, init_propagation, SpanKind, SpanStatus, init_types, OTelTracerProvider, getTracerProvider, resetTracerProvider, exports_tracer_provider, init_tracer_provider };
|