@prefactor/core 0.1.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 (43) hide show
  1. package/dist/config.d.ts +259 -0
  2. package/dist/config.d.ts.map +1 -0
  3. package/dist/config.js +110 -0
  4. package/dist/config.js.map +1 -0
  5. package/dist/index.cjs +642 -0
  6. package/dist/index.cjs.map +17 -0
  7. package/dist/index.d.ts +10 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +610 -0
  10. package/dist/index.js.map +17 -0
  11. package/dist/tracing/context.d.ts +53 -0
  12. package/dist/tracing/context.d.ts.map +1 -0
  13. package/dist/tracing/context.js +66 -0
  14. package/dist/tracing/context.js.map +1 -0
  15. package/dist/tracing/span.d.ts +68 -0
  16. package/dist/tracing/span.d.ts.map +1 -0
  17. package/dist/tracing/span.js +21 -0
  18. package/dist/tracing/span.js.map +1 -0
  19. package/dist/tracing/tracer.d.ts +100 -0
  20. package/dist/tracing/tracer.d.ts.map +1 -0
  21. package/dist/tracing/tracer.js +151 -0
  22. package/dist/tracing/tracer.js.map +1 -0
  23. package/dist/transport/base.d.ts +38 -0
  24. package/dist/transport/base.d.ts.map +1 -0
  25. package/dist/transport/base.js +2 -0
  26. package/dist/transport/base.js.map +1 -0
  27. package/dist/transport/http.d.ts +90 -0
  28. package/dist/transport/http.d.ts.map +1 -0
  29. package/dist/transport/http.js +399 -0
  30. package/dist/transport/http.js.map +1 -0
  31. package/dist/transport/stdio.d.ts +48 -0
  32. package/dist/transport/stdio.d.ts.map +1 -0
  33. package/dist/transport/stdio.js +71 -0
  34. package/dist/transport/stdio.js.map +1 -0
  35. package/dist/utils/logging.d.ts +29 -0
  36. package/dist/utils/logging.d.ts.map +1 -0
  37. package/dist/utils/logging.js +71 -0
  38. package/dist/utils/logging.js.map +1 -0
  39. package/dist/utils/serialization.d.ts +24 -0
  40. package/dist/utils/serialization.d.ts.map +1 -0
  41. package/dist/utils/serialization.js +60 -0
  42. package/dist/utils/serialization.js.map +1 -0
  43. package/package.json +36 -0
