@probelabs/probe 0.6.0-rc294 → 0.6.0-rc296
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 +7 -0
- package/bin/binaries/{probe-v0.6.0-rc294-aarch64-apple-darwin.tar.gz → probe-v0.6.0-rc296-aarch64-apple-darwin.tar.gz} +0 -0
- package/bin/binaries/{probe-v0.6.0-rc294-aarch64-unknown-linux-musl.tar.gz → probe-v0.6.0-rc296-aarch64-unknown-linux-musl.tar.gz} +0 -0
- package/bin/binaries/{probe-v0.6.0-rc294-x86_64-apple-darwin.tar.gz → probe-v0.6.0-rc296-x86_64-apple-darwin.tar.gz} +0 -0
- package/bin/binaries/{probe-v0.6.0-rc294-x86_64-pc-windows-msvc.zip → probe-v0.6.0-rc296-x86_64-pc-windows-msvc.zip} +0 -0
- package/bin/binaries/{probe-v0.6.0-rc294-x86_64-unknown-linux-musl.tar.gz → probe-v0.6.0-rc296-x86_64-unknown-linux-musl.tar.gz} +0 -0
- package/build/agent/ProbeAgent.d.ts +10 -0
- package/build/agent/ProbeAgent.js +868 -29
- package/build/agent/mcp/client.js +81 -4
- package/build/agent/mcp/xmlBridge.js +11 -0
- package/build/agent/otelLogBridge.js +184 -0
- package/build/agent/simpleTelemetry.js +8 -0
- package/build/delegate.js +75 -6
- package/build/index.js +6 -2
- package/build/tools/common.js +84 -11
- package/build/tools/vercel.js +78 -18
- package/cjs/agent/ProbeAgent.cjs +1004 -48
- package/cjs/agent/simpleTelemetry.cjs +112 -0
- package/cjs/index.cjs +1116 -48
- package/index.d.ts +26 -0
- package/package.json +1 -1
- package/src/agent/ProbeAgent.d.ts +10 -0
- package/src/agent/ProbeAgent.js +868 -29
- package/src/agent/mcp/client.js +81 -4
- package/src/agent/mcp/xmlBridge.js +11 -0
- package/src/agent/otelLogBridge.js +184 -0
- package/src/agent/simpleTelemetry.js +8 -0
- package/src/delegate.js +75 -6
- package/src/index.js +6 -2
- package/src/tools/common.js +84 -11
- package/src/tools/vercel.js +78 -18
|
@@ -27,6 +27,117 @@ __export(simpleTelemetry_exports, {
|
|
|
27
27
|
module.exports = __toCommonJS(simpleTelemetry_exports);
|
|
28
28
|
var import_fs = require("fs");
|
|
29
29
|
var import_path = require("path");
|
|
30
|
+
|
|
31
|
+
// src/agent/otelLogBridge.js
|
|
32
|
+
var import_module = require("module");
|
|
33
|
+
var _require = (0, import_module.createRequire)("file:///");
|
|
34
|
+
var OTEL_SEVERITY = {
|
|
35
|
+
log: 9,
|
|
36
|
+
// INFO
|
|
37
|
+
info: 9,
|
|
38
|
+
// INFO
|
|
39
|
+
warn: 13,
|
|
40
|
+
// WARN
|
|
41
|
+
error: 17,
|
|
42
|
+
// ERROR
|
|
43
|
+
debug: 5
|
|
44
|
+
// DEBUG
|
|
45
|
+
};
|
|
46
|
+
var patched = false;
|
|
47
|
+
var originals = {};
|
|
48
|
+
var otelApi = null;
|
|
49
|
+
var otelApiAttempted = false;
|
|
50
|
+
var otelLogger = null;
|
|
51
|
+
var otelLoggerAttempted = false;
|
|
52
|
+
function getOtelApi() {
|
|
53
|
+
if (otelApiAttempted) return otelApi;
|
|
54
|
+
otelApiAttempted = true;
|
|
55
|
+
try {
|
|
56
|
+
otelApi = (function(name) {
|
|
57
|
+
return _require(name);
|
|
58
|
+
})("@opentelemetry/api");
|
|
59
|
+
} catch {
|
|
60
|
+
}
|
|
61
|
+
return otelApi;
|
|
62
|
+
}
|
|
63
|
+
function getOtelLogger() {
|
|
64
|
+
if (otelLoggerAttempted) return otelLogger;
|
|
65
|
+
otelLoggerAttempted = true;
|
|
66
|
+
try {
|
|
67
|
+
const { logs } = (function(name) {
|
|
68
|
+
return _require(name);
|
|
69
|
+
})("@opentelemetry/api-logs");
|
|
70
|
+
otelLogger = logs.getLogger("probe-agent");
|
|
71
|
+
} catch {
|
|
72
|
+
}
|
|
73
|
+
return otelLogger;
|
|
74
|
+
}
|
|
75
|
+
function getTraceSuffix() {
|
|
76
|
+
try {
|
|
77
|
+
const api = getOtelApi();
|
|
78
|
+
if (!api) return "";
|
|
79
|
+
const span = api.trace.getSpan(api.context.active());
|
|
80
|
+
const ctx = span?.spanContext?.();
|
|
81
|
+
if (!ctx?.traceId) return "";
|
|
82
|
+
return ` [trace_id=${ctx.traceId} span_id=${ctx.spanId}]`;
|
|
83
|
+
} catch {
|
|
84
|
+
return "";
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function emitOtelLog(msg, level) {
|
|
88
|
+
try {
|
|
89
|
+
const logger = getOtelLogger();
|
|
90
|
+
if (!logger) return;
|
|
91
|
+
const api = getOtelApi();
|
|
92
|
+
let traceId, spanId;
|
|
93
|
+
if (api) {
|
|
94
|
+
const span = api.trace.getSpan(api.context.active());
|
|
95
|
+
const ctx = span?.spanContext?.();
|
|
96
|
+
if (ctx?.traceId) {
|
|
97
|
+
traceId = ctx.traceId;
|
|
98
|
+
spanId = ctx.spanId;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
logger.emit({
|
|
102
|
+
severityNumber: OTEL_SEVERITY[level] || 9,
|
|
103
|
+
severityText: level.toUpperCase(),
|
|
104
|
+
body: msg,
|
|
105
|
+
attributes: {
|
|
106
|
+
"probe.logger": true,
|
|
107
|
+
...traceId ? { trace_id: traceId, span_id: spanId } : {}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
} catch {
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function patchConsole() {
|
|
114
|
+
if (patched) return;
|
|
115
|
+
const methods = ["log", "info", "warn", "error"];
|
|
116
|
+
const c = globalThis.console;
|
|
117
|
+
for (const m of methods) {
|
|
118
|
+
const orig = c[m].bind(c);
|
|
119
|
+
originals[m] = orig;
|
|
120
|
+
c[m] = (...args) => {
|
|
121
|
+
const msgParts = args.map(
|
|
122
|
+
(a) => typeof a === "string" ? a : a instanceof Error ? a.message : JSON.stringify(a)
|
|
123
|
+
);
|
|
124
|
+
const msg = msgParts.join(" ");
|
|
125
|
+
emitOtelLog(msg, m === "log" ? "log" : m);
|
|
126
|
+
const suffix = getTraceSuffix();
|
|
127
|
+
if (suffix) {
|
|
128
|
+
if (typeof args[0] === "string") {
|
|
129
|
+
args[0] = args[0] + suffix;
|
|
130
|
+
} else {
|
|
131
|
+
args.push(suffix);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return orig(...args);
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
patched = true;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// src/agent/simpleTelemetry.js
|
|
30
141
|
var SimpleTelemetry = class {
|
|
31
142
|
constructor(options = {}) {
|
|
32
143
|
this.serviceName = options.serviceName || "probe-agent";
|
|
@@ -460,6 +571,7 @@ function initializeSimpleTelemetryFromOptions(options) {
|
|
|
460
571
|
enableConsole: options.traceConsole,
|
|
461
572
|
filePath: options.traceFile || "./traces.jsonl"
|
|
462
573
|
});
|
|
574
|
+
patchConsole();
|
|
463
575
|
return telemetry;
|
|
464
576
|
}
|
|
465
577
|
// Annotate the CommonJS export names for ESM import in node:
|