{"version":3,"file":"run_collector.cjs","names":["BaseTracer"],"sources":["../../src/tracers/run_collector.ts"],"sourcesContent":["import { BaseRun, Run } from \"langsmith/schemas\";\nimport { BaseTracer } from \"./base.js\";\n\n/**\n * A callback handler that collects traced runs and makes it easy to fetch the traced run object from calls through any langchain object.\n * For instance, it makes it easy to fetch the run ID and then do things with that, such as log feedback.\n */\nexport class RunCollectorCallbackHandler extends BaseTracer {\n  /** The name of the callback handler. */\n  name = \"run_collector\";\n\n  /** The ID of the example. */\n  exampleId?: string;\n\n  /** An array of traced runs. */\n  tracedRuns: Run[];\n\n  /**\n   * Creates a new instance of the RunCollectorCallbackHandler class.\n   * @param exampleId The ID of the example.\n   */\n  constructor({ exampleId }: { exampleId?: string } = {}) {\n    super({ _awaitHandler: true });\n    this.exampleId = exampleId;\n    this.tracedRuns = [];\n  }\n\n  /**\n   * Persists the given run object.\n   * @param run The run object to persist.\n   */\n  protected async persistRun(run: BaseRun): Promise<void> {\n    const run_ = { ...run } as Run;\n    run_.reference_example_id = this.exampleId;\n    this.tracedRuns.push(run_);\n  }\n}\n"],"mappings":";;;;;;;;;AAOA,IAAa,8BAAb,cAAiDA,qBAAAA,WAAW;;CAE1D,OAAO;;CAGP;;CAGA;;;;;CAMA,YAAY,EAAE,cAAsC,EAAE,EAAE;AACtD,QAAM,EAAE,eAAe,MAAM,CAAC;AAC9B,OAAK,YAAY;AACjB,OAAK,aAAa,EAAE;;;;;;CAOtB,MAAgB,WAAW,KAA6B;EACtD,MAAM,OAAO,EAAE,GAAG,KAAK;AACvB,OAAK,uBAAuB,KAAK;AACjC,OAAK,WAAW,KAAK,KAAK"}