package/dist/index.js ADDED
@@ -0,0 +1,610 @@
1
+ // packages/core/src/config.ts
2
+ import { z } from "zod";
3
+ var HttpTransportConfigSchema = z.object({
4
+ apiUrl: z.string().url(),
5
+ apiToken: z.string().min(1),
6
+ agentId: z.string().optional(),
7
+ agentVersion: z.string().optional(),
8
+ agentName: z.string().optional(),
9
+ agentDescription: z.string().optional(),
10
+ agentSchema: z.record(z.unknown()).optional(),
11
+ agentSchemaVersion: z.string().optional(),
12
+ skipSchema: z.boolean().default(false),
13
+ requestTimeout: z.number().positive().default(30000),
14
+ connectTimeout: z.number().positive().default(1e4),
15
+ maxRetries: z.number().int().nonnegative().default(3),
16
+ initialRetryDelay: z.number().positive().default(1000),
17
+ maxRetryDelay: z.number().positive().default(60000),
18
+ retryMultiplier: z.number().positive().default(2)
19
+ });
20
+ var PartialHttpConfigSchema = z.object({
21
+ apiUrl: z.string().url(),
22
+ apiToken: z.string().min(1),
23
+ agentId: z.string().optional(),
24
+ agentVersion: z.string().optional(),
25
+ agentName: z.string().optional(),
26
+ agentDescription: z.string().optional(),
27
+ agentSchema: z.record(z.unknown()).optional(),
28
+ agentSchemaVersion: z.string().optional(),
29
+ skipSchema: z.boolean().optional(),
30
+ requestTimeout: z.number().positive().optional(),
31
+ connectTimeout: z.number().positive().optional(),
32
+ maxRetries: z.number().int().nonnegative().optional(),
33
+ initialRetryDelay: z.number().positive().optional(),
34
+ maxRetryDelay: z.number().positive().optional(),
35
+ retryMultiplier: z.number().positive().optional()
36
+ });
37
+ var ConfigSchema = z.object({
38
+ transportType: z.enum(["stdio", "http"]).default("stdio"),
39
+ sampleRate: z.number().min(0).max(1).default(1),
40
+ captureInputs: z.boolean().default(true),
41
+ captureOutputs: z.boolean().default(true),
42
+ maxInputLength: z.number().int().positive().default(1e4),
43
+ maxOutputLength: z.number().int().positive().default(1e4),
44
+ httpConfig: PartialHttpConfigSchema.optional()
45
+ });
46
+ function createConfig(options) {
47
+ const config = {
48
+ transportType: options?.transportType ?? process.env.PREFACTOR_TRANSPORT ?? "stdio",
49
+ sampleRate: options?.sampleRate ?? parseFloat(process.env.PREFACTOR_SAMPLE_RATE ?? "1.0"),
50
+ captureInputs: options?.captureInputs ?? process.env.PREFACTOR_CAPTURE_INPUTS !== "false",
51
+ captureOutputs: options?.captureOutputs ?? process.env.PREFACTOR_CAPTURE_OUTPUTS !== "false",
52
+ maxInputLength: options?.maxInputLength ?? parseInt(process.env.PREFACTOR_MAX_INPUT_LENGTH ?? "10000", 10),
53
+ maxOutputLength: options?.maxOutputLength ?? parseInt(process.env.PREFACTOR_MAX_OUTPUT_LENGTH ?? "10000", 10),
54
+ httpConfig: options?.httpConfig
55
+ };
56
+ return ConfigSchema.parse(config);
57
+ }
58
+ // packages/core/src/tracing/context.ts
59
+ import { AsyncLocalStorage } from "node:async_hooks";
60
+ var spanStorage = new AsyncLocalStorage;
61
+
62
+ class SpanContext {
63
+ static getCurrent() {
64
+ return spanStorage.getStore();
65
+ }
66
+ static run(span, fn) {
67
+ return spanStorage.run(span, fn);
68
+ }
69
+ static async runAsync(span, fn) {
70
+ return spanStorage.run(span, fn);
71
+ }
72
+ static clear() {
73
+ spanStorage.disable();
74
+ }
75
+ }
76
+ // packages/core/src/tracing/span.ts
77
+ var SpanType;
78
+ ((SpanType2) => {
79
+ SpanType2["AGENT"] = "agent";
80
+ SpanType2["LLM"] = "llm";
81
+ SpanType2["TOOL"] = "tool";
82
+ SpanType2["CHAIN"] = "chain";
83
+ SpanType2["RETRIEVER"] = "retriever";
84
+ })(SpanType ||= {});
85
+ var SpanStatus;
86
+ ((SpanStatus2) => {
87
+ SpanStatus2["RUNNING"] = "running";
88
+ SpanStatus2["SUCCESS"] = "success";
89
+ SpanStatus2["ERROR"] = "error";
90
+ })(SpanStatus ||= {});
91
+ // packages/core/src/tracing/tracer.ts
92
+ import { generate, generatePartition } from "@prefactor/pfid";
93
+ class Tracer {
94
+ transport;
95
+ partition;
96
+ constructor(transport, partition) {
97
+ this.transport = transport;
98
+ this.partition = partition ?? generatePartition();
99
+ }
100
+ startSpan(options) {
101
+ const spanId = generate(this.partition);
102
+ const traceId = options.traceId ?? generate(this.partition);
103
+ const span = {
104
+ spanId,
105
+ parentSpanId: options.parentSpanId ?? null,
106
+ traceId,
107
+ name: options.name,
108
+ spanType: options.spanType,
109
+ startTime: Date.now(),
110
+ endTime: null,
111
+ status: "running" /* RUNNING */,
112
+ inputs: options.inputs,
113
+ outputs: null,
114
+ tokenUsage: null,
115
+ error: null,
116
+ metadata: options.metadata ?? {},
117
+ tags: options.tags ?? []
118
+ };
119
+ if (options.spanType === "agent") {
120
+ try {
121
+ this.transport.emit(span);
122
+ } catch (error) {
123
+ console.error("Failed to emit agent span:", error);
124
+ }
125
+ }
126
+ return span;
127
+ }
128
+ endSpan(span, options) {
129
+ span.endTime = Date.now();
130
+ span.outputs = options?.outputs ?? null;
131
+ span.tokenUsage = options?.tokenUsage ?? null;
132
+ if (options?.error) {
133
+ span.status = "error" /* ERROR */;
134
+ span.error = {
135
+ errorType: options.error.constructor.name,
136
+ message: options.error.message,
137
+ stacktrace: options.error.stack ?? ""
138
+ };
139
+ } else {
140
+ span.status = "success" /* SUCCESS */;
141
+ }
142
+ try {
143
+ if (span.spanType === "agent") {
144
+ this.transport.finishSpan(span.spanId, span.endTime);
145
+ } else {
146
+ this.transport.emit(span);
147
+ }
148
+ } catch (error) {
149
+ console.error("Failed to emit/finish span:", error);
150
+ }
151
+ }
152
+ startAgentInstance() {
153
+ try {
154
+ this.transport.startAgentInstance();
155
+ } catch (error) {
156
+ console.error("Failed to start agent instance:", error);
157
+ }
158
+ }
159
+ finishAgentInstance() {
160
+ try {
161
+ this.transport.finishAgentInstance();
162
+ } catch (error) {
163
+ console.error("Failed to finish agent instance:", error);
164
+ }
165
+ }
166
+ async close() {
167
+ try {
168
+ await this.transport.close();
169
+ } catch (error) {
170
+ console.error("Failed to close transport:", error);
171
+ }
172
+ }
173
+ }
174
+ // packages/core/src/utils/logging.ts
175
+ class Logger {
176
+ namespace;
177
+ static level = 1 /* INFO */;
178
+ constructor(namespace) {
179
+ this.namespace = namespace;
180
+ }
181
+ debug(message, ...args) {
182
+ if (Logger.level <= 0 /* DEBUG */) {
183
+ console.debug(`[prefactor:${this.namespace}] ${message}`, ...args);
184
+ }
185
+ }
186
+ info(message, ...args) {
187
+ if (Logger.level <= 1 /* INFO */) {
188
+ console.info(`[prefactor:${this.namespace}] ${message}`, ...args);
189
+ }
190
+ }
191
+ warn(message, ...args) {
192
+ if (Logger.level <= 2 /* WARN */) {
193
+ console.warn(`[prefactor:${this.namespace}] ${message}`, ...args);
194
+ }
195
+ }
196
+ error(message, ...args) {
197
+ if (Logger.level <= 3 /* ERROR */) {
198
+ console.error(`[prefactor:${this.namespace}] ${message}`, ...args);
199
+ }
200
+ }
201
+ static setLevel(level) {
202
+ const levelMap = {
203
+ debug: 0 /* DEBUG */,
204
+ info: 1 /* INFO */,
205
+ warn: 2 /* WARN */,
206
+ error: 3 /* ERROR */
207
+ };
208
+ Logger.level = levelMap[level];
209
+ }
210
+ }
211
+ function getLogger(namespace) {
212
+ return new Logger(namespace);
213
+ }
214
+ function configureLogging() {
215
+ const level = process.env.PREFACTOR_LOG_LEVEL?.toLowerCase();
216
+ if (level) {
217
+ Logger.setLevel(level);
218
+ }
219
+ }
220
+
221
+ // packages/core/src/transport/http.ts
222
+ var logger = getLogger("http-transport");
223
+
224
+ class HttpTransport {
225
+ config;
226
+ queue = [];
227
+ processing = false;
228
+ closed = false;
229
+ agentInstanceId = null;
230
+ spanIdMap = new Map;
231
+ constructor(config) {
232
+ this.config = config;
233
+ this.startProcessing();
234
+ }
235
+ emit(span) {
236
+ if (this.closed) {
237
+ return;
238
+ }
239
+ this.queue.push({ type: "span", data: span });
240
+ }
241
+ finishSpan(spanId, endTime) {
242
+ if (this.closed) {
243
+ return;
244
+ }
245
+ const timestamp = new Date(endTime).toISOString();
246
+ this.queue.push({ type: "finish_span", data: { spanId, timestamp } });
247
+ }
248
+ startAgentInstance() {
249
+ if (this.closed) {
250
+ return;
251
+ }
252
+ this.queue.push({ type: "start_agent", data: null });
253
+ }
254
+ finishAgentInstance() {
255
+ if (this.closed) {
256
+ return;
257
+ }
258
+ this.queue.push({ type: "finish_agent", data: null });
259
+ }
260
+ async startProcessing() {
261
+ this.processing = true;
262
+ while (!this.closed || this.queue.length > 0) {
263
+ if (this.queue.length === 0) {
264
+ await new Promise((resolve) => setTimeout(resolve, 100));
265
+ continue;
266
+ }
267
+ const item = this.queue.shift();
268
+ if (!item)
269
+ continue;
270
+ try {
271
+ if (!this.agentInstanceId && item.type !== "start_agent") {
272
+ await this.ensureAgentRegistered();
273
+ }
274
+ switch (item.type) {
275
+ case "span":
276
+ await this.sendSpan(item.data);
277
+ break;
278
+ case "finish_span":
279
+ await this.finishSpanHttp(item.data);
280
+ break;
281
+ case "start_agent":
282
+ await this.startAgentInstanceHttp();
283
+ break;
284
+ case "finish_agent":
285
+ await this.finishAgentInstanceHttp();
286
+ break;
287
+ }
288
+ } catch (error) {
289
+ logger.error("Error processing queue item:", error);
290
+ }
291
+ }
292
+ this.processing = false;
293
+ }
294
+ async sendSpan(span, retry = 0) {
295
+ const url = `${this.config.apiUrl}/api/v1/agent_spans`;
296
+ const payload = this.transformSpanToApiFormat(span);
297
+ try {
298
+ const response = await fetch(url, {
299
+ method: "POST",
300
+ headers: {
301
+ Authorization: `Bearer ${this.config.apiToken}`,
302
+ "Content-Type": "application/json"
303
+ },
304
+ body: JSON.stringify(payload),
305
+ signal: AbortSignal.timeout(this.config.requestTimeout)
306
+ });
307
+ if (response.ok) {
308
+ const data = await response.json();
309
+ const backendSpanId = data?.details?.id;
310
+ if (backendSpanId) {
311
+ this.spanIdMap.set(span.spanId, backendSpanId);
312
+ }
313
+ return;
314
+ }
315
+ if ((response.status >= 500 || response.status === 429) && retry < this.config.maxRetries) {
316
+ const delay = Math.min(this.config.initialRetryDelay * this.config.retryMultiplier ** retry, this.config.maxRetryDelay);
317
+ logger.debug(`Retrying span send after ${delay}ms (attempt ${retry + 1})`);
318
+ await new Promise((resolve) => setTimeout(resolve, delay));
319
+ return this.sendSpan(span, retry + 1);
320
+ }
321
+ logger.error(`Failed to send span: ${response.status} ${response.statusText}`);
322
+ } catch (error) {
323
+ logger.error("Error sending span:", error);
324
+ if (retry < this.config.maxRetries) {
325
+ const delay = Math.min(this.config.initialRetryDelay * this.config.retryMultiplier ** retry, this.config.maxRetryDelay);
326
+ await new Promise((resolve) => setTimeout(resolve, delay));
327
+ return this.sendSpan(span, retry + 1);
328
+ }
329
+ }
330
+ }
331
+ transformSpanToApiFormat(span) {
332
+ const startedAt = new Date(span.startTime).toISOString();
333
+ const finishedAt = span.endTime ? new Date(span.endTime).toISOString() : null;
334
+ const payload = {
335
+ span_id: span.spanId,
336
+ trace_id: span.traceId,
337
+ name: span.name,
338
+ status: span.status,
339
+ inputs: span.inputs,
340
+ outputs: span.outputs,
341
+ metadata: span.metadata,
342
+ tags: span.tags,
343
+ token_usage: null,
344
+ error: null
345
+ };
346
+ if (span.tokenUsage) {
347
+ payload.token_usage = {
348
+ prompt_tokens: span.tokenUsage.promptTokens,
349
+ completion_tokens: span.tokenUsage.completionTokens,
350
+ total_tokens: span.tokenUsage.totalTokens
351
+ };
352
+ }
353
+ if (span.error) {
354
+ payload.error = {
355
+ error_type: span.error.errorType,
356
+ message: span.error.message,
357
+ stacktrace: span.error.stacktrace
358
+ };
359
+ }
360
+ const parentSpanId = span.parentSpanId ? this.spanIdMap.get(span.parentSpanId) ?? null : null;
361
+ return {
362
+ details: {
363
+ agent_instance_id: this.agentInstanceId,
364
+ schema_name: span.spanType,
365
+ payload,
366
+ parent_span_id: parentSpanId,
367
+ started_at: startedAt,
368
+ finished_at: finishedAt
369
+ }
370
+ };
371
+ }
372
+ getDefaultSchema() {
373
+ return {
374
+ external_identifier: "1.0.0",
375
+ span_schemas: {
376
+ agent: {
377
+ type: "object",
378
+ properties: { type: { type: "string", const: "agent" } }
379
+ },
380
+ llm: {
381
+ type: "object",
382
+ properties: { type: { type: "string", const: "llm" } }
383
+ },
384
+ tool: {
385
+ type: "object",
386
+ properties: { type: { type: "string", const: "tool" } }
387
+ },
388
+ chain: {
389
+ type: "object",
390
+ properties: { type: { type: "string", const: "chain" } }
391
+ },
392
+ retriever: {
393
+ type: "object",
394
+ properties: { type: { type: "string", const: "retriever" } }
395
+ }
396
+ }
397
+ };
398
+ }
399
+ async ensureAgentRegistered() {
400
+ if (this.agentInstanceId) {
401
+ return;
402
+ }
403
+ const url = `${this.config.apiUrl}/api/v1/agent_instance/register`;
404
+ const payload = {};
405
+ if (this.config.agentId)
406
+ payload.agent_id = this.config.agentId;
407
+ if (this.config.agentVersion) {
408
+ payload.agent_version = {
409
+ external_identifier: this.config.agentVersion,
410
+ name: this.config.agentName || "Agent",
411
+ description: this.config.agentDescription || ""
412
+ };
413
+ }
414
+ if (this.config.skipSchema) {
415
+ logger.debug("Skipping schema in registration (skipSchema=true)");
416
+ } else if (this.config.agentSchema) {
417
+ logger.debug("Using custom agent schema");
418
+ payload.agent_schema_version = this.config.agentSchema;
419
+ } else if (this.config.agentSchemaVersion) {
420
+ logger.debug(`Using schema version: ${this.config.agentSchemaVersion}`);
421
+ payload.agent_schema_version = {
422
+ external_identifier: this.config.agentSchemaVersion
423
+ };
424
+ } else {
425
+ logger.debug("Using default hardcoded schema (v1.0.0)");
426
+ payload.agent_schema_version = this.getDefaultSchema();
427
+ }
428
+ try {
429
+ const response = await fetch(url, {
430
+ method: "POST",
431
+ headers: {
432
+ Authorization: `Bearer ${this.config.apiToken}`,
433
+ "Content-Type": "application/json"
434
+ },
435
+ body: JSON.stringify(payload),
436
+ signal: AbortSignal.timeout(this.config.requestTimeout)
437
+ });
438
+ if (response.ok) {
439
+ const data = await response.json();
440
+ this.agentInstanceId = data?.details?.id ?? null;
441
+ logger.debug(`Registered agent instance: ${this.agentInstanceId}`);
442
+ } else {
443
+ logger.error(`Failed to register agent: ${response.status} ${response.statusText}`);
444
+ }
445
+ } catch (error) {
446
+ logger.error("Error registering agent:", error);
447
+ }
448
+ }
449
+ async startAgentInstanceHttp() {
450
+ await this.ensureAgentRegistered();
451
+ if (!this.agentInstanceId) {
452
+ logger.error("Cannot start agent instance: not registered");
453
+ return;
454
+ }
455
+ const url = `${this.config.apiUrl}/api/v1/agent_instance/${this.agentInstanceId}/start`;
456
+ try {
457
+ const response = await fetch(url, {
458
+ method: "POST",
459
+ headers: {
460
+ Authorization: `Bearer ${this.config.apiToken}`,
461
+ "Content-Type": "application/json"
462
+ },
463
+ body: JSON.stringify({}),
464
+ signal: AbortSignal.timeout(this.config.requestTimeout)
465
+ });
466
+ if (!response.ok) {
467
+ logger.error(`Failed to start agent instance: ${response.status} ${response.statusText}`);
468
+ }
469
+ } catch (error) {
470
+ logger.error("Error starting agent instance:", error);
471
+ }
472
+ }
473
+ async finishAgentInstanceHttp() {
474
+ if (!this.agentInstanceId) {
475
+ logger.error("Cannot finish agent instance: not registered");
476
+ return;
477
+ }
478
+ const url = `${this.config.apiUrl}/api/v1/agent_instance/${this.agentInstanceId}/finish`;
479
+ try {
480
+ const response = await fetch(url, {
481
+ method: "POST",
482
+ headers: {
483
+ Authorization: `Bearer ${this.config.apiToken}`,
484
+ "Content-Type": "application/json"
485
+ },
486
+ body: JSON.stringify({}),
487
+ signal: AbortSignal.timeout(this.config.requestTimeout)
488
+ });
489
+ if (!response.ok) {
490
+ logger.error(`Failed to finish agent instance: ${response.status} ${response.statusText}`);
491
+ }
492
+ } catch (error) {
493
+ logger.error("Error finishing agent instance:", error);
494
+ }
495
+ }
496
+ async finishSpanHttp(data) {
497
+ const backendSpanId = this.spanIdMap.get(data.spanId);
498
+ if (!backendSpanId) {
499
+ logger.warn(`Cannot finish span ${data.spanId}: backend ID not found`);
500
+ return;
501
+ }
502
+ const url = `${this.config.apiUrl}/api/v1/agent_spans/${backendSpanId}/finish`;
503
+ try {
504
+ const response = await fetch(url, {
505
+ method: "POST",
506
+ headers: {
507
+ Authorization: `Bearer ${this.config.apiToken}`,
508
+ "Content-Type": "application/json"
509
+ },
510
+ body: JSON.stringify({ timestamp: data.timestamp }),
511
+ signal: AbortSignal.timeout(this.config.requestTimeout)
512
+ });
513
+ if (!response.ok) {
514
+ logger.error(`Failed to finish span: ${response.status} ${response.statusText}`);
515
+ }
516
+ } catch (error) {
517
+ logger.error("Error finishing span:", error);
518
+ }
519
+ }
520
+ async close() {
521
+ this.closed = true;
522
+ const timeout = 1e4;
523
+ const start = Date.now();
524
+ while (this.processing && Date.now() - start < timeout) {
525
+ await new Promise((resolve) => setTimeout(resolve, 100));
526
+ }
527
+ if (this.processing) {
528
+ logger.warn("Transport closed with pending queue items");
529
+ }
530
+ }
531
+ }
532
+ // packages/core/src/utils/serialization.ts
533
+ function truncateString(value, maxLength) {
534
+ if (value.length <= maxLength) {
535
+ return value;
536
+ }
537
+ return `${value.slice(0, maxLength)}... [truncated]`;
538
+ }
539
+ function serializeValue(value, maxLength = 1e4) {
540
+ if (value === null || value === undefined) {
541
+ return value;
542
+ }
543
+ if (typeof value === "boolean" || typeof value === "number") {
544
+ return value;
545
+ }
546
+ if (typeof value === "string") {
547
+ return maxLength !== null ? truncateString(value, maxLength) : value;
548
+ }
549
+ if (Array.isArray(value)) {
550
+ return value.map((item) => serializeValue(item, maxLength));
551
+ }
552
+ if (typeof value === "object") {
553
+ const result = {};
554
+ for (const [key, val] of Object.entries(value)) {
555
+ result[key] = serializeValue(val, maxLength);
556
+ }
557
+ return result;
558
+ }
559
+ try {
560
+ return String(value);
561
+ } catch {
562
+ return `<${typeof value} object>`;
563
+ }
564
+ }
565
+
566
+ // packages/core/src/transport/stdio.ts
567
+ class StdioTransport {
568
+ closed = false;
569
+ writeLock = Promise.resolve();
570
+ emit(span) {
571
+ if (this.closed) {
572
+ return;
573
+ }
574
+ this.writeLock = this.writeLock.then(async () => {
575
+ try {
576
+ const serialized = serializeValue(span);
577
+ const json = JSON.stringify(serialized);
578
+ await Bun.write(Bun.stdout, `${json}
579
+ `);
580
+ } catch (error) {
581
+ console.error("Failed to emit span to stdout:", error);
582
+ }
583
+ });
584
+ }
585
+ finishSpan() {}
586
+ startAgentInstance() {}
587
+ finishAgentInstance() {}
588
+ async close() {
589
+ this.closed = true;
590
+ await this.writeLock;
591
+ }
592
+ }
593
+ export {
594
+ truncateString,
595
+ serializeValue,
596
+ getLogger,
597
+ createConfig,
598
+ configureLogging,
599
+ Tracer,
600
+ StdioTransport,
601
+ SpanType,
602
+ SpanStatus,
603
+ SpanContext,
604
+ PartialHttpConfigSchema,
605
+ HttpTransportConfigSchema,
606
+ HttpTransport,
607
+ ConfigSchema
608
+ };
609
+
610
+ //# debugId=48E67D6DE4160D4864756E2164756E21