opensteer 0.8.14 → 0.8.15

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.cjs CHANGED
@@ -5966,11 +5966,11 @@ var targetByElementSchema2 = objectSchema(
5966
5966
  var targetByPersistSchema2 = objectSchema(
5967
5967
  {
5968
5968
  kind: enumSchema(["persist"]),
5969
- name: stringSchema()
5969
+ persist: stringSchema()
5970
5970
  },
5971
5971
  {
5972
5972
  title: "OpensteerTargetByPersist",
5973
- required: ["kind", "name"]
5973
+ required: ["kind", "persist"]
5974
5974
  }
5975
5975
  );
5976
5976
  var targetBySelectorSchema2 = objectSchema(
@@ -6017,8 +6017,7 @@ var opensteerResolvedTargetSchema = objectSchema(
6017
6017
  var opensteerActionResultSchema = objectSchema(
6018
6018
  {
6019
6019
  target: opensteerResolvedTargetSchema,
6020
- point: pointSchema,
6021
- persisted: stringSchema()
6020
+ point: pointSchema
6022
6021
  },
6023
6022
  {
6024
6023
  title: "OpensteerActionResult",
@@ -10578,8 +10577,8 @@ function createDomDescriptorStore(options) {
10578
10577
  }
10579
10578
  return new MemoryDomDescriptorStore(namespace);
10580
10579
  }
10581
- function hashDomDescriptorName(name) {
10582
- return sha256Hex2(name.trim());
10580
+ function hashDomDescriptorPersist(persist) {
10581
+ return sha256Hex2(persist.trim());
10583
10582
  }
10584
10583
  var DOM_DESCRIPTOR_METHOD_ALIASES = Object.freeze({
10585
10584
  click: "dom.click",
@@ -10593,14 +10592,14 @@ function normalizeDomDescriptorMethod(method) {
10593
10592
  }
10594
10593
  function buildDomDescriptorKeys(options) {
10595
10594
  const namespace = normalizeDomDescriptorNamespace(options.namespace);
10596
- const nameHash = hashDomDescriptorName(options.name);
10595
+ const persistHash = hashDomDescriptorPersist(options.persist);
10597
10596
  const rawMethod = options.method.trim();
10598
10597
  const canonicalMethod = normalizeDomDescriptorMethod(rawMethod);
10599
10598
  const methods = /* @__PURE__ */ new Set([canonicalMethod]);
10600
10599
  if (rawMethod.length > 0) {
10601
10600
  methods.add(rawMethod);
10602
10601
  }
10603
- return [...methods].map((method) => `dom:${namespace}:${method}:${nameHash}`);
10602
+ return [...methods].map((method) => `dom:${namespace}:${method}:${persistHash}`);
10604
10603
  }
10605
10604
  function buildDomDescriptorKey(options) {
10606
10605
  return buildDomDescriptorKeys(options)[0];
@@ -10616,7 +10615,7 @@ function buildDomDescriptorPayload(input) {
10616
10615
  return {
10617
10616
  kind: "dom-target",
10618
10617
  method: normalizeDomDescriptorMethod(input.method),
10619
- name: input.name,
10618
+ persist: input.persist,
10620
10619
  path: sanitizeReplayElementPath(input.path),
10621
10620
  ...input.sourceUrl === void 0 ? {} : { sourceUrl: input.sourceUrl }
10622
10621
  };
@@ -10633,8 +10632,7 @@ function parseDomDescriptorRecord(record) {
10633
10632
  if (raw.kind !== "dom-target") {
10634
10633
  return void 0;
10635
10634
  }
10636
- const name = typeof raw.name === "string" ? raw.name : typeof raw.description === "string" ? raw.description : void 0;
10637
- if (typeof raw.method !== "string" || name === void 0) {
10635
+ if (typeof raw.method !== "string" || typeof raw.persist !== "string") {
10638
10636
  return void 0;
10639
10637
  }
10640
10638
  if (!raw.path || typeof raw.path !== "object" || Array.isArray(raw.path)) {
@@ -10646,7 +10644,7 @@ function parseDomDescriptorRecord(record) {
10646
10644
  const normalizedPayload = {
10647
10645
  kind: "dom-target",
10648
10646
  method: normalizeDomDescriptorMethod(raw.method),
10649
- name,
10647
+ persist: raw.persist,
10650
10648
  path: sanitizeReplayElementPath(raw.path),
10651
10649
  ...typeof raw.sourceUrl === "string" ? { sourceUrl: raw.sourceUrl } : {}
10652
10650
  };
@@ -10668,7 +10666,7 @@ var FilesystemDomDescriptorStore = class {
10668
10666
  for (const key of buildDomDescriptorKeys({
10669
10667
  namespace: this.namespace,
10670
10668
  method: input.method,
10671
- name: input.name
10669
+ persist: input.persist
10672
10670
  })) {
10673
10671
  const record = await this.registry.resolve({ key });
10674
10672
  if (!record) {
@@ -10683,7 +10681,7 @@ var FilesystemDomDescriptorStore = class {
10683
10681
  const key = buildDomDescriptorKey({
10684
10682
  namespace: this.namespace,
10685
10683
  method: input.method,
10686
- name: input.name
10684
+ persist: input.persist
10687
10685
  });
10688
10686
  const version = buildDomDescriptorVersion(payload);
10689
10687
  const existing = await this.registry.resolve({ key, version });
@@ -10726,7 +10724,7 @@ var MemoryDomDescriptorStore = class {
10726
10724
  for (const key of buildDomDescriptorKeys({
10727
10725
  namespace: this.namespace,
10728
10726
  method: input.method,
10729
- name: input.name
10727
+ persist: input.persist
10730
10728
  })) {
10731
10729
  const record = this.latestByKey.get(key);
10732
10730
  if (record) {
@@ -10740,7 +10738,7 @@ var MemoryDomDescriptorStore = class {
10740
10738
  const key = buildDomDescriptorKey({
10741
10739
  namespace: this.namespace,
10742
10740
  method: input.method,
10743
- name: input.name
10741
+ persist: input.persist
10744
10742
  });
10745
10743
  const version = buildDomDescriptorVersion(payload);
10746
10744
  const existing = this.recordsByKey.get(key)?.get(version);
@@ -11707,15 +11705,15 @@ var DefaultDomRuntime = class {
11707
11705
  async resolveDescriptorTarget(session, pageRef, method, target) {
11708
11706
  const descriptor = await this.descriptors.read({
11709
11707
  method,
11710
- name: target.name
11708
+ persist: target.persist
11711
11709
  });
11712
11710
  if (!descriptor) {
11713
11711
  throw new OpensteerProtocolError(
11714
11712
  "not-found",
11715
- `no stored DOM descriptor found for "${target.name}"`,
11713
+ `no stored DOM descriptor found for "${target.persist}"`,
11716
11714
  {
11717
11715
  details: {
11718
- name: target.name,
11716
+ persist: target.persist,
11719
11717
  kind: "dom-descriptor"
11720
11718
  }
11721
11719
  }
@@ -11729,7 +11727,7 @@ var DefaultDomRuntime = class {
11729
11727
  pageRef,
11730
11728
  descriptor.payload.path,
11731
11729
  "descriptor",
11732
- descriptor.payload.name,
11730
+ descriptor.payload.persist,
11733
11731
  descriptor
11734
11732
  );
11735
11733
  }
@@ -11759,7 +11757,7 @@ var DefaultDomRuntime = class {
11759
11757
  const replayPath = await this.tryBuildPathFromNode(snapshot, node);
11760
11758
  const descriptor = target.persist === void 0 ? void 0 : await writeDescriptor({
11761
11759
  method,
11762
- name: target.persist,
11760
+ persist: target.persist,
11763
11761
  path: replayPath ?? await this.buildPathForNode(snapshot, node),
11764
11762
  sourceUrl: snapshot.url
11765
11763
  });
@@ -13851,8 +13849,7 @@ function parseExtractionDescriptorRecord(record) {
13851
13849
  return void 0;
13852
13850
  }
13853
13851
  const raw = payload;
13854
- const persist = typeof raw.persist === "string" ? raw.persist : raw.description;
13855
- if (raw.kind !== "dom-extraction" || typeof persist !== "string") {
13852
+ if (raw.kind !== "dom-extraction" || typeof raw.persist !== "string") {
13856
13853
  return void 0;
13857
13854
  }
13858
13855
  const root = normalizePersistedExtractionNode(raw.root, "root");
@@ -13867,7 +13864,7 @@ function parseExtractionDescriptorRecord(record) {
13867
13864
  updatedAt: record.updatedAt,
13868
13865
  payload: {
13869
13866
  kind: "dom-extraction",
13870
- persist,
13867
+ persist: raw.persist,
13871
13868
  root,
13872
13869
  ...typeof raw.schemaHash === "string" ? { schemaHash: raw.schemaHash } : {},
13873
13870
  ...typeof raw.sourceUrl === "string" ? { sourceUrl: raw.sourceUrl } : {}
@@ -16922,8 +16919,8 @@ var OpensteerCloudClient = class {
16922
16919
  entries: entries.map((entry) => ({
16923
16920
  workspace: entry.workspace,
16924
16921
  method: entry.method,
16925
- descriptionHash: entry.nameHash,
16926
- ...entry.name === void 0 ? {} : { description: entry.name },
16922
+ persistHash: entry.persistHash,
16923
+ ...entry.persist === void 0 ? {} : { persist: entry.persist },
16927
16924
  path: entry.path,
16928
16925
  ...entry.schemaHash === void 0 ? {} : { schemaHash: entry.schemaHash },
16929
16926
  createdAt: entry.createdAt,
@@ -19067,7 +19064,7 @@ function ensureSparseCountersForAllRecords(counterRecords) {
19067
19064
  )
19068
19065
  );
19069
19066
  }
19070
- async function clearLiveCounters(engine, pageRef) {
19067
+ async function clearOpensteerLiveCounters(engine, pageRef) {
19071
19068
  const frames = await engine.listFrames({ pageRef });
19072
19069
  const failures = [];
19073
19070
  for (const frame of frames) {
@@ -19165,7 +19162,7 @@ async function compileOpensteerSnapshot(options) {
19165
19162
  engine: options.engine,
19166
19163
  pageRef: options.pageRef
19167
19164
  });
19168
- await clearLiveCounters(options.engine, options.pageRef);
19165
+ await clearOpensteerLiveCounters(options.engine, options.pageRef);
19169
19166
  await assignSparseCountersToLiveDom(options.engine, options.pageRef);
19170
19167
  const pageInfo = await options.engine.getPageInfo({ pageRef: options.pageRef });
19171
19168
  const mainSnapshot = await getMainDocumentSnapshot(options.engine, options.pageRef);
@@ -19202,7 +19199,7 @@ async function compileOpensteerSnapshot(options) {
19202
19199
  counters: [...compiledHtml.counterRecords.values()].map(toPublicCounterRecord)
19203
19200
  };
19204
19201
  } catch (error) {
19205
- await clearLiveCounters(options.engine, options.pageRef).catch(() => void 0);
19202
+ await clearOpensteerLiveCounters(options.engine, options.pageRef).catch(() => void 0);
19206
19203
  if (attempt < MAX_LIVE_COUNTER_SYNC_ATTEMPTS && isLiveCounterSyncError(error)) {
19207
19204
  lastCounterSyncError = error;
19208
19205
  continue;
@@ -22566,6 +22563,7 @@ var OpensteerSessionRuntime = class {
22566
22563
  });
22567
22564
  boundaryDiagnostics = takeActionBoundaryDiagnostics(timeout.signal);
22568
22565
  timeout.throwIfAborted();
22566
+ await this.invalidateLiveSnapshotCounters([pageRef, output2.pageRef], timeout);
22569
22567
  this.pageRef = output2.pageRef;
22570
22568
  const artifacts2 = await this.persistComputerArtifacts(output2, timeout);
22571
22569
  return {
@@ -22755,7 +22753,7 @@ var OpensteerSessionRuntime = class {
22755
22753
  mutationCaptureDiagnostics = diagnostics;
22756
22754
  }
22757
22755
  );
22758
- const output = toOpensteerActionResult(executed.result, preparedTarget.persisted);
22756
+ const output = toOpensteerActionResult(executed.result);
22759
22757
  const actionEvents = "events" in executed.result ? executed.result.events : void 0;
22760
22758
  await this.appendTrace({
22761
22759
  operation,
@@ -22766,7 +22764,6 @@ var OpensteerSessionRuntime = class {
22766
22764
  data: {
22767
22765
  target: output.target,
22768
22766
  ...output.point === void 0 ? {} : { point: output.point },
22769
- ...output.persisted === void 0 ? {} : { persisted: output.persisted },
22770
22767
  ...boundaryDiagnostics === void 0 ? {} : { settle: boundaryDiagnostics },
22771
22768
  ...buildMutationCaptureTraceData(mutationCaptureDiagnostics)
22772
22769
  },
@@ -22830,7 +22827,7 @@ var OpensteerSessionRuntime = class {
22830
22827
  await timeout.runStep(
22831
22828
  () => this.requireDom().writeDescriptor({
22832
22829
  method,
22833
- name: persist,
22830
+ persist,
22834
22831
  path: stablePath2,
22835
22832
  sourceUrl: resolved2.snapshot.url
22836
22833
  })
@@ -22838,9 +22835,8 @@ var OpensteerSessionRuntime = class {
22838
22835
  return {
22839
22836
  target: {
22840
22837
  kind: "descriptor",
22841
- name: persist
22842
- },
22843
- persisted: persist
22838
+ persist
22839
+ }
22844
22840
  };
22845
22841
  }
22846
22842
  const resolved = await timeout.runStep(
@@ -22863,7 +22859,7 @@ var OpensteerSessionRuntime = class {
22863
22859
  await timeout.runStep(
22864
22860
  () => this.requireDom().writeDescriptor({
22865
22861
  method,
22866
- name: persist,
22862
+ persist,
22867
22863
  path: stablePath,
22868
22864
  sourceUrl: resolved.snapshot.url
22869
22865
  })
@@ -22871,9 +22867,8 @@ var OpensteerSessionRuntime = class {
22871
22867
  return {
22872
22868
  target: {
22873
22869
  kind: "descriptor",
22874
- name: persist
22875
- },
22876
- persisted: persist
22870
+ persist
22871
+ }
22877
22872
  };
22878
22873
  }
22879
22874
  async queryLiveNetwork(input, timeout, options = {}) {
@@ -22929,6 +22924,18 @@ var OpensteerSessionRuntime = class {
22929
22924
  const byRequestId = new Map(withBodies.map((record) => [record.record.requestId, record]));
22930
22925
  return limited.map((record) => byRequestId.get(record.record.requestId) ?? record);
22931
22926
  }
22927
+ async invalidateLiveSnapshotCounters(pageRefs, timeout) {
22928
+ const engine = this.requireEngine();
22929
+ for (const pageRef of new Set(pageRefs)) {
22930
+ try {
22931
+ await timeout.runStep(() => clearOpensteerLiveCounters(engine, pageRef));
22932
+ } catch (error) {
22933
+ if (!isIgnorableRuntimeBindingError(error)) {
22934
+ throw error;
22935
+ }
22936
+ }
22937
+ }
22938
+ }
22932
22939
  async captureScriptsInternal(pageRef, input, timeout) {
22933
22940
  const root = await this.ensureRoot();
22934
22941
  const evaluated = await timeout.runStep(
@@ -24054,7 +24061,7 @@ var OpensteerSessionRuntime = class {
24054
24061
  if (target.kind === "persist") {
24055
24062
  return {
24056
24063
  kind: "descriptor",
24057
- name: target.name
24064
+ persist: target.persist
24058
24065
  };
24059
24066
  }
24060
24067
  if (target.kind === "selector") {
@@ -25771,7 +25778,7 @@ function normalizeNamespace2(value) {
25771
25778
  const normalized = String(value ?? "default").trim();
25772
25779
  return normalized.length === 0 ? "default" : normalized;
25773
25780
  }
25774
- function toOpensteerActionResult(result, persisted) {
25781
+ function toOpensteerActionResult(result) {
25775
25782
  return {
25776
25783
  target: toOpensteerResolvedTarget2(result.resolved),
25777
25784
  ...result.point === void 0 ? {} : {
@@ -25779,8 +25786,7 @@ function toOpensteerActionResult(result, persisted) {
25779
25786
  x: result.point.x,
25780
25787
  y: result.point.y
25781
25788
  }
25782
- },
25783
- ...persisted === void 0 ? {} : { persisted }
25789
+ }
25784
25790
  };
25785
25791
  }
25786
25792
  function toOpensteerResolvedTarget2(target) {
@@ -27483,7 +27489,7 @@ function normalizeTargetOptions(input) {
27483
27489
  return {
27484
27490
  target: {
27485
27491
  kind: "persist",
27486
- name: input.persist
27492
+ persist: input.persist
27487
27493
  },
27488
27494
  ...input.captureNetwork === void 0 ? {} : { captureNetwork: input.captureNetwork }
27489
27495
  };
@@ -27557,7 +27563,7 @@ exports.defaultTimeoutPolicy = defaultTimeoutPolicy;
27557
27563
  exports.delayWithSignal = delayWithSignal;
27558
27564
  exports.discoverLocalCdpBrowsers = discoverLocalCdpBrowsers;
27559
27565
  exports.dispatchSemanticOperation = dispatchSemanticOperation;
27560
- exports.hashDomDescriptorName = hashDomDescriptorName;
27566
+ exports.hashDomDescriptorPersist = hashDomDescriptorPersist;
27561
27567
  exports.inspectCdpEndpoint = inspectCdpEndpoint;
27562
27568
  exports.isCurrentUrlField = isCurrentUrlField;
27563
27569
  exports.isValidCssAttributeKey = isValidCssAttributeKey;