opensteer 0.9.5 → 0.9.7

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.
Files changed (35) hide show
  1. package/dist/{chunk-7LQL5YUR.js → chunk-3OHKIPBD.js} +571 -738
  2. package/dist/chunk-3OHKIPBD.js.map +1 -0
  3. package/dist/chunk-52UNH5UW.js +458 -0
  4. package/dist/chunk-52UNH5UW.js.map +1 -0
  5. package/dist/{chunk-GSCQQKZZ.js → chunk-PJXN7HED.js} +334 -18
  6. package/dist/chunk-PJXN7HED.js.map +1 -0
  7. package/dist/{chunk-ZRF7WMS3.js → chunk-R33BXCMQ.js} +16 -7
  8. package/dist/chunk-R33BXCMQ.js.map +1 -0
  9. package/dist/{chunk-T5P2QGZ3.js → chunk-U4BUCIZ4.js} +153 -12
  10. package/dist/chunk-U4BUCIZ4.js.map +1 -0
  11. package/dist/cli/bin.cjs +1421 -824
  12. package/dist/cli/bin.cjs.map +1 -1
  13. package/dist/cli/bin.js +286 -129
  14. package/dist/cli/bin.js.map +1 -1
  15. package/dist/index.cjs +1117 -703
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +58 -53
  18. package/dist/index.d.ts +58 -53
  19. package/dist/index.js +4 -4
  20. package/dist/local-view/public/assets/app.js +10 -1
  21. package/dist/local-view/serve-entry.cjs +6815 -1272
  22. package/dist/local-view/serve-entry.cjs.map +1 -1
  23. package/dist/local-view/serve-entry.js +2 -2
  24. package/dist/opensteer-CY2QUJEG.js +6 -0
  25. package/dist/{opensteer-T2JENADR.js.map → opensteer-CY2QUJEG.js.map} +1 -1
  26. package/dist/{session-control-M3JD7ZKA.js → session-control-FIP6ZJLH.js} +4 -4
  27. package/dist/{session-control-M3JD7ZKA.js.map → session-control-FIP6ZJLH.js.map} +1 -1
  28. package/package.json +7 -7
  29. package/dist/chunk-7D45QUZ3.js +0 -332
  30. package/dist/chunk-7D45QUZ3.js.map +0 -1
  31. package/dist/chunk-7LQL5YUR.js.map +0 -1
  32. package/dist/chunk-GSCQQKZZ.js.map +0 -1
  33. package/dist/chunk-T5P2QGZ3.js.map +0 -1
  34. package/dist/chunk-ZRF7WMS3.js.map +0 -1
  35. package/dist/opensteer-T2JENADR.js +0 -6
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { runLocalViewService } from '../chunk-ZRF7WMS3.js';
3
- import '../chunk-T5P2QGZ3.js';
2
+ import { runLocalViewService } from '../chunk-R33BXCMQ.js';
3
+ import '../chunk-U4BUCIZ4.js';
4
4
 
5
5
  // src/local-view/serve-entry.ts
