opensteer 0.8.15 → 0.8.17

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
@@ -2428,6 +2428,20 @@ var opensteerNetworkRedirectHopSchema = objectSchema(
2428
2428
  required: ["method", "url"]
2429
2429
  }
2430
2430
  );
2431
+ var opensteerReplayAttemptSchema = objectSchema(
2432
+ {
2433
+ transport: transportKindSchema,
2434
+ status: integerSchema({ minimum: 100, maximum: 599 }),
2435
+ ok: { type: "boolean" },
2436
+ durationMs: integerSchema({ minimum: 0 }),
2437
+ note: stringSchema(),
2438
+ error: stringSchema()
2439
+ },
2440
+ {
2441
+ title: "OpensteerReplayAttempt",
2442
+ required: ["transport", "ok", "durationMs"]
2443
+ }
2444
+ );
2431
2445
  var opensteerNetworkDetailOutputSchema = objectSchema(
2432
2446
  {
2433
2447
  recordId: stringSchema({ minLength: 1 }),
@@ -2451,28 +2465,24 @@ var opensteerNetworkDetailOutputSchema = objectSchema(
2451
2465
  }
2452
2466
  ),
2453
2467
  redirectChain: arraySchema(opensteerNetworkRedirectHopSchema),
2454
- notes: arraySchema(stringSchema())
2468
+ notes: arraySchema(stringSchema()),
2469
+ transportProbe: objectSchema(
2470
+ {
2471
+ recommended: transportKindSchema,
2472
+ attempts: arraySchema(opensteerReplayAttemptSchema)
2473
+ },
2474
+ {
2475
+ title: "OpensteerTransportProbeResult",
2476
+ required: ["attempts"]
2477
+ }
2478
+ )
2455
2479
  },
2456
2480
  {
2457
2481
  title: "OpensteerNetworkDetailOutput",
2458
2482
  required: ["recordId", "summary", "requestHeaders", "responseHeaders"]
2459
2483
  }
2460
2484
  );
