mesedi 0.6.0 → 0.7.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.
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LangChain.js integration for Mesedi (Wave 4.C).
|
|
3
|
+
*
|
|
4
|
+
* Ships as a LangChain callback handler that emits Mesedi telemetry.
|
|
5
|
+
* The customer wraps their entry function with `mesedi.wrap()` (which
|
|
6
|
+
* owns the execution boundary) and attaches an instance of this
|
|
7
|
+
* handler to LangChain's `callbacks:` slot (which owns intra-execution
|
|
8
|
+
* events).
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
*
|
|
12
|
+
* import { wrap } from "mesedi";
|
|
13
|
+
* import { MesediLangChainCallbackHandler } from "mesedi/integrations/langchain";
|
|
14
|
+
* import { ChatOpenAI } from "@langchain/openai";
|
|
15
|
+
*
|
|
16
|
+
* export const runAgent = wrap(
|
|
17
|
+
* { agentName: "support-triage" },
|
|
18
|
+
* async (question: string) => {
|
|
19
|
+
* const llm = new ChatOpenAI({ model: "gpt-4o" });
|
|
20
|
+
* const result = await llm.invoke(
|
|
21
|
+
* [{ role: "user", content: question }],
|
|
22
|
+
* { callbacks: [new MesediLangChainCallbackHandler()] },
|
|
23
|
+
* );
|
|
24
|
+
* return String(result.content);
|
|
25
|
+
* },
|
|
26
|
+
* );
|
|
27
|
+
*
|
|
28
|
+
* Design.
|
|
29
|
+
*
|
|
30
|
+
* `mesedi.wrap()` manages the execution boundary (started / completed /
|
|
31
|
+
* crash signature). The callback handler emits the intra-execution
|
|
32
|
+
* events — `llm_call` and `tool_call` — that Mesedi's detectors
|
|
33
|
+
* consume. Splitting responsibility this way lets the customer adopt
|
|
34
|
+
* Mesedi without reshaping their LangChain code: `wrap` goes around
|
|
35
|
+
* the entry point, the handler gets attached at the existing
|
|
36
|
+
* `callbacks:` slot LangChain already accepts.
|
|
37
|
+
*
|
|
38
|
+
* Mirrors the Python `mesedi.integrations.langchain.MesediCallbackHandler`
|
|
39
|
+
* surface. Wire format is byte-identical so backend detectors see one
|
|
40
|
+
* unified event stream whether the customer writes Python or TypeScript.
|
|
41
|
+
*
|
|
42
|
+
* Fail-open posture matches the rest of the SDK: any exception inside
|
|
43
|
+
* a handler method is swallowed and logged via `console.warn`. Never
|
|
44
|
+
* blocks or breaks the customer's LangChain pipeline.
|
|
45
|
+
*
|
|
46
|
+
* Out of scope for v1:
|
|
47
|
+
* - Streaming responses (`handleLLMNewToken`). Receivers see only
|
|
48
|
+
* the final assembled response. Streaming attribution is a v2
|
|
49
|
+
* concern that needs an event-payload schema change.
|
|
50
|
+
* - Per-chain depth tracking. Every chain start fires but we ignore
|
|
51
|
+
* it because `wrap` already owns the execution boundary. A
|
|
52
|
+
* chain-as-execution mode (no `wrap` required) is a later
|
|
53
|
+
* iteration.
|
|
54
|
+
* - Multi-modal content blocks (images in messages). We extract the
|
|
55
|
+
* text parts and ignore the rest.
|
|
56
|
+
*/
|
|
57
|
+
import { BaseCallbackHandler } from "@langchain/core/callbacks/base";
|
|
58
|
+
import type { Serialized } from "@langchain/core/load/serializable";
|
|
59
|
+
import type { BaseMessage } from "@langchain/core/messages";
|
|
60
|
+
/**
|
|
61
|
+
* LangChain callback handler that emits Mesedi events. Attach an
|
|
62
|
+
* instance to any LangChain runnable via the standard `callbacks:`
|
|
63
|
+
* config slot:
|
|
64
|
+
*
|
|
65
|
+
* runnable.invoke(input, { callbacks: [new MesediLangChainCallbackHandler()] });
|
|
66
|
+
*
|
|
67
|
+
* Emits one `llm_call` event per LLM invocation (matching the wire
|
|
68
|
+
* format from `emit_llm_call` and the Anthropic patch) and one
|
|
69
|
+
* `tool_call` event per tool invocation (matching the wire format
|
|
70
|
+
* from `@mesedi.tool`). Both event types feed the standard Mesedi
|
|
71
|
+
* detector chain — drift, identical / similar-call loops,
|
|
72
|
+
* tool-failures, cost-velocity, prompt-injection.
|
|
73
|
+
*
|
|
74
|
+
* Outside a `wrap()` execution context, all emissions silently no-op
|
|
75
|
+
* (matches the rest of Mesedi's observe layer).
|
|
76
|
+
*/
|
|
77
|
+
export declare class MesediLangChainCallbackHandler extends BaseCallbackHandler {
|
|
78
|
+
name: string;
|
|
79
|
+
/**
|
|
80
|
+
* Tell LangChain's dispatcher not to reraise handler exceptions.
|
|
81
|
+
* We already swallow inside each method; this is belt-and-suspenders
|
|
82
|
+
* for any future LangChain version that changes the default.
|
|
83
|
+
*/
|
|
84
|
+
raiseError: boolean;
|
|
85
|
+
private readonly llmStarts;
|
|
86
|
+
private readonly toolStarts;
|
|
87
|
+
handleLLMStart(llm: Serialized, prompts: string[], runId: string, _parentRunId?: string, extraParams?: Record<string, unknown>, _tags?: string[], _metadata?: Record<string, unknown>, _runName?: string): void;
|
|
88
|
+
handleChatModelStart(llm: Serialized, messages: BaseMessage[][], runId: string, _parentRunId?: string, extraParams?: Record<string, unknown>, _tags?: string[], _metadata?: Record<string, unknown>, _runName?: string): void;
|
|
89
|
+
handleLLMEnd(output: unknown, runId: string, _parentRunId?: string, _tags?: string[]): void;
|
|
90
|
+
handleLLMError(_err: unknown, runId: string, _parentRunId?: string, _tags?: string[]): void;
|
|
91
|
+
handleToolStart(tool: Serialized, input: string, runId: string, _parentRunId?: string, _tags?: string[], _metadata?: Record<string, unknown>, _name?: string): void;
|
|
92
|
+
handleToolEnd(output: unknown, runId: string, _parentRunId?: string, _tags?: string[]): void;
|
|
93
|
+
handleToolError(err: unknown, runId: string, _parentRunId?: string, _tags?: string[]): void;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=langchain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"langchain.d.ts","sourceRoot":"","sources":["../../src/integrations/langchain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAcH,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC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M,EAAE,GACf,IAAI;IAuBP,eAAe,CACb,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,MAAM,EACrB,KAAK,CAAC,EAAE,MAAM,EAAE,EAChB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnC,KAAK,CAAC,EAAE,MAAM,GACb,IAAI;IAcP,aAAa,CACX,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,MAAM,EACrB,KAAK,CAAC,EAAE,MAAM,EAAE,GACf,IAAI;IAwBP,eAAe,CACb,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,MAAM,EACrB,KAAK,CAAC,EAAE,MAAM,EAAE,GACf,IAAI;CAoBR"}
|
|
@@ -0,0 +1,549 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LangChain.js integration for Mesedi (Wave 4.C).
|
|
3
|
+
*
|
|
4
|
+
* Ships as a LangChain callback handler that emits Mesedi telemetry.
|
|
5
|
+
* The customer wraps their entry function with `mesedi.wrap()` (which
|
|
6
|
+
* owns the execution boundary) and attaches an instance of this
|
|
7
|
+
* handler to LangChain's `callbacks:` slot (which owns intra-execution
|
|
8
|
+
* events).
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
*
|
|
12
|
+
* import { wrap } from "mesedi";
|
|
13
|
+
* import { MesediLangChainCallbackHandler } from "mesedi/integrations/langchain";
|
|
14
|
+
* import { ChatOpenAI } from "@langchain/openai";
|
|
15
|
+
*
|
|
16
|
+
* export const runAgent = wrap(
|
|
17
|
+
* { agentName: "support-triage" },
|
|
18
|
+
* async (question: string) => {
|
|
19
|
+
* const llm = new ChatOpenAI({ model: "gpt-4o" });
|
|
20
|
+
* const result = await llm.invoke(
|
|
21
|
+
* [{ role: "user", content: question }],
|
|
22
|
+
* { callbacks: [new MesediLangChainCallbackHandler()] },
|
|
23
|
+
* );
|
|
24
|
+
* return String(result.content);
|
|
25
|
+
* },
|
|
26
|
+
* );
|
|
27
|
+
*
|
|
28
|
+
* Design.
|
|
29
|
+
*
|
|
30
|
+
* `mesedi.wrap()` manages the execution boundary (started / completed /
|
|
31
|
+
* crash signature). The callback handler emits the intra-execution
|
|
32
|
+
* events — `llm_call` and `tool_call` — that Mesedi's detectors
|
|
33
|
+
* consume. Splitting responsibility this way lets the customer adopt
|
|
34
|
+
* Mesedi without reshaping their LangChain code: `wrap` goes around
|
|
35
|
+
* the entry point, the handler gets attached at the existing
|
|
36
|
+
* `callbacks:` slot LangChain already accepts.
|
|
37
|
+
*
|
|
38
|
+
* Mirrors the Python `mesedi.integrations.langchain.MesediCallbackHandler`
|
|
39
|
+
* surface. Wire format is byte-identical so backend detectors see one
|
|
40
|
+
* unified event stream whether the customer writes Python or TypeScript.
|
|
41
|
+
*
|
|
42
|
+
* Fail-open posture matches the rest of the SDK: any exception inside
|
|
43
|
+
* a handler method is swallowed and logged via `console.warn`. Never
|
|
44
|
+
* blocks or breaks the customer's LangChain pipeline.
|
|
45
|
+
*
|
|
46
|
+
* Out of scope for v1:
|
|
47
|
+
* - Streaming responses (`handleLLMNewToken`). Receivers see only
|
|
48
|
+
* the final assembled response. Streaming attribution is a v2
|
|
49
|
+
* concern that needs an event-payload schema change.
|
|
50
|
+
* - Per-chain depth tracking. Every chain start fires but we ignore
|
|
51
|
+
* it because `wrap` already owns the execution boundary. A
|
|
52
|
+
* chain-as-execution mode (no `wrap` required) is a later
|
|
53
|
+
* iteration.
|
|
54
|
+
* - Multi-modal content blocks (images in messages). We extract the
|
|
55
|
+
* text parts and ignore the rest.
|
|
56
|
+
*/
|
|
57
|
+
import { getClient } from "../client.js";
|
|
58
|
+
import { currentExecutionContext, newEventId } from "../context.js";
|
|
59
|
+
import { EventType, utcNowRfc3339 } from "../events.js";
|
|
60
|
+
// ── Peer-dep imports ─────────────────────────────────────────────────
|
|
61
|
+
//
|
|
62
|
+
// `@langchain/core` is declared as an OPTIONAL peer dependency in
|
|
63
|
+
// package.json. Customers who never import this module never pay the
|
|
64
|
+
// install cost. `tsc` resolves `BaseCallbackHandler` against the
|
|
65
|
+
// devDependency version at build time; at runtime the customer's
|
|
66
|
+
// installed `@langchain/core` provides the actual class.
|
|
67
|
+
import { BaseCallbackHandler } from "@langchain/core/callbacks/base";
|
|
68
|
+
// Truncation budgets. Kept in sync with `vercel_ai.ts` / `mastra.ts` /
|
|
69
|
+
// the Python `emit_llm_call` so wire-format payloads from this
|
|
70
|
+
// adapter and from hand-written code are byte-indistinguishable.
|
|
71
|
+
const MAX_SYSTEM = 1000;
|
|
72
|
+
const MAX_USER_MSG = 1000;
|
|
73
|
+
const MAX_RESPONSE = 1000;
|
|
74
|
+
const MAX_TOOL_INPUT_REPR = 200;
|
|
75
|
+
const MAX_TOOL_OUTPUT_REPR = 500;
|
|
76
|
+
const MAX_EXC_MSG = 500;
|
|
77
|
+
/**
|
|
78
|
+
* LangChain callback handler that emits Mesedi events. Attach an
|
|
79
|
+
* instance to any LangChain runnable via the standard `callbacks:`
|
|
80
|
+
* config slot:
|
|
81
|
+
*
|
|
82
|
+
* runnable.invoke(input, { callbacks: [new MesediLangChainCallbackHandler()] });
|
|
83
|
+
*
|
|
84
|
+
* Emits one `llm_call` event per LLM invocation (matching the wire
|
|
85
|
+
* format from `emit_llm_call` and the Anthropic patch) and one
|
|
86
|
+
* `tool_call` event per tool invocation (matching the wire format
|
|
87
|
+
* from `@mesedi.tool`). Both event types feed the standard Mesedi
|
|
88
|
+
* detector chain — drift, identical / similar-call loops,
|
|
89
|
+
* tool-failures, cost-velocity, prompt-injection.
|
|
90
|
+
*
|
|
91
|
+
* Outside a `wrap()` execution context, all emissions silently no-op
|
|
92
|
+
* (matches the rest of Mesedi's observe layer).
|
|
93
|
+
*/
|
|
94
|
+
export class MesediLangChainCallbackHandler extends BaseCallbackHandler {
|
|
95
|
+
name = "mesedi-langchain";
|
|
96
|
+
/**
|
|
97
|
+
* Tell LangChain's dispatcher not to reraise handler exceptions.
|
|
98
|
+
* We already swallow inside each method; this is belt-and-suspenders
|
|
99
|
+
* for any future LangChain version that changes the default.
|
|
100
|
+
*/
|
|
101
|
+
raiseError = false;
|
|
102
|
+
llmStarts = new Map();
|
|
103
|
+
toolStarts = new Map();
|
|
104
|
+
// ── LLM events ──────────────────────────────────────────────────
|
|
105
|
+
handleLLMStart(llm, prompts, runId, _parentRunId, extraParams, _tags, _metadata, _runName) {
|
|
106
|
+
try {
|
|
107
|
+
const model = extractModel(llm, extraParams);
|
|
108
|
+
const userMessage = prompts.length > 0 ? (prompts[prompts.length - 1] ?? "") : "";
|
|
109
|
+
this.llmStarts.set(runId, {
|
|
110
|
+
model,
|
|
111
|
+
userMessage,
|
|
112
|
+
systemPrompt: "",
|
|
113
|
+
startedAt: Date.now(),
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
console.warn("mesedi langchain handler: handleLLMStart error", err);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
handleChatModelStart(llm, messages, runId, _parentRunId, extraParams, _tags, _metadata, _runName) {
|
|
121
|
+
try {
|
|
122
|
+
const model = extractModel(llm, extraParams);
|
|
123
|
+
const lastConversation = messages.length > 0 ? (messages[messages.length - 1] ?? []) : [];
|
|
124
|
+
const { userMessage, systemPrompt } = extractRoleMessages(lastConversation);
|
|
125
|
+
this.llmStarts.set(runId, {
|
|
126
|
+
model,
|
|
127
|
+
userMessage,
|
|
128
|
+
systemPrompt,
|
|
129
|
+
startedAt: Date.now(),
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
console.warn("mesedi langchain handler: handleChatModelStart error", err);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
handleLLMEnd(output, runId, _parentRunId, _tags) {
|
|
137
|
+
try {
|
|
138
|
+
const ctx = this.llmStarts.get(runId);
|
|
139
|
+
if (!ctx)
|
|
140
|
+
return;
|
|
141
|
+
this.llmStarts.delete(runId);
|
|
142
|
+
const responseText = extractResponseText(output);
|
|
143
|
+
const [inputTokens, outputTokens] = extractTokenUsage(output);
|
|
144
|
+
const durationMs = Math.max(0, Date.now() - ctx.startedAt);
|
|
145
|
+
emitLlmCallEvent({
|
|
146
|
+
model: ctx.model,
|
|
147
|
+
userMessage: ctx.userMessage,
|
|
148
|
+
systemPrompt: ctx.systemPrompt,
|
|
149
|
+
responseText,
|
|
150
|
+
inputTokens,
|
|
151
|
+
outputTokens,
|
|
152
|
+
durationMs,
|
|
153
|
+
status: "ok",
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
catch (err) {
|
|
157
|
+
console.warn("mesedi langchain handler: handleLLMEnd error", err);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
handleLLMError(_err, runId, _parentRunId, _tags) {
|
|
161
|
+
try {
|
|
162
|
+
const ctx = this.llmStarts.get(runId);
|
|
163
|
+
if (!ctx)
|
|
164
|
+
return;
|
|
165
|
+
this.llmStarts.delete(runId);
|
|
166
|
+
const durationMs = Math.max(0, Date.now() - ctx.startedAt);
|
|
167
|
+
emitLlmCallEvent({
|
|
168
|
+
model: ctx.model,
|
|
169
|
+
userMessage: ctx.userMessage,
|
|
170
|
+
systemPrompt: ctx.systemPrompt,
|
|
171
|
+
responseText: "",
|
|
172
|
+
inputTokens: 0,
|
|
173
|
+
outputTokens: 0,
|
|
174
|
+
durationMs,
|
|
175
|
+
status: "failed",
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
catch (err) {
|
|
179
|
+
console.warn("mesedi langchain handler: handleLLMError error", err);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// ── Tool events ─────────────────────────────────────────────────
|
|
183
|
+
handleToolStart(tool, input, runId, _parentRunId, _tags, _metadata, _name) {
|
|
184
|
+
try {
|
|
185
|
+
const name = extractToolName(tool);
|
|
186
|
+
const inputStr = typeof input === "string" ? input : reprValue(input);
|
|
187
|
+
this.toolStarts.set(runId, {
|
|
188
|
+
name,
|
|
189
|
+
inputStr,
|
|
190
|
+
startedAt: Date.now(),
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
catch (err) {
|
|
194
|
+
console.warn("mesedi langchain handler: handleToolStart error", err);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
handleToolEnd(output, runId, _parentRunId, _tags) {
|
|
198
|
+
try {
|
|
199
|
+
const ctx = this.toolStarts.get(runId);
|
|
200
|
+
if (!ctx)
|
|
201
|
+
return;
|
|
202
|
+
this.toolStarts.delete(runId);
|
|
203
|
+
const durationMs = Math.max(0, Date.now() - ctx.startedAt);
|
|
204
|
+
const resultSummary = output == null
|
|
205
|
+
? ""
|
|
206
|
+
: typeof output === "string"
|
|
207
|
+
? output
|
|
208
|
+
: reprValue(output);
|
|
209
|
+
emitToolCallEvent({
|
|
210
|
+
toolName: ctx.name,
|
|
211
|
+
inputStr: ctx.inputStr,
|
|
212
|
+
resultSummary,
|
|
213
|
+
durationMs,
|
|
214
|
+
status: "ok",
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
catch (err) {
|
|
218
|
+
console.warn("mesedi langchain handler: handleToolEnd error", err);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
handleToolError(err, runId, _parentRunId, _tags) {
|
|
222
|
+
try {
|
|
223
|
+
const ctx = this.toolStarts.get(runId);
|
|
224
|
+
if (!ctx)
|
|
225
|
+
return;
|
|
226
|
+
this.toolStarts.delete(runId);
|
|
227
|
+
const durationMs = Math.max(0, Date.now() - ctx.startedAt);
|
|
228
|
+
const [excType, excMessage] = extractError(err);
|
|
229
|
+
emitToolCallEvent({
|
|
230
|
+
toolName: ctx.name,
|
|
231
|
+
inputStr: ctx.inputStr,
|
|
232
|
+
resultSummary: "",
|
|
233
|
+
durationMs,
|
|
234
|
+
status: "failed",
|
|
235
|
+
exceptionType: excType,
|
|
236
|
+
exceptionMessage: excMessage,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
catch (e) {
|
|
240
|
+
console.warn("mesedi langchain handler: handleToolError error", e);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
// ── Emitters ────────────────────────────────────────────────────────
|
|
245
|
+
function emitLlmCallEvent(args) {
|
|
246
|
+
const ctx = currentExecutionContext();
|
|
247
|
+
if (!ctx)
|
|
248
|
+
return;
|
|
249
|
+
// Halt-safe boundary at LLM call. Matches @mesedi.tool, the
|
|
250
|
+
// Anthropic patch, and vercel_ai's emitLlmCallEvent.
|
|
251
|
+
ctx.checkBudget();
|
|
252
|
+
if (ctx.budgetTracker) {
|
|
253
|
+
ctx.budgetTracker.incrementSteps();
|
|
254
|
+
if (args.inputTokens > 0 || args.outputTokens > 0) {
|
|
255
|
+
ctx.budgetTracker.addTokens(args.inputTokens, args.outputTokens);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
const payload = {
|
|
259
|
+
model: args.model,
|
|
260
|
+
system_prompt: truncate(args.systemPrompt, MAX_SYSTEM),
|
|
261
|
+
user_message: truncate(args.userMessage, MAX_USER_MSG),
|
|
262
|
+
status: args.status,
|
|
263
|
+
};
|
|
264
|
+
if (args.status === "ok") {
|
|
265
|
+
payload["response_text"] = truncate(args.responseText, MAX_RESPONSE);
|
|
266
|
+
payload["input_tokens"] = args.inputTokens;
|
|
267
|
+
payload["output_tokens"] = args.outputTokens;
|
|
268
|
+
}
|
|
269
|
+
const event = {
|
|
270
|
+
event_id: newEventId(),
|
|
271
|
+
execution_id: ctx.executionId,
|
|
272
|
+
event_type: EventType.LLM_CALL,
|
|
273
|
+
sequence: ctx.nextSequence(),
|
|
274
|
+
timestamp: utcNowRfc3339(),
|
|
275
|
+
duration_ms: args.durationMs,
|
|
276
|
+
payload,
|
|
277
|
+
};
|
|
278
|
+
getClient().submitEvent(event);
|
|
279
|
+
}
|
|
280
|
+
function emitToolCallEvent(args) {
|
|
281
|
+
const ctx = currentExecutionContext();
|
|
282
|
+
if (!ctx)
|
|
283
|
+
return;
|
|
284
|
+
// Halt-safe boundary at tool call, matches @mesedi.tool.
|
|
285
|
+
ctx.checkBudget();
|
|
286
|
+
if (ctx.budgetTracker) {
|
|
287
|
+
ctx.budgetTracker.incrementSteps();
|
|
288
|
+
}
|
|
289
|
+
const payload = {
|
|
290
|
+
tool_name: args.toolName,
|
|
291
|
+
// LangChain tools take a single input string. Mimic the
|
|
292
|
+
// @mesedi.tool wire shape ({args: [...], kwargs: {...}}) by
|
|
293
|
+
// dropping the input into args[0]; kwargs stays empty.
|
|
294
|
+
arguments: {
|
|
295
|
+
args: [truncate(args.inputStr, MAX_TOOL_INPUT_REPR)],
|
|
296
|
+
kwargs: {},
|
|
297
|
+
},
|
|
298
|
+
status: args.status,
|
|
299
|
+
};
|
|
300
|
+
if (args.status === "ok") {
|
|
301
|
+
payload["result_summary"] = truncate(args.resultSummary, MAX_TOOL_OUTPUT_REPR);
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
if (args.exceptionType)
|
|
305
|
+
payload["exception_type"] = args.exceptionType;
|
|
306
|
+
if (args.exceptionMessage) {
|
|
307
|
+
payload["exception_message"] = truncate(args.exceptionMessage, MAX_EXC_MSG);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
const event = {
|
|
311
|
+
event_id: newEventId(),
|
|
312
|
+
execution_id: ctx.executionId,
|
|
313
|
+
event_type: EventType.TOOL_CALL,
|
|
314
|
+
sequence: ctx.nextSequence(),
|
|
315
|
+
timestamp: utcNowRfc3339(),
|
|
316
|
+
duration_ms: args.durationMs,
|
|
317
|
+
payload,
|
|
318
|
+
};
|
|
319
|
+
getClient().submitEvent(event);
|
|
320
|
+
}
|
|
321
|
+
// ── Extractors ──────────────────────────────────────────────────────
|
|
322
|
+
//
|
|
323
|
+
// LangChain's serialized-object shape and message-class hierarchy have
|
|
324
|
+
// shifted across versions. Each extractor below tries the known shapes
|
|
325
|
+
// in order and falls through to a safe default so the adapter still
|
|
326
|
+
// emits a useful event on a version we haven't seen.
|
|
327
|
+
function extractModel(serialized, extraParams) {
|
|
328
|
+
const inv = extraParams?.["invocation_params"] ??
|
|
329
|
+
{};
|
|
330
|
+
for (const key of ["model", "model_name", "deployment_name"]) {
|
|
331
|
+
const v = inv[key];
|
|
332
|
+
if (typeof v === "string" && v)
|
|
333
|
+
return v;
|
|
334
|
+
}
|
|
335
|
+
if (serialized && typeof serialized === "object") {
|
|
336
|
+
const kw = serialized["kwargs"] ?? {};
|
|
337
|
+
for (const key of ["model", "model_name", "deployment_name"]) {
|
|
338
|
+
const v = kw[key];
|
|
339
|
+
if (typeof v === "string" && v)
|
|
340
|
+
return v;
|
|
341
|
+
}
|
|
342
|
+
const ident = serialized["id"];
|
|
343
|
+
if (Array.isArray(ident) && ident.length > 0) {
|
|
344
|
+
const last = ident[ident.length - 1];
|
|
345
|
+
if (typeof last === "string" && last)
|
|
346
|
+
return last;
|
|
347
|
+
}
|
|
348
|
+
const name = serialized["name"];
|
|
349
|
+
if (typeof name === "string" && name)
|
|
350
|
+
return name;
|
|
351
|
+
}
|
|
352
|
+
return "unknown";
|
|
353
|
+
}
|
|
354
|
+
function extractRoleMessages(conversation) {
|
|
355
|
+
let userMessage = "";
|
|
356
|
+
let systemPrompt = "";
|
|
357
|
+
for (const msg of conversation) {
|
|
358
|
+
if (!msg || typeof msg !== "object")
|
|
359
|
+
continue;
|
|
360
|
+
const m = msg;
|
|
361
|
+
let msgType = "";
|
|
362
|
+
if (typeof m.type === "string" && m.type) {
|
|
363
|
+
msgType = m.type;
|
|
364
|
+
}
|
|
365
|
+
else if (typeof m._getType === "function") {
|
|
366
|
+
try {
|
|
367
|
+
msgType = m._getType();
|
|
368
|
+
}
|
|
369
|
+
catch {
|
|
370
|
+
// ignore, fall through to constructor name
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
if (!msgType && m.constructor?.name) {
|
|
374
|
+
msgType = m.constructor.name;
|
|
375
|
+
}
|
|
376
|
+
let content = m.content;
|
|
377
|
+
if (Array.isArray(content)) {
|
|
378
|
+
const parts = [];
|
|
379
|
+
for (const block of content) {
|
|
380
|
+
if (typeof block === "string") {
|
|
381
|
+
parts.push(block);
|
|
382
|
+
}
|
|
383
|
+
else if (block && typeof block === "object") {
|
|
384
|
+
const b = block;
|
|
385
|
+
if (b.type === "text" && typeof b.text === "string") {
|
|
386
|
+
parts.push(b.text);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
content = parts.join(" ");
|
|
391
|
+
}
|
|
392
|
+
const contentStr = typeof content === "string" ? content : content == null ? "" : String(content);
|
|
393
|
+
const t = msgType.toLowerCase();
|
|
394
|
+
if (t === "system" || t === "systemmessage") {
|
|
395
|
+
systemPrompt = contentStr;
|
|
396
|
+
}
|
|
397
|
+
else if (t === "human" ||
|
|
398
|
+
t === "humanmessage" ||
|
|
399
|
+
t === "user" ||
|
|
400
|
+
t === "usermessage") {
|
|
401
|
+
userMessage = contentStr;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
return { userMessage, systemPrompt };
|
|
405
|
+
}
|
|
406
|
+
function extractResponseText(response) {
|
|
407
|
+
try {
|
|
408
|
+
if (!response || typeof response !== "object")
|
|
409
|
+
return "";
|
|
410
|
+
const r = response;
|
|
411
|
+
const generations = r.generations;
|
|
412
|
+
if (!Array.isArray(generations) || generations.length === 0)
|
|
413
|
+
return "";
|
|
414
|
+
const firstBatch = generations[0];
|
|
415
|
+
if (!Array.isArray(firstBatch) || firstBatch.length === 0)
|
|
416
|
+
return "";
|
|
417
|
+
const gen = firstBatch[0];
|
|
418
|
+
if (typeof gen?.text === "string" && gen.text)
|
|
419
|
+
return gen.text;
|
|
420
|
+
const message = gen?.message;
|
|
421
|
+
if (message && typeof message === "object") {
|
|
422
|
+
const content = message.content;
|
|
423
|
+
if (typeof content === "string")
|
|
424
|
+
return content;
|
|
425
|
+
if (Array.isArray(content)) {
|
|
426
|
+
const parts = [];
|
|
427
|
+
for (const block of content) {
|
|
428
|
+
if (typeof block === "string") {
|
|
429
|
+
parts.push(block);
|
|
430
|
+
}
|
|
431
|
+
else if (block && typeof block === "object") {
|
|
432
|
+
const b = block;
|
|
433
|
+
if (b.type === "text" && typeof b.text === "string") {
|
|
434
|
+
parts.push(b.text);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
return parts.join(" ");
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
catch {
|
|
443
|
+
// fall through to empty
|
|
444
|
+
}
|
|
445
|
+
return "";
|
|
446
|
+
}
|
|
447
|
+
function extractTokenUsage(response) {
|
|
448
|
+
try {
|
|
449
|
+
if (!response || typeof response !== "object")
|
|
450
|
+
return [0, 0];
|
|
451
|
+
const r = response;
|
|
452
|
+
const llmOutput = r.llmOutput ?? r.llm_output ?? {};
|
|
453
|
+
const usageAny = llmOutput["tokenUsage"] ??
|
|
454
|
+
llmOutput["token_usage"] ??
|
|
455
|
+
llmOutput["usage"] ??
|
|
456
|
+
{};
|
|
457
|
+
const usage = typeof usageAny === "object" && usageAny !== null
|
|
458
|
+
? usageAny
|
|
459
|
+
: {};
|
|
460
|
+
const inputTokens = toInt(usage["promptTokens"]) ||
|
|
461
|
+
toInt(usage["prompt_tokens"]) ||
|
|
462
|
+
toInt(usage["inputTokens"]) ||
|
|
463
|
+
toInt(usage["input_tokens"]);
|
|
464
|
+
const outputTokens = toInt(usage["completionTokens"]) ||
|
|
465
|
+
toInt(usage["completion_tokens"]) ||
|
|
466
|
+
toInt(usage["outputTokens"]) ||
|
|
467
|
+
toInt(usage["output_tokens"]);
|
|
468
|
+
if (inputTokens > 0 || outputTokens > 0) {
|
|
469
|
+
return [inputTokens, outputTokens];
|
|
470
|
+
}
|
|
471
|
+
// Newer LangChain: `usage_metadata` on the generation itself.
|
|
472
|
+
const generations = r.generations;
|
|
473
|
+
if (Array.isArray(generations) && generations.length > 0) {
|
|
474
|
+
const firstBatch = generations[0];
|
|
475
|
+
if (Array.isArray(firstBatch) && firstBatch.length > 0) {
|
|
476
|
+
const gen = firstBatch[0];
|
|
477
|
+
const meta = gen?.message?.usage_metadata ?? gen?.message?.usageMetadata ?? {};
|
|
478
|
+
if (meta && typeof meta === "object") {
|
|
479
|
+
return [
|
|
480
|
+
toInt(meta["input_tokens"]) || toInt(meta["inputTokens"]),
|
|
481
|
+
toInt(meta["output_tokens"]) || toInt(meta["outputTokens"]),
|
|
482
|
+
];
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
catch {
|
|
488
|
+
// fall through
|
|
489
|
+
}
|
|
490
|
+
return [0, 0];
|
|
491
|
+
}
|
|
492
|
+
function extractToolName(serialized) {
|
|
493
|
+
if (!serialized || typeof serialized !== "object")
|
|
494
|
+
return "unknown_tool";
|
|
495
|
+
const name = serialized["name"];
|
|
496
|
+
if (typeof name === "string" && name)
|
|
497
|
+
return name;
|
|
498
|
+
const ident = serialized["id"];
|
|
499
|
+
if (Array.isArray(ident) && ident.length > 0) {
|
|
500
|
+
const last = ident[ident.length - 1];
|
|
501
|
+
if (typeof last === "string" && last)
|
|
502
|
+
return last;
|
|
503
|
+
}
|
|
504
|
+
return "unknown_tool";
|
|
505
|
+
}
|
|
506
|
+
function extractError(err) {
|
|
507
|
+
if (err instanceof Error) {
|
|
508
|
+
return [err.constructor.name || "Error", err.message];
|
|
509
|
+
}
|
|
510
|
+
if (err && typeof err === "object") {
|
|
511
|
+
const e = err;
|
|
512
|
+
return [
|
|
513
|
+
typeof e.name === "string" && e.name ? e.name : "Error",
|
|
514
|
+
typeof e.message === "string" ? e.message : "",
|
|
515
|
+
];
|
|
516
|
+
}
|
|
517
|
+
return ["Error", typeof err === "string" ? err : ""];
|
|
518
|
+
}
|
|
519
|
+
// ── Helpers ────────────────────────────────────────────────────────
|
|
520
|
+
function truncate(s, maxLen) {
|
|
521
|
+
if (!s)
|
|
522
|
+
return "";
|
|
523
|
+
if (s.length <= maxLen)
|
|
524
|
+
return s;
|
|
525
|
+
return s.slice(0, maxLen - 3) + "...";
|
|
526
|
+
}
|
|
527
|
+
function toInt(v) {
|
|
528
|
+
if (typeof v === "number" && Number.isFinite(v)) {
|
|
529
|
+
return Math.max(0, Math.floor(v));
|
|
530
|
+
}
|
|
531
|
+
if (typeof v === "string") {
|
|
532
|
+
const n = parseInt(v, 10);
|
|
533
|
+
return Number.isFinite(n) ? Math.max(0, n) : 0;
|
|
534
|
+
}
|
|
535
|
+
return 0;
|
|
536
|
+
}
|
|
537
|
+
function reprValue(v) {
|
|
538
|
+
if (v == null)
|
|
539
|
+
return "";
|
|
540
|
+
if (typeof v === "string")
|
|
541
|
+
return v;
|
|
542
|
+
try {
|
|
543
|
+
return JSON.stringify(v);
|
|
544
|
+
}
|
|
545
|
+
catch {
|
|
546
|
+
return String(v);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
//# sourceMappingURL=langchain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"langchain.js","sourceRoot":"","sources":["../../src/integrations/langchain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAS,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE/D,wEAAwE;AACxE,EAAE;AACF,kEAAkE;AAClE,qEAAqE;AACrE,iEAAiE;AACjE,iEAAiE;AACjE,yDAAyD;AAEzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAIrE,uEAAuE;AACvE,+DAA+D;AAC/D,iEAAiE;AACjE,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM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G,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,SAAS,CAAC,CAAU;IAC3B,IAAI,CAAC,IAAI,IAAI;QAAE,OAAO,EAAE,CAAC;IACzB,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAC;IACpC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -162,7 +162,7 @@ export class MesediExporter extends BaseExporter {
|
|
|
162
162
|
status: Status.STARTED,
|
|
163
163
|
started_at: utcNowRfc3339(),
|
|
164
164
|
sdk_language: "typescript",
|
|
165
|
-
sdk_version: "0.
|
|
165
|
+
sdk_version: "0.7.0",
|
|
166
166
|
};
|
|
167
167
|
if (this.tenantId !== undefined)
|
|
168
168
|
execution.tenant_id = this.tenantId;
|
|
@@ -226,7 +226,7 @@ export class MesediExporter extends BaseExporter {
|
|
|
226
226
|
status: mapStatus(span),
|
|
227
227
|
started_at: utcNowRfc3339(),
|
|
228
228
|
sdk_language: "typescript",
|
|
229
|
-
sdk_version: "0.
|
|
229
|
+
sdk_version: "0.7.0",
|
|
230
230
|
ended_at: utcNowRfc3339(),
|
|
231
231
|
};
|
|
232
232
|
if (durationMs !== undefined)
|
package/dist/wrap.js
CHANGED
|
@@ -79,7 +79,7 @@ export function wrap(fnOrOpts, maybeFn) {
|
|
|
79
79
|
status: Status.STARTED,
|
|
80
80
|
started_at: utcNowRfc3339(),
|
|
81
81
|
sdk_language: "typescript",
|
|
82
|
-
sdk_version: "0.
|
|
82
|
+
sdk_version: "0.7.0",
|
|
83
83
|
// Optional tenant_id flows through to the wire body via
|
|
84
84
|
// executionStartPayload's omitempty-style assignment.
|
|
85
85
|
...(opts.tenant_id !== undefined ? { tenant_id: opts.tenant_id } : {}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mesedi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Mesedi SDK — guardians for autonomous AI agents. Detect failures, halt runaways, escalate first occurrence.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://mesedi.ai",
|
|
@@ -36,12 +36,17 @@
|
|
|
36
36
|
"./integrations/mastra": {
|
|
37
37
|
"types": "./dist/integrations/mastra.d.ts",
|
|
38
38
|
"import": "./dist/integrations/mastra.js"
|
|
39
|
+
},
|
|
40
|
+
"./integrations/langchain": {
|
|
41
|
+
"types": "./dist/integrations/langchain.d.ts",
|
|
42
|
+
"import": "./dist/integrations/langchain.js"
|
|
39
43
|
}
|
|
40
44
|
},
|
|
41
45
|
"peerDependencies": {
|
|
42
46
|
"ai": ">=3.0.0",
|
|
43
47
|
"@mastra/core": ">=1.0.0",
|
|
44
|
-
"@mastra/observability": ">=1.0.0"
|
|
48
|
+
"@mastra/observability": ">=1.0.0",
|
|
49
|
+
"@langchain/core": ">=0.3.0 <0.5.0"
|
|
45
50
|
},
|
|
46
51
|
"peerDependenciesMeta": {
|
|
47
52
|
"ai": {
|
|
@@ -52,6 +57,9 @@
|
|
|
52
57
|
},
|
|
53
58
|
"@mastra/observability": {
|
|
54
59
|
"optional": true
|
|
60
|
+
},
|
|
61
|
+
"@langchain/core": {
|
|
62
|
+
"optional": true
|
|
55
63
|
}
|
|
56
64
|
},
|
|
57
65
|
"files": [
|
|
@@ -89,6 +97,7 @@
|
|
|
89
97
|
"@types/node": "^20.11.0",
|
|
90
98
|
"vitest": "^4.1.9",
|
|
91
99
|
"@mastra/core": "^1.48.0",
|
|
92
|
-
"@mastra/observability": "^1.15.2"
|
|
100
|
+
"@mastra/observability": "^1.15.2",
|
|
101
|
+
"@langchain/core": "^0.3.0"
|
|
93
102
|
}
|
|
94
103
|
}
|