evalution 1.0.4 → 1.0.5

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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as MemoryTraceProvider, c as PROMPT_NAME_ATTRIBUTE, d as createTracerForPrompt, f as getPromptSpanAttributes, l as PROMPT_PROVIDER_ID_ATTRIBUTE, n as findPackageDts, o as PROMPT_ID_ATTRIBUTE, p as isEditable, s as PROMPT_INPUTS_ATTRIBUTE, t as VercelAISDK, u as SPAN_KIND_ATTRIBUTE } from "./vercel-ai-sdk-B8ivuOzP.js";
1
+ import { _ as BaseTraceProvider, a as BaseTraceIngestor, c as PROMPT_NAME_ATTRIBUTE, d as createTracerForPrompt, f as getPromptSpanAttributes, g as MemoryTraceProvider, h as isEditable, i as OTelTraceIngestor, l as PROMPT_PROVIDER_ID_ATTRIBUTE, n as VercelAISDKTelemetry, o as PROMPT_ID_ATTRIBUTE, r as findPackageDts, s as PROMPT_INPUTS_ATTRIBUTE, t as VercelAISDK, u as SPAN_KIND_ATTRIBUTE, v as mergeSpans } from "./vercel-ai-sdk-JhQ1efcg.js";
2
2
  import fs, { glob } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { pathToFileURL } from "node:url";
