langwatch 1.11.0 → 1.12.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.
- package/dist/agent/index.d.mts +7 -1
- package/dist/agent/index.d.ts +7 -1
- package/dist/agent/index.js +26 -1
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/index.mjs +26 -1
- package/dist/agent/index.mjs.map +1 -1
- package/dist/{chunk-2PD3YA5H.js → chunk-3WIN2UXZ.js} +2 -2
- package/dist/{chunk-2PD3YA5H.js.map → chunk-3WIN2UXZ.js.map} +1 -1
- package/dist/{chunk-VMNKKJVI.mjs → chunk-BAE4KYKJ.mjs} +2 -2
- package/dist/{chunk-BS5CNZ5S.mjs → chunk-F5UYCQT3.mjs} +2 -2
- package/dist/{chunk-BS5CNZ5S.mjs.map → chunk-F5UYCQT3.mjs.map} +1 -1
- package/dist/{chunk-AJDFFRSW.js → chunk-QLYKPPAW.js} +12 -12
- package/dist/{chunk-AJDFFRSW.js.map → chunk-QLYKPPAW.js.map} +1 -1
- package/dist/cli/bundle.js +295 -217
- package/dist/{implementation-aczLxVpV.d.mts → implementation-BA3xa5UR.d.mts} +1 -1
- package/dist/{implementation-D58yPTJW.d.ts → implementation-rpImK8WS.d.ts} +1 -1
- package/dist/index.d.mts +55 -2
- package/dist/index.d.ts +55 -2
- package/dist/index.js +89 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -2
- package/dist/index.mjs.map +1 -1
- package/dist/observability-sdk/index.d.mts +3 -3
- package/dist/observability-sdk/index.d.ts +3 -3
- package/dist/observability-sdk/index.js +2 -2
- package/dist/observability-sdk/index.mjs +1 -1
- package/dist/observability-sdk/instrumentation/langchain/index.d.mts +1 -1
- package/dist/observability-sdk/instrumentation/langchain/index.d.ts +1 -1
- package/dist/observability-sdk/setup/node/index.js +3 -3
- package/dist/observability-sdk/setup/node/index.mjs +2 -2
- package/dist/{types-D_YNU-VL.d.ts → types-Cr25FO-i.d.ts} +395 -293
- package/dist/{types-BmMuUDrO.d.mts → types-DJyJypkv.d.mts} +395 -293
- package/package.json +1 -1
- /package/dist/{chunk-VMNKKJVI.mjs.map → chunk-BAE4KYKJ.mjs.map} +0 -0
package/dist/agent/index.mjs
CHANGED
|
@@ -44,7 +44,7 @@ import * as os from "os";
|
|
|
44
44
|
import { randomUUID } from "crypto";
|
|
45
45
|
|
|
46
46
|
// package.json
|
|
47
|
-
var version = "1.
|
|
47
|
+
var version = "1.12.0";
|
|
48
48
|
|
|
49
49
|
// src/internal/constants.ts
|
|
50
50
|
var LANGWATCH_SDK_VERSION = version;
|
|
@@ -1169,6 +1169,8 @@ var AgentClient = class {
|
|
|
1169
1169
|
try {
|
|
1170
1170
|
const result = await context.with(parent, () => runtime.run(call));
|
|
1171
1171
|
if (entry.cancelled) return;
|
|
1172
|
+
this.releaseCall({ callId: frame.callId, entry });
|
|
1173
|
+
await this.flushSpans();
|
|
1172
1174
|
this.send({
|
|
1173
1175
|
type: "result",
|
|
1174
1176
|
protocol: PROTOCOL_VERSION,
|
|
@@ -1181,11 +1183,34 @@ var AgentClient = class {
|
|
|
1181
1183
|
const code = error instanceof AgentParameterError ? error.code : "agent_call_failed";
|
|
1182
1184
|
const message = describeError(error);
|
|
1183
1185
|
this.logger.warn(`agent "${runtime.name}" call ${frame.callId} failed: ${message}`);
|
|
1186
|
+
this.releaseCall({ callId: frame.callId, entry });
|
|
1187
|
+
await this.flushSpans();
|
|
1184
1188
|
this.sendError({ callId: frame.callId, code, message });
|
|
1185
1189
|
} finally {
|
|
1186
1190
|
this.releaseCall({ callId: frame.callId, entry });
|
|
1187
1191
|
}
|
|
1188
1192
|
}
|
|
1193
|
+
/**
|
|
1194
|
+
* Exports the spans of the call now instead of at the exporter's next
|
|
1195
|
+
* schedule. The judge reads the agent's spans right after the last turn,
|
|
1196
|
+
* and a batch exporter would otherwise hold them for seconds, which is what
|
|
1197
|
+
* made the judge report the spans missing.
|
|
1198
|
+
*
|
|
1199
|
+
* The call awaits this before it sends its result or its error: the frame is
|
|
1200
|
+
* what tells the platform the turn is over, so a frame that goes out first
|
|
1201
|
+
* lets the judge read the call while its spans are still in the exporter.
|
|
1202
|
+
*/
|
|
1203
|
+
async flushSpans() {
|
|
1204
|
+
const provider = trace.getTracerProvider();
|
|
1205
|
+
const delegate = typeof provider.getDelegate === "function" ? provider.getDelegate() : provider;
|
|
1206
|
+
const flush = delegate?.forceFlush;
|
|
1207
|
+
if (typeof flush !== "function") return;
|
|
1208
|
+
try {
|
|
1209
|
+
await flush.call(delegate);
|
|
1210
|
+
} catch (error) {
|
|
1211
|
+
this.logger.debug(`span flush after a call failed: ${describeError(error)}`);
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1189
1214
|
/** Frees the slot the call holds and drops its deadline timer. */
|
|
1190
1215
|
releaseCall({ callId, entry }) {
|
|
1191
1216
|
if (entry.timer) {
|