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/cli/bin.cjs CHANGED
@@ -7212,11 +7212,11 @@ var targetByElementSchema2 = objectSchema(
7212
7212
  var targetByPersistSchema2 = objectSchema(
7213
7213
  {
7214
7214
  kind: enumSchema(["persist"]),
7215
- name: stringSchema()
7215
+ persist: stringSchema()
7216
7216
  },
7217
7217
  {
7218
7218
  title: "OpensteerTargetByPersist",
7219
- required: ["kind", "name"]
7219
+ required: ["kind", "persist"]
7220
7220
  }
7221
7221
  );
7222
7222
  var targetBySelectorSchema2 = objectSchema(
@@ -7263,8 +7263,7 @@ var opensteerResolvedTargetSchema = objectSchema(
7263
7263
  var opensteerActionResultSchema = objectSchema(
7264
7264
  {
7265
7265
  target: opensteerResolvedTargetSchema,
7266
- point: pointSchema,
7267
- persisted: stringSchema()
7266
+ point: pointSchema
7268
7267
  },
7269
7268
  {
7270
7269
  title: "OpensteerActionResult",
@@ -11678,8 +11677,8 @@ var OpensteerCloudClient = class {
11678
11677
  entries: entries.map((entry) => ({
11679
11678
  workspace: entry.workspace,
11680
11679
  method: entry.method,
11681
- descriptionHash: entry.nameHash,
11682
- ...entry.name === void 0 ? {} : { description: entry.name },
11680
+ persistHash: entry.persistHash,
11681
+ ...entry.persist === void 0 ? {} : { persist: entry.persist },
11683
11682
  path: entry.path,
11684
11683
  ...entry.schemaHash === void 0 ? {} : { schemaHash: entry.schemaHash },
11685
11684
  createdAt: entry.createdAt,
@@ -13504,8 +13503,8 @@ function createDomDescriptorStore(options) {
13504
13503
  }
13505
13504
  return new MemoryDomDescriptorStore(namespace);
13506
13505
  }
13507
- function hashDomDescriptorName(name) {
13508
- return sha256Hex2(name.trim());
13506
+ function hashDomDescriptorPersist(persist) {
13507
+ return sha256Hex2(persist.trim());
13509
13508
  }
13510
13509
  var DOM_DESCRIPTOR_METHOD_ALIASES = Object.freeze({
13511
13510
  click: "dom.click",
@@ -13519,14 +13518,14 @@ function normalizeDomDescriptorMethod(method) {
13519
13518
  }
13520
13519
  function buildDomDescriptorKeys(options) {
13521
13520
  const namespace = normalizeDomDescriptorNamespace(options.namespace);
13522
- const nameHash = hashDomDescriptorName(options.name);
13521
+ const persistHash = hashDomDescriptorPersist(options.persist);
13523
13522
  const rawMethod = options.method.trim();
13524
13523
  const canonicalMethod = normalizeDomDescriptorMethod(rawMethod);
13525
13524
  const methods = /* @__PURE__ */ new Set([canonicalMethod]);
13526
13525
  if (rawMethod.length > 0) {
13527
13526
  methods.add(rawMethod);
13528
13527
  }
13529
- return [...methods].map((method) => `dom:${namespace}:${method}:${nameHash}`);
13528
+ return [...methods].map((method) => `dom:${namespace}:${method}:${persistHash}`);
13530
13529
  }
13531
13530
  function buildDomDescriptorKey(options) {
13532
13531
  return buildDomDescriptorKeys(options)[0];
@@ -13542,7 +13541,7 @@ function buildDomDescriptorPayload(input) {
13542
13541
  return {
13543
13542
  kind: "dom-target",
13544
13543
  method: normalizeDomDescriptorMethod(input.method),
13545
- name: input.name,
13544
+ persist: input.persist,
13546
13545
  path: sanitizeReplayElementPath(input.path),
13547
13546
  ...input.sourceUrl === void 0 ? {} : { sourceUrl: input.sourceUrl }
13548
13547
  };
@@ -13559,8 +13558,7 @@ function parseDomDescriptorRecord(record) {
13559
13558
  if (raw.kind !== "dom-target") {
13560
13559
  return void 0;
13561
13560
  }
13562
- const name = typeof raw.name === "string" ? raw.name : typeof raw.description === "string" ? raw.description : void 0;
13563
- if (typeof raw.method !== "string" || name === void 0) {
13561
+ if (typeof raw.method !== "string" || typeof raw.persist !== "string") {
13564
13562
  return void 0;
13565
13563
  }
13566
13564
  if (!raw.path || typeof raw.path !== "object" || Array.isArray(raw.path)) {
@@ -13572,7 +13570,7 @@ function parseDomDescriptorRecord(record) {
13572
13570
  const normalizedPayload = {
13573
13571
  kind: "dom-target",
13574
13572
  method: normalizeDomDescriptorMethod(raw.method),
13575
- name,
13573
+ persist: raw.persist,
13576
13574
  path: sanitizeReplayElementPath(raw.path),
13577
13575
  ...typeof raw.sourceUrl === "string" ? { sourceUrl: raw.sourceUrl } : {}
13578
13576
  };
@@ -13594,7 +13592,7 @@ var FilesystemDomDescriptorStore = class {
13594
13592
  for (const key of buildDomDescriptorKeys({
13595
13593
  namespace: this.namespace,
13596
13594
  method: input.method,
13597
- name: input.name
13595
+ persist: input.persist
13598
13596
  })) {
13599
13597
  const record = await this.registry.resolve({ key });
13600
13598
  if (!record) {
@@ -13609,7 +13607,7 @@ var FilesystemDomDescriptorStore = class {
13609
13607
  const key = buildDomDescriptorKey({
13610
13608
  namespace: this.namespace,
13611
13609
  method: input.method,
13612
- name: input.name
13610
+ persist: input.persist
13613
13611
  });
13614
13612
  const version = buildDomDescriptorVersion(payload);
13615
13613
  const existing = await this.registry.resolve({ key, version });
@@ -13652,7 +13650,7 @@ var MemoryDomDescriptorStore = class {
13652
13650
  for (const key of buildDomDescriptorKeys({
13653
13651
  namespace: this.namespace,
13654
13652
  method: input.method,
13655
- name: input.name
13653
+ persist: input.persist
13656
13654
  })) {
13657
13655
  const record = this.latestByKey.get(key);
13658
13656
  if (record) {
@@ -13666,7 +13664,7 @@ var MemoryDomDescriptorStore = class {
13666
13664
  const key = buildDomDescriptorKey({
13667
13665
  namespace: this.namespace,
13668
13666
  method: input.method,
13669
- name: input.name
13667
+ persist: input.persist
13670
13668
  });
13671
13669
  const version = buildDomDescriptorVersion(payload);
13672
13670
  const existing = this.recordsByKey.get(key)?.get(version);
@@ -14598,15 +14596,15 @@ var DefaultDomRuntime = class {
14598
14596
  async resolveDescriptorTarget(session, pageRef, method, target) {
14599
14597
  const descriptor = await this.descriptors.read({
14600
14598
  method,
14601
- name: target.name
14599
+ persist: target.persist
14602
14600
  });
14603
14601
  if (!descriptor) {
14604
14602
  throw new OpensteerProtocolError(
14605
14603
  "not-found",
14606
- `no stored DOM descriptor found for "${target.name}"`,
14604
+ `no stored DOM descriptor found for "${target.persist}"`,
14607
14605
  {
14608
14606
  details: {
14609
- name: target.name,
14607
+ persist: target.persist,
14610
14608
  kind: "dom-descriptor"
14611
14609
  }
14612
14610
  }
@@ -14620,7 +14618,7 @@ var DefaultDomRuntime = class {
14620
14618
  pageRef,
14621
14619
  descriptor.payload.path,
14622
14620
  "descriptor",
14623
- descriptor.payload.name,
14621
+ descriptor.payload.persist,
14624
14622
  descriptor
14625
14623
  );
14626
14624
  }
@@ -14650,7 +14648,7 @@ var DefaultDomRuntime = class {
14650
14648
  const replayPath = await this.tryBuildPathFromNode(snapshot, node);
14651
14649
  const descriptor = target.persist === void 0 ? void 0 : await writeDescriptor({
14652
14650
  method,
14653
- name: target.persist,
14651
+ persist: target.persist,
14654
14652
  path: replayPath ?? await this.buildPathForNode(snapshot, node),
14655
14653
  sourceUrl: snapshot.url
14656
14654
  });
@@ -17666,8 +17664,7 @@ function parseExtractionDescriptorRecord(record) {
17666
17664
  return void 0;
17667
17665
  }
17668
17666
  const raw = payload;
17669
- const persist = typeof raw.persist === "string" ? raw.persist : raw.description;
17670
- if (raw.kind !== "dom-extraction" || typeof persist !== "string") {
17667
+ if (raw.kind !== "dom-extraction" || typeof raw.persist !== "string") {
17671
17668
  return void 0;
17672
17669
  }
17673
17670
  const root = normalizePersistedExtractionNode(raw.root, "root");
@@ -17682,7 +17679,7 @@ function parseExtractionDescriptorRecord(record) {
17682
17679
  updatedAt: record.updatedAt,
17683
17680
  payload: {
17684
17681
  kind: "dom-extraction",
17685
- persist,
17682
+ persist: raw.persist,
17686
17683
  root,
17687
17684
  ...typeof raw.schemaHash === "string" ? { schemaHash: raw.schemaHash } : {},
17688
17685
  ...typeof raw.sourceUrl === "string" ? { sourceUrl: raw.sourceUrl } : {}
@@ -18937,7 +18934,7 @@ function ensureSparseCountersForAllRecords(counterRecords) {
18937
18934
  )
18938
18935
  );
18939
18936
  }
18940
- async function clearLiveCounters(engine, pageRef) {
18937
+ async function clearOpensteerLiveCounters(engine, pageRef) {
18941
18938
  const frames = await engine.listFrames({ pageRef });
18942
18939
  const failures = [];
18943
18940
  for (const frame of frames) {
@@ -19035,7 +19032,7 @@ async function compileOpensteerSnapshot(options) {
19035
19032
  engine: options.engine,
19036
19033
  pageRef: options.pageRef
19037
19034
  });
19038
- await clearLiveCounters(options.engine, options.pageRef);
19035
+ await clearOpensteerLiveCounters(options.engine, options.pageRef);
19039
19036
  await assignSparseCountersToLiveDom(options.engine, options.pageRef);
19040
19037
  const pageInfo = await options.engine.getPageInfo({ pageRef: options.pageRef });
19041
19038
  const mainSnapshot = await getMainDocumentSnapshot(options.engine, options.pageRef);
@@ -19072,7 +19069,7 @@ async function compileOpensteerSnapshot(options) {
19072
19069
  counters: [...compiledHtml.counterRecords.values()].map(toPublicCounterRecord)
19073
19070
  };
19074
19071
  } catch (error) {
19075
- await clearLiveCounters(options.engine, options.pageRef).catch(() => void 0);
19072
+ await clearOpensteerLiveCounters(options.engine, options.pageRef).catch(() => void 0);
19076
19073
  if (attempt < MAX_LIVE_COUNTER_SYNC_ATTEMPTS && isLiveCounterSyncError(error)) {
19077
19074
  lastCounterSyncError = error;
19078
19075
  continue;
@@ -22436,6 +22433,7 @@ var OpensteerSessionRuntime = class {
22436
22433
  });
22437
22434
  boundaryDiagnostics = takeActionBoundaryDiagnostics(timeout.signal);
22438
22435
  timeout.throwIfAborted();
22436
+ await this.invalidateLiveSnapshotCounters([pageRef, output2.pageRef], timeout);
22439
22437
  this.pageRef = output2.pageRef;
22440
22438
  const artifacts2 = await this.persistComputerArtifacts(output2, timeout);
22441
22439
  return {
@@ -22625,7 +22623,7 @@ var OpensteerSessionRuntime = class {
22625
22623
  mutationCaptureDiagnostics = diagnostics;
22626
22624
  }
22627
22625
  );
22628
- const output = toOpensteerActionResult(executed.result, preparedTarget.persisted);
22626
+ const output = toOpensteerActionResult(executed.result);
22629
22627
  const actionEvents = "events" in executed.result ? executed.result.events : void 0;
22630
22628
  await this.appendTrace({
22631
22629
  operation,
@@ -22636,7 +22634,6 @@ var OpensteerSessionRuntime = class {
22636
22634
  data: {
22637
22635
  target: output.target,
22638
22636
  ...output.point === void 0 ? {} : { point: output.point },
22639
- ...output.persisted === void 0 ? {} : { persisted: output.persisted },
22640
22637
  ...boundaryDiagnostics === void 0 ? {} : { settle: boundaryDiagnostics },
22641
22638
  ...buildMutationCaptureTraceData(mutationCaptureDiagnostics)
22642
22639
  },
@@ -22700,7 +22697,7 @@ var OpensteerSessionRuntime = class {
22700
22697
  await timeout.runStep(
22701
22698
  () => this.requireDom().writeDescriptor({
22702
22699
  method,
22703
- name: persist,
22700
+ persist,
22704
22701
  path: stablePath2,
22705
22702
  sourceUrl: resolved2.snapshot.url
22706
22703
  })
@@ -22708,9 +22705,8 @@ var OpensteerSessionRuntime = class {
22708
22705
  return {
22709
22706
  target: {
22710
22707
  kind: "descriptor",
22711
- name: persist
22712
- },
22713
- persisted: persist
22708
+ persist
22709
+ }
22714
22710
  };
22715
22711
  }
22716
22712
  const resolved = await timeout.runStep(
@@ -22733,7 +22729,7 @@ var OpensteerSessionRuntime = class {
22733
22729
  await timeout.runStep(
22734
22730
  () => this.requireDom().writeDescriptor({
22735
22731
  method,
22736
- name: persist,
22732
+ persist,
22737
22733
  path: stablePath,
22738
22734
  sourceUrl: resolved.snapshot.url
22739
22735
  })
@@ -22741,9 +22737,8 @@ var OpensteerSessionRuntime = class {
22741
22737
  return {
22742
22738
  target: {
22743
22739
  kind: "descriptor",
22744
- name: persist
22745
- },
22746
- persisted: persist
22740
+ persist
22741
+ }
22747
22742
  };
22748
22743
  }
22749
22744
  async queryLiveNetwork(input, timeout, options = {}) {
@@ -22799,6 +22794,18 @@ var OpensteerSessionRuntime = class {
22799
22794
  const byRequestId = new Map(withBodies.map((record) => [record.record.requestId, record]));
22800
22795
  return limited.map((record) => byRequestId.get(record.record.requestId) ?? record);
22801
22796
  }
22797
+ async invalidateLiveSnapshotCounters(pageRefs, timeout) {
22798
+ const engine = this.requireEngine();
22799
+ for (const pageRef of new Set(pageRefs)) {
22800
+ try {
22801
+ await timeout.runStep(() => clearOpensteerLiveCounters(engine, pageRef));
22802
+ } catch (error) {
22803
+ if (!isIgnorableRuntimeBindingError(error)) {
22804
+ throw error;
22805
+ }
22806
+ }
22807
+ }
22808
+ }
22802
22809
  async captureScriptsInternal(pageRef, input, timeout) {
22803
22810
  const root = await this.ensureRoot();
22804
22811
  const evaluated = await timeout.runStep(
@@ -23924,7 +23931,7 @@ var OpensteerSessionRuntime = class {
23924
23931
  if (target.kind === "persist") {
23925
23932
  return {
23926
23933
  kind: "descriptor",
23927
- name: target.name
23934
+ persist: target.persist
23928
23935
  };
23929
23936
  }
23930
23937
  if (target.kind === "selector") {
@@ -25641,7 +25648,7 @@ function normalizeNamespace2(value) {
25641
25648
  const normalized = String(value ?? "default").trim();
25642
25649
  return normalized.length === 0 ? "default" : normalized;
25643
25650
  }
25644
- function toOpensteerActionResult(result, persisted) {
25651
+ function toOpensteerActionResult(result) {
25645
25652
  return {
25646
25653
  target: toOpensteerResolvedTarget2(result.resolved),
25647
25654
  ...result.point === void 0 ? {} : {
@@ -25649,8 +25656,7 @@ function toOpensteerActionResult(result, persisted) {
25649
25656
  x: result.point.x,
25650
25657
  y: result.point.y
25651
25658
  }
25652
- },
25653
- ...persisted === void 0 ? {} : { persisted }
25659
+ }
25654
25660
  };
25655
25661
  }
25656
25662
  function toOpensteerResolvedTarget2(target) {
@@ -28875,11 +28881,11 @@ Navigation:
28875
28881
 
28876
28882
  DOM:
28877
28883
  snapshot [action|extraction]
28878
- click <element> [--button left|middle|right] [--persist <name>] [--capture-network <label>]
28879
- hover <element> [--persist <name>] [--capture-network <label>]
28880
- input <element> <text> [--press-enter] [--persist <name>] [--capture-network <label>]
28881
- scroll <direction> <amount> [--element <n>] [--persist <name>] [--capture-network <label>]
28882
- extract <schema> [--persist <name>]
28884
+ click <element> [--button left|middle|right] [--persist <key>] [--capture-network <label>]
28885
+ hover <element> [--persist <key>] [--capture-network <label>]
28886
+ input <element> <text> [--press-enter] [--persist <key>] [--capture-network <label>]
28887
+ scroll <direction> <amount> [--element <n>] [--persist <key>] [--capture-network <label>]
28888
+ extract <schema> [--persist <key>]
28883
28889
  evaluate <script>
28884
28890
  init-script <script>
28885
28891
 
@@ -29399,7 +29405,7 @@ async function buildOperationInput(operation, parsed, runtime) {
29399
29405
  const direction = readSingleDirection(parsed.rest[0]);
29400
29406
  const amount = readRequiredPositiveInteger(parsed.rest[1], "scroll requires an amount.");
29401
29407
  const element = readOptionalNumber(parsed.rawOptions, "element");
29402
- const persist = readPersistName(parsed, "scroll");
29408
+ const persist = readPersistKey(parsed, "scroll");
29403
29409
  const captureNetwork = readSingle(parsed.rawOptions, "capture-network");
29404
29410
  return {
29405
29411
  target: element === void 0 ? {
@@ -29419,7 +29425,7 @@ async function buildOperationInput(operation, parsed, runtime) {
29419
29425
  if (parsed.rest[0] === void 0) {
29420
29426
  throw new Error("extract requires a schema.");
29421
29427
  }
29422
- const persist = readExtractPersistName(parsed);
29428
+ const persist = readExtractPersistKey(parsed);
29423
29429
  return {
29424
29430
  schema: parseRequiredJsonObjectArgument(joinRest(parsed.rest, 0), "extract schema"),
29425
29431
  ...persist === void 0 ? {} : { persist }
@@ -29638,7 +29644,7 @@ function buildElementTargetInput(parsed, verb) {
29638
29644
  parsed.rest[0],
29639
29645
  `${verb} requires an element number.`
29640
29646
  );
29641
- const persist = readPersistName(parsed, verb);
29647
+ const persist = readPersistKey(parsed, verb);
29642
29648
  const captureNetwork = readSingle(parsed.rawOptions, "capture-network");
29643
29649
  return {
29644
29650
  target: {
@@ -29847,26 +29853,26 @@ function readKeyModifiers(value) {
29847
29853
  }
29848
29854
  return [...new Set(modifiers)];
29849
29855
  }
29850
- function readPersistName(parsed, verb) {
29856
+ function readPersistKey(parsed, verb) {
29851
29857
  const value = readSingle(parsed.rawOptions, "persist");
29852
29858
  if (value === void 0) {
29853
29859
  return void 0;
29854
29860
  }
29855
29861
  if (value === "true" || value === "false") {
29856
- throw new Error(`${verb} requires "--persist <name>" when using --persist.`);
29862
+ throw new Error(`${verb} requires "--persist <key>" when using --persist.`);
29857
29863
  }
29858
29864
  if (verb === "scroll" && readOptionalNumber(parsed.rawOptions, "element") === void 0) {
29859
- throw new Error('scroll requires "--element <n>" when using "--persist <name>".');
29865
+ throw new Error('scroll requires "--element <n>" when using "--persist <key>".');
29860
29866
  }
29861
29867
  return value;
29862
29868
  }
29863
- function readExtractPersistName(parsed) {
29869
+ function readExtractPersistKey(parsed) {
29864
29870
  const value = readSingle(parsed.rawOptions, "persist");
29865
29871
  if (value === void 0) {
29866
29872
  return void 0;
29867
29873
  }
29868
29874
  if (value === "true" || value === "false") {
29869
- throw new Error('extract requires "--persist <name>" when using --persist.');
29875
+ throw new Error('extract requires "--persist <key>" when using --persist.');
29870
29876
  }
29871
29877
  return value;
29872
29878
  }
@@ -29963,9 +29969,9 @@ function formatActionOutput(result, input) {
29963
29969
  ...readNumberField(point, "y") === void 0 ? {} : { y: readNumberField(point, "y") }
29964
29970
  };
29965
29971
  }
29966
- const persisted = readStringField(result, "persisted");
29967
- if (persisted !== void 0) {
29968
- output.persisted = persisted;
29972
+ const persist = readStringField(target, "persist");
29973
+ if (persist !== void 0) {
29974
+ output.persist = persist;
29969
29975
  }
29970
29976
  const text = readStringField(input, "text");
29971
29977
  if (text !== void 0) {