@@ -7,7 +7,6 @@ import { addProperty, extractPropertiesFromDeclaration, extractPropertiesFromObj
7
7
  import ts from "typescript";
8
8
  import chokidar from "chokidar";
9
9
  import { makeRe, minimatch } from "minimatch";
10
- import { GoogleGenAI } from "@google/genai";
11
10
  //#region src/file-provider-local.ts
12
11
  /**
13
12
  * A {@link FileProvider} backed by the local file system.
@@ -443,7 +442,7 @@ function getPropertyFunction(prop) {
443
442
  */
444
443
  function resolveBindingsAndAugment(sourceCode, value) {
445
444
  const sourceFile = ts.createSourceFile("helper-adjust.ts", sourceCode, ts.ScriptTarget.Latest, true);
446
- const destructureAdditions = /* @__PURE__ */ new Map();
445
+ const targetAdditions = /* @__PURE__ */ new Map();
447
446
  const resolveCandidate = (_fc, candidates) => {
448
447
  for (const c of candidates) if (c.kind === "parameter") {
449
448
  const dest = findEnclosingCallDestructure(sourceFile, c.enclosingCall);
@@ -455,9 +454,9 @@ function resolveBindingsAndAugment(sourceCode, value) {
455
454
  if (!fc.binding) return fc;
456
455
  const result = resolveCandidate(fc, Array.isArray(fc.binding) ? fc.binding : [fc.binding]);
457
456
  if (result.viaDestructure) {
458
- const set = destructureAdditions.get(result.viaDestructure) ?? /* @__PURE__ */ new Set();
457
+ const set = targetAdditions.get(result.viaDestructure) ?? /* @__PURE__ */ new Set();
459
458
  set.add(fc.callee);
460
- destructureAdditions.set(result.viaDestructure, set);
459
+ targetAdditions.set(result.viaDestructure, set);
461
460
  const { binding: _drop, ...rest } = fc;
462
461
  return rest;
463
462
  }
@@ -468,31 +467,45 @@ function resolveBindingsAndAugment(sourceCode, value) {
468
467
  const { binding: _none, ...rest } = fc;
469
468
  return rest;
470
469
  });
471
- const augmentations = [...destructureAdditions.entries()].map(([dest, names]) => {
470
+ const edits = [...targetAdditions.entries()].map(([target, names]) => {
472
471
  const existing = /* @__PURE__ */ new Set();
473
- for (const el of dest.elements) if (ts.isIdentifier(el.name)) existing.add(el.name.text);
472
+ for (const el of target.pattern?.elements ?? []) if (ts.isIdentifier(el.name)) existing.add(el.name.text);
473
+ const toAdd = [...names].filter((n) => !existing.has(n));
474
+ if (toAdd.length === 0) return null;
475
+ if (target.pattern) {
476
+ const isEmpty = target.pattern.elements.length === 0;
477
+ return {
478
+ end: target.pattern.getEnd(),
479
+ apply: (src) => {
480
+ let offset = target.pattern.getEnd() - 1;
481
+ while (src[offset - 1] === " ") offset--;
482
+ const insertion = (isEmpty ? " " : ", ") + toAdd.join(", ") + (isEmpty ? " " : "");
483
+ return src.slice(0, offset) + insertion + src.slice(offset);
484
+ }
485
+ };
486
+ }
487
+ const openParen = target.paramOpenParen;
474
488
  return {
475
- dest,
476
- toAdd: [...names].filter((n) => !existing.has(n))
489
+ end: openParen + 1,
490
+ apply: (src) => src.slice(0, openParen + 1) + `{ ${toAdd.join(", ")} }` + src.slice(openParen + 1)
477
491
  };
478
- }).filter((a) => a.toAdd.length > 0).sort((a, b) => b.dest.getEnd() - a.dest.getEnd());
492
+ }).filter((e) => e !== null).sort((a, b) => b.end - a.end);
479
493
  let nextSource = sourceCode;
480
- for (const { dest, toAdd } of augmentations) {
481
- let closeOffset = dest.getEnd() - 1;
482
- while (nextSource[closeOffset - 1] === " ") closeOffset--;
483
- const isEmpty = dest.elements.length === 0;
484
- const insertion = (isEmpty ? " " : ", ") + toAdd.join(", ") + (isEmpty ? " " : "");
485
- nextSource = nextSource.slice(0, closeOffset) + insertion + nextSource.slice(closeOffset);
486
- }
494
+ for (const edit of edits) nextSource = edit.apply(nextSource);
487
495
  return {
488
496
  sourceCode: nextSource,
489
497
  value: adjusted
490
498
  };
491
499
  }
492
500
  /**
493
- * Find the destructured first parameter of a call matching `enclosingCall` at
494
- * the top level of `sourceFile`. Returns null when no such call exists or when
495
- * its first parameter is not an object binding pattern.
501
+ * Find where to bind a callee against the destructured first parameter of a
502
+ * call matching `enclosingCall` at the top level of `sourceFile`.
503
+ *
504
+ * Returns the existing object binding pattern when the factory already
505
+ * destructures its first parameter, or — when the factory takes no parameters
506
+ * yet (e.g. a freshly-created `() => …` skeleton) — a target describing where to
507
+ * create one. Returns null when no matching call exists or when its first
508
+ * parameter is present but is not an object binding pattern.
496
509
  *
497
510
  * When `enclosingCall.import` is provided, the callee identifier must resolve
498
511
  * to a named import matching that spec.
@@ -508,9 +521,16 @@ function findEnclosingCallDestructure(sourceFile, enclosingCall) {
508
521
  if (factory) {
509
522
  const param = factory.parameters[0];
510
523
  if (param?.name && ts.isObjectBindingPattern(param.name)) {
511
- found = param.name;
524
+ found = { pattern: param.name };
512
525
  return;
513
526
  }
527
+ if (!param) {
528
+ const openParen = sourceFile.text.indexOf("(", factory.getStart(sourceFile));
529
+ if (openParen >= 0) {
530
+ found = { paramOpenParen: openParen };
531
+ return;
532
+ }
533
+ }
514
534
  }
515
535
  }
516
536
  ts.forEachChild(node, visit);
@@ -668,10 +688,20 @@ var FilePromptProvider = class {
668
688
  getModelParameters() {
669
689
  return this.sdkAdapter.getModelParameters(this.rootDir);
670
690
  }
671
- async execute(promptId, params) {
691
+ async execute(promptId, params, { traceId } = {}) {
672
692
  const [filePath, promptName] = this.parsePromptId(promptId);
673
693
  const config = await this.fileType.loadConfig(filePath, promptName, params);
674
- await this.sdkAdapter.executeConfig(config);
694
+ return this.sdkAdapter.executeConfig(config, {
695
+ traceId,
696
+ identity: {
697
+ id: promptId,
698
+ name: promptName,
699
+ functionParameters: params
700
+ }
701
+ });
702
+ }
703
+ async setupTraceIngestion() {
704
+ return this.sdkAdapter.setupTraceIngestion?.();
675
705
  }
676
706
  async renamePrompt(promptId, newName) {
677
707
  const [filePath, oldName] = this.parsePromptId(promptId);
@@ -786,7 +816,7 @@ var FilePromptProvider = class {
786
816
  return [path.isAbsolute(relativePath) ? relativePath : path.join(this.rootDir, relativePath), functionName];
787
817
  }
788
818
  async listDirectories() {
789
- const dirs = new Set(["."]);
819
+ const dirs = /* @__PURE__ */ new Set(["."]);
790
820
  const iter = this.fileProvider.glob("**/", {
791
821
  cwd: this.rootDir,
792
822
  ignore: this.ignorePatterns
@@ -1106,6 +1136,7 @@ var GeminiInteractionsSDK = class {
1106
1136
  return FALLBACK_GENERATION_CONFIG_PARAMS;
1107
1137
  }
1108
1138
  async executeConfig(config) {
1139
+ const { GoogleGenAI } = await import("@google/genai");
1109
1140
  await new GoogleGenAI({}).interactions.create({
1110
1141
  ...config,
1111
1142
  store: false
@@ -1288,4 +1319,4 @@ function extractMessages(value) {
1288
1319
  return results;
1289
1320
  }
1290
1321
  //#endregion
1291
- export { FilePromptProvider, GeminiInteractionsSDK, LocalFileProvider, MemoryFileProvider, MemoryTraceProvider, PROMPT_ID_ATTRIBUTE, PROMPT_INPUTS_ATTRIBUTE, PROMPT_NAME_ATTRIBUTE, PROMPT_PROVIDER_ID_ATTRIBUTE, SPAN_KIND_ATTRIBUTE, TSPromptFileType, VercelAISDK, createTracerForPrompt, getPromptSpanAttributes };
1322
+ export { BaseTraceIngestor, BaseTraceProvider, FilePromptProvider, GeminiInteractionsSDK, LocalFileProvider, MemoryFileProvider, MemoryTraceProvider, OTelTraceIngestor, PROMPT_ID_ATTRIBUTE, PROMPT_INPUTS_ATTRIBUTE, PROMPT_NAME_ATTRIBUTE, PROMPT_PROVIDER_ID_ATTRIBUTE, SPAN_KIND_ATTRIBUTE, TSPromptFileType, VercelAISDK, VercelAISDKTelemetry, createTracerForPrompt, getPromptSpanAttributes, mergeSpans };