@lmnr-ai/lmnr 0.8.22 → 0.8.23

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.
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require("../../chunk-Do9eywBl.cjs");
2
- const require_decorators = require("../../decorators-CKzMiD2H.cjs");
2
+ const require_decorators = require("../../decorators-LxN0pWBY.cjs");
3
3
  const require_cli_worker_build = require("./build.cjs");
4
4
  let readline = require("readline");
5
5
  readline = require_chunk.__toESM(readline);
@@ -1,4 +1,4 @@
1
- import { d as Laminar, g as consumeStreamResult } from "../../decorators-DrWG-1Po.mjs";
1
+ import { d as Laminar, g as consumeStreamResult } from "../../decorators-BKinfQHD.mjs";
2
2
  import { buildFile, loadModule, selectRolloutFunction } from "./build.mjs";
3
3
  import * as readline from "readline";
4
4
  //#region src/cli/worker/index.ts
package/dist/cli.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  const require_chunk = require("./chunk-Do9eywBl.cjs");
3
- const require_dist = require("./dist-CzSNkDiM.cjs");
3
+ const require_dist = require("./dist-B7-TO5Cy.cjs");
4
4
  const require_utils = require("./utils-C8Tl1vKD.cjs");
5
5
  const require_file_utils = require("./file-utils-yJ5ephze.cjs");
6
6
  const require_proxy_to_lmnr_cli = require("./proxy-to-lmnr-cli-OA7sXzcz.cjs");
package/dist/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { r as __require } from "./chunk-BEJ448es.mjs";
3
- import { n as version, t as LaminarClient } from "./dist-BXwORFgR.mjs";
3
+ import { n as version, t as LaminarClient } from "./dist-CUxvL7k9.mjs";
4
4
  import { i as getDirname, s as initializeLogger } from "./utils-CHJ0KZUR.mjs";
5
5
  import { i as writeToFile, n as loadFromPaths, r as printToConsole } from "./file-utils-CHoR9VB8.mjs";
6
6
  import { t as proxyToLmnrCli } from "./proxy-to-lmnr-cli-DNDxudgt.mjs";
@@ -1,5 +1,5 @@
1
1
  import { r as __require } from "./chunk-BEJ448es.mjs";
2
- import { n as version, t as LaminarClient } from "./dist-BXwORFgR.mjs";
2
+ import { n as version, t as LaminarClient } from "./dist-CUxvL7k9.mjs";
3
3
  import { A as SPAN_OUTPUT, C as PARENT_SPAN_PATH, D as SPAN_INPUT, E as SPAN_IDS_PATH, F as TRACE_TYPE, I as USER_ID, M as SPAN_SDK_VERSION, N as SPAN_TYPE, O as SPAN_INSTRUMENTATION_SOURCE, P as TRACE_HAS_BROWSER_SESSION, S as PARENT_SPAN_IDS_PATH, T as SESSION_ID, _ as validateTracingConfig, c as loadEnv, g as tryToOtelSpanContext, h as parseOtelHeaders, j as SPAN_PATH, k as SPAN_LANGUAGE_VERSION, l as metadataToAttributes, m as otelTraceIdToUUID, o as getOtelEnvVar, p as otelSpanIdToUUID, r as deserializeLaminarSpanContext, s as initializeLogger, t as NIL_UUID, u as newUUID, v as ASSOCIATION_PROPERTIES, w as ROLLOUT_SESSION_ID, x as LaminarAttributes, y as ASSOCIATION_PROPERTIES_OVERRIDES } from "./utils-CHJ0KZUR.mjs";
4
4
  import { DiagConsoleLogger, DiagLogLevel, ROOT_CONTEXT, SpanStatusCode, context, createContextKey, diag, isSpanContextValid, trace } from "@opentelemetry/api";
5
5
  import { AsyncLocalStorageContextManager } from "@opentelemetry/context-async-hooks";
@@ -2920,14 +2920,26 @@ function shouldSkipUrl(url) {
2920
2920
  return SKIP_URL_PATTERNS.some((pattern) => url.startsWith(pattern));
2921
2921
  }
2922
2922
  /**
2923
+ * Send a CDP command to the given page. Works across Stagehand 3.0.x and 3.1.x+.
2924
+ *
2925
+ * `page.sendCDP` was added in Stagehand 3.1.0. On 3.0.x we fall back to
2926
+ * `getSessionForFrame(mainFrameId()).send(...)` (both methods are public on
2927
+ * the 3.0.x Page; `mainSession` is not).
2928
+ */
2929
+ async function sendCDP(page, method, params) {
2930
+ if (typeof page.sendCDP === "function") return await page.sendCDP(method, params);
2931
+ if (typeof page.getSessionForFrame === "function") return await page.getSessionForFrame(page.mainFrameId()).send(method, params);
2932
+ throw new Error("Stagehand page does not expose sendCDP or getSessionForFrame; unable to send CDP commands");
2933
+ }
2934
+ /**
2923
2935
  * Create an isolated world for a page and return the execution context ID
2924
2936
  */