2461
- var opensteerReplayAttemptSchema = objectSchema(
2462
- {
2463
- transport: transportKindSchema,
2464
- status: integerSchema({ minimum: 100, maximum: 599 }),
2465
- ok: { type: "boolean" },
2466
- durationMs: integerSchema({ minimum: 0 }),
2467
- note: stringSchema(),
2468
- error: stringSchema()
2469
- },
2470
- {
2471
- title: "OpensteerReplayAttempt",
2472
- required: ["transport", "ok", "durationMs"]
2473
- }
2474
- );
2475
- var opensteerNetworkReplayInputSchema = objectSchema(
2485
+ objectSchema(
2476
2486
  {
2477
2487
  recordId: stringSchema({ minLength: 1 }),
2478
2488
  pageRef: pageRefSchema,
@@ -2486,7 +2496,6 @@ var opensteerNetworkReplayInputSchema = objectSchema(
2486
2496
  required: ["recordId"]
2487
2497
  }
2488
2498
  );
2489
- var opensteerNetworkReplayOutputSchema;
2490
2499
  var opensteerSessionFetchTransportSchema = enumSchema(
2491
2500
  ["auto", "direct", "matched-tls", "page"],
2492
2501
  {
@@ -2828,7 +2837,7 @@ var opensteerRequestResponseResultSchema = objectSchema(
2828
2837
  required: ["url", "status", "statusText", "headers", "redirected"]
2829
2838
  }
2830
2839
  );
2831
- opensteerNetworkReplayOutputSchema = objectSchema(
2840
+ objectSchema(
2832
2841
  {
2833
2842
  recordId: stringSchema({ minLength: 1 }),
2834
2843
  transport: transportKindSchema,
@@ -5808,7 +5817,6 @@ var opensteerExposedSemanticOperationNames = [
5808
5817
  "dom.extract",
5809
5818
  "network.query",
5810
5819
  "network.detail",
5811
- "network.replay",
5812
5820
  "interaction.capture",
5813
5821
  "interaction.get",
5814
5822
  "interaction.diff",
@@ -5845,7 +5853,6 @@ var opensteerPackageRunnableSemanticOperationNames = /* @__PURE__ */ new Set([
5845
5853
  "dom.extract",
5846
5854
  "network.query",
5847
5855
  "network.detail",
5848
- "network.replay",
5849
5856
  "interaction.capture",
5850
5857
  "interaction.get",
5851
5858
  "interaction.diff",
@@ -6283,9 +6290,12 @@ var opensteerNetworkDetailInputSchema = objectSchema(
6283
6290
  required: ["recordId"]
6284
6291
  }
6285
6292
  );
6286
- var opensteerComputerMouseButtonSchema = enumSchema(["left", "middle", "right"], {
6287
- title: "OpensteerComputerMouseButton"
6288
- });
6293
+ var opensteerComputerMouseButtonSchema = enumSchema(
6294
+ ["left", "middle", "right"],
6295
+ {
6296
+ title: "OpensteerComputerMouseButton"
6297
+ }
6298
+ );
6289
6299
  var opensteerComputerKeyModifierSchema = enumSchema(
6290
6300
  ["Shift", "Control", "Alt", "Meta"],
6291
6301
  {
@@ -6362,10 +6372,7 @@ var opensteerDomExtractInputSchema = defineSchema({
6362
6372
  title: "OpensteerDomExtractInput"
6363
6373
  }
6364
6374
  ),
6365
- anyOf: [
6366
- defineSchema({ required: ["persist"] }),
6367
- defineSchema({ required: ["schema"] })
6368
- ]
6375
+ anyOf: [defineSchema({ required: ["persist"] }), defineSchema({ required: ["schema"] })]
6369
6376
  });
6370
6377
  var jsonValueSchema3 = recordSchema({}, { title: "JsonValueRecord" });
6371
6378
  var opensteerDomExtractOutputSchema = objectSchema(
@@ -6745,13 +6752,6 @@ var opensteerSemanticOperationSpecificationsBase = [
6745
6752
  outputSchema: opensteerNetworkDetailOutputSchema,
6746
6753
  requiredCapabilities: ["inspect.network", "inspect.networkBodies"]
6747
6754
  }),
6748
- defineSemanticOperationSpec({
6749
- name: "network.replay",
6750
- description: "Replay a captured request through the transport ladder and report the transport that worked.",
6751
- inputSchema: opensteerNetworkReplayInputSchema,
6752
- outputSchema: opensteerNetworkReplayOutputSchema,
6753
- requiredCapabilities: ["inspect.network", "inspect.cookies", "pages.manage"]
6754
- }),
6755
6755
  defineSemanticOperationSpec({
6756
6756
  name: "interaction.capture",
6757
6757
  description: "Capture a guarded interaction window, including event properties, state changes, and downstream network.",
@@ -16481,12 +16481,7 @@ var BRAND_KEYCHAIN_SERVICE = {
16481
16481
  async function resolveKeychainPassword(brandId) {
16482
16482
  const service = BRAND_KEYCHAIN_SERVICE[brandId];
16483
16483
  try {
16484
- const { stdout } = await execFile2("security", [
16485
- "find-generic-password",
16486
- "-s",
16487
- service,
16488
- "-w"
16489
- ]);
16484
+ const { stdout } = await execFile2("security", ["find-generic-password", "-s", service, "-w"]);
16490
16485
  return stdout.trim();
16491
16486
  } catch {
16492
16487
  throw new Error(
@@ -17034,7 +17029,7 @@ function resolveCloudConfig(input = {}) {
17034
17029
 
17035
17030
  // ../runtime-core/package.json
17036
17031
  var package_default = {
17037
- version: "0.1.6"};
17032
+ version: "0.1.7"};
17038
17033
 
17039
17034
  // ../runtime-core/src/version.ts
17040
17035
  var OPENSTEER_RUNTIME_CORE_VERSION = package_default.version;
@@ -21782,7 +21777,12 @@ var OpensteerSessionRuntime = class {
21782
21777
  includeBodies: true,
21783
21778
  redactSecretHeaders: false
21784
21779
  });
21785
- return this.buildNetworkDetail(record, timeout);
21780
+ const detail = await this.buildNetworkDetail(record, timeout);
21781
+ if (input.probe !== true) {
21782
+ return detail;
21783
+ }
21784
+ const transportProbe = await this.probeTransportsForRecord(record, timeout);
21785
+ return transportProbe === void 0 ? detail : { ...detail, transportProbe };
21786
21786
  },
21787
21787
  options
21788
21788
  );
@@ -21817,54 +21817,6 @@ var OpensteerSessionRuntime = class {
21817
21817
  throw error;
21818
21818
  }
21819
21819
  }
21820
- async replayNetwork(input, options = {}) {
21821
- const startedAt = Date.now();
21822
- try {
21823
- const output = await this.runWithOperationTimeout(
21824
- "network.replay",
21825
- async (timeout) => {
21826
- const source = await this.resolveNetworkRecordByRecordId(input.recordId, timeout, {
21827
- includeBodies: true,
21828
- redactSecretHeaders: false
21829
- });
21830
- const replayRequest = buildReplayTransportRequest(source, input);
21831
- return this.executeNetworkReplay(source, replayRequest, timeout, {
21832
- ...input.pageRef === void 0 ? {} : { pageRef: input.pageRef }
21833
- });
21834
- },
21835
- options
21836
- );
21837
- await this.appendTrace({
21838
- operation: "network.replay",
21839
- startedAt,
21840
- completedAt: Date.now(),
21841
- outcome: "ok",
21842
- data: {
21843
- recordId: input.recordId,
21844
- transport: output.transport,
21845
- attempts: output.attempts.length
21846
- },
21847
- context: buildRuntimeTraceContext({
21848
- sessionRef: this.sessionRef,
21849
- pageRef: this.pageRef
21850
- })
21851
- });
21852
- return output;
21853
- } catch (error) {
21854
- await this.appendTrace({
21855
- operation: "network.replay",
21856
- startedAt,
21857
- completedAt: Date.now(),
21858
- outcome: "error",
21859
- error,
21860
- context: buildRuntimeTraceContext({
21861
- sessionRef: this.sessionRef,
21862
- pageRef: this.pageRef
21863
- })
21864
- });
21865
- throw error;
21866
- }
21867
- }
21868
21820
  async captureScripts(input = {}, options = {}) {
21869
21821
  assertValidSemanticOperationInput("scripts.capture", input);
21870
21822
  const pageRef = input.pageRef ?? await this.ensurePageRef();
@@ -22460,7 +22412,7 @@ var OpensteerSessionRuntime = class {
22460
22412
  completedAt: Date.now(),
22461
22413
  outcome: "ok",
22462
22414
  data: {
22463
- transport: output.transport,
22415
+ ...output.transport === void 0 ? {} : { transport: output.transport },
22464
22416
  attempts: output.attempts.length,
22465
22417
  ...output.response === void 0 ? {} : { status: output.response.status },
22466
22418
  url: input.url
@@ -23265,6 +23217,42 @@ var OpensteerSessionRuntime = class {
23265
23217
  ...notes.length === 0 ? {} : { notes }
23266
23218
  };
23267
23219
  }
23220
+ async probeTransportsForRecord(record, timeout) {
23221
+ if (record.record.status === void 0) {
23222
+ return void 0;
23223
+ }
23224
+ const request = buildReplayTransportRequest(record, { recordId: record.recordId });
23225
+ const fingerprint = buildCapturedRecordSuccessFingerprint(record);
23226
+ const attempts = [];
23227
+ let recommended;
23228
+ for (const transport of REPLAY_TRANSPORT_LADDER) {
23229
+ const attemptStartedAt = Date.now();
23230
+ try {
23231
+ const output = await this.executeReplayTransportAttempt(transport, request, timeout);
23232
+ const ok = matchesSuccessFingerprintFromProtocolResponse(output.response, fingerprint);
23233
+ attempts.push({
23234
+ transport,
23235
+ status: output.response.status,
23236
+ ok,
23237
+ durationMs: Date.now() - attemptStartedAt
23238
+ });
23239
+ if (ok && recommended === void 0) {
23240
+ recommended = transport;
23241
+ }
23242
+ } catch (error) {
23243
+ attempts.push({
23244
+ transport,
23245
+ ok: false,
23246
+ durationMs: Date.now() - attemptStartedAt,
23247
+ error: normalizeRuntimeErrorMessage(error)
23248
+ });
23249
+ }
23250
+ }
23251
+ return {
23252
+ ...recommended === void 0 ? {} : { recommended },
23253
+ attempts
23254
+ };
23255
+ }
23268
23256
  async buildRedirectChain(record, timeout) {
23269
23257
  if (record.record.redirectFromRequestId === void 0 && record.record.redirectToRequestId === void 0) {
23270
23258
  return {};
@@ -23383,57 +23371,6 @@ var OpensteerSessionRuntime = class {
23383
23371
  })
23384
23372
  };
23385
23373
  }
23386
- async executeNetworkReplay(source, request, timeout, options) {
23387
- const fingerprint = buildCapturedRecordSuccessFingerprint(source);
23388
- const attempts = [];
23389
- let lastOutput;
23390
- for (const transport of REPLAY_TRANSPORT_LADDER) {
23391
- const attemptStartedAt = Date.now();
23392
- try {
23393
- const output = await this.executeReplayTransportAttempt(
23394
- transport,
23395
- request,
23396
- timeout,
23397
- options.pageRef
23398
- );
23399
- lastOutput = output;
23400
- const ok = matchesSuccessFingerprintFromProtocolResponse(output.response, fingerprint);
23401
- attempts.push({
23402
- transport,
23403
- status: output.response.status,
23404
- ok,
23405
- durationMs: Date.now() - attemptStartedAt
23406
- });
23407
- if (ok) {
23408
- const fallbackNote = attempts.length > 1 ? buildReplayFallbackNote(attempts, transport) : void 0;
23409
- const previewData2 = toStructuredPreviewData(output.data);
23410
- return {
23411
- recordId: source.recordId,
23412
- transport,
23413
- attempts,
23414
- response: output.response,
23415
- ...previewData2 === void 0 ? {} : { data: previewData2 },
23416
- ...fallbackNote === void 0 ? {} : { note: fallbackNote }
23417
- };
23418
- }
23419
- } catch (error) {
23420
- attempts.push({
23421
- transport,
23422
- ok: false,
23423
- durationMs: Date.now() - attemptStartedAt,
23424
- error: normalizeRuntimeErrorMessage(error)
23425
- });
23426
- }
23427
- }
23428
- const previewData = toStructuredPreviewData(lastOutput?.data);
23429
- return {
23430
- recordId: source.recordId,
23431
- attempts,
23432
- ...lastOutput?.response === void 0 ? {} : { response: lastOutput.response },
23433
- ...previewData === void 0 ? {} : { data: previewData },
23434
- note: "all replay transports failed to reproduce the captured response"
23435
- };
23436
- }
23437
23374
  async executeSessionFetch(request, input, timeout) {
23438
23375
  const attempts = [];
23439
23376
  let lastOutput;
@@ -26036,11 +25973,6 @@ async function dispatchSemanticOperation(runtime, operation, input, options = {}
26036
25973
  input,
26037
25974
  options
26038
25975
  );
26039
- case "network.replay":
26040
- return runtime.replayNetwork(
26041
- input,
26042
- options
26043
- );
26044
25976
  case "interaction.capture":
26045
25977
  return runtime.captureInteraction(
26046
25978
  input,
@@ -26736,10 +26668,6 @@ var CloudSessionProxy = class {
26736
26668
  await this.ensureSession();
26737
26669
  return this.requireClient().invoke("network.detail", input);
26738
26670
  }
26739
- async replayNetwork(input) {
26740
- await this.ensureSession();
26741
- return this.requireClient().invoke("network.replay", input);
26742
- }
26743
26671
  async captureInteraction(input) {
26744
26672
  await this.ensureSession();
26745
26673
  return this.requireClient().invoke("interaction.capture", input);
@@ -27259,11 +27187,7 @@ var Opensteer = class {
27259
27187
  };
27260
27188
  this.network = {
27261
27189
  query: (input = {}) => this.queryNetwork(input),
27262
- detail: (recordId) => this.runtime.getNetworkDetail({ recordId }),
27263
- replay: (recordId, overrides = {}) => this.runtime.replayNetwork({
27264
- recordId,
27265
- ...overrides
27266
- })
27190
+ detail: (recordId, options2) => this.runtime.getNetworkDetail({ recordId, ...options2 })
27267
27191
  };
27268
27192
  }
27269
27193
  async open(input = {}) {
@@ -27410,10 +27334,8 @@ var Opensteer = class {
27410
27334
  return this.runtime.getBrowserState(domain === void 0 ? {} : { domain });
27411
27335
  }
27412
27336
  async fetch(url, options = {}) {
27413
- const result = await this.runtime.fetch({
27414
- url,
27415
- ...options
27416
- });
27337
+ const input = buildFetchInput(url, options);
27338
+ const result = await this.runtime.fetch(input);
27417
27339
  if (result.response === void 0) {
27418
27340
  throw new Error(result.note ?? `session.fetch did not produce a response for ${url}`);
27419
27341
  }
@@ -27503,6 +27425,25 @@ function pickStorageDomainSnapshot(snapshot, domain) {
27503
27425
  }
27504
27426
  return snapshot.domains.find((entry) => entry.domain === domain);
27505
27427
  }
27428
+ function buildFetchInput(url, options) {
27429
+ return {
27430
+ url,
27431
+ ...options.method !== void 0 && { method: options.method },
27432
+ ...options.headers !== void 0 && { headers: options.headers },
27433
+ ...options.query !== void 0 && { query: options.query },
27434
+ ...options.transport !== void 0 && { transport: options.transport },
27435
+ ...options.cookies !== void 0 && { cookies: options.cookies },
27436
+ ...options.followRedirects !== void 0 && { followRedirects: options.followRedirects },
27437
+ ...options.body !== void 0 && { body: toRuntimeBody(options.body) }
27438
+ };
27439
+ }
27440
+ function toRuntimeBody(body) {
27441
+ try {
27442
+ return { json: JSON.parse(body) };
27443
+ } catch {
27444
+ return { text: body };
27445
+ }
27446
+ }
27506
27447
  function toResponse(response) {
27507
27448
  return new Response(decodeBody(response), {
27508
27449
  status: response.status,