6
6
  runLocalViewService().catch((error) => {
@@ -0,0 +1,6 @@
1
+ export { Opensteer } from './chunk-52UNH5UW.js';
2
+ import './chunk-3OHKIPBD.js';
3
+ import './chunk-PJXN7HED.js';
4
+ import './chunk-U4BUCIZ4.js';
5
+ //# sourceMappingURL=opensteer-CY2QUJEG.js.map
6
+ //# sourceMappingURL=opensteer-CY2QUJEG.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"opensteer-T2JENADR.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"opensteer-CY2QUJEG.js"}
@@ -1,5 +1,5 @@
1
- import { OpensteerBrowserManager } from './chunk-GSCQQKZZ.js';
2
- import { readLocalViewSessionManifest, readPersistedLocalBrowserSessionRecord, deleteLocalViewSessionManifest } from './chunk-T5P2QGZ3.js';
1
+ import { OpensteerBrowserManager } from './chunk-PJXN7HED.js';
2
+ import { readLocalViewSessionManifest, readPersistedLocalBrowserSessionRecord, deleteLocalViewSessionManifest } from './chunk-U4BUCIZ4.js';
3
3
 
4
4
  // src/local-view/session-control.ts
5
5
  var LocalViewSessionCloseError = class extends Error {
@@ -35,5 +35,5 @@ async function closeLocalViewSessionBrowser(sessionId) {
35
35
  }
36
36
 
37
37
  export { LocalViewSessionCloseError, closeLocalViewSessionBrowser };
38
- //# sourceMappingURL=session-control-M3JD7ZKA.js.map
39
- //# sourceMappingURL=session-control-M3JD7ZKA.js.map
38
+ //# sourceMappingURL=session-control-FIP6ZJLH.js.map
39
+ //# sourceMappingURL=session-control-FIP6ZJLH.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/local-view/session-control.ts"],"names":[],"mappings":";;;;AAOO,IAAM,0BAAA,GAAN,cAAyC,KAAA,CAAM;AAAA,EACpD,WAAA,CACE,SACS,UAAA,EACT;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AAFJ,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AAGT,IAAA,IAAA,CAAK,IAAA,GAAO,4BAAA;AAAA,EACd;AACF;AAEA,eAAsB,6BAA6B,SAAA,EAAkC;AACnF,EAAA,MAAM,QAAA,GAAW,MAAM,4BAAA,CAA6B,SAAS,CAAA;AAC7D,EAAA,IAAI,CAAC,QAAA,EAAU;AACb,IAAA,MAAM,IAAI,0BAAA,CAA2B,oBAAA,EAAsB,GAAG,CAAA;AAAA,EAChE;AAEA,EAAA,IAAI,QAAA,CAAS,cAAc,OAAA,EAAS;AAClC,IAAA,MAAM,IAAI,0BAAA;AAAA,MACR,wEAAA;AAAA,MACA;AAAA,KACF;AAAA,EACF;AAEA,EAAA,MAAM,MAAA,GAAS,MAAM,sCAAA,CAAuC,QAAA,CAAS,QAAQ,CAAA;AAC7E,EAAA,IACE,CAAC,MAAA,IACD,MAAA,CAAO,GAAA,KAAQ,QAAA,CAAS,GAAA,IACxB,MAAA,CAAO,SAAA,KAAc,QAAA,CAAS,SAAA,IAC9B,MAAA,CAAO,MAAA,KAAW,SAAS,MAAA,EAC3B;AACA,IAAA,MAAM,8BAAA,CAA+B,SAAS,CAAA,CAAE,KAAA,CAAM,MAAM,MAAS,CAAA;AACrE,IAAA,MAAM,IAAI,0BAAA,CAA2B,oBAAA,EAAsB,GAAG,CAAA;AAAA,EAChE;AAEA,EAAA,MAAM,OAAA,GAAU,IAAI,uBAAA,CAAwB;AAAA,IAC1C,UAAU,QAAA,CAAS,QAAA;AAAA,IACnB,GAAI,SAAS,SAAA,KAAc,MAAA,GAAY,EAAC,GAAI,EAAE,SAAA,EAAW,QAAA,CAAS,SAAA,EAAU;AAAA,IAC5E,YAAY,MAAA,CAAO,MAAA;AAAA,IACnB,OAAA,EAAS;AAAA,GACV,CAAA;AACD,EAAA,MAAM,QAAQ,KAAA,EAAM;AACtB","file":"session-control-M3JD7ZKA.js","sourcesContent":["import { readPersistedLocalBrowserSessionRecord } from \"../live-session.js\";\nimport { OpensteerBrowserManager } from \"../browser-manager.js\";\nimport {\n deleteLocalViewSessionManifest,\n readLocalViewSessionManifest,\n} from \"./session-manifest.js\";\n\nexport class LocalViewSessionCloseError extends Error {\n constructor(\n message: string,\n readonly statusCode: 404 | 409,\n ) {\n super(message);\n this.name = \"LocalViewSessionCloseError\";\n }\n}\n\nexport async function closeLocalViewSessionBrowser(sessionId: string): Promise<void> {\n const manifest = await readLocalViewSessionManifest(sessionId);\n if (!manifest) {\n throw new LocalViewSessionCloseError(\"Session not found.\", 404);\n }\n\n if (manifest.ownership !== \"owned\") {\n throw new LocalViewSessionCloseError(\n \"Only Opensteer-owned local browsers can be closed from the local view.\",\n 409,\n );\n }\n\n const record = await readPersistedLocalBrowserSessionRecord(manifest.rootPath);\n if (\n !record ||\n record.pid !== manifest.pid ||\n record.startedAt !== manifest.startedAt ||\n record.engine !== manifest.engine\n ) {\n await deleteLocalViewSessionManifest(sessionId).catch(() => undefined);\n throw new LocalViewSessionCloseError(\"Session not found.\", 404);\n }\n\n const manager = new OpensteerBrowserManager({\n rootPath: manifest.rootPath,\n ...(manifest.workspace === undefined ? {} : { workspace: manifest.workspace }),\n engineName: record.engine,\n browser: \"persistent\",\n });\n await manager.close();\n}\n"]}
1
+ {"version":3,"sources":["../src/local-view/session-control.ts"],"names":[],"mappings":";;;;AAOO,IAAM,0BAAA,GAAN,cAAyC,KAAA,CAAM;AAAA,EACpD,WAAA,CACE,SACS,UAAA,EACT;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;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";\nimport { OpensteerBrowserManager } from \"../browser-manager.js\";\nimport {\n deleteLocalViewSessionManifest,\n readLocalViewSessionManifest,\n} from \"./session-manifest.js\";\n\nexport class LocalViewSessionCloseError extends Error {\n constructor(\n message: string,\n readonly statusCode: 404 | 409,\n ) {\n super(message);\n this.name = \"LocalViewSessionCloseError\";\n }\n}\n\nexport async function closeLocalViewSessionBrowser(sessionId: string): Promise<void> {\n const manifest = await readLocalViewSessionManifest(sessionId);\n if (!manifest) {\n throw new LocalViewSessionCloseError(\"Session not found.\", 404);\n }\n\n if (manifest.ownership !== \"owned\") {\n throw new LocalViewSessionCloseError(\n \"Only Opensteer-owned local browsers can be closed from the local view.\",\n 409,\n );\n }\n\n const record = await readPersistedLocalBrowserSessionRecord(manifest.rootPath);\n if (\n !record ||\n record.pid !== manifest.pid ||\n record.startedAt !== manifest.startedAt ||\n record.engine !== manifest.engine\n ) {\n await deleteLocalViewSessionManifest(sessionId).catch(() => undefined);\n throw new LocalViewSessionCloseError(\"Session not found.\", 404);\n }\n\n const manager = new OpensteerBrowserManager({\n rootPath: manifest.rootPath,\n ...(manifest.workspace === undefined ? {} : { workspace: manifest.workspace }),\n engineName: record.engine,\n browser: \"persistent\",\n });\n await manager.close();\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opensteer",
3
- "version": "0.9.5",
3
+ "version": "0.9.7",
4
4
  "description": "Opensteer browser automation, replay, and reverse-engineering toolkit.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -56,14 +56,14 @@
56
56
  "sharp": "^0.34.5",
57
57
  "skills": "^1.4.6",
58
58
  "ws": "^8.18.0",
59
- "@opensteer/engine-playwright": "0.8.9",
60
- "@opensteer/runtime-core": "0.2.4"
59
+ "@opensteer/engine-playwright": "0.8.11",
60
+ "@opensteer/runtime-core": "0.2.6"
61
61
  },
62
62
  "optionalDependencies": {
63
63
  "webcrack": "^2.15.1"
64
64
  },
65
65
  "peerDependencies": {
66
- "@opensteer/engine-abp": "0.8.9"
66
+ "@opensteer/engine-abp": "0.8.11"
67
67
  },
68
68
  "peerDependenciesMeta": {
69
69
  "@opensteer/engine-abp": {
@@ -71,9 +71,9 @@
71
71
  }
72
72
  },
73
73
  "devDependencies": {
74
- "@opensteer/browser-core": "0.7.10",
75
- "@opensteer/engine-abp": "0.8.9",
76
- "@opensteer/protocol": "0.8.4"
74
+ "@opensteer/browser-core": "0.7.11",
75
+ "@opensteer/engine-abp": "0.8.11",
76
+ "@opensteer/protocol": "0.8.6"
77
77
  },
78
78
  "scripts": {
79
79
  "build": "tsup && node ../../scripts/copy-opensteer-local-view-assets.mjs && node ../../scripts/sync-package-skills.mjs && node ../../scripts/sync-package-readme.mjs",
@@ -1,332 +0,0 @@
1
- import { resolveOpensteerEnvironment, resolveOpensteerRuntimeConfig, createOpensteerSemanticRuntime } from './chunk-7LQL5YUR.js';
2
- import { OpensteerBrowserManager } from './chunk-GSCQQKZZ.js';
3
-
4
- // src/sdk/opensteer.ts
5
- var SessionCookieJar = class {
6
- domain;
7
- cookies;
8
- constructor(output) {
9
- if (output.domain !== void 0) {
10
- this.domain = output.domain;
11
- }
12
- this.cookies = output.cookies;
13
- }
14
- has(name) {
15
- return this.cookies.some((cookie) => cookie.name === name);
16
- }
17
- get(name) {
18
- return this.cookies.find((cookie) => cookie.name === name)?.value;
19
- }
20
- getAll() {
21
- return this.cookies;
22
- }
23
- serialize() {
24
- return this.cookies.map((cookie) => `${cookie.name}=${cookie.value}`).join("; ");
25
- }
26
- };
27
- var Opensteer = class {
28
- runtime;
29
- browserManager;
30
- browser;
31
- dom;
32
- network;
33
- constructor(options = {}) {
34
- const environment = resolveOpensteerEnvironment(options.rootDir);
35
- const { provider, engineName, ...runtimeOptions } = options;
36
- const runtimeConfig = resolveOpensteerRuntimeConfig({
37
- ...provider === void 0 ? {} : { provider },
38
- environment
39
- });
40
- if (runtimeConfig.provider.mode === "cloud") {
41
- this.browserManager = void 0;
42
- this.runtime = createOpensteerSemanticRuntime({
43
- ...provider === void 0 ? {} : { provider },
44
- ...engineName === void 0 ? {} : { engine: engineName },
45
- environment,
46
- runtimeOptions
47
- });
48
- this.browser = createUnsupportedBrowserController();
49
- } else {
50
- this.browserManager = new OpensteerBrowserManager({
51
- ...runtimeOptions.rootDir === void 0 ? {} : { rootDir: runtimeOptions.rootDir },
52
- ...runtimeOptions.rootPath === void 0 ? {} : { rootPath: runtimeOptions.rootPath },
53
- ...runtimeOptions.workspace === void 0 ? {} : { workspace: runtimeOptions.workspace },
54
- ...engineName === void 0 ? {} : { engineName },
55
- environment,
56
- ...runtimeOptions.browser === void 0 ? {} : { browser: runtimeOptions.browser },
57
- ...runtimeOptions.launch === void 0 ? {} : { launch: runtimeOptions.launch },
58
- ...runtimeOptions.context === void 0 ? {} : { context: runtimeOptions.context }
59
- });
60
- this.runtime = createOpensteerSemanticRuntime({
61
- ...provider === void 0 ? {} : { provider },
62
- ...engineName === void 0 ? {} : { engine: engineName },
63
- environment,
64
- runtimeOptions: {
65
- ...runtimeOptions,
66
- rootPath: this.browserManager.rootPath,
67
- cleanupRootOnClose: this.browserManager.cleanupRootOnDisconnect
68
- }
69
- });
70
- this.browser = {
71
- status: () => this.browserManager.status(),
72
- clone: (input) => this.browserManager.clonePersistentBrowser(input),
73
- reset: () => this.browserManager.reset(),
74
- delete: () => this.browserManager.delete()
75
- };
76
- }
77
- this.dom = {
78
- click: (input) => this.click(input),
79
- hover: (input) => this.hover(input),
80
- input: (input) => this.input(input),
81
- scroll: (input) => this.scroll(input)
82
- };
83
- this.network = {
84
- query: (input = {}) => this.runtime.queryNetwork(input),
85
- detail: (recordId, options2) => this.runtime.getNetworkDetail({ recordId, ...options2 })
86
- };
87
- }
88
- async open(input = {}) {
89
- return this.runtime.open(typeof input === "string" ? { url: input } : input);
90
- }
91
- async info() {
92
- return this.runtime.info();
93
- }
94
- async listPages(input = {}) {
95
- return this.runtime.listPages(input);
96
- }
97
- async newPage(input = {}) {
98
- return this.runtime.newPage(input);
99
- }
100
- async activatePage(input) {
101
- return this.runtime.activatePage(input);
102
- }
103
- async closePage(input = {}) {
104
- return this.runtime.closePage(input);
105
- }
106
- async goto(url, options = {}) {
107
- return this.runtime.goto({
108
- url,
109
- ...options
110
- });
111
- }
112
- async evaluate(input) {
113
- const normalized = typeof input === "string" ? {
114
- script: input
115
- } : input;
116
- return (await this.runtime.evaluate(normalized)).value;
117
- }
118
- async addInitScript(input) {
119
- return this.runtime.addInitScript(
120
- typeof input === "string" ? {
121
- script: input
122
- } : input
123
- );
124
- }
125
- async click(input) {
126
- const { button, clickCount, modifiers, ...target } = input;
127
- return this.runtime.click({
128
- ...normalizeTargetOptions(target),
129
- ...button === void 0 ? {} : { button },
130
- ...clickCount === void 0 ? {} : { clickCount },
131
- ...modifiers === void 0 ? {} : { modifiers }
132
- });
133
- }
134
- async hover(input) {
135
- return this.runtime.hover(normalizeTargetOptions(input));
136
- }
137
- async input(input) {
138
- return this.runtime.input({
139
- ...normalizeTargetOptions(input),
140
- text: input.text,
141
- ...input.pressEnter === void 0 ? {} : { pressEnter: input.pressEnter }
142
- });
143
- }
144
- async scroll(input) {
145
- return this.runtime.scroll({
146
- ...normalizeTargetOptions(input),
147
- direction: input.direction,
148
- amount: input.amount
149
- });
150
- }
151
- async extract(input) {
152
- return (await this.runtime.extract(input)).data;
153
- }
154
- async waitForPage(input = {}) {
155
- const baseline = new Set((await this.runtime.listPages()).pages.map((page) => page.pageRef));
156
- const timeoutAt = Date.now() + (input.timeoutMs ?? 3e4);
157
- const pollIntervalMs = input.pollIntervalMs ?? 100;
158
- while (true) {
159
- const match = (await this.runtime.listPages()).pages.find((page) => {
160
- if (baseline.has(page.pageRef)) {
161
- return false;
162
- }
163
- if (input.openerPageRef !== void 0 && page.openerPageRef !== input.openerPageRef) {
164
- return false;
165
- }
166
- if (input.urlIncludes !== void 0 && !page.url.includes(input.urlIncludes)) {
167
- return false;
168
- }
169
- return true;
170
- });
171
- if (match !== void 0) {
172
- return match;
173
- }
174
- if (Date.now() >= timeoutAt) {
175
- throw new Error("waitForPage timed out");
176
- }
177
- await delay(pollIntervalMs);
178
- }
179
- }
180
- async cookies(domain) {
181
- return new SessionCookieJar(
182
- await this.runtime.getCookies(domain === void 0 ? {} : { domain })
183
- );
184
- }
185
- async storage(domain, type = "local") {
186
- const snapshot = await this.runtime.getStorageSnapshot(domain === void 0 ? {} : { domain });
187
- const domainSnapshot = pickStorageDomainSnapshot(snapshot, domain);
188
- if (domainSnapshot === void 0) {
189
- return {};
190
- }
191
- const entries = type === "local" ? domainSnapshot.localStorage : domainSnapshot.sessionStorage;
192
- return Object.fromEntries(entries.map((entry) => [entry.key, entry.value]));
193
- }
194
- async state(domain) {
195
- return this.runtime.getBrowserState(domain === void 0 ? {} : { domain });
196
- }
197
- async fetch(url, options = {}) {
198
- const input = buildFetchInput(url, options);
199
- const result = await this.runtime.fetch(input);
200
- if (result.response === void 0) {
201
- throw new Error(result.note ?? `session.fetch did not produce a response for ${url}`);
202
- }
203
- return toResponse(result.response);
204
- }
205
- async computerExecute(input) {
206
- return this.runtime.computerExecute(input);
207
- }
208
- async route(input) {
209
- return this.requireOwnedInstrumentationRuntime("route").route(input);
210
- }
211
- async interceptScript(input) {
212
- return this.requireOwnedInstrumentationRuntime("interceptScript").interceptScript(input);
213
- }
214
- async close() {
215
- if (this.browserManager === void 0 || this.browserManager.mode === "temporary") {
216
- return this.runtime.close();
217
- }
218
- const output = await this.runtime.close();
219
- await this.browserManager.close();
220
- return output;
221
- }
222
- async disconnect() {
223
- await this.runtime.disconnect();
224
- }
225
- requireOwnedInstrumentationRuntime(method) {
226
- if (typeof this.runtime.route === "function" && typeof this.runtime.interceptScript === "function") {
227
- return this.runtime;
228
- }
229
- throw new Error(`${method}() is not available for this session runtime.`);
230
- }
231
- };
232
- function createUnsupportedBrowserController() {
233
- const fail = async () => {
234
- throw new Error("browser.* helpers are only available in local mode.");
235
- };
236
- return {
237
- status: fail,
238
- clone: fail,
239
- reset: fail,
240
- delete: fail
241
- };
242
- }
243
- function normalizeTargetOptions(input) {
244
- const hasElement = input.element !== void 0;
245
- const hasSelector = input.selector !== void 0;
246
- if (hasElement && hasSelector) {
247
- throw new Error("Specify exactly one of element, selector, or persist.");
248
- }
249
- if (hasElement) {
250
- return {
251
- target: {
252
- kind: "element",
253
- element: input.element
254
- },
255
- ...input.persist === void 0 ? {} : { persist: input.persist },
256
- ...input.captureNetwork === void 0 ? {} : { captureNetwork: input.captureNetwork }
257
- };
258
- }
259
- if (hasSelector) {
260
- return {
261
- target: {
262
- kind: "selector",
263
- selector: input.selector
264
- },
265
- ...input.persist === void 0 ? {} : { persist: input.persist },
266
- ...input.captureNetwork === void 0 ? {} : { captureNetwork: input.captureNetwork }
267
- };
268
- }
269
- if (input.persist === void 0) {
270
- throw new Error("Specify exactly one of element, selector, or persist.");
271
- }
272
- return {
273
- target: {
274
- kind: "persist",
275
- persist: input.persist
276
- },
277
- ...input.captureNetwork === void 0 ? {} : { captureNetwork: input.captureNetwork }
278
- };
279
- }
280
- function pickStorageDomainSnapshot(snapshot, domain) {
281
- if (snapshot.domains.length === 0) {
282
- return void 0;
283
- }
284
- if (domain === void 0) {
285
- return snapshot.domains[0];
286
- }
287
- return snapshot.domains.find((entry) => entry.domain === domain);
288
- }
289
- function buildFetchInput(url, options) {
290
- const { body, ...rest } = options;
291
- return {
292
- url,
293
- ...rest,
294
- ...body === void 0 ? {} : { body: normalizeFetchBody(body, rest.headers) }
295
- };
296
- }
297
- function normalizeFetchBody(body, headers) {
298
- if (typeof body !== "string") {
299
- return body;
300
- }
301
- const contentType = findHeaderValue(headers, "content-type");
302
- return contentType === void 0 ? { text: body } : { text: body, contentType };
303
- }
304
- function findHeaderValue(headers, headerName) {
305
- if (headers === void 0) {
306
- return void 0;
307
- }
308
- const match = Object.entries(headers).find(
309
- ([name]) => name.toLowerCase() === headerName.toLowerCase()
310
- );
311
- return match === void 0 ? void 0 : String(match[1]);
312
- }
313
- function toResponse(response) {
314
- return new Response(decodeBody(response), {
315
- status: response.status,
316
- statusText: response.statusText,
317
- headers: Object.fromEntries(response.headers.map((header) => [header.name, header.value]))
318
- });
319
- }
320
- function decodeBody(response) {
321
- if (response.body === void 0) {
322
- return void 0;
323
- }
324
- return Uint8Array.from(Buffer.from(response.body.data, "base64"));
325
- }
326
- function delay(ms) {
327
- return new Promise((resolve) => setTimeout(resolve, ms));
328
- }
329
-
330
- export { Opensteer };
331
- //# sourceMappingURL=chunk-7D45QUZ3.js.map
332
- //# sourceMappingURL=chunk-7D45QUZ3.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/sdk/opensteer.ts"],"names":["options"],"mappings":";;;;AA+IA,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,CAA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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-7D45QUZ3.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 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 interface OpensteerExtractOptions {\n readonly persist: string;\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 environment,\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.runtime.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 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 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 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"]}