2925
2937
  async function getOrCreateIsolatedWorld(page) {
2926
2938
  try {
2927
- const frameTreeResult = await Promise.race([page.sendCDP("Page.getFrameTree"), new Promise((_, reject) => setTimeout(() => reject(/* @__PURE__ */ new Error("Timeout getting frame tree")), CDP_OPERATION_TIMEOUT_MS))]);
2939
+ const frameTreeResult = await Promise.race([sendCDP(page, "Page.getFrameTree"), new Promise((_, reject) => setTimeout(() => reject(/* @__PURE__ */ new Error("Timeout getting frame tree")), CDP_OPERATION_TIMEOUT_MS))]);
2928
2940
  if (!frameTreeResult) return null;
2929
2941
  const frameId = frameTreeResult.frameTree.frame.id;
2930
- const isolatedWorldResult = await Promise.race([page.sendCDP("Page.createIsolatedWorld", {
2942
+ const isolatedWorldResult = await Promise.race([sendCDP(page, "Page.createIsolatedWorld", {
2931
2943
  frameId,
2932
2944
  worldName: "laminar-recorder"
2933
2945
  }), new Promise((_, reject) => setTimeout(() => reject(/* @__PURE__ */ new Error("Timeout creating isolated world")), CDP_OPERATION_TIMEOUT_MS))]);
@@ -2946,7 +2958,7 @@ async function getOrCreateIsolatedWorld(page) {
2946
2958
  */
2947
2959
  async function isRecorderPresent(page, contextId) {
2948
2960
  try {
2949
- const result = await Promise.race([page.sendCDP("Runtime.evaluate", {
2961
+ const result = await Promise.race([sendCDP(page, "Runtime.evaluate", {
2950
2962
  expression: "typeof window.lmnrRrweb !== 'undefined'",
2951
2963
  contextId,
2952
2964
  returnByValue: true
@@ -2989,7 +3001,7 @@ async function injectRecorderViaCDP(page, state, conn, sessionRecordingOptions,
2989
3001
  return contextId;
2990
3002
  }
2991
3003
  try {
2992
- await page.sendCDP("Runtime.evaluate", {
3004
+ await sendCDP(page, "Runtime.evaluate", {
2993
3005
  expression: RECORDER,
2994
3006
  contextId
2995
3007
  });
@@ -3000,7 +3012,7 @@ async function injectRecorderViaCDP(page, state, conn, sessionRecordingOptions,
3000
3012
  const optionsJson = JSON.stringify(sessionRecordingOptions ?? {});
3001
3013
  const injectExpression = `(${injectScript.toString()})(${optionsJson}, true);`;
3002
3014
  try {
3003
- await page.sendCDP("Runtime.evaluate", {
3015
+ await sendCDP(page, "Runtime.evaluate", {
3004
3016
  expression: injectExpression,
3005
3017
  contextId
3006
3018
  });
@@ -3009,7 +3021,7 @@ async function injectRecorderViaCDP(page, state, conn, sessionRecordingOptions,
3009
3021
  return null;
3010
3022
  }
3011
3023
  try {
3012
- await page.sendCDP("Runtime.addBinding", { name: "lmnrSendEvents" });
3024
+ await sendCDP(page, "Runtime.addBinding", { name: "lmnrSendEvents" });
3013
3025
  logger$8.debug(`Added binding 'lmnrSendEvents' for page ${frameId}, context ${contextId}`);
3014
3026
  } catch (error) {
3015
3027
  logger$8.debug(`Binding may already exist: ${error instanceof Error ? error.message : String(error)}`);
@@ -5778,4 +5790,4 @@ function observeExperimentalDecorator(config) {
5778
5790
  //#endregion
5779
5791
  export { stringifyPromptForTelemetry as _, getSpanProcessor as a, LaminarSpanProcessor as c, Laminar as d, instrumentClaudeAgentQuery as f, consumeStreamResult as g, TracingLevel as h, withTracingLevel as i, getLangVersion as l, LaminarContextManager as m, observeDecorator as n, getTracer as o, ASSOCIATION_PROPERTIES_KEY as p, observeExperimentalDecorator as r, getTracerProvider as s, observe as t, initializeLaminarInstrumentations as u };
5780
5792
 
5781
- //# sourceMappingURL=decorators-DrWG-1Po.mjs.map
5793
+ //# sourceMappingURL=decorators-BKinfQHD.mjs.map