@dvina/agents 0.3.7 → 0.5.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,643 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/eval/index.ts
31
+ var eval_exports = {};
32
+ __export(eval_exports, {
33
+ ai: () => ai,
34
+ configureEvals: () => configureEvals,
35
+ contains: () => contains,
36
+ defineSuite: () => defineSuite,
37
+ fromToolSpecs: () => fromToolSpecs,
38
+ human: () => human,
39
+ llmJudge: () => llmJudge,
40
+ noTools: () => noTools,
41
+ notContains: () => notContains,
42
+ respondsInLanguage: () => respondsInLanguage,
43
+ toolResult: () => toolResult,
44
+ toolsCalled: () => toolsCalled
45
+ });
46
+ module.exports = __toCommonJS(eval_exports);
47
+
48
+ // src/eval/config.ts
49
+ var _config = null;
50
+ function configureEvals(config) {
51
+ _config = config;
52
+ }
53
+ function getEvalConfig() {
54
+ if (!_config) {
55
+ throw new Error("Evals not configured. Call configureEvals() in your vitest setupFiles.");
56
+ }
57
+ return _config;
58
+ }
59
+
60
+ // src/eval/suite.ts
61
+ var ls = __toESM(require("langsmith/vitest"));
62
+
63
+ // src/eval/target.ts
64
+ var import_tools = require("@langchain/core/tools");
65
+ var import_messages = require("@langchain/core/messages");
66
+ var import_zod = require("zod");
67
+
68
+ // src/runtime/langchain/model-resolver.ts
69
+ var import_openai = require("@langchain/openai");
70
+ var LangchainModelResolver = class {
71
+ constructor(config) {
72
+ this.config = config;
73
+ }
74
+ resolve(modelString, tags) {
75
+ const parts = modelString.split(":");
76
+ if (parts.length === 2) {
77
+ const [provider, modelName] = parts;
78
+ return this.resolveByProvider(provider, "default", modelName, tags);
79
+ }
80
+ if (parts.length === 3) {
81
+ const [provider, configName, modelName] = parts;
82
+ return this.resolveByProvider(provider, configName, modelName, tags);
83
+ }
84
+ throw new Error(
85
+ 'Model string must follow format "provider:modelName" (uses "default" config) or "provider:configName:modelName"'
86
+ );
87
+ }
88
+ resolveByProvider(provider, configName, modelName, tags) {
89
+ switch (provider) {
90
+ case "openai":
91
+ return this.resolveOpenAI(configName, modelName, tags);
92
+ case "azure":
93
+ return this.resolveAzure(configName, modelName, tags);
94
+ default:
95
+ throw new Error(`Unsupported model provider: ${provider}`);
96
+ }
97
+ }
98
+ resolveOpenAI(configName, modelName, tags) {
99
+ const providerConfig = this.config.openai?.[configName];
100
+ if (!providerConfig) {
101
+ throw new Error(`Configuration "${configName}" for provider "openai" is missing`);
102
+ }
103
+ return new import_openai.ChatOpenAI({
104
+ apiKey: providerConfig.apiKey,
105
+ modelName,
106
+ tags
107
+ });
108
+ }
109
+ resolveAzure(resourceName, modelName, tags) {
110
+ const resource = this.config.azure?.[resourceName];
111
+ if (!resource) {
112
+ throw new Error(`Resource "${resourceName}" for provider "azure" is missing`);
113
+ }
114
+ const modelEntry = resource.models.find((m) => m.model === modelName);
115
+ if (!modelEntry) {
116
+ throw new Error(`Model "${modelName}" not found in Azure resource "${resourceName}"`);
117
+ }
118
+ return new import_openai.AzureChatOpenAI({
119
+ model: modelEntry.model,
120
+ azureOpenAIApiKey: resource.apiKey,
121
+ azureOpenAIApiInstanceName: this.extractInstanceName(resource.endpoint),
122
+ azureOpenAIApiDeploymentName: modelEntry.deploymentName,
123
+ azureOpenAIApiVersion: modelEntry.apiVersion,
124
+ tags
125
+ });
126
+ }
127
+ extractInstanceName(endpoint) {
128
+ try {
129
+ const url = new URL(endpoint);
130
+ return url.hostname.split(".")[0];
131
+ } catch (e) {
132
+ return endpoint;
133
+ }
134
+ }
135
+ };
136
+
137
+ // src/runtime/langchain/utils.ts
138
+ var import_langchain = require("langchain");
139
+ function convertToLangchainMessages(messages) {
140
+ const result = [];
141
+ let tcIdx = 0;
142
+ let pendingToolCallIds = [];
143
+ for (const msg of messages) {
144
+ if (msg.role === "human") {
145
+ result.push(
146
+ new import_langchain.HumanMessage({
147
+ content: msg.content.map((c) => {
148
+ if (c.type === "image") {
149
+ return { type: "image_url", image_url: { url: c.url } };
150
+ }
151
+ return c;
152
+ })
153
+ })
154
+ );
155
+ } else if (msg.role === "ai") {
156
+ if (msg.toolCalls && msg.toolCalls.length > 0) {
157
+ pendingToolCallIds = msg.toolCalls.map(() => `tc_${++tcIdx}`);
158
+ result.push(
159
+ new import_langchain.AIMessage({
160
+ content: msg.content,
161
+ tool_calls: msg.toolCalls.map((tc, i) => ({
162
+ id: pendingToolCallIds[i],
163
+ name: tc.name,
164
+ args: tc.input ? JSON.parse(tc.input) : {}
165
+ }))
166
+ })
167
+ );
168
+ } else {
169
+ result.push(new import_langchain.AIMessage(msg.content));
170
+ }
171
+ } else if (msg.role === "tool") {
172
+ const toolCallId = pendingToolCallIds.shift();
173
+ if (!toolCallId)
174
+ throw new Error(`ToolMessage for "${msg.name}" without a preceding AiMessage with toolCalls`);
175
+ result.push(
176
+ new import_langchain.ToolMessage({
177
+ content: msg.output,
178
+ tool_call_id: toolCallId,
179
+ name: msg.name
180
+ })
181
+ );
182
+ }
183
+ }
184
+ return result;
185
+ }
186
+
187
+ // src/eval/target.ts
188
+ var MAX_AGENT_LOOPS = 10;
189
+ function createEvalTarget(modelConfig, modelString) {
190
+ return async (inputs) => {
191
+ const config = modelConfig && modelString ? { modelConfig, model: modelString } : getEvalConfig();
192
+ if (!config.model) {
193
+ throw new Error("model is required for model-based target. Add it to your configureEvals() call.");
194
+ }
195
+ const resolver = new LangchainModelResolver(config.modelConfig);
196
+ const model = resolver.resolve(config.model);
197
+ const toolCallCounts = {};
198
+ const langchainTools = inputs.tools.map((mockTool) => {
199
+ toolCallCounts[mockTool.name] = 0;
200
+ return (0, import_tools.tool)(
201
+ async (toolInput) => {
202
+ toolCallCounts[mockTool.name]++;
203
+ if (typeof mockTool.response === "function") {
204
+ return mockTool.response(toolInput, toolCallCounts[mockTool.name]);
205
+ }
206
+ return mockTool.response;
207
+ },
208
+ {
209
+ name: mockTool.name,
210
+ description: mockTool.description,
211
+ schema: mockTool.schema instanceof import_zod.z.ZodObject ? mockTool.schema : import_zod.z.object(
212
+ Object.fromEntries(
213
+ Object.entries(mockTool.schema).map(([key, val]) => {
214
+ if (typeof val === "string") return [key, import_zod.z.string().describe(val)];
215
+ if (typeof val === "number") return [key, import_zod.z.number().describe(String(val))];
216
+ return [key, import_zod.z.any()];
217
+ })
218
+ )
219
+ )
220
+ }
221
+ );
222
+ });
223
+ const boundModel = langchainTools.length > 0 ? model.bindTools(langchainTools) : model;
224
+ const messages = [];
225
+ if (inputs.systemPrompt) {
226
+ messages.push(new import_messages.SystemMessage(inputs.systemPrompt));
227
+ }
228
+ messages.push(...convertToLangchainMessages(inputs.messages));
229
+ let loopCount = 0;
230
+ while (loopCount < MAX_AGENT_LOOPS) {
231
+ loopCount++;
232
+ const response = await boundModel.invoke(messages);
233
+ messages.push(response);
234
+ const aiMessage = response;
235
+ if (!aiMessage.tool_calls || aiMessage.tool_calls.length === 0) {
236
+ break;
237
+ }
238
+ for (const tc of aiMessage.tool_calls) {
239
+ const mockTool = langchainTools.find((t) => t.name === tc.name);
240
+ if (mockTool) {
241
+ const result = await mockTool.invoke(tc.args);
242
+ messages.push(
243
+ new import_messages.ToolMessage({
244
+ content: typeof result === "string" ? result : JSON.stringify(result),
245
+ tool_call_id: tc.id,
246
+ name: tc.name
247
+ })
248
+ );
249
+ } else {
250
+ messages.push(
251
+ new import_messages.ToolMessage({
252
+ content: `Tool "${tc.name}" not found`,
253
+ tool_call_id: tc.id,
254
+ name: tc.name
255
+ })
256
+ );
257
+ }
258
+ }
259
+ }
260
+ return { messages };
261
+ };
262
+ }
263
+ function agentResultToMessages(inputMessages, result) {
264
+ const messages = convertToLangchainMessages(inputMessages);
265
+ let pendingToolCalls = [];
266
+ for (const block of result.content) {
267
+ if (block.type === "tool_call") {
268
+ const tc = block;
269
+ pendingToolCalls.push({
270
+ id: tc.toolCallId,
271
+ name: tc.name,
272
+ args: tc.input ? JSON.parse(tc.input) : {},
273
+ output: tc.output
274
+ });
275
+ } else if (block.type === "text") {
276
+ if (pendingToolCalls.length > 0) {
277
+ messages.push(
278
+ new import_messages.AIMessage({
279
+ content: "",
280
+ tool_calls: pendingToolCalls.map((tc) => ({ id: tc.id, name: tc.name, args: tc.args }))
281
+ })
282
+ );
283
+ for (const tc of pendingToolCalls) {
284
+ messages.push(new import_messages.ToolMessage({ content: tc.output, tool_call_id: tc.id, name: tc.name }));
285
+ }
286
+ pendingToolCalls = [];
287
+ }
288
+ messages.push(new import_messages.AIMessage(block.output));
289
+ }
290
+ }
291
+ if (pendingToolCalls.length > 0) {
292
+ messages.push(
293
+ new import_messages.AIMessage({
294
+ content: "",
295
+ tool_calls: pendingToolCalls.map((tc) => ({ id: tc.id, name: tc.name, args: tc.args }))
296
+ })
297
+ );
298
+ for (const tc of pendingToolCalls) {
299
+ messages.push(new import_messages.ToolMessage({ content: tc.output, tool_call_id: tc.id, name: tc.name }));
300
+ }
301
+ }
302
+ return messages;
303
+ }
304
+ function toolDefsToDefinitions(defs) {
305
+ const callCounts = {};
306
+ return Object.entries(defs).map(([name, def]) => {
307
+ callCounts[name] = 0;
308
+ return {
309
+ name,
310
+ toolKit: "eval-mock",
311
+ description: def.description,
312
+ inputSchema: def.schema instanceof import_zod.z.ZodObject ? def.schema : import_zod.z.object(
313
+ Object.fromEntries(
314
+ Object.entries(def.schema ?? {}).map(([key, val]) => {
315
+ if (typeof val === "string") return [key, import_zod.z.string().describe(val)];
316
+ return [key, import_zod.z.any()];
317
+ })
318
+ )
319
+ ),
320
+ exec: async (input) => {
321
+ callCounts[name]++;
322
+ if (typeof def.response === "function") {
323
+ return def.response(
324
+ input,
325
+ callCounts[name]
326
+ );
327
+ }
328
+ return typeof def.response === "string" ? def.response : JSON.stringify(def.response);
329
+ }
330
+ };
331
+ });
332
+ }
333
+ async function runAgentTarget(createTarget, evalMessages, extraToolDefs) {
334
+ const extraTools = Object.keys(extraToolDefs).length > 0 ? toolDefsToDefinitions(extraToolDefs) : [];
335
+ const agent = await createTarget(extraTools);
336
+ const result = await agent.run({
337
+ threadId: `eval_${Date.now()}_${Math.random().toString(36).slice(2)}`,
338
+ messages: evalMessages
339
+ });
340
+ return { messages: agentResultToMessages(evalMessages, result) };
341
+ }
342
+
343
+ // src/eval/suite.ts
344
+ function human(content) {
345
+ return { role: "human", content: [{ type: "text", text: content }] };
346
+ }
347
+ function ai(content, toolCalls) {
348
+ return { role: "ai", content, ...toolCalls ? { toolCalls: toolCalls.map((name) => ({ name })) } : {} };
349
+ }
350
+ function toolResult(name, output) {
351
+ return { role: "tool", name, output };
352
+ }
353
+ function fromToolSpecs(specs, responses = {}) {
354
+ return Object.fromEntries(
355
+ specs.map((spec) => [
356
+ spec.name,
357
+ {
358
+ description: spec.description,
359
+ schema: spec.inputSchema,
360
+ response: responses[spec.name] ?? ""
361
+ }
362
+ ])
363
+ );
364
+ }
365
+ function toMockTools(defs) {
366
+ return Object.entries(defs).map(([name, def]) => ({
367
+ name,
368
+ description: def.description,
369
+ schema: def.schema ?? {},
370
+ response: typeof def.response === "function" ? def.response : typeof def.response === "string" ? def.response : JSON.stringify(def.response)
371
+ }));
372
+ }
373
+ function toSerializableTools(tools) {
374
+ return tools.map((t) => ({
375
+ ...t,
376
+ schema: t.schema instanceof Object && "shape" in t.schema ? "<ZodObject>" : t.schema,
377
+ response: typeof t.response === "function" ? "<function>" : t.response
378
+ }));
379
+ }
380
+ function lastHumanContent(messages) {
381
+ for (let i = messages.length - 1; i >= 0; i--) {
382
+ const msg = messages[i];
383
+ if (msg.role === "human") {
384
+ const textBlock = msg.content.find((c) => c.type === "text");
385
+ return textBlock ? textBlock.text : "";
386
+ }
387
+ }
388
+ return "";
389
+ }
390
+ function resolveModelTarget(config) {
391
+ if (typeof config.target === "function") return config.target;
392
+ const evalConfig = getEvalConfig();
393
+ if (!evalConfig.model && typeof config.target !== "string") {
394
+ throw new Error("model is required for model-based target. Add it to your configureEvals() call.");
395
+ }
396
+ const model = typeof config.target === "string" ? config.target : evalConfig.model;
397
+ return createEvalTarget(evalConfig.modelConfig, model);
398
+ }
399
+ function resolveCreateTarget(config) {
400
+ return config.createTarget ?? getEvalConfig().createTarget;
401
+ }
402
+ function defineSuite(name, config) {
403
+ const suiteTools = config.tools ?? {};
404
+ const createTarget = config.target ? void 0 : resolveCreateTarget(config);
405
+ ls.describe(name, () => {
406
+ for (const tc of config.cases) {
407
+ const testName = tc.name ?? lastHumanContent(tc.messages);
408
+ const caseToolDefs = tc.tools ?? suiteTools;
409
+ const tools = toMockTools(caseToolDefs);
410
+ const ctx = { message: lastHumanContent(tc.messages) };
411
+ const resolved = tc.expect.map((exp) => exp(ctx));
412
+ const evaluators = resolved.map((r) => r.evaluator);
413
+ const referenceOutputs = Object.assign({}, ...resolved.map((r) => r.referenceOutputs));
414
+ ls.test(
415
+ testName,
416
+ {
417
+ inputs: {
418
+ messages: tc.messages,
419
+ tools: toSerializableTools(tools)
420
+ },
421
+ referenceOutputs
422
+ },
423
+ async ({ referenceOutputs: refOut }) => {
424
+ let output;
425
+ if (createTarget) {
426
+ output = await runAgentTarget(createTarget, tc.messages, caseToolDefs);
427
+ } else {
428
+ const target = resolveModelTarget(config);
429
+ const globalPrompt = getEvalConfig().systemPrompt;
430
+ const systemPrompt = tc.systemPrompt ?? config.systemPrompt ?? globalPrompt;
431
+ output = await target({
432
+ messages: tc.messages,
433
+ tools,
434
+ ...systemPrompt ? { systemPrompt } : {}
435
+ });
436
+ }
437
+ ls.logOutputs(output);
438
+ for (const evaluator of evaluators) {
439
+ await evaluator({ outputs: output, referenceOutputs: refOut ?? {} });
440
+ }
441
+ }
442
+ );
443
+ }
444
+ });
445
+ }
446
+
447
+ // src/eval/expectations.ts
448
+ var ls2 = __toESM(require("langsmith/vitest"));
449
+ var import_agentevals = require("agentevals");
450
+
451
+ // src/eval/evaluators/language.ts
452
+ var import_messages2 = require("@langchain/core/messages");
453
+ function createLanguageEvaluator(modelConfig, model) {
454
+ const resolver = new LangchainModelResolver(modelConfig);
455
+ const judge = resolver.resolve(model);
456
+ return async ({
457
+ outputs,
458
+ referenceOutputs
459
+ }) => {
460
+ const expectedLanguage = referenceOutputs?.expectedLanguage;
461
+ if (!expectedLanguage) {
462
+ return { key: "language_match", score: true, comment: "No expected language specified, skipping" };
463
+ }
464
+ const messages = outputs.messages || [];
465
+ const lastAiMessage = [...messages].reverse().find((m) => m instanceof import_messages2.AIMessage);
466
+ if (!lastAiMessage) {
467
+ return { key: "language_match", score: false, comment: "No AI message found in trajectory" };
468
+ }
469
+ const responseText = typeof lastAiMessage.content === "string" ? lastAiMessage.content : JSON.stringify(lastAiMessage.content);
470
+ const detection = await judge.invoke([
471
+ {
472
+ role: "system",
473
+ content: 'You are a language detection tool. Respond with ONLY the ISO 639-1 language code (e.g., "en", "tr", "de", "fr") of the text provided. Nothing else.'
474
+ },
475
+ {
476
+ role: "user",
477
+ content: responseText
478
+ }
479
+ ]);
480
+ const detectedLanguage = (typeof detection.content === "string" ? detection.content : "").trim().toLowerCase();
481
+ const matches = detectedLanguage === expectedLanguage.toLowerCase();
482
+ return {
483
+ key: "language_match",
484
+ score: matches,
485
+ comment: matches ? `Response language matches expected: ${expectedLanguage}` : `Expected "${expectedLanguage}" but detected "${detectedLanguage}"`
486
+ };
487
+ };
488
+ }
489
+
490
+ // src/eval/evaluators/response-content.ts
491
+ var import_messages3 = require("@langchain/core/messages");
492
+ function createResponseContentEvaluator() {
493
+ return async ({
494
+ outputs,
495
+ referenceOutputs
496
+ }) => {
497
+ const mustContain = referenceOutputs?.responseContains || [];
498
+ const mustNotContain = referenceOutputs?.responseMustNotContain || [];
499
+ if (mustContain.length === 0 && mustNotContain.length === 0) {
500
+ return { key: "response_content", score: true, comment: "No content assertions specified, skipping" };
501
+ }
502
+ const messages = outputs.messages || [];
503
+ const lastAiMessage = [...messages].reverse().find((m) => m instanceof import_messages3.AIMessage);
504
+ if (!lastAiMessage) {
505
+ return { key: "response_content", score: false, comment: "No AI message found in trajectory" };
506
+ }
507
+ const responseText = (typeof lastAiMessage.content === "string" ? lastAiMessage.content : JSON.stringify(lastAiMessage.content)).toLowerCase();
508
+ const failures = [];
509
+ for (const expected of mustContain) {
510
+ if (!responseText.includes(expected.toLowerCase())) {
511
+ failures.push(`Missing expected text: "${expected}"`);
512
+ }
513
+ }
514
+ for (const forbidden of mustNotContain) {
515
+ if (responseText.includes(forbidden.toLowerCase())) {
516
+ failures.push(`Contains forbidden text: "${forbidden}"`);
517
+ }
518
+ }
519
+ const passed = failures.length === 0;
520
+ return {
521
+ key: "response_content",
522
+ score: passed,
523
+ comment: passed ? "All content assertions passed" : failures.join("; ")
524
+ };
525
+ };
526
+ }
527
+
528
+ // src/eval/evaluators/no-tool-calls.ts
529
+ var import_messages4 = require("@langchain/core/messages");
530
+ function createNoToolCallsEvaluator() {
531
+ return async ({
532
+ outputs,
533
+ referenceOutputs
534
+ }) => {
535
+ if (referenceOutputs?.maxToolCalls !== 0 && referenceOutputs?.expectNoToolCalls !== true) {
536
+ return { key: "no_tool_calls", score: true, comment: "No tool call restriction specified, skipping" };
537
+ }
538
+ const messages = outputs.messages || [];
539
+ const toolCalls = messages.filter((m) => m instanceof import_messages4.AIMessage).flatMap((m) => m.tool_calls || []);
540
+ const passed = toolCalls.length === 0;
541
+ return {
542
+ key: "no_tool_calls",
543
+ score: passed,
544
+ comment: passed ? "No tool calls made (as expected)" : `Agent made ${toolCalls.length} tool call(s): ${toolCalls.map((tc) => tc.name).join(", ")}`
545
+ };
546
+ };
547
+ }
548
+
549
+ // src/eval/expectations.ts
550
+ function withTrajectoryGuard(evaluator, key) {
551
+ return async ({ outputs, referenceOutputs }) => {
552
+ if (!referenceOutputs?.referenceTrajectory) {
553
+ return { key, score: true, comment: "No referenceTrajectory specified, skipping" };
554
+ }
555
+ return evaluator({ outputs, referenceOutputs: referenceOutputs.referenceTrajectory });
556
+ };
557
+ }
558
+ function buildTrajectory(message, toolNames) {
559
+ const trajectory = [];
560
+ let tcIdx = 0;
561
+ trajectory.push({ role: "user", content: message });
562
+ for (const name of toolNames) {
563
+ const id = `tc${++tcIdx}`;
564
+ trajectory.push({
565
+ role: "assistant",
566
+ content: "",
567
+ tool_calls: [{ function: { name, arguments: "{}" }, id, type: "function" }]
568
+ });
569
+ trajectory.push({ role: "tool", content: "...", tool_call_id: id });
570
+ }
571
+ trajectory.push({ role: "assistant", content: "..." });
572
+ return trajectory;
573
+ }
574
+ function toolsCalled(tools) {
575
+ return (ctx) => ({
576
+ evaluator: ls2.wrapEvaluator(
577
+ withTrajectoryGuard(
578
+ (0, import_agentevals.createTrajectoryMatchEvaluator)({ trajectoryMatchMode: "superset", toolArgsMatchMode: "ignore" }),
579
+ "trajectory_match"
580
+ )
581
+ ),
582
+ referenceOutputs: { referenceTrajectory: buildTrajectory(ctx.message, tools) }
583
+ });
584
+ }
585
+ function llmJudge() {
586
+ return () => {
587
+ const config = getEvalConfig();
588
+ const model = config.evaluatorModel;
589
+ return {
590
+ evaluator: ls2.wrapEvaluator(
591
+ withTrajectoryGuard(
592
+ (0, import_agentevals.createTrajectoryLLMAsJudge)({ prompt: import_agentevals.TRAJECTORY_ACCURACY_PROMPT, model }),
593
+ "trajectory_llm_judge"
594
+ )
595
+ ),
596
+ referenceOutputs: {}
597
+ };
598
+ };
599
+ }
600
+ function noTools() {
601
+ return () => ({
602
+ evaluator: ls2.wrapEvaluator(createNoToolCallsEvaluator()),
603
+ referenceOutputs: { expectNoToolCalls: true }
604
+ });
605
+ }
606
+ function respondsInLanguage(code) {
607
+ return () => {
608
+ const config = getEvalConfig();
609
+ const model = config.evaluatorModel;
610
+ return {
611
+ evaluator: ls2.wrapEvaluator(createLanguageEvaluator(config.modelConfig, model)),
612
+ referenceOutputs: { expectedLanguage: code }
613
+ };
614
+ };
615
+ }
616
+ function contains(strings) {
617
+ return () => ({
618
+ evaluator: ls2.wrapEvaluator(createResponseContentEvaluator()),
619
+ referenceOutputs: { responseContains: strings }
620
+ });
621
+ }
622
+ function notContains(strings) {
623
+ return () => ({
624
+ evaluator: ls2.wrapEvaluator(createResponseContentEvaluator()),
625
+ referenceOutputs: { responseMustNotContain: strings }
626
+ });
627
+ }
628
+ // Annotate the CommonJS export names for ESM import in node:
629
+ 0 && (module.exports = {
630
+ ai,
631
+ configureEvals,
632
+ contains,
633
+ defineSuite,
634
+ fromToolSpecs,
635
+ human,
636
+ llmJudge,
637
+ noTools,
638
+ notContains,
639
+ respondsInLanguage,
640
+ toolResult,
641
+ toolsCalled
642
+ });
643
+ //# sourceMappingURL=index.js.map