opensteer 0.8.7 → 0.8.8

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.
@@ -1442,7 +1442,7 @@ var networkRecordSchema = objectSchema(
1442
1442
  var networkQueryRecordSchema = objectSchema(
1443
1443
  {
1444
1444
  recordId: stringSchema({ minLength: 1 }),
1445
- actionId: stringSchema({ minLength: 1 }),
1445
+ capture: stringSchema({ minLength: 1 }),
1446
1446
  tags: arraySchema(stringSchema({ minLength: 1 }), {
1447
1447
  uniqueItems: true
1448
1448
  }),
@@ -1922,8 +1922,7 @@ var opensteerRecipeStepSchema = oneOfSchema(
1922
1922
  objectSchema(
1923
1923
  {
1924
1924
  kind: enumSchema(["goto"]),
1925
- url: stringSchema({ minLength: 1 }),
1926
- networkTag: stringSchema({ minLength: 1 })
1925
+ url: stringSchema({ minLength: 1 })
1927
1926
  },
1928
1927
  {
1929
1928
  title: "OpensteerAuthRecipeGotoStep",
@@ -1932,8 +1931,7 @@ var opensteerRecipeStepSchema = oneOfSchema(
1932
1931
  ),
1933
1932
  objectSchema(
1934
1933
  {
1935
- kind: enumSchema(["reload"]),
1936
- networkTag: stringSchema({ minLength: 1 })
1934
+ kind: enumSchema(["reload"])
1937
1935
  },
1938
1936
  {
1939
1937
  title: "OpensteerAuthRecipeReloadStep",
@@ -2150,7 +2148,7 @@ var opensteerNetworkQueryInputSchema = objectSchema(
2150
2148
  pageRef: pageRefSchema,
2151
2149
  recordId: stringSchema({ minLength: 1 }),
2152
2150
  requestId: stringSchema({ minLength: 1 }),
2153
- actionId: stringSchema({ minLength: 1 }),
2151
+ capture: stringSchema({ minLength: 1 }),
2154
2152
  tag: stringSchema({ minLength: 1 }),
2155
2153
  url: stringSchema({ minLength: 1 }),
2156
2154
  hostname: stringSchema({ minLength: 1 }),
@@ -2179,7 +2177,7 @@ var opensteerNetworkTagInputSchema = objectSchema(
2179
2177
  pageRef: pageRefSchema,
2180
2178
  recordId: stringSchema({ minLength: 1 }),
2181
2179
  requestId: stringSchema({ minLength: 1 }),
2182
- actionId: stringSchema({ minLength: 1 }),
2180
+ capture: stringSchema({ minLength: 1 }),
2183
2181
  tag: stringSchema({ minLength: 1 }),
2184
2182
  url: stringSchema({ minLength: 1 }),
2185
2183
  hostname: stringSchema({ minLength: 1 }),
@@ -2204,6 +2202,7 @@ var opensteerNetworkTagOutputSchema = objectSchema(
2204
2202
  );
2205
2203
  var opensteerNetworkClearInputSchema = objectSchema(
2206
2204
  {
2205
+ capture: stringSchema({ minLength: 1 }),
2207
2206
  tag: stringSchema({ minLength: 1 })
2208
2207
  },
2209
2208
  {
@@ -6055,7 +6054,7 @@ var opensteerPageCloseOutputSchema = objectSchema(
6055
6054
  var opensteerPageGotoInputSchema = objectSchema(
6056
6055
  {
6057
6056
  url: stringSchema(),
6058
- networkTag: stringSchema({ minLength: 1 })
6057
+ captureNetwork: stringSchema({ minLength: 1 })
6059
6058
  },
6060
6059
  {
6061
6060
  title: "OpensteerPageGotoInput",
@@ -6206,7 +6205,7 @@ var opensteerDomClickInputSchema = objectSchema(
6206
6205
  {
6207
6206
  target: opensteerTargetInputSchema,
6208
6207
  persistAsDescription: stringSchema(),
6209
- networkTag: stringSchema({ minLength: 1 })
6208
+ captureNetwork: stringSchema({ minLength: 1 })
6210
6209
  },
6211
6210
  {
6212
6211
  title: "OpensteerDomClickInput",
@@ -6217,7 +6216,7 @@ var opensteerDomHoverInputSchema = objectSchema(
6217
6216
  {
6218
6217
  target: opensteerTargetInputSchema,
6219
6218
  persistAsDescription: stringSchema(),
6220
- networkTag: stringSchema({ minLength: 1 })
6219
+ captureNetwork: stringSchema({ minLength: 1 })
6221
6220
  },
6222
6221
  {
6223
6222
  title: "OpensteerDomHoverInput",
@@ -6230,7 +6229,7 @@ var opensteerDomInputInputSchema = objectSchema(
6230
6229
  text: stringSchema(),
6231
6230
  pressEnter: { type: "boolean" },
6232
6231
  persistAsDescription: stringSchema(),
6233
- networkTag: stringSchema({ minLength: 1 })
6232
+ captureNetwork: stringSchema({ minLength: 1 })
6234
6233
  },
6235
6234
  {
6236
6235
  title: "OpensteerDomInputInput",
@@ -6243,7 +6242,7 @@ var opensteerDomScrollInputSchema = objectSchema(
6243
6242
  direction: enumSchema(["up", "down", "left", "right"]),
6244
6243
  amount: integerSchema({ minimum: 1 }),
6245
6244
  persistAsDescription: stringSchema(),
6246
- networkTag: stringSchema({ minLength: 1 })
6245
+ captureNetwork: stringSchema({ minLength: 1 })
6247
6246
  },
6248
6247
  {
6249
6248
  title: "OpensteerDomScrollInput",
@@ -6444,7 +6443,7 @@ var opensteerComputerExecuteInputSchema = objectSchema(
6444
6443
  {
6445
6444
  action: opensteerComputerActionSchema,
6446
6445
  screenshot: opensteerComputerScreenshotOptionsSchema,
6447
- networkTag: stringSchema({ minLength: 1 })
6446
+ captureNetwork: stringSchema({ minLength: 1 })
6448
6447
  },
6449
6448
  {
6450
6449
  title: "OpensteerComputerExecuteInput",
@@ -7570,7 +7569,7 @@ var SqliteSavedNetworkStore = class {
7570
7569
  page_ref_key: pageRefKey,
7571
7570
  frame_ref: entry.record.frameRef ?? null,
7572
7571
  document_ref: entry.record.documentRef ?? null,
7573
- action_id: entry.actionId ?? null,
7572
+ capture: entry.capture ?? null,
7574
7573
  method: entry.record.method,
7575
7574
  method_lc: entry.record.method.toLowerCase(),
7576
7575
  url: entry.record.url,
@@ -7683,39 +7682,31 @@ var SqliteSavedNetworkStore = class {
7683
7682
  }
7684
7683
  async clear(input = {}) {
7685
7684
  const database = await this.requireDatabase();
7686
- const countAll = database.prepare(`
7687
- SELECT COUNT(*) AS cleared
7688
- FROM saved_network_records
7689
- `);
7690
- const countByTag = database.prepare(`
7691
- SELECT COUNT(DISTINCT record_id) AS cleared
7692
- FROM saved_network_tags
7693
- WHERE tag = @tag
7694
- `);
7695
- const deleteAllTags = database.prepare(`DELETE FROM saved_network_tags`);
7685
+ const countAll = database.prepare(`SELECT COUNT(*) AS cleared FROM saved_network_records`);
7696
7686
  const deleteAllRecords = database.prepare(`DELETE FROM saved_network_records`);
7697
- const deleteTag = database.prepare(`
7698
- DELETE FROM saved_network_tags
7699
- WHERE tag = @tag
7687
+ const { whereSql, parameters } = buildSavedNetworkWhere(input);
7688
+ const countFiltered = database.prepare(`
7689
+ SELECT COUNT(*) AS cleared
7690
+ FROM saved_network_records r
7691
+ ${whereSql}
7700
7692
  `);
7701
- const deleteOrphans = database.prepare(`
7693
+ const deleteFiltered = database.prepare(`
7702
7694
  DELETE FROM saved_network_records
7703
- WHERE NOT EXISTS (
7704
- SELECT 1
7705
- FROM saved_network_tags t
7706
- WHERE t.record_id = saved_network_records.record_id
7695
+ WHERE record_id IN (
7696
+ SELECT r.record_id
7697
+ FROM saved_network_records r
7698
+ ${whereSql}
7707
7699
  )
7708
7700
  `);
7709
7701
  return withSqliteTransaction(database, () => {
7710
- const tag = input.tag;
7711
- const cleared = tag === void 0 ? countAll.get().cleared : countByTag.get({ tag }).cleared;
7712
- if (tag === void 0) {
7713
- deleteAllTags.run();
7702
+ if (input.capture === void 0 && input.tag === void 0) {
7703
+ const cleared2 = countAll.get().cleared;
7714
7704
  deleteAllRecords.run();
7715
- return cleared;
7705
+ return cleared2;
7716
7706
  }
7717
- deleteTag.run({ tag });
7718
- deleteOrphans.run();
7707
+ const args = parameters;
7708
+ const cleared = countFiltered.get(...args).cleared;
7709
+ deleteFiltered.run(...args);
7719
7710
  return cleared;
7720
7711
  });
7721
7712
  }
@@ -7770,7 +7761,7 @@ var SqliteSavedNetworkStore = class {
7770
7761
  page_ref_key TEXT NOT NULL,
7771
7762
  frame_ref TEXT,
7772
7763
  document_ref TEXT,
7773
- action_id TEXT,
7764
+ capture TEXT,
7774
7765
  method TEXT NOT NULL,
7775
7766
  method_lc TEXT NOT NULL,
7776
7767
  url TEXT NOT NULL,
@@ -7809,6 +7800,9 @@ var SqliteSavedNetworkStore = class {
7809
7800
  CREATE INDEX IF NOT EXISTS saved_network_records_saved_at
7810
7801
  ON saved_network_records (saved_at DESC);
7811
7802
 
7803
+ CREATE INDEX IF NOT EXISTS saved_network_records_capture
7804
+ ON saved_network_records (capture);
7805
+
7812
7806
  CREATE TABLE IF NOT EXISTS saved_network_tags (
7813
7807
  record_id TEXT NOT NULL REFERENCES saved_network_records(record_id) ON DELETE CASCADE,
7814
7808
  tag TEXT NOT NULL,
@@ -7824,6 +7818,7 @@ var SqliteSavedNetworkStore = class {
7824
7818
  "capture_state",
7825
7819
  "TEXT NOT NULL DEFAULT 'complete'"
7826
7820
  );
7821
+ this.ensureColumn(database, "saved_network_records", "capture", "TEXT");
7827
7822
  this.ensureColumn(
7828
7823
  database,
7829
7824
  "saved_network_records",
@@ -7864,9 +7859,9 @@ function buildSavedNetworkWhere(input) {
7864
7859
  clauses.push("r.request_id = ?");
7865
7860
  parameters.push(input.requestId);
7866
7861
  }
7867
- if (input.actionId !== void 0) {
7868
- clauses.push("r.action_id = ?");
7869
- parameters.push(input.actionId);
7862
+ if (input.capture !== void 0) {
7863
+ clauses.push("r.capture = ?");
7864
+ parameters.push(input.capture);
7870
7865
  }
7871
7866
  if (input.tag !== void 0) {
7872
7867
  clauses.push(`
@@ -7928,7 +7923,7 @@ function buildSavedNetworkUpsertSql(bodyWriteMode) {
7928
7923
  page_ref_key,
7929
7924
  frame_ref,
7930
7925
  document_ref,
7931
- action_id,
7926
+ capture,
7932
7927
  method,
7933
7928
  method_lc,
7934
7929
  url,
@@ -7967,7 +7962,7 @@ function buildSavedNetworkUpsertSql(bodyWriteMode) {
7967
7962
  @page_ref_key,
7968
7963
  @frame_ref,
7969
7964
  @document_ref,
7970
- @action_id,
7965
+ @capture,
7971
7966
  @method,
7972
7967
  @method_lc,
7973
7968
  @url,
@@ -8004,7 +7999,7 @@ function buildSavedNetworkUpsertSql(bodyWriteMode) {
8004
7999
  page_ref_key = excluded.page_ref_key,
8005
8000
  frame_ref = excluded.frame_ref,
8006
8001
  document_ref = excluded.document_ref,
8007
- action_id = excluded.action_id,
8002
+ capture = excluded.capture,
8008
8003
  method = excluded.method,
8009
8004
  method_lc = excluded.method_lc,
8010
8005
  url = excluded.url,
@@ -8099,7 +8094,7 @@ function inflateSavedNetworkRow(row, includeBodies) {
8099
8094
  }
8100
8095
  return {
8101
8096
  recordId: row.record_id,
8102
- ...row.action_id === null ? {} : { actionId: row.action_id },
8097
+ ...row.capture === null ? {} : { capture: row.capture },
8103
8098
  ...row.tags === null || row.tags.length === 0 ? {} : { tags: row.tags.split(TAG_DELIMITER).filter((tag) => tag.length > 0) },
8104
8099
  savedAt: row.saved_at,
8105
8100
  record
@@ -8439,9 +8434,9 @@ var DEFAULT_TIMEOUTS = {
8439
8434
  "page.add-init-script": 1e4,
8440
8435
  "page.snapshot": 15e3,
8441
8436
  "computer.execute": 3e4,
8442
- "dom.click": 1e4,
8437
+ "dom.click": 3e4,
8443
8438
  "dom.hover": 1e4,
8444
- "dom.input": 1e4,
8439
+ "dom.input": 3e4,
8445
8440
  "dom.scroll": 1e4,
8446
8441
  "dom.extract": 15e3,
8447
8442
  "network.query": 15e3,
@@ -10236,6 +10231,7 @@ var MemoryDomDescriptorStore = class {
10236
10231
  };
10237
10232
 
10238
10233
  // ../runtime-core/src/action-boundary.ts
10234
+ var actionBoundaryDiagnosticsBySignal = /* @__PURE__ */ new WeakMap();
10239
10235
  async function captureActionBoundarySnapshot(engine, pageRef) {
10240
10236
  const frames = await engine.listFrames({ pageRef });
10241
10237
  const mainFrame = frames.find((frame) => frame.isMainFrame);
@@ -10247,6 +10243,35 @@ async function captureActionBoundarySnapshot(engine, pageRef) {
10247
10243
  documentRef: mainFrame.documentRef
10248
10244
  };
10249
10245
  }
10246
+ function createActionBoundaryDiagnostics(input) {
10247
+ return {
10248
+ trigger: input.boundary.trigger,
10249
+ crossDocument: input.boundary.crossDocument,
10250
+ bootstrapSettled: input.boundary.bootstrapSettled,
10251
+ visualSettled: input.visualSettled,
10252
+ ...input.boundary.timedOutPhase !== void 0 ? { timedOutPhase: input.boundary.timedOutPhase } : !input.visualSettled ? { timedOutPhase: "visual" } : {}
10253
+ };
10254
+ }
10255
+ function recordActionBoundaryDiagnostics(signal, diagnostics) {
10256
+ actionBoundaryDiagnosticsBySignal.set(signal, diagnostics);
10257
+ }
10258
+ function takeActionBoundaryDiagnostics(signal) {
10259
+ const diagnostics = actionBoundaryDiagnosticsBySignal.get(signal);
10260
+ actionBoundaryDiagnosticsBySignal.delete(signal);
10261
+ return diagnostics;
10262
+ }
10263
+ function isSoftSettleTimeoutError(error, signal) {
10264
+ if (isTimeoutError(error)) {
10265
+ return true;
10266
+ }
10267
+ return signal?.aborted === true && isTimeoutError(signal.reason) && (error === signal.reason || isAbortError(error));
10268
+ }
10269
+ function isAbortError(error) {
10270
+ return error instanceof Error && error.name === "AbortError";
10271
+ }
10272
+ function isTimeoutError(error) {
10273
+ return isOpensteerProtocolError(error) && error.code === "timeout";
10274
+ }
10250
10275
 
10251
10276
  // ../runtime-core/src/runtimes/dom/executor.ts
10252
10277
  var MAX_DOM_ACTION_ATTEMPTS = 3;
@@ -10379,7 +10404,7 @@ var DomActionExecutor = class {
10379
10404
  let finalResolved = resolved;
10380
10405
  let finalSnapshot;
10381
10406
  if (input.pressEnter) {
10382
- await this.settle(resolved.pageRef, "dom.input", timeout);
10407
+ await this.waitForPressEnterReaction(timeout);
10383
10408
  const enterSession = this.options.createResolutionSession();
10384
10409
  const enterResolved = await timeout.runStep(
10385
10410
  () => this.options.resolveTarget(enterSession, {
@@ -10403,7 +10428,15 @@ var DomActionExecutor = class {
10403
10428
  );
10404
10429
  finalResolved = enterResolved;
10405
10430
  }
10406
- await this.settle(finalResolved.pageRef, "dom.input", timeout, finalSnapshot);
10431
+ const settleDiagnostics = await this.settle(
10432
+ finalResolved.pageRef,
10433
+ "dom.input",
10434
+ timeout,
10435
+ finalSnapshot
10436
+ );
10437
+ if (finalSnapshot !== void 0) {
10438
+ recordActionBoundaryDiagnostics(timeout.signal, settleDiagnostics);
10439
+ }
10407
10440
  return finalResolved;
10408
10441
  } catch (error) {
10409
10442
  lastError = error;
@@ -10480,12 +10513,13 @@ var DomActionExecutor = class {
10480
10513
  () => captureActionBoundarySnapshot(this.options.engine, pointerTarget.resolved.pageRef)
10481
10514
  );
10482
10515
  const outcome = await dispatch(pointerTarget, point, timeout);
10483
- await this.settle(
10516
+ const settleDiagnostics = await this.settle(
10484
10517
  pointerTarget.resolved.pageRef,
10485
10518
  input.operation,
10486
10519
  timeout,
10487
10520
  actionBoundarySnapshot
10488
10521
  );
10522
+ recordActionBoundaryDiagnostics(timeout.signal, settleDiagnostics);
10489
10523
  return outcome;
10490
10524
  } catch (error) {
10491
10525
  lastError = error;
@@ -10505,22 +10539,47 @@ var DomActionExecutor = class {
10505
10539
  }
10506
10540
  async settle(pageRef, operation, timeout, snapshot) {
10507
10541
  const bridge = this.requireBridge();
10508
- await timeout.runStep(
10542
+ let visualSettled = true;
10543
+ const boundary = await timeout.runStep(
10509
10544
  () => bridge.finalizeDomAction(pageRef, {
10510
10545
  operation,
10511
10546
  ...snapshot === void 0 ? {} : { snapshot },
10512
10547
  signal: timeout.signal,
10513
10548
  remainingMs: () => timeout.remainingMs(),
10514
- policySettle: (targetPageRef, trigger) => settleWithPolicy(this.options.policy.settle, {
10515
- operation,
10516
- trigger,
10517
- engine: this.options.engine,
10518
- pageRef: targetPageRef,
10519
- signal: timeout.signal,
10520
- remainingMs: timeout.remainingMs()
10521
- })
10549
+ policySettle: async (targetPageRef, trigger) => {
10550
+ try {
10551
+ await settleWithPolicy(this.options.policy.settle, {
10552
+ operation,
10553
+ trigger,
10554
+ engine: this.options.engine,
10555
+ pageRef: targetPageRef,
10556
+ signal: timeout.signal,
10557
+ remainingMs: timeout.remainingMs()
10558
+ });
10559
+ } catch (error) {
10560
+ if (snapshot !== void 0 && isSoftSettleTimeoutError(error, timeout.signal)) {
10561
+ visualSettled = false;
10562
+ return;
10563
+ }
10564
+ throw error;
10565
+ }
10566
+ }
10522
10567
  })
10523
10568
  );
10569
+ return createActionBoundaryDiagnostics({
10570
+ boundary,
10571
+ visualSettled
10572
+ });
10573
+ }
10574
+ async waitForPressEnterReaction(timeout) {
10575
+ const delayMs = this.options.policy.settle.resolveDelayMs({
10576
+ operation: "dom.input",
10577
+ trigger: "dom-action"
10578
+ });
10579
+ if (delayMs <= 0) {
10580
+ return;
10581
+ }
10582
+ await delayWithSignal(delayMs, timeout.signal);
10524
10583
  }
10525
10584
  requireBridge() {
10526
10585
  if (this.bridge !== void 0) {
@@ -16044,7 +16103,7 @@ async function dispatchSemanticOperation(runtime, operation, input, options = {}
16044
16103
 
16045
16104
  // ../runtime-core/package.json
16046
16105
  var package_default = {
16047
- version: "0.1.1"};
16106
+ version: "0.1.2"};
16048
16107
 
16049
16108
  // ../runtime-core/src/version.ts
16050
16109
  var OPENSTEER_RUNTIME_CORE_VERSION = package_default.version;
@@ -16345,6 +16404,7 @@ var DefaultComputerUseRuntime = class {
16345
16404
  const snapshot = await input.timeout.runStep(
16346
16405
  () => captureActionBoundarySnapshot(this.options.engine, input.pageRef)
16347
16406
  );
16407
+ let visualSettled = true;
16348
16408
  const executed = await input.timeout.runStep(
16349
16409
  () => bridge.execute({
16350
16410
  pageRef: input.pageRef,
@@ -16353,16 +16413,35 @@ var DefaultComputerUseRuntime = class {
16353
16413
  screenshot,
16354
16414
  signal: input.timeout.signal,
16355
16415
  remainingMs: () => input.timeout.remainingMs(),
16356
- policySettle: async (pageRef, trigger) => settleWithPolicy(this.options.policy.settle, {
16357
- operation: "computer.execute",
16358
- trigger,
16359
- engine: this.options.engine,
16360
- pageRef,
16361
- signal: input.timeout.signal,
16362
- remainingMs: input.timeout.remainingMs()
16363
- })
16416
+ policySettle: async (pageRef, trigger) => {
16417
+ try {
16418
+ await settleWithPolicy(this.options.policy.settle, {
16419
+ operation: "computer.execute",
16420
+ trigger,
16421
+ engine: this.options.engine,
16422
+ pageRef,
16423
+ signal: input.timeout.signal,
16424
+ remainingMs: input.timeout.remainingMs()
16425
+ });
16426
+ } catch (error) {
16427
+ if (pageRef === input.pageRef && isSoftSettleTimeoutError(error, input.timeout.signal)) {
16428
+ visualSettled = false;
16429
+ return;
16430
+ }
16431
+ throw error;
16432
+ }
16433
+ }
16364
16434
  })
16365
16435
  );
16436
+ if (executed.boundary !== void 0 && executed.pageRef === input.pageRef) {
16437
+ recordActionBoundaryDiagnostics(
16438
+ input.timeout.signal,
16439
+ createActionBoundaryDiagnostics({
16440
+ boundary: executed.boundary,
16441
+ visualSettled
16442
+ })
16443
+ );
16444
+ }
16366
16445
  let trace = void 0;
16367
16446
  if (!input.timeout.signal.aborted) {
16368
16447
  try {
@@ -17474,7 +17553,7 @@ function resolveBodyEncoding(charset) {
17474
17553
  var NetworkHistory = class {
17475
17554
  metadataByRequestId = /* @__PURE__ */ new Map();
17476
17555
  requestIdByRecordId = /* @__PURE__ */ new Map();
17477
- requestIdsByActionId = /* @__PURE__ */ new Map();
17556
+ requestIdsByCapture = /* @__PURE__ */ new Map();
17478
17557
  requestIdsByTag = /* @__PURE__ */ new Map();
17479
17558
  tombstonedRequestIds = /* @__PURE__ */ new Set();
17480
17559
  materialize(records, options = {}) {
@@ -17521,17 +17600,17 @@ var NetworkHistory = class {
17521
17600
  }
17522
17601
  return persisted;
17523
17602
  }
17524
- assignActionId(records, actionId) {
17603
+ assignCapture(records, capture) {
17525
17604
  for (const record of records) {
17526
17605
  const metadata = this.metadataByRequestId.get(record.record.requestId);
17527
- if (!metadata || metadata.actionId === actionId) {
17606
+ if (!metadata || metadata.capture === capture) {
17528
17607
  continue;
17529
17608
  }
17530
- if (metadata.actionId !== void 0) {
17531
- this.requestIdsByActionId.get(metadata.actionId)?.delete(record.record.requestId);
17609
+ if (metadata.capture !== void 0) {
17610
+ this.requestIdsByCapture.get(metadata.capture)?.delete(record.record.requestId);
17532
17611
  }
17533
- metadata.actionId = actionId;
17534
- this.addIndexedRequestId(this.requestIdsByActionId, actionId, record.record.requestId);
17612
+ metadata.capture = capture;
17613
+ this.addIndexedRequestId(this.requestIdsByCapture, capture, record.record.requestId);
17535
17614
  }
17536
17615
  }
17537
17616
  addTag(records, tag) {
@@ -17551,8 +17630,8 @@ var NetworkHistory = class {
17551
17630
  getRequestId(recordId) {
17552
17631
  return this.requestIdByRecordId.get(recordId);
17553
17632
  }
17554
- getRequestIdsForActionId(actionId) {
17555
- return new Set(this.requestIdsByActionId.get(actionId) ?? []);
17633
+ getRequestIdsForCapture(capture) {
17634
+ return new Set(this.requestIdsByCapture.get(capture) ?? []);
17556
17635
  }
17557
17636
  getRequestIdsForTag(tag) {
17558
17637
  return new Set(this.requestIdsByTag.get(tag) ?? []);
@@ -17563,20 +17642,6 @@ var NetworkHistory = class {
17563
17642
  getKnownRequestIds() {
17564
17643
  return new Set(this.metadataByRequestId.keys());
17565
17644
  }
17566
- clearTag(tag) {
17567
- const requestIds = [...this.requestIdsByTag.get(tag) ?? []];
17568
- this.requestIdsByTag.delete(tag);
17569
- for (const requestId of requestIds) {
17570
- const metadata = this.metadataByRequestId.get(requestId);
17571
- if (!metadata) {
17572
- continue;
17573
- }
17574
- metadata.tags.delete(tag);
17575
- if (metadata.tags.size === 0) {
17576
- this.tombstoneRequestIds([requestId]);
17577
- }
17578
- }
17579
- }
17580
17645
  tombstoneRequestIds(requestIds) {
17581
17646
  for (const requestId of requestIds) {
17582
17647
  this.tombstonedRequestIds.add(requestId);
@@ -17586,8 +17651,8 @@ var NetworkHistory = class {
17586
17651
  }
17587
17652
  this.metadataByRequestId.delete(requestId);
17588
17653
  this.requestIdByRecordId.delete(metadata.recordId);
17589
- if (metadata.actionId !== void 0) {
17590
- this.requestIdsByActionId.get(metadata.actionId)?.delete(requestId);
17654
+ if (metadata.capture !== void 0) {
17655
+ this.requestIdsByCapture.get(metadata.capture)?.delete(requestId);
17591
17656
  }
17592
17657
  for (const tag of metadata.tags) {
17593
17658
  this.requestIdsByTag.get(tag)?.delete(requestId);
@@ -17597,7 +17662,7 @@ var NetworkHistory = class {
17597
17662
  clear() {
17598
17663
  this.metadataByRequestId.clear();
17599
17664
  this.requestIdByRecordId.clear();
17600
- this.requestIdsByActionId.clear();
17665
+ this.requestIdsByCapture.clear();
17601
17666
  this.requestIdsByTag.clear();
17602
17667
  this.tombstonedRequestIds.clear();
17603
17668
  }
@@ -17620,7 +17685,7 @@ var NetworkHistory = class {
17620
17685
  }
17621
17686
  return {
17622
17687
  recordId: metadata.recordId,
17623
- ...metadata.actionId === void 0 ? {} : { actionId: metadata.actionId },
17688
+ ...metadata.capture === void 0 ? {} : { capture: metadata.capture },
17624
17689
  ...metadata.tags.size === 0 ? {} : { tags: [...metadata.tags].sort() },
17625
17690
  ...metadata.savedAt === void 0 ? {} : { savedAt: metadata.savedAt },
17626
17691
  record: toProtocolNetworkRecord(record, {
@@ -22438,6 +22503,7 @@ function diffInteractionTraces(left, right) {
22438
22503
 
22439
22504
  // ../runtime-core/src/sdk/runtime.ts
22440
22505
  var requireForAuthRecipeHook = createRequire(import.meta.url);
22506
+ var MUTATION_CAPTURE_FINALIZE_TIMEOUT_MS = 5e3;
22441
22507
  var OpensteerSessionRuntime = class {
22442
22508
  workspace;
22443
22509
  rootPath;
@@ -22820,34 +22886,32 @@ var OpensteerSessionRuntime = class {
22820
22886
  assertValidSemanticOperationInput("page.goto", input);
22821
22887
  const pageRef = await this.ensurePageRef();
22822
22888
  const startedAt = Date.now();
22889
+ let mutationCaptureDiagnostics;
22823
22890
  try {
22824
- const { navigation, state } = await this.runWithOperationTimeout(
22891
+ const { navigation, state } = await this.runMutationCapturedOperation(
22825
22892
  "page.goto",
22893
+ {
22894
+ ...input.captureNetwork === void 0 ? {} : { captureNetwork: input.captureNetwork },
22895
+ options
22896
+ },
22826
22897
  async (timeout) => {
22827
- const baselineRequestIds = await this.beginMutationCapture(timeout);
22828
- try {
22829
- const navigation2 = await this.navigatePage(
22830
- {
22831
- operation: "page.goto",
22832
- pageRef,
22833
- url: input.url
22834
- },
22835
- timeout
22836
- );
22837
- timeout.throwIfAborted();
22838
- await this.completeMutationCapture(timeout, baselineRequestIds, input.networkTag);
22839
- return {
22840
- navigation: navigation2,
22841
- state: await timeout.runStep(() => this.readSessionState())
22842
- };
22843
- } catch (error) {
22844
- await this.completeMutationCapture(timeout, baselineRequestIds, input.networkTag).catch(
22845
- () => void 0
22846
- );
22847
- throw error;
22848
- }
22898
+ const navigation2 = await this.navigatePage(
22899
+ {
22900
+ operation: "page.goto",
22901
+ pageRef,
22902
+ url: input.url
22903
+ },
22904
+ timeout
22905
+ );
22906
+ timeout.throwIfAborted();
22907
+ return {
22908
+ navigation: navigation2,
22909
+ state: await timeout.runStep(() => this.readSessionState())
22910
+ };
22849
22911
  },
22850
- options
22912
+ (diagnostics) => {
22913
+ mutationCaptureDiagnostics = diagnostics;
22914
+ }
22851
22915
  );
22852
22916
  await this.appendTrace({
22853
22917
  operation: "page.goto",
@@ -22856,7 +22920,8 @@ var OpensteerSessionRuntime = class {
22856
22920
  outcome: "ok",
22857
22921
  data: {
22858
22922
  url: input.url,
22859
- state
22923
+ state,
22924
+ ...buildMutationCaptureTraceData(mutationCaptureDiagnostics)
22860
22925
  },
22861
22926
  context: buildRuntimeTraceContext({
22862
22927
  sessionRef: this.sessionRef,
@@ -22872,6 +22937,7 @@ var OpensteerSessionRuntime = class {
22872
22937
  completedAt: Date.now(),
22873
22938
  outcome: "error",
22874
22939
  error,
22940
+ data: buildMutationCaptureTraceData(mutationCaptureDiagnostics),
22875
22941
  context: buildRuntimeTraceContext({
22876
22942
  sessionRef: this.sessionRef,
22877
22943
  pageRef
@@ -22884,34 +22950,29 @@ var OpensteerSessionRuntime = class {
22884
22950
  assertValidSemanticOperationInput("page.evaluate", input);
22885
22951
  const pageRef = input.pageRef ?? await this.ensurePageRef();
22886
22952
  const startedAt = Date.now();
22953
+ let mutationCaptureDiagnostics;
22887
22954
  try {
22888
- const output = await this.runWithOperationTimeout(
22955
+ const output = await this.runMutationCapturedOperation(
22889
22956
  "page.evaluate",
22957
+ { options },
22890
22958
  async (timeout) => {
22891
- const baselineRequestIds = await this.beginMutationCapture(timeout);
22892
- try {
22893
- const remainingMs = timeout.remainingMs();
22894
- const evaluated = await timeout.runStep(
22895
- () => this.requireEngine().evaluatePage({
22896
- pageRef,
22897
- script: input.script,
22898
- ...input.args === void 0 ? {} : { args: input.args },
22899
- ...remainingMs === void 0 ? {} : { timeoutMs: remainingMs }
22900
- })
22901
- );
22902
- await this.completeMutationCapture(timeout, baselineRequestIds, void 0);
22903
- return {
22959
+ const remainingMs = timeout.remainingMs();
22960
+ const evaluated = await timeout.runStep(
22961
+ () => this.requireEngine().evaluatePage({
22904
22962
  pageRef,
22905
- value: toJsonValueOrNull(evaluated.data)
22906
- };
22907
- } catch (error) {
22908
- await this.completeMutationCapture(timeout, baselineRequestIds, void 0).catch(
22909
- () => void 0
22910
- );
22911
- throw error;
22912
- }
22963
+ script: input.script,
22964
+ ...input.args === void 0 ? {} : { args: input.args },
22965
+ ...remainingMs === void 0 ? {} : { timeoutMs: remainingMs }
22966
+ })
22967
+ );
22968
+ return {
22969
+ pageRef,
22970
+ value: toJsonValueOrNull(evaluated.data)
22971
+ };
22913
22972
  },
22914
- options
22973
+ (diagnostics) => {
22974
+ mutationCaptureDiagnostics = diagnostics;
22975
+ }
22915
22976
  );
22916
22977
  await this.appendTrace({
22917
22978
  operation: "page.evaluate",
@@ -22920,7 +22981,8 @@ var OpensteerSessionRuntime = class {
22920
22981
  outcome: "ok",
22921
22982
  data: {
22922
22983
  pageRef: output.pageRef,
22923
- value: output.value
22984
+ value: output.value,
22985
+ ...buildMutationCaptureTraceData(mutationCaptureDiagnostics)
22924
22986
  },
22925
22987
  context: buildRuntimeTraceContext({
22926
22988
  sessionRef: this.sessionRef,
@@ -22935,6 +22997,7 @@ var OpensteerSessionRuntime = class {
22935
22997
  completedAt: Date.now(),
22936
22998
  outcome: "error",
22937
22999
  error,
23000
+ data: buildMutationCaptureTraceData(mutationCaptureDiagnostics),
22938
23001
  context: buildRuntimeTraceContext({
22939
23002
  sessionRef: this.sessionRef,
22940
23003
  pageRef
@@ -23374,17 +23437,29 @@ var OpensteerSessionRuntime = class {
23374
23437
  "network.clear",
23375
23438
  async (timeout) => {
23376
23439
  if (this.sessionRef !== void 0) {
23377
- const liveRequestIds = await this.readLiveRequestIds(timeout, {
23378
- includeCurrentPageOnly: false
23379
- });
23380
- if (input.tag === void 0) {
23440
+ if (input.capture !== void 0 || input.tag !== void 0) {
23441
+ const records = await this.queryLiveNetwork(
23442
+ {
23443
+ ...input.capture === void 0 ? {} : { capture: input.capture },
23444
+ ...input.tag === void 0 ? {} : { tag: input.tag }
23445
+ },
23446
+ timeout,
23447
+ {
23448
+ ignoreLimit: true
23449
+ }
23450
+ );
23451
+ this.networkHistory.tombstoneRequestIds(
23452
+ records.map((record) => record.record.requestId)
23453
+ );
23454
+ } else {
23455
+ const liveRequestIds = await this.readLiveRequestIds(timeout, {
23456
+ includeCurrentPageOnly: false
23457
+ });
23381
23458
  this.networkHistory.tombstoneRequestIds(liveRequestIds);
23382
23459
  }
23383
23460
  }
23384
- if (input.tag === void 0) {
23461
+ if (input.capture === void 0 && input.tag === void 0) {
23385
23462
  this.networkHistory.tombstoneRequestIds(this.networkHistory.getKnownRequestIds());
23386
- } else {
23387
- this.networkHistory.clearTag(input.tag);
23388
23463
  }
23389
23464
  return {
23390
23465
  clearedCount: await timeout.runStep(() => root.registry.savedNetwork.clear(input))
@@ -23398,6 +23473,7 @@ var OpensteerSessionRuntime = class {
23398
23473
  completedAt: Date.now(),
23399
23474
  outcome: "ok",
23400
23475
  data: {
23476
+ ...input.capture === void 0 ? {} : { capture: input.capture },
23401
23477
  ...input.tag === void 0 ? {} : { tag: input.tag },
23402
23478
  clearedCount: output.clearedCount
23403
23479
  }
@@ -24579,7 +24655,9 @@ var OpensteerSessionRuntime = class {
24579
24655
  };
24580
24656
  }
24581
24657
  const bindings = /* @__PURE__ */ new Map();
24582
- const baselineRequestIds = await this.beginMutationCapture(timeout);
24658
+ const baselineRequestIds = await this.readLiveRequestIds(timeout, {
24659
+ includeCurrentPageOnly: true
24660
+ });
24583
24661
  const pageRef = explicitPageRef ?? await this.ensurePageRef();
24584
24662
  const validatorMap = new Map(
24585
24663
  packageRecord.payload.validators.map((validator) => [validator.id, validator])
@@ -26251,33 +26329,38 @@ var OpensteerSessionRuntime = class {
26251
26329
  assertValidSemanticOperationInput("computer.execute", input);
26252
26330
  const pageRef = await this.ensurePageRef();
26253
26331
  const startedAt = Date.now();
26332
+ let mutationCaptureDiagnostics;
26333
+ let boundaryDiagnostics;
26254
26334
  try {
26255
- const { artifacts, output } = await this.runWithOperationTimeout(
26335
+ const { artifacts, output } = await this.runMutationCapturedOperation(
26256
26336
  "computer.execute",
26337
+ {
26338
+ ...input.captureNetwork === void 0 ? {} : { captureNetwork: input.captureNetwork },
26339
+ options
26340
+ },
26257
26341
  async (timeout) => {
26258
- const baselineRequestIds = await this.beginMutationCapture(timeout);
26259
26342
  try {
26260
26343
  const output2 = await this.requireComputer().execute({
26261
26344
  pageRef,
26262
26345
  input,
26263
26346
  timeout
26264
26347
  });
26348
+ boundaryDiagnostics = takeActionBoundaryDiagnostics(timeout.signal);
26265
26349
  timeout.throwIfAborted();
26266
26350
  this.pageRef = output2.pageRef;
26267
- await this.completeMutationCapture(timeout, baselineRequestIds, input.networkTag);
26268
26351
  const artifacts2 = await this.persistComputerArtifacts(output2, timeout);
26269
26352
  return {
26270
26353
  artifacts: { manifests: artifacts2.manifests },
26271
26354
  output: artifacts2.output
26272
26355
  };
26273
26356
  } catch (error) {
26274
- await this.completeMutationCapture(timeout, baselineRequestIds, input.networkTag).catch(
26275
- () => void 0
26276
- );
26357
+ boundaryDiagnostics ??= takeActionBoundaryDiagnostics(timeout.signal);
26277
26358
  throw error;
26278
26359
  }
26279
26360
  },
26280
- options
26361
+ (diagnostics) => {
26362
+ mutationCaptureDiagnostics = diagnostics;
26363
+ }
26281
26364
  );
26282
26365
  await this.appendTrace({
26283
26366
  operation: "computer.execute",
@@ -26293,6 +26376,8 @@ var OpensteerSessionRuntime = class {
26293
26376
  nativeViewport: output.nativeViewport,
26294
26377
  displayScale: output.displayScale,
26295
26378
  timing: output.timing,
26379
+ ...boundaryDiagnostics === void 0 ? {} : { settle: boundaryDiagnostics },
26380
+ ...buildMutationCaptureTraceData(mutationCaptureDiagnostics),
26296
26381
  ...output.trace === void 0 ? {} : { trace: output.trace }
26297
26382
  },
26298
26383
  context: buildRuntimeTraceContext({
@@ -26311,6 +26396,10 @@ var OpensteerSessionRuntime = class {
26311
26396
  completedAt: Date.now(),
26312
26397
  outcome: "error",
26313
26398
  error,
26399
+ data: {
26400
+ ...boundaryDiagnostics === void 0 ? {} : { settle: boundaryDiagnostics },
26401
+ ...buildMutationCaptureTraceData(mutationCaptureDiagnostics)
26402
+ },
26314
26403
  context: buildRuntimeTraceContext({
26315
26404
  sessionRef: this.sessionRef,
26316
26405
  pageRef: this.pageRef
@@ -26414,33 +26503,38 @@ var OpensteerSessionRuntime = class {
26414
26503
  async runDomAction(operation, input, executor, options = {}) {
26415
26504
  const pageRef = await this.ensurePageRef();
26416
26505
  const startedAt = Date.now();
26506
+ let mutationCaptureDiagnostics;
26507
+ let boundaryDiagnostics;
26417
26508
  try {
26418
- const { executed, preparedTarget } = await this.runWithOperationTimeout(
26509
+ const { executed, preparedTarget } = await this.runMutationCapturedOperation(
26419
26510
  operation,
26511
+ {
26512
+ ...input.captureNetwork === void 0 ? {} : { captureNetwork: input.captureNetwork },
26513
+ options
26514
+ },
26420
26515
  async (timeout) => {
26421
- const baselineRequestIds = await this.beginMutationCapture(timeout);
26516
+ const preparedTarget2 = await this.prepareDomTarget(
26517
+ pageRef,
26518
+ operation,
26519
+ input.target,
26520
+ input.persistAsDescription,
26521
+ timeout
26522
+ );
26422
26523
  try {
26423
- const preparedTarget2 = await this.prepareDomTarget(
26424
- pageRef,
26425
- operation,
26426
- input.target,
26427
- input.persistAsDescription,
26428
- timeout
26429
- );
26430
26524
  const executed2 = await executor(pageRef, preparedTarget2.target, timeout);
26431
- await this.completeMutationCapture(timeout, baselineRequestIds, input.networkTag);
26525
+ boundaryDiagnostics = takeActionBoundaryDiagnostics(timeout.signal);
26432
26526
  return {
26433
26527
  executed: executed2,
26434
26528
  preparedTarget: preparedTarget2
26435
26529
  };
26436
26530
  } catch (error) {
26437
- await this.completeMutationCapture(timeout, baselineRequestIds, input.networkTag).catch(
26438
- () => void 0
26439
- );
26531
+ boundaryDiagnostics ??= takeActionBoundaryDiagnostics(timeout.signal);
26440
26532
  throw error;
26441
26533
  }
26442
26534
  },
26443
- options
26535
+ (diagnostics) => {
26536
+ mutationCaptureDiagnostics = diagnostics;
26537
+ }
26444
26538
  );
26445
26539
  const output = toOpensteerActionResult(executed.result, preparedTarget.persistedDescription);
26446
26540
  await this.appendTrace({
@@ -26451,7 +26545,9 @@ var OpensteerSessionRuntime = class {
26451
26545
  data: {
26452
26546
  target: output.target,
26453
26547
  ...output.point === void 0 ? {} : { point: output.point },
26454
- ...output.persistedDescription === void 0 ? {} : { persistedDescription: output.persistedDescription }
26548
+ ...output.persistedDescription === void 0 ? {} : { persistedDescription: output.persistedDescription },
26549
+ ...boundaryDiagnostics === void 0 ? {} : { settle: boundaryDiagnostics },
26550
+ ...buildMutationCaptureTraceData(mutationCaptureDiagnostics)
26455
26551
  },
26456
26552
  context: buildRuntimeTraceContext({
26457
26553
  sessionRef: this.sessionRef,
@@ -26469,6 +26565,10 @@ var OpensteerSessionRuntime = class {
26469
26565
  completedAt: Date.now(),
26470
26566
  outcome: "error",
26471
26567
  error,
26568
+ data: {
26569
+ ...boundaryDiagnostics === void 0 ? {} : { settle: boundaryDiagnostics },
26570
+ ...buildMutationCaptureTraceData(mutationCaptureDiagnostics)
26571
+ },
26472
26572
  context: buildRuntimeTraceContext({
26473
26573
  sessionRef: this.sessionRef,
26474
26574
  pageRef
@@ -26578,7 +26678,7 @@ var OpensteerSessionRuntime = class {
26578
26678
  const filtered = filterNetworkQueryRecords(metadataRecords, {
26579
26679
  ...input.recordId === void 0 ? {} : { recordId: input.recordId },
26580
26680
  ...input.requestId === void 0 ? {} : { requestId: input.requestId },
26581
- ...input.actionId === void 0 ? {} : { actionId: input.actionId },
26681
+ ...input.capture === void 0 ? {} : { capture: input.capture },
26582
26682
  ...input.tag === void 0 ? {} : { tag: input.tag },
26583
26683
  ...input.url === void 0 ? {} : { url: input.url },
26584
26684
  ...input.hostname === void 0 ? {} : { hostname: input.hostname },
@@ -26784,32 +26884,68 @@ var OpensteerSessionRuntime = class {
26784
26884
  artifactId: manifest.artifactId
26785
26885
  };
26786
26886
  }
26787
- beginMutationCapture(timeout) {
26788
- return this.readLiveRequestIds(timeout, {
26789
- includeCurrentPageOnly: true
26790
- });
26791
- }
26792
- async completeMutationCapture(timeout, baselineRequestIds, networkTag) {
26793
- const records = await timeout.runStep(
26794
- () => this.readLiveNetworkRecords(
26795
- {
26796
- includeBodies: false,
26797
- includeCurrentPageOnly: true
26887
+ async runMutationCapturedOperation(operation, input, execute, onFinalized) {
26888
+ let plan;
26889
+ try {
26890
+ const result = await this.runWithOperationTimeout(
26891
+ operation,
26892
+ async (timeout) => {
26893
+ plan = await this.beginMutationCapture(timeout, input.captureNetwork);
26894
+ return execute(timeout);
26798
26895
  },
26799
- timeout.signal
26800
- )
26896
+ input.options
26897
+ );
26898
+ const diagnostics = await this.finalizeMutationCaptureBestEffort(plan);
26899
+ onFinalized?.(diagnostics);
26900
+ return result;
26901
+ } catch (error) {
26902
+ const diagnostics = await this.finalizeMutationCaptureBestEffort(plan);
26903
+ onFinalized?.(diagnostics);
26904
+ throw error;
26905
+ }
26906
+ }
26907
+ async beginMutationCapture(timeout, capture) {
26908
+ if (capture === void 0) {
26909
+ return void 0;
26910
+ }
26911
+ return {
26912
+ baselineRequestIds: await this.readLiveRequestIds(timeout, {
26913
+ includeCurrentPageOnly: true
26914
+ }),
26915
+ capture
26916
+ };
26917
+ }
26918
+ async finalizeMutationCaptureBestEffort(plan) {
26919
+ if (plan === void 0) {
26920
+ return {};
26921
+ }
26922
+ try {
26923
+ await withDetachedTimeoutSignal(MUTATION_CAPTURE_FINALIZE_TIMEOUT_MS, async (signal) => {
26924
+ await this.completeMutationCaptureWithSignal(signal, plan);
26925
+ });
26926
+ return {};
26927
+ } catch (error) {
26928
+ return {
26929
+ finalizeError: normalizeOpensteerError(error)
26930
+ };
26931
+ }
26932
+ }
26933
+ async completeMutationCaptureWithSignal(signal, plan) {
26934
+ const records = await this.readLiveNetworkRecords(
26935
+ {
26936
+ includeBodies: false,
26937
+ includeCurrentPageOnly: true
26938
+ },
26939
+ signal
26801
26940
  );
26802
- const delta = records.filter((record) => !baselineRequestIds.has(record.record.requestId));
26941
+ const delta = records.filter((record) => !plan.baselineRequestIds.has(record.record.requestId));
26803
26942
  if (delta.length === 0) {
26804
26943
  return;
26805
26944
  }
26806
- this.networkHistory.assignActionId(delta, `action:${randomUUID()}`);
26807
- if (networkTag !== void 0) {
26808
- this.networkHistory.addTag(delta, networkTag);
26809
- }
26810
- await this.persistLiveRequestIds(
26945
+ this.networkHistory.assignCapture(delta, plan.capture);
26946
+ await this.persistLiveRequestIdsWithSignal(
26811
26947
  delta.map((record) => record.record.requestId),
26812
- timeout,
26948
+ signal,
26813
26949
  {
26814
26950
  includeCurrentPageOnly: true
26815
26951
  }
@@ -27216,27 +27352,28 @@ var OpensteerSessionRuntime = class {
27216
27352
  });
27217
27353
  }
27218
27354
  async persistLiveRequestIds(requestIds, timeout, options) {
27355
+ return timeout.runStep(
27356
+ () => this.persistLiveRequestIdsWithSignal(requestIds, timeout.signal, options)
27357
+ );
27358
+ }
27359
+ async persistLiveRequestIdsWithSignal(requestIds, signal, options) {
27219
27360
  if (requestIds.length === 0) {
27220
27361
  return [];
27221
27362
  }
27222
27363
  const root = await this.ensureRoot();
27223
- const browserRecords = await timeout.runStep(
27224
- () => this.readBrowserNetworkRecords(
27225
- {
27226
- includeBodies: true,
27227
- includeCurrentPageOnly: options.includeCurrentPageOnly,
27228
- ...options.pageRef === void 0 ? {} : { pageRef: options.pageRef },
27229
- requestIds
27230
- },
27231
- timeout.signal
27232
- )
27233
- );
27234
- return timeout.runStep(
27235
- () => this.networkHistory.persist(browserRecords, root.registry.savedNetwork, {
27236
- bodyWriteMode: "authoritative",
27237
- redactSecretHeaders: false
27238
- })
27364
+ const browserRecords = await this.readBrowserNetworkRecords(
27365
+ {
27366
+ includeBodies: true,
27367
+ includeCurrentPageOnly: options.includeCurrentPageOnly,
27368
+ ...options.pageRef === void 0 ? {} : { pageRef: options.pageRef },
27369
+ requestIds
27370
+ },
27371
+ signal
27239
27372
  );
27373
+ return this.networkHistory.persist(browserRecords, root.registry.savedNetwork, {
27374
+ bodyWriteMode: "authoritative",
27375
+ redactSecretHeaders: false
27376
+ });
27240
27377
  }
27241
27378
  async syncPersistedNetworkSelection(timeout, input, options) {
27242
27379
  if (this.sessionRef === void 0) {
@@ -27278,7 +27415,7 @@ var OpensteerSessionRuntime = class {
27278
27415
  ...input.pageRef === void 0 ? {} : { pageRef: input.pageRef },
27279
27416
  ...input.recordId === void 0 ? {} : { recordId: input.recordId },
27280
27417
  ...input.requestId === void 0 ? {} : { requestId: input.requestId },
27281
- ...input.actionId === void 0 ? {} : { actionId: input.actionId },
27418
+ ...input.capture === void 0 ? {} : { capture: input.capture },
27282
27419
  ...input.tag === void 0 ? {} : { tag: input.tag },
27283
27420
  ...input.url === void 0 ? {} : { url: input.url },
27284
27421
  ...input.hostname === void 0 ? {} : { hostname: input.hostname },
@@ -27295,7 +27432,7 @@ var OpensteerSessionRuntime = class {
27295
27432
  ...input.pageRef === void 0 ? {} : { pageRef: input.pageRef },
27296
27433
  ...input.recordId === void 0 ? {} : { recordId: input.recordId },
27297
27434
  ...input.requestId === void 0 ? {} : { requestId: input.requestId },
27298
- ...input.actionId === void 0 ? {} : { actionId: input.actionId },
27435
+ ...input.capture === void 0 ? {} : { capture: input.capture },
27299
27436
  ...input.url === void 0 ? {} : { url: input.url },
27300
27437
  ...input.hostname === void 0 ? {} : { hostname: input.hostname },
27301
27438
  ...input.path === void 0 ? {} : { path: input.path },
@@ -28857,8 +28994,8 @@ function resolveLiveQueryRequestIds(input, history) {
28857
28994
  if (input.requestId !== void 0) {
28858
28995
  requestIdCandidates.push(/* @__PURE__ */ new Set([input.requestId]));
28859
28996
  }
28860
- if (input.actionId !== void 0) {
28861
- requestIdCandidates.push(history.getRequestIdsForActionId(input.actionId));
28997
+ if (input.capture !== void 0) {
28998
+ requestIdCandidates.push(history.getRequestIdsForCapture(input.capture));
28862
28999
  }
28863
29000
  if (input.tag !== void 0) {
28864
29001
  requestIdCandidates.push(history.getRequestIdsForTag(input.tag));
@@ -28905,7 +29042,7 @@ function filterNetworkQueryRecords(records, input) {
28905
29042
  if (input.requestId !== void 0 && record.record.requestId !== input.requestId) {
28906
29043
  return false;
28907
29044
  }
28908
- if (input.actionId !== void 0 && record.actionId !== input.actionId) {
29045
+ if (input.capture !== void 0 && record.capture !== input.capture) {
28909
29046
  return false;
28910
29047
  }
28911
29048
  if (input.tag !== void 0 && !(record.tags ?? []).includes(input.tag)) {
@@ -31315,9 +31452,40 @@ function toOpensteerResolvedTarget2(target) {
31315
31452
  function normalizeOpensteerError(error) {
31316
31453
  return normalizeThrownOpensteerError(error, "Unknown Opensteer runtime failure");
31317
31454
  }
31455
+ function buildMutationCaptureTraceData(diagnostics) {
31456
+ if (diagnostics?.finalizeError === void 0) {
31457
+ return {};
31458
+ }
31459
+ return {
31460
+ networkCapture: {
31461
+ finalizeError: diagnostics.finalizeError
31462
+ }
31463
+ };
31464
+ }
31318
31465
  function isIgnorableRuntimeBindingError(error) {
31319
31466
  return isBrowserCoreError(error) && (error.code === "not-found" || error.code === "page-closed" || error.code === "session-closed");
31320
31467
  }
31468
+ async function withDetachedTimeoutSignal(timeoutMs, operation) {
31469
+ const controller = new AbortController();
31470
+ const timeoutError = new OpensteerProtocolError(
31471
+ "timeout",
31472
+ `mutation capture finalization exceeded ${String(timeoutMs)}ms timeout`,
31473
+ {
31474
+ details: {
31475
+ policy: "mutation-capture-finalize",
31476
+ budgetMs: timeoutMs
31477
+ }
31478
+ }
31479
+ );
31480
+ const timer = setTimeout(() => {
31481
+ controller.abort(timeoutError);
31482
+ }, timeoutMs);
31483
+ try {
31484
+ return await operation(controller.signal);
31485
+ } finally {
31486
+ clearTimeout(timer);
31487
+ }
31488
+ }
31321
31489
  function screenshotMediaType(format2) {
31322
31490
  switch (format2) {
31323
31491
  case "png":
@@ -33288,5 +33456,5 @@ function createOpensteerSemanticRuntime(input = {}) {
33288
33456
  }
33289
33457
 
33290
33458
  export { CloudSessionProxy, DEFAULT_OPENSTEER_ENGINE, DEFERRED_MATCH_ATTR_KEYS, ElementPathError, MATCH_ATTRIBUTE_PRIORITY, OPENSTEER_DOM_ACTION_BRIDGE_SYMBOL, OPENSTEER_ENGINE_NAMES, OPENSTEER_FILESYSTEM_WORKSPACE_LAYOUT, OPENSTEER_FILESYSTEM_WORKSPACE_VERSION, OpensteerAttachAmbiguousError, OpensteerBrowserManager, OpensteerCloudClient, OpensteerRuntime, OpensteerSessionRuntime2 as OpensteerSessionRuntime, STABLE_PRIMARY_ATTR_KEYS, assertProviderSupportsEngine, buildArrayFieldPathCandidates, buildDomDescriptorKey, buildDomDescriptorPayload, buildDomDescriptorVersion, buildPathCandidates, buildPathSelectorHint, buildSegmentSelector, clearPersistedSessionRecord, cloneElementPath, cloneReplayElementPath, cloneStructuralElementAnchor, createDomRuntime, createFilesystemOpensteerWorkspace, createOpensteerExtractionDescriptorStore, createOpensteerSemanticRuntime, defaultFallbackPolicy, defaultPolicy, defaultRetryPolicy, defaultSettlePolicy, defaultTimeoutPolicy, delayWithSignal, discoverLocalCdpBrowsers, dispatchSemanticOperation, hashDomDescriptorDescription, inspectCdpEndpoint, isCurrentUrlField, isProcessRunning, isValidCssAttributeKey, listLocalChromeProfiles, normalizeExtractedValue, normalizeOpensteerEngineName, normalizeOpensteerProviderMode, normalizeWorkspaceId, parseDomDescriptorRecord, parseExtractionDescriptorRecord, pathExists, readPersistedCloudSessionRecord, readPersistedLocalBrowserSessionRecord, readPersistedSessionRecord, resolveCloudConfig, resolveCloudSessionRecordPath, resolveDomActionBridge, resolveExtractedValueInContext, resolveFilesystemWorkspacePath, resolveLiveSessionRecordPath, resolveLocalSessionRecordPath, resolveOpensteerEngineName, resolveOpensteerProvider, resolveOpensteerRuntimeConfig, runWithPolicyTimeout, sanitizeElementPath, sanitizeReplayElementPath, sanitizeStructuralElementAnchor, settleWithPolicy, shouldKeepAttributeForPath, writePersistedSessionRecord };
33291
- //# sourceMappingURL=chunk-IAA57HNW.js.map
33292
- //# sourceMappingURL=chunk-IAA57HNW.js.map
33459
+ //# sourceMappingURL=chunk-3QJGBVWT.js.map
33460
+ //# sourceMappingURL=chunk-3QJGBVWT.js.map