@e2e-dev/kernel 0.1.0
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/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +41 -0
- package/dist/.build.json +1 -0
- package/dist/client.d.ts +32 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +75 -0
- package/dist/client.js.map +1 -0
- package/dist/env.d.ts +3 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +6 -0
- package/dist/env.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/provider.d.ts +36 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +105 -0
- package/dist/provider.js.map +1 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @e2e-dev/kernel
|
|
2
|
+
|
|
3
|
+
[Kernel](https://kernel.sh) hosted browsers for [`e2e`](https://www.npmjs.com/package/e2e):
|
|
4
|
+
`web({ browser: kernel() })` runs a web target in Kernel's hosted Chromium.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install --save-dev @e2e-dev/kernel @onkernel/sdk
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```ts title="e2e.config.ts"
|
|
15
|
+
import type { E2EConfig } from 'e2e';
|
|
16
|
+
import { web } from '@e2e-dev/web';
|
|
17
|
+
import { kernel } from '@e2e-dev/kernel';
|
|
18
|
+
|
|
19
|
+
export default {
|
|
20
|
+
targets: [{ engine: web({ browser: kernel({ stealth: true }), viewport: null }), app: { url: 'https://staging.example.com' } }],
|
|
21
|
+
workers: 4,
|
|
22
|
+
} satisfies E2EConfig;
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`KERNEL_API_KEY` comes from the run's environment. `kernel(options)` takes
|
|
26
|
+
Kernel's create-browser body as is (`stealth`, `headless`, `timeout_seconds`,
|
|
27
|
+
`profile`, `proxy_id`, `viewport`, `tags`, ...) plus the lease `scope`:
|
|
28
|
+
`worker` (default) is one browser per worker slot for the run, `attempt` a
|
|
29
|
+
fresh browser per test attempt. Every browser is tagged with the run, target,
|
|
30
|
+
and slot, `timeout_seconds` defaults to 600 so Kernel deletes a browser a dead
|
|
31
|
+
worker never released, and each lease logs its live view URL when Kernel
|
|
32
|
+
gives one. On a headed browser, an attempt that records video (`--video`, or
|
|
33
|
+
a test's `video` option) gets a Kernel replay of the browser's screen as its
|
|
34
|
+
`video/replay.mp4`; a headless browser and `replay: false` get the page
|
|
35
|
+
screencast.
|
|
36
|
+
|
|
37
|
+
Full documentation lives at [e2e.tester.army/docs/integrations/kernel](https://e2e.tester.army/docs/integrations/kernel).
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
|
|
41
|
+
Apache-2.0
|
package/dist/.build.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"0.1.0"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** The slice of the Kernel SDK the provider uses, loaded on first use so a config load never pays for it. */
|
|
2
|
+
import type { Kernel } from '@onkernel/sdk';
|
|
3
|
+
/** Kernel's create-browser body, its tags read-only. */
|
|
4
|
+
export type KernelBrowserParams = Omit<Kernel.BrowserCreateParams, 'tags'> & {
|
|
5
|
+
readonly tags?: Readonly<Record<string, string>> | undefined;
|
|
6
|
+
};
|
|
7
|
+
/** Kernel's start-replay body: `framerate`, `max_duration_in_seconds`, `record_audio`. */
|
|
8
|
+
export type KernelReplayParams = Kernel.Browsers.ReplayStartParams;
|
|
9
|
+
interface KernelBrowser {
|
|
10
|
+
readonly sessionId: string;
|
|
11
|
+
readonly cdpWsUrl: string;
|
|
12
|
+
readonly liveViewUrl?: string | undefined;
|
|
13
|
+
}
|
|
14
|
+
export interface KernelBrowsers {
|
|
15
|
+
create(params: KernelBrowserParams, signal: AbortSignal): Promise<KernelBrowser>;
|
|
16
|
+
/** Deletes the browser; one Kernel no longer knows counts as deleted. Resolves to whether Kernel still knew it. */
|
|
17
|
+
delete(sessionId: string, signal: AbortSignal): Promise<boolean>;
|
|
18
|
+
/** The session ids of the active browsers carrying every one of `tags`. */
|
|
19
|
+
listActive(tags: Readonly<Record<string, string>>, signal: AbortSignal): Promise<string[]>;
|
|
20
|
+
/** Starts recording the browser's screen; resolves to the replay id. */
|
|
21
|
+
startReplay(sessionId: string, params: KernelReplayParams, signal: AbortSignal): Promise<string>;
|
|
22
|
+
/** Stops a recording. */
|
|
23
|
+
stopReplay(sessionId: string, replayId: string, signal: AbortSignal): Promise<void>;
|
|
24
|
+
/** Downloads a stopped recording's MP4 to `file`. */
|
|
25
|
+
downloadReplay(sessionId: string, replayId: string, file: string, signal: AbortSignal): Promise<void>;
|
|
26
|
+
/** The bytes of one file on the browser's own disk. */
|
|
27
|
+
readFile(sessionId: string, file: string, signal: AbortSignal): Promise<Uint8Array>;
|
|
28
|
+
}
|
|
29
|
+
/** Kernel browsers for one API key, through the SDK. */
|
|
30
|
+
export declare function kernelBrowsers(apiKey: string): KernelBrowsers;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":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AW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpF,qDAAqD;IACrD,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtG,uDAAuD;IACvD,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACrF;AAqBD,wDAAwD;AACxD,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,CAoD7D"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/** The slice of the Kernel SDK the provider uses, loaded on first use so a config load never pays for it. */
|
|
2
|
+
import { createWriteStream } from 'node:fs';
|
|
3
|
+
import { Readable } from 'node:stream';
|
|
4
|
+
import { pipeline } from 'node:stream/promises';
|
|
5
|
+
/**
|
|
6
|
+
* An SDK error with its message trimmed: Kernel's error bodies end in a
|
|
7
|
+
* newline the SDK keeps (`401 Invalid or disabled API key\n`), which would
|
|
8
|
+
* split the run's error line. The error itself is kept, class and all.
|
|
9
|
+
*/
|
|
10
|
+
function trimmed(cause) {
|
|
11
|
+
if (cause instanceof Error && cause.message !== cause.message.trim())
|
|
12
|
+
cause.message = cause.message.trim();
|
|
13
|
+
return cause;
|
|
14
|
+
}
|
|
15
|
+
/** Runs one SDK request, its failure's message trimmed. */
|
|
16
|
+
async function request(run) {
|
|
17
|
+
try {
|
|
18
|
+
return await run();
|
|
19
|
+
}
|
|
20
|
+
catch (cause) {
|
|
21
|
+
throw trimmed(cause);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** Kernel browsers for one API key, through the SDK. */
|
|
25
|
+
export function kernelBrowsers(apiKey) {
|
|
26
|
+
const sdk = import('@onkernel/sdk').then((module) => ({ client: new module.Kernel({ apiKey }), NotFoundError: module.NotFoundError }));
|
|
27
|
+
return {
|
|
28
|
+
create: (params, signal) => request(async () => {
|
|
29
|
+
const { client } = await sdk;
|
|
30
|
+
const created = await client.browsers.create({ ...params, tags: { ...params.tags } }, { signal });
|
|
31
|
+
return { sessionId: created.session_id, cdpWsUrl: created.cdp_ws_url, liveViewUrl: created.browser_live_view_url };
|
|
32
|
+
}),
|
|
33
|
+
delete: (sessionId, signal) => request(async () => {
|
|
34
|
+
const { client, NotFoundError } = await sdk;
|
|
35
|
+
try {
|
|
36
|
+
await client.browsers.deleteByID(sessionId, { signal });
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
catch (cause) {
|
|
40
|
+
if (!(cause instanceof NotFoundError))
|
|
41
|
+
throw cause;
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}),
|
|
45
|
+
listActive: (tags, signal) => request(async () => {
|
|
46
|
+
const { client } = await sdk;
|
|
47
|
+
const ids = [];
|
|
48
|
+
for await (const browser of client.browsers.list({ status: 'active', tags: { ...tags } }, { signal }))
|
|
49
|
+
ids.push(browser.session_id);
|
|
50
|
+
return ids;
|
|
51
|
+
}),
|
|
52
|
+
startReplay: (sessionId, params, signal) => request(async () => {
|
|
53
|
+
const { client } = await sdk;
|
|
54
|
+
const replay = await client.browsers.replays.start(sessionId, params, { signal });
|
|
55
|
+
return replay.replay_id;
|
|
56
|
+
}),
|
|
57
|
+
stopReplay: (sessionId, replayId, signal) => request(async () => {
|
|
58
|
+
const { client } = await sdk;
|
|
59
|
+
await client.browsers.replays.stop(replayId, { id_or_name: sessionId }, { signal });
|
|
60
|
+
}),
|
|
61
|
+
downloadReplay: (sessionId, replayId, file, signal) => request(async () => {
|
|
62
|
+
const { client } = await sdk;
|
|
63
|
+
const response = await client.browsers.replays.download(replayId, { id_or_name: sessionId }, { signal });
|
|
64
|
+
if (response.body === null)
|
|
65
|
+
throw new Error(`replay ${replayId} downloaded empty`);
|
|
66
|
+
await pipeline(Readable.fromWeb(response.body), createWriteStream(file), { signal });
|
|
67
|
+
}),
|
|
68
|
+
readFile: (sessionId, file, signal) => request(async () => {
|
|
69
|
+
const { client } = await sdk;
|
|
70
|
+
const response = await client.browsers.fs.readFile(sessionId, { path: file }, { signal });
|
|
71
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
72
|
+
}),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,6GAA6G;AAE7G,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAiChD;;;;GAIG;AACH,SAAS,OAAO,CAAC,KAAc;IAC7B,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE;QAAE,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IAC3G,OAAO,KAAK,CAAC;AACf,CAAC;AAED,2DAA2D;AAC3D,KAAK,UAAU,OAAO,CAAI,GAAqB;IAC7C,IAAI,CAAC;QACH,OAAO,MAAM,GAAG,EAAE,CAAC;IACrB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,MAAM,GAAG,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,a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,CAAC;YACzG,IAAI,QAAQ,CAAC,IAAI,KAAK,IAAI;gBAAE,MAAM,IAAI,KAAK,CAAC,UAAU,QAAQ,mBAAmB,CAAC,CAAC;YACnF,MAAM,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,iBAAiB,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;QACvF,CAAC,CAAC;QACJ,QAAQ,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,CACpC,OAAO,CAAC,KAAK,IAAI,EAAE;YACjB,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC;YAC7B,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;YAC1F,OAAO,IAAI,UAAU,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;QACtD,CAAC,CAAC;KACL,CAAC;AACJ,CAAC"}
|
package/dist/env.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,wBAAgB,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG5G"}
|
package/dist/env.js
ADDED
package/dist/env.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,MAAM,UAAU,QAAQ,CAAC,GAAiD,EAAE,IAAY;IACtF,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC;IAChC,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC;AACjE,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@e2e-dev/kernel` public surface: `kernel()`, a browser provider that leases
|
|
3
|
+
* hosted Chromium from Kernel for `@e2e-dev/web`.
|
|
4
|
+
*/
|
|
5
|
+
export { kernel } from './provider.ts';
|
|
6
|
+
export type { KernelOptions } from './provider.ts';
|
|
7
|
+
export type { KernelBrowserParams, KernelReplayParams } from './client.ts';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** Kernel's hosted Chromium as a `BrowserProvider` for the web engine. */
|
|
2
|
+
import type { BrowserProvider, BrowserProviderScope } from '@e2e-dev/web';
|
|
3
|
+
import { type KernelBrowserParams, type KernelReplayParams } from './client.ts';
|
|
4
|
+
/**
|
|
5
|
+
* Kernel's create-browser body (`stealth`, `headless`, `timeout_seconds`,
|
|
6
|
+
* `profile`, `proxy_id`, `viewport`, `tags`, ...) plus the lease scope the
|
|
7
|
+
* web engine defines.
|
|
8
|
+
*/
|
|
9
|
+
export interface KernelOptions extends KernelBrowserParams {
|
|
10
|
+
/**
|
|
11
|
+
* `worker` (default): one browser per worker slot, leased in `prepare` and
|
|
12
|
+
* released in `finish`. `attempt`: a fresh browser per test attempt,
|
|
13
|
+
* reattached after a CDP transport drop; rules out `headers`, `basicAuth`,
|
|
14
|
+
* and `userAgent`.
|
|
15
|
+
*/
|
|
16
|
+
readonly scope?: BrowserProviderScope | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* How an attempt that records video is recorded. On (the default), or
|
|
19
|
+
* Kernel's start-replay body (`framerate`, `max_duration_in_seconds`,
|
|
20
|
+
* `record_audio`): a Kernel replay of the browser's screen, saved as the
|
|
21
|
+
* attempt's `video/replay.mp4`. `false`: the web engine's screencast of
|
|
22
|
+
* the page. A headless browser, which Kernel cannot replay, always gets
|
|
23
|
+
* the screencast.
|
|
24
|
+
*/
|
|
25
|
+
readonly replay?: boolean | KernelReplayParams | undefined;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Kernel browsers for `web({ browser: kernel() })`: one hosted Chromium per
|
|
29
|
+
* worker slot, or per attempt with `scope: 'attempt'`, created when the
|
|
30
|
+
* engine asks and deleted when it gives the lease back. Every browser is
|
|
31
|
+
* tagged with the run, target, slot, and attempt, and saves downloads to its
|
|
32
|
+
* own disk, read back through Kernel's browser filesystem API.
|
|
33
|
+
* `KERNEL_API_KEY` comes from the run's environment.
|
|
34
|
+
*/
|
|
35
|
+
export declare function kernel(options?: KernelOptions): BrowserProvider;
|
|
36
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAG1E,OAAO,KAAK,EAEV,eAAe,EACf,oBAAoB,EAGrB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAkB,KAAK,mBAAmB,EAAuB,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAWrH;;;;GAIG;AACH,MAAM,WAAW,aAAc,SAAQ,mBAAmB;IACxD;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,oBAAoB,GAAG,SAAS,CAAC;IAClD;;;;;;;OAOG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,kBAAkB,GAAG,SAAS,CAAC;CAC5D;AAOD;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,OAAO,GAAE,aAAkB,GAAG,eAAe,CAsFnE"}
|
package/dist/provider.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/** Kernel's hosted Chromium as a `BrowserProvider` for the web engine. */
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { envValue } from './env.js';
|
|
4
|
+
import { kernelBrowsers } from './client.js';
|
|
5
|
+
const KERNEL_API_KEY = 'KERNEL_API_KEY';
|
|
6
|
+
/**
|
|
7
|
+
* Kernel terminates a browser idle this long: the backstop for a run that
|
|
8
|
+
* died before the engine could release or sweep its leases. Kernel's own
|
|
9
|
+
* default is shorter than a slow suite's gaps between attempts.
|
|
10
|
+
*/
|
|
11
|
+
const DEFAULT_TIMEOUT_SECONDS = 600;
|
|
12
|
+
const REPLAY_FILE = 'replay.mp4';
|
|
13
|
+
/** Where each Kernel browser saves downloads on its own disk, for the engine to read back through the browser filesystem API. */
|
|
14
|
+
const DOWNLOADS_DIR = '/tmp/e2e-downloads';
|
|
15
|
+
/**
|
|
16
|
+
* Kernel browsers for `web({ browser: kernel() })`: one hosted Chromium per
|
|
17
|
+
* worker slot, or per attempt with `scope: 'attempt'`, created when the
|
|
18
|
+
* engine asks and deleted when it gives the lease back. Every browser is
|
|
19
|
+
* tagged with the run, target, slot, and attempt, and saves downloads to its
|
|
20
|
+
* own disk, read back through Kernel's browser filesystem API.
|
|
21
|
+
* `KERNEL_API_KEY` comes from the run's environment.
|
|
22
|
+
*/
|
|
23
|
+
export function kernel(options = {}) {
|
|
24
|
+
const { scope, replay = true, ...params } = options;
|
|
25
|
+
const clients = new Map();
|
|
26
|
+
const clientFor = (env) => {
|
|
27
|
+
const apiKey = envValue(env, KERNEL_API_KEY);
|
|
28
|
+
if (apiKey === undefined)
|
|
29
|
+
throw new Error(`${KERNEL_API_KEY} is not set`);
|
|
30
|
+
let client = clients.get(apiKey);
|
|
31
|
+
if (client === undefined) {
|
|
32
|
+
client = kernelBrowsers(apiKey);
|
|
33
|
+
clients.set(apiKey, client);
|
|
34
|
+
}
|
|
35
|
+
return client;
|
|
36
|
+
};
|
|
37
|
+
// Kernel replays headful browsers only; without `record` the engine records the screencast.
|
|
38
|
+
const replayParams = replay === false || params.headless === true ? undefined : replay === true ? {} : replay;
|
|
39
|
+
/** Records each attempt as a Kernel replay of the lease's screen, started with `body` and saved as `replay.mp4`. */
|
|
40
|
+
const replays = (body) => async (lease, context) => {
|
|
41
|
+
const client = clientFor(context.env);
|
|
42
|
+
const startedAt = new Date().toISOString();
|
|
43
|
+
const replayId = await client.startReplay(lease.id, body, context.signal);
|
|
44
|
+
// A retried stop (the download failed after the replay stopped) downloads again without stopping twice.
|
|
45
|
+
let stopped = false;
|
|
46
|
+
return {
|
|
47
|
+
startedAt,
|
|
48
|
+
async stop({ dir, signal }) {
|
|
49
|
+
if (!stopped) {
|
|
50
|
+
await client.stopReplay(lease.id, replayId, signal);
|
|
51
|
+
stopped = true;
|
|
52
|
+
}
|
|
53
|
+
await client.downloadReplay(lease.id, replayId, path.join(dir, REPLAY_FILE), signal);
|
|
54
|
+
return { file: REPLAY_FILE };
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
return {
|
|
59
|
+
name: 'kernel',
|
|
60
|
+
...(scope === undefined ? {} : { scope }),
|
|
61
|
+
async acquire(request) {
|
|
62
|
+
const client = clientFor(request.env);
|
|
63
|
+
const browser = await client.create({
|
|
64
|
+
timeout_seconds: DEFAULT_TIMEOUT_SECONDS,
|
|
65
|
+
...params,
|
|
66
|
+
tags: {
|
|
67
|
+
...params.tags,
|
|
68
|
+
e2e_run: request.runId,
|
|
69
|
+
e2e_target: request.targetName,
|
|
70
|
+
e2e_slot: String(request.slot),
|
|
71
|
+
...(request.attemptId === undefined ? {} : { e2e_attempt: request.attemptId }),
|
|
72
|
+
},
|
|
73
|
+
}, request.signal);
|
|
74
|
+
if (request.signal.aborted) {
|
|
75
|
+
const outcome = await client.delete(browser.sessionId, AbortSignal.timeout(10_000)).then(() => 'deleted', (cause) => `deleting it failed, so Kernel ends it after timeout_seconds: ${cause instanceof Error ? cause.message : String(cause)}`);
|
|
76
|
+
throw new Error(`browser ${browser.sessionId} arrived after the request was cancelled; ${outcome}`);
|
|
77
|
+
}
|
|
78
|
+
request.log(browser.liveViewUrl === undefined ? `browser ${browser.sessionId}` : `browser ${browser.sessionId}, watch at ${browser.liveViewUrl}`);
|
|
79
|
+
return { id: browser.sessionId, cdpEndpoint: browser.cdpWsUrl };
|
|
80
|
+
},
|
|
81
|
+
async release(lease, context) {
|
|
82
|
+
await clientFor(context.env).delete(lease.id, context.signal);
|
|
83
|
+
},
|
|
84
|
+
async sweep(context) {
|
|
85
|
+
const client = clientFor(context.env);
|
|
86
|
+
const open = await client.listActive({ e2e_run: context.runId, e2e_target: context.targetName }, context.signal);
|
|
87
|
+
const settled = await Promise.allSettled(open.map(async (id) => ((await client.delete(id, context.signal)) ? id : undefined)));
|
|
88
|
+
const deleted = settled.flatMap((result) => (result.status === 'fulfilled' && result.value !== undefined ? [result.value] : []));
|
|
89
|
+
const failed = open.flatMap((id, index) => {
|
|
90
|
+
const result = settled[index];
|
|
91
|
+
return result.status === 'rejected' ? [`${id} (${result.reason instanceof Error ? result.reason.message : String(result.reason)})`] : [];
|
|
92
|
+
});
|
|
93
|
+
if (failed.length > 0) {
|
|
94
|
+
throw new Error(`deleted ${deleted.length === 0 ? 'none' : deleted.join(', ')}; could not delete ${failed.join(', ')}, so Kernel ends it after timeout_seconds`);
|
|
95
|
+
}
|
|
96
|
+
return deleted;
|
|
97
|
+
},
|
|
98
|
+
downloads: {
|
|
99
|
+
dir: DOWNLOADS_DIR,
|
|
100
|
+
read: async (lease, file, context) => clientFor(context.env).readFile(lease.id, file, context.signal),
|
|
101
|
+
},
|
|
102
|
+
...(replayParams === undefined ? {} : { record: replays(replayParams) }),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAE1E,OAAO,IAAI,MAAM,WAAW,CAAC;AAS7B,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,cAAc,EAA0E,MAAM,aAAa,CAAC;AAErH,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAExC;;;;GAIG;AACH,MAAM,uBAAuB,GAAG,GAAG,CAAC;AA0BpC,MAAM,WAAW,GAAG,YAAY,CAAC;AAEjC,iIAAiI;AACjI,MAAM,aAAa,GAAG,oBAAoB,CAAC;AAE3C;;;;;;;GAOG;AACH,MAAM,UAAU,MAAM,CAAC,OAAO,GAAkB,EAAE;IAChD,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC;IACpD,MAAM,OAAO,GAAG,IAAI,GAAG,EAA0B,CAAC;IAClD,MAAM,SAAS,GAAG,CAAC,GAA0B,EAAkB,EAAE;QAC/D,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QAC7C,IAAI,MAAM,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,GAAG,cAAc,aAAa,CAAC,CAAC;QAC1E,IAAI,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACjC,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-0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@e2e-dev/kernel",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Kernel hosted browsers for e2e: run web targets in Kernel's hosted Chromium",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"e2e",
|
|
7
|
+
"testing",
|
|
8
|
+
"agentic",
|
|
9
|
+
"end-to-end",
|
|
10
|
+
"kernel",
|
|
11
|
+
"hosted-browsers"
|
|
12
|
+
],
|
|
13
|
+
"license": "Apache-2.0",
|
|
14
|
+
"contributors": [
|
|
15
|
+
"Oskar Kwaśniewski <oskar@tester.army>",
|
|
16
|
+
"Szymon Rybczak <szymon@tester.army>"
|
|
17
|
+
],
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/tester-army/e2e.git",
|
|
21
|
+
"directory": "packages/kernel"
|
|
22
|
+
},
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/tester-army/e2e/issues"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/tester-army/e2e/tree/main/packages/kernel#readme",
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"registry": "https://registry.npmjs.org/",
|
|
29
|
+
"access": "public",
|
|
30
|
+
"provenance": false,
|
|
31
|
+
"tag": "latest"
|
|
32
|
+
},
|
|
33
|
+
"type": "module",
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"default": "./dist/index.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist",
|
|
42
|
+
"NOTICE"
|
|
43
|
+
],
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"@e2e-dev/web": ">=0.11.0 <1",
|
|
46
|
+
"@onkernel/sdk": ">=0.113.0 <1",
|
|
47
|
+
"e2e": ">=0.15.0 <1"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@e2e-dev/web": "0.11.0",
|
|
51
|
+
"@onkernel/sdk": "0.113.0",
|
|
52
|
+
"@types/node": "26.6.2",
|
|
53
|
+
"e2e": "0.15.0",
|
|
54
|
+
"typescript": "7.0.2",
|
|
55
|
+
"vitest": "5.0.1"
|
|
56
|
+
},
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": ">=22.12.0"
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc --project tsconfig.build.json && node ../../scripts/stamp-dist.ts",
|
|
62
|
+
"typecheck": "tsc --noEmit",
|
|
63
|
+
"test": "vitest run",
|
|
64
|
+
"test:watch": "vitest",
|
|
65
|
+
"test:unit": "vitest run tests/unit"
|
|
66
|
+
}
|
|
67
|
+
}
|