opensteer 0.8.17 → 0.8.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { resolveOpensteerEnvironment, resolveOpensteerRuntimeConfig, createOpensteerSemanticRuntime, OpensteerBrowserManager } from './chunk-KBO7DDPF.js';
1
+ import { resolveOpensteerEnvironment, resolveOpensteerRuntimeConfig, createOpensteerSemanticRuntime, OpensteerBrowserManager } from './chunk-GQ3PGLYQ.js';
2
2
 
3
3
  // src/sdk/opensteer.ts
4
4
  var SessionCookieJar = class {
@@ -319,23 +319,28 @@ function pickStorageDomainSnapshot(snapshot, domain) {
319
319
  return snapshot.domains.find((entry) => entry.domain === domain);
320
320
  }
321
321
  function buildFetchInput(url, options) {
322
+ const { body, ...rest } = options;
322
323
  return {
323
324
  url,
324
- ...options.method !== void 0 && { method: options.method },
325
- ...options.headers !== void 0 && { headers: options.headers },
326
- ...options.query !== void 0 && { query: options.query },
327
- ...options.transport !== void 0 && { transport: options.transport },
328
- ...options.cookies !== void 0 && { cookies: options.cookies },
329
- ...options.followRedirects !== void 0 && { followRedirects: options.followRedirects },
330
- ...options.body !== void 0 && { body: toRuntimeBody(options.body) }
325
+ ...rest,
326
+ ...body === void 0 ? {} : { body: normalizeFetchBody(body, rest.headers) }
331
327
  };
332
328
  }
333
- function toRuntimeBody(body) {
334
- try {
335
- return { json: JSON.parse(body) };
336
- } catch {
337
- return { text: body };
329
+ function normalizeFetchBody(body, headers) {
330
+ if (typeof body !== "string") {
331
+ return body;
338
332
  }
333
+ const contentType = findHeaderValue(headers, "content-type");
334
+ return contentType === void 0 ? { text: body } : { text: body, contentType };
335
+ }
336
+ function findHeaderValue(headers, headerName) {
337
+ if (headers === void 0) {
338
+ return void 0;
339
+ }
340
+ const match = Object.entries(headers).find(
341
+ ([name]) => name.toLowerCase() === headerName.toLowerCase()
342
+ );
343
+ return match === void 0 ? void 0 : String(match[1]);
339
344
  }
340
345
  function toResponse(response) {
341
346
  return new Response(decodeBody(response), {
@@ -355,5 +360,5 @@ function delay(ms) {
355
360
  }
356
361
 
357
362
  export { Opensteer };
358
- //# sourceMappingURL=chunk-Y3ULLNOS.js.map
359
- //# sourceMappingURL=chunk-Y3ULLNOS.js.map
363
+ //# sourceMappingURL=chunk-T6TG4WO2.js.map
364
+ //# sourceMappingURL=chunk-T6TG4WO2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/sdk/opensteer.ts"],"names":["options"],"mappings":";;;AA2JA,IAAM,mBAAN,MAAqD;AAAA,EAC1C,MAAA;AAAA,EACQ,OAAA;AAAA,EAEjB,YAAY,MAAA,EAAoC;AAC9C,IAAA,IAAI,MAAA,CAAO,WAAW,MAAA,EAAW;AAC/B,MAAA,IAAA,CAAK,SAAS,MAAA,CAAO,MAAA;AAAA,IACvB;AACA,IAAA,IAAA,CAAK,UAAU,MAAA,CAAO,OAAA;AAAA,EACxB;AAAA,EAEA,IAAI,IAAA,EAAuB;AACzB,IAAA,OAAO,KAAK,OAAA,CAAQ,IAAA,CAAK,CAAC,MAAA,KAAW,MAAA,CAAO,SAAS,IAAI,CAAA;AAAA,EAC3D;AAAA,EAEA,IAAI,IAAA,EAAkC;AACpC,IAAA,OAAO,IAAA,CAAK,QAAQ,IAAA,CAAK,CAAC,WAAW,MAAA,CAAO,IAAA,KAAS,IAAI,CAAA,EAAG,KAAA;AAAA,EAC9D;AAAA,EAEA,MAAA,GAAkC;AAChC,IAAA,OAAO,IAAA,CAAK,OAAA;AAAA,EACd;AAAA,EAEA,SAAA,GAAoB;AAClB,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,GAAA,CAAI,CAAC,WAAW,CAAA,EAAG,MAAA,CAAO,IAAI,CAAA,CAAA,EAAI,MAAA,CAAO,KAAK,CAAA,CAAE,CAAA,CAAE,KAAK,IAAI,CAAA;AAAA,EACjF;AACF,CAAA;AAEO,IAAM,YAAN,MAAgB;AAAA,EACJ,OAAA;A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,EAAY,KAAM,WAAW,WAAA;AAAY,GAC5D;AACA,EAAA,OAAO,UAAU,MAAA,GAAY,MAAA,GAAY,MAAA,CAAO,KAAA,CAAM,CAAC,CAAC,CAAA;AAC1D;AAEA,SAAS,WAAW,QAAA,EAAoD;AACtE,EAAA,OAAO,IAAI,QAAA,CAAS,UAAA,CAAW,QAAQ,CAAA,EAAG;AAAA,IACxC,QAAQ,QAAA,CAAS,MAAA;AAAA,IACjB,YAAY,QAAA,CAAS,UAAA;AAAA,IACrB,OAAA,EAAS,MAAA,CAAO,WAAA,CAAY,QAAA,CAAS,QAAQ,GAAA,CAAI,CAAC,MAAA,KAAW,CAAC,MAAA,CAAO,IAAA,EAAM,MAAA,CAAO,KAAK,CAAC,CAAC;AAAA,GAC1F,CAAA;AACH;AAEA,SAAS,WAAW,QAAA,EAAkE;AACpF,EAAA,IAAI,QAAA,CAAS,SAAS,MAAA,EAAW;AAC/B,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,OAAO,UAAA,CAAW,KAAK,MAAA,CAAO,IAAA,CAAK,SAAS,IAAA,CAAK,IAAA,EAAM,QAAQ,CAAC,CAAA;AAClE;AAEA,SAAS,MAAM,EAAA,EAA2B;AACxC,EAAA,OAAO,IAAI,OAAA,CAAQ,CAAC,YAAY,UAAA,CAAW,OAAA,EAAS,EAAE,CAAC,CAAA;AACzD","file":"chunk-T6TG4WO2.js","sourcesContent":["import type {\n CookieRecord,\n OpensteerCookieQueryOutput,\n OpensteerActionResult,\n OpensteerAddInitScriptInput,\n OpensteerAddInitScriptOutput,\n OpensteerComputerExecuteInput,\n OpensteerComputerExecuteOutput,\n OpensteerComputerKeyModifier,\n OpensteerComputerMouseButton,\n OpensteerNetworkDetailOutput,\n OpensteerNetworkQueryInput,\n OpensteerNetworkQueryOutput,\n OpensteerOpenInput,\n OpensteerOpenOutput,\n OpensteerPageActivateInput,\n OpensteerPageActivateOutput,\n OpensteerPageCloseInput,\n OpensteerPageCloseOutput,\n OpensteerPageEvaluateInput,\n OpensteerPageEvaluateOutput,\n OpensteerPageGotoInput,\n OpensteerPageGotoOutput,\n OpensteerPageListInput,\n OpensteerPageListOutput,\n OpensteerPageNewInput,\n OpensteerPageNewOutput,\n OpensteerRequestBodyInput,\n OpensteerRequestResponseResult,\n OpensteerSessionCloseOutput,\n OpensteerSessionFetchInput,\n OpensteerSessionInfo,\n OpensteerSnapshotMode,\n OpensteerStateQueryOutput,\n OpensteerStorageArea,\n OpensteerStorageDomainSnapshot,\n OpensteerTargetInput,\n} from \"@opensteer/protocol\";\n\nimport {\n OpensteerBrowserManager,\n type OpensteerBrowserStatus,\n type WorkspaceBrowserManifest,\n} from \"../browser-manager.js\";\nimport { resolveOpensteerEnvironment } from \"../env.js\";\nimport type { OpensteerProviderOptions } from \"../provider/config.js\";\nimport type {\n OpensteerInterceptScriptOptions,\n OpensteerInstrumentableRuntime,\n OpensteerRouteOptions,\n OpensteerRouteRegistration,\n} from \"./instrumentation.js\";\nimport type { OpensteerRuntimeOptions } from \"./runtime.js\";\nimport {\n createOpensteerSemanticRuntime,\n resolveOpensteerRuntimeConfig,\n} from \"./runtime-resolution.js\";\nimport type { OpensteerDisconnectableRuntime } from \"./semantic-runtime.js\";\n\nexport interface OpensteerTargetOptions {\n readonly element?: number;\n readonly selector?: string;\n readonly persist?: string;\n readonly captureNetwork?: string;\n}\n\nexport interface OpensteerClickOptions extends OpensteerTargetOptions {\n readonly button?: OpensteerComputerMouseButton;\n readonly clickCount?: number;\n readonly modifiers?: readonly OpensteerComputerKeyModifier[];\n}\n\nexport interface OpensteerInputOptions extends OpensteerTargetOptions {\n readonly text: string;\n readonly pressEnter?: boolean;\n}\n\nexport interface OpensteerScrollOptions extends OpensteerTargetOptions {\n readonly direction: \"up\" | \"down\" | \"left\" | \"right\";\n readonly amount: number;\n}\n\nexport type OpensteerExtractOptions =\n | {\n readonly persist: string;\n readonly schema?: Record<string, unknown>;\n }\n | {\n readonly persist?: string;\n readonly schema: Record<string, unknown>;\n };\n\nexport interface OpensteerWaitForNetworkOptions extends OpensteerNetworkQueryInput {\n readonly timeoutMs?: number;\n readonly pollIntervalMs?: number;\n}\n\nexport interface OpensteerWaitForPageOptions {\n readonly openerPageRef?: string;\n readonly urlIncludes?: string;\n readonly timeoutMs?: number;\n readonly pollIntervalMs?: number;\n}\n\nexport type OpensteerAddInitScriptOptions = OpensteerAddInitScriptInput;\nexport type OpensteerGotoOptions = Omit<OpensteerPageGotoInput, \"url\">;\nexport type OpensteerNetworkQueryOptions = OpensteerNetworkQueryInput;\nexport type OpensteerNetworkQueryResult = OpensteerNetworkQueryOutput;\nexport type OpensteerNetworkDetailResult = OpensteerNetworkDetailOutput;\nexport type OpensteerFetchOptions = Omit<OpensteerSessionFetchInput, \"url\" | \"body\"> & {\n readonly body?: string | OpensteerRequestBodyInput;\n};\nexport type OpensteerComputerExecuteOptions = OpensteerComputerExecuteInput;\nexport type OpensteerStorageMap = Readonly<Record<string, string>>;\nexport type OpensteerBrowserState = OpensteerStateQueryOutput;\n\nexport interface OpensteerCookieJar {\n readonly domain?: string;\n has(name: string): boolean;\n get(name: string): string | undefined;\n getAll(): readonly CookieRecord[];\n serialize(): string;\n}\n\nexport interface OpensteerDomController {\n click(input: OpensteerClickOptions): Promise<OpensteerActionResult>;\n hover(input: OpensteerTargetOptions): Promise<OpensteerActionResult>;\n input(input: OpensteerInputOptions): Promise<OpensteerActionResult>;\n scroll(input: OpensteerScrollOptions): Promise<OpensteerActionResult>;\n}\n\nexport interface OpensteerNetworkController {\n query(input?: OpensteerNetworkQueryOptions): Promise<OpensteerNetworkQueryResult>;\n detail(\n recordId: string,\n options?: { readonly probe?: boolean },\n ): Promise<OpensteerNetworkDetailResult>;\n}\n\nexport interface OpensteerOptions extends OpensteerRuntimeOptions {\n readonly provider?: OpensteerProviderOptions;\n}\n\nexport interface OpensteerBrowserCloneOptions {\n readonly sourceUserDataDir: string;\n readonly sourceProfileDirectory?: string;\n}\n\nexport interface OpensteerBrowserController {\n status(): Promise<OpensteerBrowserStatus>;\n clone(input: OpensteerBrowserCloneOptions): Promise<WorkspaceBrowserManifest>;\n reset(): Promise<void>;\n delete(): Promise<void>;\n}\n\nclass SessionCookieJar implements OpensteerCookieJar {\n readonly domain?: string;\n private readonly cookies: readonly CookieRecord[];\n\n constructor(output: OpensteerCookieQueryOutput) {\n if (output.domain !== undefined) {\n this.domain = output.domain;\n }\n this.cookies = output.cookies;\n }\n\n has(name: string): boolean {\n return this.cookies.some((cookie) => cookie.name === name);\n }\n\n get(name: string): string | undefined {\n return this.cookies.find((cookie) => cookie.name === name)?.value;\n }\n\n getAll(): readonly CookieRecord[] {\n return this.cookies;\n }\n\n serialize(): string {\n return this.cookies.map((cookie) => `${cookie.name}=${cookie.value}`).join(\"; \");\n }\n}\n\nexport class Opensteer {\n private readonly runtime: OpensteerDisconnectableRuntime;\n private readonly browserManager: OpensteerBrowserManager | undefined;\n readonly browser: OpensteerBrowserController;\n readonly dom: OpensteerDomController;\n readonly network: OpensteerNetworkController;\n\n constructor(options: OpensteerOptions = {}) {\n const environment = resolveOpensteerEnvironment(options.rootDir);\n const { provider, engineName, ...runtimeOptions } = options;\n const runtimeConfig = resolveOpensteerRuntimeConfig({\n ...(provider === undefined ? {} : { provider }),\n environment,\n });\n\n if (runtimeConfig.provider.mode === \"cloud\") {\n this.browserManager = undefined;\n this.runtime = createOpensteerSemanticRuntime({\n ...(provider === undefined ? {} : { provider }),\n ...(engineName === undefined ? {} : { engine: engineName }),\n environment,\n runtimeOptions,\n });\n this.browser = createUnsupportedBrowserController();\n } else {\n this.browserManager = new OpensteerBrowserManager({\n ...(runtimeOptions.rootDir === undefined ? {} : { rootDir: runtimeOptions.rootDir }),\n ...(runtimeOptions.rootPath === undefined ? {} : { rootPath: runtimeOptions.rootPath }),\n ...(runtimeOptions.workspace === undefined ? {} : { workspace: runtimeOptions.workspace }),\n ...(engineName === undefined ? {} : { engineName }),\n ...(runtimeOptions.browser === undefined ? {} : { browser: runtimeOptions.browser }),\n ...(runtimeOptions.launch === undefined ? {} : { launch: runtimeOptions.launch }),\n ...(runtimeOptions.context === undefined ? {} : { context: runtimeOptions.context }),\n });\n this.runtime = createOpensteerSemanticRuntime({\n ...(provider === undefined ? {} : { provider }),\n ...(engineName === undefined ? {} : { engine: engineName }),\n environment,\n runtimeOptions: {\n ...runtimeOptions,\n rootPath: this.browserManager.rootPath,\n cleanupRootOnClose: this.browserManager.cleanupRootOnDisconnect,\n },\n });\n this.browser = {\n status: () => this.browserManager!.status(),\n clone: (input) => this.browserManager!.clonePersistentBrowser(input),\n reset: () => this.browserManager!.reset(),\n delete: () => this.browserManager!.delete(),\n };\n }\n\n this.dom = {\n click: (input) => this.click(input),\n hover: (input) => this.hover(input),\n input: (input) => this.input(input),\n scroll: (input) => this.scroll(input),\n };\n\n this.network = {\n query: (input = {}) => this.queryNetwork(input),\n detail: (recordId, options) => this.runtime.getNetworkDetail({ recordId, ...options }),\n };\n }\n\n async open(input: string | OpensteerOpenInput = {}): Promise<OpensteerOpenOutput> {\n return this.runtime.open(typeof input === \"string\" ? { url: input } : input);\n }\n\n async info(): Promise<OpensteerSessionInfo> {\n return this.runtime.info();\n }\n\n async listPages(input: OpensteerPageListInput = {}): Promise<OpensteerPageListOutput> {\n return this.runtime.listPages(input);\n }\n\n async newPage(input: OpensteerPageNewInput = {}): Promise<OpensteerPageNewOutput> {\n return this.runtime.newPage(input);\n }\n\n async activatePage(input: OpensteerPageActivateInput): Promise<OpensteerPageActivateOutput> {\n return this.runtime.activatePage(input);\n }\n\n async closePage(input: OpensteerPageCloseInput = {}): Promise<OpensteerPageCloseOutput> {\n return this.runtime.closePage(input);\n }\n\n async goto(url: string, options: OpensteerGotoOptions = {}): Promise<OpensteerPageGotoOutput> {\n return this.runtime.goto({\n url,\n ...options,\n });\n }\n\n async evaluate(\n input: string | OpensteerPageEvaluateInput,\n ): Promise<OpensteerPageEvaluateOutput[\"value\"]> {\n const normalized =\n typeof input === \"string\"\n ? {\n script: input,\n }\n : input;\n return (await this.runtime.evaluate(normalized)).value;\n }\n\n async evaluateJson(\n input: string | OpensteerPageEvaluateInput,\n ): Promise<OpensteerPageEvaluateOutput[\"value\"]> {\n return this.evaluate(input);\n }\n\n async addInitScript(\n input: string | OpensteerAddInitScriptInput,\n ): Promise<OpensteerAddInitScriptOutput> {\n return this.runtime.addInitScript(\n typeof input === \"string\"\n ? {\n script: input,\n }\n : input,\n );\n }\n\n async click(input: OpensteerClickOptions): Promise<OpensteerActionResult> {\n const { button, clickCount, modifiers, ...target } = input;\n return this.runtime.click({\n ...normalizeTargetOptions(target),\n ...(button === undefined ? {} : { button }),\n ...(clickCount === undefined ? {} : { clickCount }),\n ...(modifiers === undefined ? {} : { modifiers }),\n });\n }\n\n async hover(input: OpensteerTargetOptions): Promise<OpensteerActionResult> {\n return this.runtime.hover(normalizeTargetOptions(input));\n }\n\n async input(input: OpensteerInputOptions): Promise<OpensteerActionResult> {\n return this.runtime.input({\n ...normalizeTargetOptions(input),\n text: input.text,\n ...(input.pressEnter === undefined ? {} : { pressEnter: input.pressEnter }),\n });\n }\n\n async scroll(input: OpensteerScrollOptions): Promise<OpensteerActionResult> {\n return this.runtime.scroll({\n ...normalizeTargetOptions(input),\n direction: input.direction,\n amount: input.amount,\n });\n }\n\n async extract(input: OpensteerExtractOptions): Promise<unknown> {\n return (await this.runtime.extract(input)).data;\n }\n\n async queryNetwork(\n input: OpensteerNetworkQueryOptions = {},\n ): Promise<OpensteerNetworkQueryResult> {\n return this.runtime.queryNetwork(input);\n }\n\n async waitForNetwork(\n input: OpensteerWaitForNetworkOptions,\n ): Promise<OpensteerNetworkQueryResult[\"records\"][number]> {\n const { timeoutMs, pollIntervalMs, ...query } = input;\n const timeoutAt = Date.now() + (timeoutMs ?? 30_000);\n const pollInterval = pollIntervalMs ?? 100;\n const baseline = new Set(\n (await this.runtime.queryNetwork({ ...query, limit: 200 })).records.map(\n (record) => record.recordId,\n ),\n );\n\n while (true) {\n const next = (await this.runtime.queryNetwork({ ...query, limit: 200 })).records.find(\n (record) => !baseline.has(record.recordId),\n );\n if (next !== undefined) {\n return next;\n }\n if (Date.now() >= timeoutAt) {\n throw new Error(\"waitForNetwork timed out\");\n }\n await delay(pollInterval);\n }\n }\n\n async waitForResponse(\n input: OpensteerWaitForNetworkOptions,\n ): Promise<OpensteerNetworkQueryResult[\"records\"][number]> {\n return this.waitForNetwork(input);\n }\n\n async waitForPage(\n input: OpensteerWaitForPageOptions = {},\n ): Promise<OpensteerPageListOutput[\"pages\"][number]> {\n const baseline = new Set((await this.runtime.listPages()).pages.map((page) => page.pageRef));\n const timeoutAt = Date.now() + (input.timeoutMs ?? 30_000);\n const pollIntervalMs = input.pollIntervalMs ?? 100;\n\n while (true) {\n const match = (await this.runtime.listPages()).pages.find((page) => {\n if (baseline.has(page.pageRef)) {\n return false;\n }\n if (input.openerPageRef !== undefined && page.openerPageRef !== input.openerPageRef) {\n return false;\n }\n if (input.urlIncludes !== undefined && !page.url.includes(input.urlIncludes)) {\n return false;\n }\n return true;\n });\n if (match !== undefined) {\n return match;\n }\n if (Date.now() >= timeoutAt) {\n throw new Error(\"waitForPage timed out\");\n }\n await delay(pollIntervalMs);\n }\n }\n\n async snapshot(mode: OpensteerSnapshotMode = \"action\"): Promise<string> {\n return (await this.runtime.snapshot({ mode })).html;\n }\n\n async cookies(domain?: string): Promise<OpensteerCookieJar> {\n return new SessionCookieJar(\n await this.runtime.getCookies(domain === undefined ? {} : { domain }),\n );\n }\n\n async storage(\n domain?: string,\n type: OpensteerStorageArea = \"local\",\n ): Promise<OpensteerStorageMap> {\n const snapshot = await this.runtime.getStorageSnapshot(domain === undefined ? {} : { domain });\n const domainSnapshot = pickStorageDomainSnapshot(snapshot, domain);\n if (domainSnapshot === undefined) {\n return {};\n }\n const entries = type === \"local\" ? domainSnapshot.localStorage : domainSnapshot.sessionStorage;\n return Object.fromEntries(entries.map((entry) => [entry.key, entry.value]));\n }\n\n async state(domain?: string): Promise<OpensteerBrowserState> {\n return this.runtime.getBrowserState(domain === undefined ? {} : { domain });\n }\n\n async fetch(url: string, options: OpensteerFetchOptions = {}): Promise<Response> {\n const input = buildFetchInput(url, options);\n const result = await this.runtime.fetch(input);\n if (result.response === undefined) {\n throw new Error(result.note ?? `session.fetch did not produce a response for ${url}`);\n }\n return toResponse(result.response);\n }\n\n async computerExecute(\n input: OpensteerComputerExecuteOptions,\n ): Promise<OpensteerComputerExecuteOutput> {\n return this.runtime.computerExecute(input);\n }\n\n async route(input: OpensteerRouteOptions): Promise<OpensteerRouteRegistration> {\n return this.requireOwnedInstrumentationRuntime(\"route\").route(input);\n }\n\n async interceptScript(\n input: OpensteerInterceptScriptOptions,\n ): Promise<OpensteerRouteRegistration> {\n return this.requireOwnedInstrumentationRuntime(\"interceptScript\").interceptScript(input);\n }\n\n async close(): Promise<OpensteerSessionCloseOutput> {\n if (this.browserManager === undefined || this.browserManager.mode === \"temporary\") {\n return this.runtime.close();\n }\n\n const output = await this.runtime.close();\n await this.browserManager.close();\n return output;\n }\n\n async disconnect(): Promise<void> {\n await this.runtime.disconnect();\n }\n\n private requireOwnedInstrumentationRuntime(\n method: \"route\" | \"interceptScript\",\n ): OpensteerInstrumentableRuntime {\n if (\n typeof (this.runtime as Partial<OpensteerInstrumentableRuntime>).route === \"function\" &&\n typeof (this.runtime as Partial<OpensteerInstrumentableRuntime>).interceptScript ===\n \"function\"\n ) {\n return this.runtime as OpensteerDisconnectableRuntime & OpensteerInstrumentableRuntime;\n }\n throw new Error(`${method}() is not available for this session runtime.`);\n }\n}\n\nfunction createUnsupportedBrowserController(): OpensteerBrowserController {\n const fail = async (): Promise<never> => {\n throw new Error(\"browser.* helpers are only available in local mode.\");\n };\n\n return {\n status: fail,\n clone: fail,\n reset: fail,\n delete: fail,\n };\n}\n\nfunction normalizeTargetOptions(input: OpensteerTargetOptions): {\n readonly target: OpensteerTargetInput;\n readonly persist?: string;\n readonly captureNetwork?: string;\n} {\n const hasElement = input.element !== undefined;\n const hasSelector = input.selector !== undefined;\n if (hasElement && hasSelector) {\n throw new Error(\"Specify exactly one of element, selector, or persist.\");\n }\n\n if (hasElement) {\n return {\n target: {\n kind: \"element\",\n element: input.element,\n },\n ...(input.persist === undefined ? {} : { persist: input.persist }),\n ...(input.captureNetwork === undefined ? {} : { captureNetwork: input.captureNetwork }),\n };\n }\n\n if (hasSelector) {\n return {\n target: {\n kind: \"selector\",\n selector: input.selector,\n },\n ...(input.persist === undefined ? {} : { persist: input.persist }),\n ...(input.captureNetwork === undefined ? {} : { captureNetwork: input.captureNetwork }),\n };\n }\n\n if (input.persist === undefined) {\n throw new Error(\"Specify exactly one of element, selector, or persist.\");\n }\n\n return {\n target: {\n kind: \"persist\",\n persist: input.persist,\n },\n ...(input.captureNetwork === undefined ? {} : { captureNetwork: input.captureNetwork }),\n };\n}\n\nfunction pickStorageDomainSnapshot(\n snapshot: {\n readonly domains: readonly OpensteerStorageDomainSnapshot[];\n },\n domain: string | undefined,\n): OpensteerStorageDomainSnapshot | undefined {\n if (snapshot.domains.length === 0) {\n return undefined;\n }\n if (domain === undefined) {\n return snapshot.domains[0];\n }\n return snapshot.domains.find((entry) => entry.domain === domain);\n}\n\nfunction buildFetchInput(url: string, options: OpensteerFetchOptions): OpensteerSessionFetchInput {\n const { body, ...rest } = options;\n return {\n url,\n ...rest,\n ...(body === undefined ? {} : { body: normalizeFetchBody(body, rest.headers) }),\n };\n}\n\nfunction normalizeFetchBody(\n body: string | OpensteerRequestBodyInput,\n headers: OpensteerSessionFetchInput[\"headers\"],\n): OpensteerRequestBodyInput {\n if (typeof body !== \"string\") {\n return body;\n }\n\n const contentType = findHeaderValue(headers, \"content-type\");\n return contentType === undefined ? { text: body } : { text: body, contentType };\n}\n\nfunction findHeaderValue(\n headers: OpensteerSessionFetchInput[\"headers\"],\n headerName: string,\n): string | undefined {\n if (headers === undefined) {\n return undefined;\n }\n\n const match = Object.entries(headers).find(\n ([name]) => name.toLowerCase() === headerName.toLowerCase(),\n );\n return match === undefined ? undefined : String(match[1]);\n}\n\nfunction toResponse(response: OpensteerRequestResponseResult): Response {\n return new Response(decodeBody(response), {\n status: response.status,\n statusText: response.statusText,\n headers: Object.fromEntries(response.headers.map((header) => [header.name, header.value])),\n });\n}\n\nfunction decodeBody(response: OpensteerRequestResponseResult): Uint8Array | undefined {\n if (response.body === undefined) {\n return undefined;\n }\n return Uint8Array.from(Buffer.from(response.body.data, \"base64\"));\n}\n\nfunction delay(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n"]}
package/dist/cli/bin.cjs CHANGED
@@ -3162,7 +3162,7 @@ var init_storage2 = __esm({
3162
3162
  });
3163
3163
 
3164
3164
  // ../protocol/src/requests.ts
3165
- var opensteerRequestScalarSchema, opensteerRequestScalarMapSchema, opensteerRequestEntrySchema, opensteerRequestPlanParameterLocationSchema, opensteerRequestPlanParameterSchema, opensteerRequestPlanTransportSchema, opensteerRequestPlanEndpointSchema, opensteerRequestPlanBodySchema, transportKindSchema, opensteerRequestPlanStatusSchema, opensteerRequestPlanResponseExpectationSchema, opensteerRecipeRefSchema, opensteerRequestFailurePolicyHeaderMatchSchema, opensteerRequestFailurePolicySchema, opensteerRequestRetryBackoffPolicySchema, opensteerRequestRetryPolicySchema, opensteerRecipeCachePolicySchema, opensteerRequestPlanRecipeBindingSchema, opensteerRequestPlanRecoverBindingSchema, opensteerRequestPlanRecipesSchema, opensteerRequestPlanAuthSchema, opensteerRequestPlanPayloadSchema, opensteerRegistryProvenanceSchema, opensteerRequestPlanFreshnessSchema, opensteerRequestPlanRecordSchema, jsonValueSchema, opensteerRequestBodyInputSchema, opensteerRecipeRetryOverridesSchema, opensteerRecipeStepResponseCaptureSchema, opensteerRecipeRequestStepInputSchema, opensteerRecipeHookRefSchema, opensteerRecipeStepSchema, opensteerRecipePayloadSchema, opensteerRecipeRecordSchema, opensteerNetworkQueryInputSchema, opensteerGraphqlSummarySchema, opensteerNetworkBodySummarySchema, opensteerNetworkSummaryRecordSchema, opensteerNetworkQueryOutputSchema, opensteerParsedCookieSchema, opensteerStructuredBodyPreviewSchema, opensteerNetworkRedirectHopSchema, opensteerReplayAttemptSchema, opensteerNetworkDetailOutputSchema, opensteerSessionFetchTransportSchema, opensteerSessionFetchInputSchema, opensteerSessionFetchOutputSchema, opensteerCookieQueryInputSchema, opensteerCookieQueryOutputSchema, opensteerStorageDomainSnapshotSchema, opensteerStorageQueryInputSchema, opensteerStorageQueryOutputSchema, opensteerHiddenFieldSchema, opensteerStateDomainSnapshotSchema, opensteerStateQueryInputSchema, opensteerStateQueryOutputSchema, opensteerRequestTransportResultSchema, opensteerRequestResponseResultSchema;
3165
+ var opensteerRequestScalarSchema, opensteerRequestScalarMapSchema, opensteerRequestEntrySchema, opensteerRequestPlanParameterLocationSchema, opensteerRequestPlanParameterSchema, opensteerRequestPlanTransportSchema, opensteerRequestPlanEndpointSchema, opensteerRequestPlanBodySchema, transportKindSchema, opensteerRequestPlanStatusSchema, opensteerRequestPlanResponseExpectationSchema, opensteerRecipeRefSchema, opensteerRequestFailurePolicyHeaderMatchSchema, opensteerRequestFailurePolicySchema, opensteerRequestRetryBackoffPolicySchema, opensteerRequestRetryPolicySchema, opensteerRecipeCachePolicySchema, opensteerRequestPlanRecipeBindingSchema, opensteerRequestPlanRecoverBindingSchema, opensteerRequestPlanRecipesSchema, opensteerRequestPlanAuthSchema, opensteerRequestPlanPayloadSchema, opensteerRegistryProvenanceSchema, opensteerRequestPlanFreshnessSchema, opensteerRequestPlanRecordSchema, jsonValueSchema, opensteerRequestBodyInputSchema, opensteerRecipeRetryOverridesSchema, opensteerRecipeStepResponseCaptureSchema, opensteerRecipeRequestStepInputSchema, opensteerRecipeHookRefSchema, opensteerRecipeStepSchema, opensteerRecipePayloadSchema, opensteerRecipeRecordSchema, opensteerNetworkQueryInputSchema, opensteerGraphqlSummarySchema, opensteerNetworkBodySummarySchema, opensteerNetworkSummaryRecordSchema, opensteerNetworkQueryOutputSchema, opensteerNetworkDetailInputSchema, opensteerParsedCookieSchema, opensteerStructuredBodyPreviewSchema, opensteerNetworkRedirectHopSchema, opensteerReplayAttemptSchema, opensteerNetworkDetailOutputSchema, opensteerSessionFetchTransportSchema, opensteerSessionFetchInputSchema, opensteerSessionFetchOutputSchema, opensteerCookieQueryInputSchema, opensteerCookieQueryOutputSchema, opensteerStorageDomainSnapshotSchema, opensteerStorageQueryInputSchema, opensteerStorageQueryOutputSchema, opensteerHiddenFieldSchema, opensteerStateDomainSnapshotSchema, opensteerStateQueryInputSchema, opensteerStateQueryOutputSchema, opensteerRequestTransportResultSchema, opensteerRequestResponseResultSchema;
3166
3166
  var init_requests = __esm({
3167
3167
  "../protocol/src/requests.ts"() {
3168
3168
  init_network2();
@@ -3886,6 +3886,16 @@ var init_requests = __esm({
3886
3886
  required: ["records"]
3887
3887
  }
3888
3888
  );
3889
+ opensteerNetworkDetailInputSchema = objectSchema(
3890
+ {
3891
+ recordId: stringSchema({ minLength: 1 }),
3892
+ probe: { type: "boolean" }
3893
+ },
3894
+ {
3895
+ title: "OpensteerNetworkDetailInput",
3896
+ required: ["recordId"]
3897
+ }
3898
+ );
3889
3899
  opensteerParsedCookieSchema = objectSchema(
3890
3900
  {
3891
3901
  name: stringSchema({ minLength: 1 }),
@@ -8437,7 +8447,7 @@ function assertValidSemanticOperationInput(name, input) {
8437
8447
  }
8438
8448
  );
8439
8449
  }
8440
- var opensteerComputerAnnotationNames, opensteerExposedSemanticOperationNames, opensteerPackageRunnableSemanticOperationNames, snapshotModeSchema, viewportSchema, opensteerBrowserLaunchOptionsSchema, attachBrowserOptionsSchema, opensteerBrowserOptionsSchema, opensteerBrowserContextOptionsSchema, targetByElementSchema2, targetByPersistSchema2, targetBySelectorSchema2, opensteerTargetInputSchema, opensteerResolvedTargetSchema, opensteerActionResultSchema, opensteerSnapshotCounterSchema, opensteerSessionStateSchema, opensteerOpenInputSchema, opensteerPageListInputSchema, opensteerPageListOutputSchema, opensteerPageNewInputSchema, opensteerPageActivateInputSchema, opensteerPageCloseInputSchema, opensteerPageCloseOutputSchema, opensteerPageGotoInputSchema, opensteerPageEvaluateInputSchema, opensteerPageEvaluateOutputSchema, opensteerAddInitScriptInputSchema, opensteerAddInitScriptOutputSchema, opensteerCapturedScriptSchema, opensteerCaptureScriptsInputSchema, opensteerCaptureScriptsOutputSchema, opensteerPageSnapshotInputSchema, opensteerPageSnapshotOutputSchema, opensteerNetworkDetailInputSchema, opensteerComputerMouseButtonSchema, opensteerComputerKeyModifierSchema, opensteerDomClickInputSchema, opensteerDomHoverInputSchema, opensteerDomInputInputSchema, opensteerDomScrollInputSchema, opensteerExtractSchemaSchema, opensteerDomExtractInputSchema, jsonValueSchema3, opensteerDomExtractOutputSchema, opensteerSessionCloseInputSchema, opensteerSessionCloseOutputSchema, opensteerComputerAnnotationSchema, opensteerComputerClickActionSchema, opensteerComputerMoveActionSchema, opensteerComputerScrollActionSchema, opensteerComputerTypeActionSchema, opensteerComputerKeyActionSchema, opensteerComputerDragActionSchema, opensteerComputerScreenshotActionSchema, opensteerComputerWaitActionSchema, opensteerComputerActionSchema, opensteerComputerScreenshotOptionsSchema, opensteerComputerExecuteInputSchema, opensteerComputerTracePointSchema, opensteerComputerTraceEnrichmentSchema, opensteerComputerExecuteTimingSchema, opensteerComputerDisplayScaleSchema, opensteerComputerExecuteOutputSchema, opensteerSemanticOperationSpecificationsBase, exposedSemanticOperationNameSet, opensteerSemanticOperationSpecificationsInternal, opensteerSemanticOperationSpecifications, opensteerSemanticOperationSpecificationMap, semanticRestBasePath, opensteerSemanticRestEndpoints;
8450
+ var opensteerComputerAnnotationNames, opensteerExposedSemanticOperationNames, opensteerPackageRunnableSemanticOperationNames, snapshotModeSchema, viewportSchema, opensteerBrowserLaunchOptionsSchema, attachBrowserOptionsSchema, opensteerBrowserOptionsSchema, opensteerBrowserContextOptionsSchema, targetByElementSchema2, targetByPersistSchema2, targetBySelectorSchema2, opensteerTargetInputSchema, opensteerResolvedTargetSchema, opensteerActionResultSchema, opensteerSnapshotCounterSchema, opensteerSessionStateSchema, opensteerOpenInputSchema, opensteerPageListInputSchema, opensteerPageListOutputSchema, opensteerPageNewInputSchema, opensteerPageActivateInputSchema, opensteerPageCloseInputSchema, opensteerPageCloseOutputSchema, opensteerPageGotoInputSchema, opensteerPageEvaluateInputSchema, opensteerPageEvaluateOutputSchema, opensteerAddInitScriptInputSchema, opensteerAddInitScriptOutputSchema, opensteerCapturedScriptSchema, opensteerCaptureScriptsInputSchema, opensteerCaptureScriptsOutputSchema, opensteerPageSnapshotInputSchema, opensteerPageSnapshotOutputSchema, opensteerComputerMouseButtonSchema, opensteerComputerKeyModifierSchema, opensteerDomClickInputSchema, opensteerDomHoverInputSchema, opensteerDomInputInputSchema, opensteerDomScrollInputSchema, opensteerExtractSchemaSchema, opensteerDomExtractInputSchema, jsonValueSchema3, opensteerDomExtractOutputSchema, opensteerSessionCloseInputSchema, opensteerSessionCloseOutputSchema, opensteerComputerAnnotationSchema, opensteerComputerClickActionSchema, opensteerComputerMoveActionSchema, opensteerComputerScrollActionSchema, opensteerComputerTypeActionSchema, opensteerComputerKeyActionSchema, opensteerComputerDragActionSchema, opensteerComputerScreenshotActionSchema, opensteerComputerWaitActionSchema, opensteerComputerActionSchema, opensteerComputerScreenshotOptionsSchema, opensteerComputerExecuteInputSchema, opensteerComputerTracePointSchema, opensteerComputerTraceEnrichmentSchema, opensteerComputerExecuteTimingSchema, opensteerComputerDisplayScaleSchema, opensteerComputerExecuteOutputSchema, opensteerSemanticOperationSpecificationsBase, exposedSemanticOperationNameSet, opensteerSemanticOperationSpecificationsInternal, opensteerSemanticOperationSpecifications, opensteerSemanticOperationSpecificationMap, semanticRestBasePath, opensteerSemanticRestEndpoints;
8441
8451
  var init_semantic = __esm({
8442
8452
  "../protocol/src/semantic.ts"() {
8443
8453
  init_json2();
@@ -8940,15 +8950,6 @@ var init_semantic = __esm({
8940
8950
  required: ["url", "title", "mode", "html", "counters"]
8941
8951
  }
8942
8952
  );
8943
- opensteerNetworkDetailInputSchema = objectSchema(
8944
- {
8945
- recordId: stringSchema({ minLength: 1 })
8946
- },
8947
- {
8948
- title: "OpensteerNetworkDetailInput",
8949
- required: ["recordId"]
8950
- }
8951
- );
8952
8953
  opensteerComputerMouseButtonSchema = enumSchema(
8953
8954
  ["left", "middle", "right"],
8954
8955
  {
@@ -30950,23 +30951,28 @@ function pickStorageDomainSnapshot(snapshot, domain) {
30950
30951
  return snapshot.domains.find((entry) => entry.domain === domain);
30951
30952
  }
30952
30953
  function buildFetchInput(url, options) {
30954
+ const { body, ...rest } = options;
30953
30955
  return {
30954
30956
  url,
30955
- ...options.method !== void 0 && { method: options.method },
30956
- ...options.headers !== void 0 && { headers: options.headers },
30957
- ...options.query !== void 0 && { query: options.query },
30958
- ...options.transport !== void 0 && { transport: options.transport },
30959
- ...options.cookies !== void 0 && { cookies: options.cookies },
30960
- ...options.followRedirects !== void 0 && { followRedirects: options.followRedirects },
30961
- ...options.body !== void 0 && { body: toRuntimeBody(options.body) }
30957
+ ...rest,
30958
+ ...body === void 0 ? {} : { body: normalizeFetchBody(body, rest.headers) }
30962
30959
  };
30963
30960
  }
30964
- function toRuntimeBody(body) {
30965
- try {
30966
- return { json: JSON.parse(body) };
30967
- } catch {
30968
- return { text: body };
30961
+ function normalizeFetchBody(body, headers) {
30962
+ if (typeof body !== "string") {
30963
+ return body;
30964
+ }
30965
+ const contentType = findHeaderValue3(headers, "content-type");
30966
+ return contentType === void 0 ? { text: body } : { text: body, contentType };
30967
+ }
30968
+ function findHeaderValue3(headers, headerName) {
30969
+ if (headers === void 0) {
30970
+ return void 0;
30969
30971
  }
30972
+ const match = Object.entries(headers).find(
30973
+ ([name]) => name.toLowerCase() === headerName.toLowerCase()
30974
+ );
30975
+ return match === void 0 ? void 0 : String(match[1]);
30970
30976
  }
30971
30977
  function toResponse(response) {
30972
30978
  return new Response(decodeBody(response), {
@@ -31255,7 +31261,7 @@ var init_opensteer = __esm({
31255
31261
 
31256
31262
  // package.json
31257
31263
  var package_default = {
31258
- version: "0.8.17"};
31264
+ version: "0.8.18"};
31259
31265
 
31260
31266
  // src/cli/bin.ts
31261
31267
  init_browser_manager();