@poe-platform/safe-bash 0.1.683 → 0.1.685
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/README.md +10 -0
- package/dist/safe-bash/chunks/chunk-4MPK7VIM.js +519 -0
- package/dist/safe-bash/chunks/chunk-4MPK7VIM.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-6R7IR2MV.js → chunk-BONY6MX5.js} +731 -15
- package/dist/safe-bash/chunks/chunk-BONY6MX5.js.map +7 -0
- package/dist/safe-bash/commands/playwright/index.d.ts.map +1 -1
- package/dist/safe-bash/commands/playwright/index.js +14 -2
- package/dist/safe-bash/commands/playwright/index.js.map +1 -1
- package/dist/safe-bash/commands/python/index.browser.js +12 -2
- package/dist/safe-bash/commands/python/index.d.ts +5 -0
- package/dist/safe-bash/commands/python/index.d.ts.map +1 -1
- package/dist/safe-bash/commands/python/index.js +15 -3
- package/dist/safe-bash/commands/python/index.js.map +1 -1
- package/dist/safe-bash/commands/python/jspi-assets.d.ts +14 -0
- package/dist/safe-bash/commands/python/jspi-assets.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/jspi-assets.js +51 -0
- package/dist/safe-bash/commands/python/jspi-assets.js.map +1 -0
- package/dist/safe-bash/commands/python/jspi-scheduler.d.ts +8 -0
- package/dist/safe-bash/commands/python/jspi-scheduler.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/jspi-scheduler.js +49 -0
- package/dist/safe-bash/commands/python/jspi-scheduler.js.map +1 -0
- package/dist/safe-bash/commands/python/jspi-trampoline.d.ts +5 -0
- package/dist/safe-bash/commands/python/jspi-trampoline.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/jspi-trampoline.js +90 -0
- package/dist/safe-bash/commands/python/jspi-trampoline.js.map +1 -0
- package/dist/safe-bash/commands/python/jspi.d.ts +22 -0
- package/dist/safe-bash/commands/python/jspi.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/jspi.js +295 -0
- package/dist/safe-bash/commands/python/jspi.js.map +1 -0
- package/dist/safe-bash/commands/python/runtime-scripts.d.ts +6 -0
- package/dist/safe-bash/commands/python/runtime-scripts.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/runtime-scripts.js +168 -0
- package/dist/safe-bash/commands/python/runtime-scripts.js.map +1 -0
- package/dist/safe-bash/commands/python/worker.browser.js +13 -368
- package/dist/safe-bash/commands/python/worker.browser.js.map +3 -3
- package/dist/safe-bash/commands/python/worker.d.ts.map +1 -1
- package/dist/safe-bash/commands/python/worker.js +6 -168
- package/dist/safe-bash/commands/python/worker.js.map +1 -1
- package/dist/safe-bash/core.browser.js +12 -2
- package/dist/safe-bash/core.browser.js.map +1 -1
- package/dist/safe-bash/playwright/ability-execution.d.ts +2 -0
- package/dist/safe-bash/playwright/ability-execution.d.ts.map +1 -1
- package/dist/safe-bash/playwright/ability-execution.js +10 -14
- package/dist/safe-bash/playwright/ability-execution.js.map +1 -1
- package/dist/safe-bash/playwright/command-budget.d.ts +5 -0
- package/dist/safe-bash/playwright/command-budget.d.ts.map +1 -0
- package/dist/safe-bash/playwright/command-budget.js +13 -0
- package/dist/safe-bash/playwright/command-budget.js.map +1 -0
- package/dist/safe-bash/playwright/controller.d.ts.map +1 -1
- package/dist/safe-bash/playwright/controller.js +44 -27
- package/dist/safe-bash/playwright/controller.js.map +1 -1
- package/dist/safe-bash/playwright/invocation.d.ts.map +1 -1
- package/dist/safe-bash/playwright/invocation.js +9 -6
- package/dist/safe-bash/playwright/invocation.js.map +1 -1
- package/dist/safe-bash/playwright/native-evaluation.d.ts +10 -0
- package/dist/safe-bash/playwright/native-evaluation.d.ts.map +1 -0
- package/dist/safe-bash/playwright/native-evaluation.js +243 -0
- package/dist/safe-bash/playwright/native-evaluation.js.map +1 -0
- package/dist/safe-bash/playwright/response.d.ts +5 -0
- package/dist/safe-bash/playwright/response.d.ts.map +1 -1
- package/dist/safe-bash/playwright/response.js +8 -3
- package/dist/safe-bash/playwright/response.js.map +1 -1
- package/dist/safe-bash/playwright/route-capabilities.d.ts.map +1 -1
- package/dist/safe-bash/playwright/route-capabilities.js +23 -5
- package/dist/safe-bash/playwright/route-capabilities.js.map +1 -1
- package/dist/safe-bash/playwright/standard-capabilities.d.ts.map +1 -1
- package/dist/safe-bash/playwright/standard-capabilities.js +17 -36
- package/dist/safe-bash/playwright/standard-capabilities.js.map +1 -1
- package/package.json +2 -2
- package/dist/safe-bash/chunks/chunk-3G3EZZ63.js +0 -145
- package/dist/safe-bash/chunks/chunk-3G3EZZ63.js.map +0 -7
- package/dist/safe-bash/chunks/chunk-6R7IR2MV.js.map +0 -7
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { PlaywrightAbilityRequest, RegisteredPlaywrightAbility } from './abilities.js';
|
|
2
2
|
import type { ParsedInvocation, PlaywrightInvocation } from './invocation.js';
|
|
3
3
|
import type { PlaywrightCommandResult } from './response.js';
|
|
4
|
+
import { createPlaywrightCommandBudget } from './command-budget.js';
|
|
4
5
|
export declare function executePlaywrightAbility(ability: RegisteredPlaywrightAbility, parsed: ParsedInvocation, invocation: PlaywrightInvocation, context: {
|
|
5
6
|
readonly signal: AbortSignal;
|
|
6
7
|
readonly maxCommandBytes: number;
|
|
7
8
|
readonly maxArtifactBytes: number;
|
|
9
|
+
readonly commandBudget?: ReturnType<typeof createPlaywrightCommandBudget>;
|
|
8
10
|
readonly actionTimeoutMs?: number;
|
|
9
11
|
readonly codeExecutionTimeoutMs?: number;
|
|
10
12
|
readonly navigationTimeoutMs?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ability-execution.d.ts","sourceRoot":"","sources":["../../src/playwright/ability-execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAE5F,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"ability-execution.d.ts","sourceRoot":"","sources":["../../src/playwright/ability-execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAE5F,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AAUpE,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,2BAA2B,EAAE,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,oBAAoB,EAAE,OAAO,EAAE;IACxJ,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,aAAa,CAAC,EAAE,UAAU,CAAC,OAAO,6BAA6B,CAAC,CAAC;IAC1E,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IACzC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,cAAc,CAAC,EAAE,wBAAwB,CAAC,gBAAgB,CAAC,CAAC;IACrE,KAAK,IAAI,IAAI,CAAC;CACf,GAAG,OAAO,CAAC,IAAI,GAAG,uBAAuB,CAAC,CAuJ1C"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createPlaywrightCommandBudget } from './command-budget.js';
|
|
1
2
|
function freezeConfiguration(value) {
|
|
2
3
|
if (value && typeof value === 'object') {
|
|
3
4
|
for (const child of Object.values(value))
|
|
@@ -8,7 +9,7 @@ function freezeConfiguration(value) {
|
|
|
8
9
|
}
|
|
9
10
|
export async function executePlaywrightAbility(ability, parsed, invocation, context) {
|
|
10
11
|
let accepting = true;
|
|
11
|
-
|
|
12
|
+
const budget = context.commandBudget ?? createPlaywrightCommandBudget(context.maxCommandBytes);
|
|
12
13
|
const pending = [];
|
|
13
14
|
const cleanups = new Set();
|
|
14
15
|
const check = () => {
|
|
@@ -16,11 +17,6 @@ export async function executePlaywrightAbility(ability, parsed, invocation, cont
|
|
|
16
17
|
if (!accepting)
|
|
17
18
|
throw new Error('Playwright ability invocation has finished');
|
|
18
19
|
};
|
|
19
|
-
const admitBytes = (bytes) => {
|
|
20
|
-
if (bytes > context.maxCommandBytes - bytesUsed)
|
|
21
|
-
throw new PlaywrightResourceLimitError('Playwright command byte limit exceeded');
|
|
22
|
-
bytesUsed += bytes;
|
|
23
|
-
};
|
|
24
20
|
const track = (action) => {
|
|
25
21
|
const operation = Promise.resolve().then(action);
|
|
26
22
|
pending.push(operation);
|
|
@@ -45,7 +41,7 @@ export async function executePlaywrightAbility(ability, parsed, invocation, cont
|
|
|
45
41
|
check();
|
|
46
42
|
if (typeof code !== 'string')
|
|
47
43
|
throw new TypeError('Native Playwright generated code must be text');
|
|
48
|
-
|
|
44
|
+
budget.admit(new TextEncoder().encode(code).byteLength);
|
|
49
45
|
return code;
|
|
50
46
|
}) } : {}),
|
|
51
47
|
...(browserSession.targetLocator ? { targetLocator(target) {
|
|
@@ -63,7 +59,7 @@ export async function executePlaywrightAbility(ability, parsed, invocation, cont
|
|
|
63
59
|
return browserSession.executeCode({ ...options,
|
|
64
60
|
signal: AbortSignal.any([context.signal, options.signal]),
|
|
65
61
|
timeoutMs: Math.min(options.timeoutMs, context.codeExecutionTimeoutMs ?? 30000),
|
|
66
|
-
maxOutputBytes: Math.min(options.maxOutputBytes,
|
|
62
|
+
maxOutputBytes: Math.min(options.maxOutputBytes, budget.remaining),
|
|
67
63
|
maxPages: Math.min(options.maxPages, context.maxPages ?? 16),
|
|
68
64
|
});
|
|
69
65
|
}) } : {}),
|
|
@@ -101,7 +97,7 @@ export async function executePlaywrightAbility(ability, parsed, invocation, cont
|
|
|
101
97
|
...(browserSession.captureArtifact ? { captureArtifact: ((produce, options) => {
|
|
102
98
|
check();
|
|
103
99
|
const signal = AbortSignal.any([context.signal, options.signal]);
|
|
104
|
-
const maxBytes = Math.min(options.maxBytes, context.maxArtifactBytes,
|
|
100
|
+
const maxBytes = Math.min(options.maxBytes, context.maxArtifactBytes, budget.remaining);
|
|
105
101
|
return track(async () => {
|
|
106
102
|
context.check();
|
|
107
103
|
const bytes = await browserSession.captureArtifact(produce, { ...options, signal, maxBytes });
|
|
@@ -122,9 +118,9 @@ export async function executePlaywrightAbility(ability, parsed, invocation, cont
|
|
|
122
118
|
check();
|
|
123
119
|
if (typeof text !== 'string')
|
|
124
120
|
throw new TypeError('Playwright output must be text');
|
|
125
|
-
if (text.length >
|
|
121
|
+
if (text.length > budget.remaining)
|
|
126
122
|
throw new PlaywrightResourceLimitError('Playwright command byte limit exceeded');
|
|
127
|
-
|
|
123
|
+
budget.admit(new TextEncoder().encode(text).byteLength);
|
|
128
124
|
return track(async () => { context.check(); await invocation.write(text); context.check(); });
|
|
129
125
|
},
|
|
130
126
|
readFile(filename) {
|
|
@@ -134,12 +130,12 @@ export async function executePlaywrightAbility(ability, parsed, invocation, cont
|
|
|
134
130
|
throw new Error('Virtual artifact input unsupported');
|
|
135
131
|
return track(async () => {
|
|
136
132
|
context.check();
|
|
137
|
-
const bytes = await invocation.readArtifact(filename, Math.min(context.maxArtifactBytes,
|
|
133
|
+
const bytes = await invocation.readArtifact(filename, Math.min(context.maxArtifactBytes, budget.remaining));
|
|
138
134
|
if (!(bytes instanceof Uint8Array))
|
|
139
135
|
throw new TypeError('Artifact input must return bytes');
|
|
140
136
|
if (bytes.byteLength > context.maxArtifactBytes)
|
|
141
137
|
throw new PlaywrightResourceLimitError('Artifact byte limit exceeded');
|
|
142
|
-
|
|
138
|
+
budget.admit(bytes.byteLength);
|
|
143
139
|
context.check();
|
|
144
140
|
return new Uint8Array(bytes);
|
|
145
141
|
});
|
|
@@ -154,7 +150,7 @@ export async function executePlaywrightAbility(ability, parsed, invocation, cont
|
|
|
154
150
|
filenameCheck(filename);
|
|
155
151
|
if (!invocation.writeArtifact)
|
|
156
152
|
throw new Error('Artifact byte destination unsupported');
|
|
157
|
-
|
|
153
|
+
budget.admit(bytes.byteLength);
|
|
158
154
|
const owned = new Uint8Array(bytes);
|
|
159
155
|
return track(async () => { context.check(); await invocation.writeArtifact(owned, filename); context.check(); });
|
|
160
156
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ability-execution.js","sourceRoot":"","sources":["../../src/playwright/ability-execution.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ability-execution.js","sourceRoot":"","sources":["../../src/playwright/ability-execution.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AAEpE,SAAS,mBAAmB,CAAI,KAAQ;IACtC,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACvC,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;YAAE,mBAAmB,CAAC,KAAK,CAAC,CAAC;QACrE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,OAAoC,EAAE,MAAwB,EAAE,UAAgC,EAAE,OAWhJ;IACC,IAAI,SAAS,GAAG,IAAI,CAAC;IACrB,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,IAAI,6BAA6B,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAC/F,MAAM,OAAO,GAAuB,EAAE,CAAC;IACvC,MAAM,QAAQ,GAAG,IAAI,GAAG,E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,MAAM,CAAC,MAAM,CAAC;YAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACnJ,IAAI,CAAC;QAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IAAC,CAAC;IACxB,OAAO,KAAK,EAAE,CAAC;QAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAAC,CAAC;IACtE,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC7C,IAAI,QAAQ,CAAC,MAAM;QAAE,MAAM,IAAI,cAAc,CAAC,QAAQ,EAAE,iDAAiD,CAAC,CAAC;IAC3G,OAAO,MAAM,CAAC;AAChB,CAAC;AACD,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-budget.d.ts","sourceRoot":"","sources":["../../src/playwright/command-budget.ts"],"names":[],"mappings":"AAEA,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,MAAM;;iBAI7C,MAAM;EAKtB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PlaywrightResourceLimitError } from './resource-limit.js';
|
|
2
|
+
export function createPlaywrightCommandBudget(maxBytes) {
|
|
3
|
+
let remaining = maxBytes;
|
|
4
|
+
return {
|
|
5
|
+
get remaining() { return remaining; },
|
|
6
|
+
admit(bytes) {
|
|
7
|
+
if (bytes > remaining)
|
|
8
|
+
throw new PlaywrightResourceLimitError('Playwright command byte limit exceeded');
|
|
9
|
+
remaining -= bytes;
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=command-budget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-budget.js","sourceRoot":"","sources":["../../src/playwright/command-budget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAEnE,MAAM,UAAU,6BAA6B,CAAC,QAAgB;IAC5D,IAAI,SAAS,GAAG,QAAQ,CAAC;IACzB,OAAO;QACL,IAAI,SAAS,KAAK,OAAO,SAAS,CAAC,CAAC,CAAC;QACrC,KAAK,CAAC,KAAa;YACjB,IAAI,KAAK,GAAG,SAAS;gBAAE,MAAM,IAAI,4BAA4B,CAAC,wCAAwC,CAAC,CAAC;YACxG,SAAS,IAAI,KAAK,CAAC;QACrB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/playwright/controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAA2B,iBAAiB,EAAE,wBAAwB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG7J,OAAO,EAAkD,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAE5G,OAAO,EAA+B,KAAK,mBAAmB,EAAiC,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/playwright/controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAA2B,iBAAiB,EAAE,wBAAwB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG7J,OAAO,EAAkD,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAE5G,OAAO,EAA+B,KAAK,mBAAmB,EAAiC,MAAM,gBAAgB,CAAC;AAkBtH,OAAO,EAAuC,KAAK,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AAKtH,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,OAAO,CAAC,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,SAAS,CAAC,EAAE,mBAAmB,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SAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KACvE,GAAG,SAAS,CAAC,CAAC;IACf,UAAU,CAAC,OAAO,EAAE,2BAA2B,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrF,iFAAiF;IACjF,KAAK,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1D;AA2BD,wBAAgB,0BAA0B,CAAC,OAAO,GAAE,2BAAgC;sBAgSnD,oBAAoB,KAAG,OAAO,CAAC,IAAI,CAAC;mBAqwB/C,OAAO,CAAC,IAAI,CAAC;8BAiBgB,+BAA+B;2BAt2BpD,SAAS,2BAA2B,EAAE;EAu2BnE"}
|
|
@@ -4,7 +4,8 @@ import { parseInvocation, validatePlaywrightSessionName } from './invocation.js'
|
|
|
4
4
|
import { formatPlaywrightHelp } from './help.js';
|
|
5
5
|
import { registerPlaywrightAbilities } from './abilities.js';
|
|
6
6
|
import { executePlaywrightAbility } from './ability-execution.js';
|
|
7
|
-
import {
|
|
7
|
+
import { createPlaywrightCommandBudget } from './command-budget.js';
|
|
8
|
+
import { PlaywrightReportedError, playwrightCliCompatibilityVersion, playwrightCodeString, serializePlaywrightResult } from './response.js';
|
|
8
9
|
import { capabilityArtifactName } from './capability-result.js';
|
|
9
10
|
import { isPlaywrightSnapshotRef, resolvePlaywrightTarget } from './targets.js';
|
|
10
11
|
import { capturePlaywrightTargetScreenshot } from './target-screenshot.js';
|
|
@@ -388,6 +389,8 @@ export function createPlaywrightController(options = {}) {
|
|
|
388
389
|
}
|
|
389
390
|
};
|
|
390
391
|
const run = async (invocation) => {
|
|
392
|
+
const commandBudget = createPlaywrightCommandBudget(maxCommandBytes);
|
|
393
|
+
let reportedError = false;
|
|
391
394
|
const writtenFiles = new Set();
|
|
392
395
|
const original = invocation;
|
|
393
396
|
if (original.writeArtifact)
|
|
@@ -449,17 +452,33 @@ export function createPlaywrightController(options = {}) {
|
|
|
449
452
|
local.signal.throwIfAborted();
|
|
450
453
|
lifetime.signal.throwIfAborted();
|
|
451
454
|
};
|
|
452
|
-
const
|
|
455
|
+
const write = async (text) => {
|
|
453
456
|
check();
|
|
454
|
-
|
|
455
|
-
if (text.length > maxCommandBytes || new TextEncoder().encode(text).byteLength > maxCommandBytes)
|
|
457
|
+
if (text.length > commandBudget.remaining)
|
|
456
458
|
throw new PlaywrightResourceLimitError('Playwright command byte limit exceeded');
|
|
459
|
+
commandBudget.admit(new TextEncoder().encode(text).byteLength);
|
|
457
460
|
await invocation.write(text);
|
|
458
461
|
check();
|
|
459
462
|
};
|
|
463
|
+
const writeArtifact = async (bytes, filename) => {
|
|
464
|
+
check();
|
|
465
|
+
if (!invocation.writeArtifact)
|
|
466
|
+
throw new Error('Artifact byte destination unsupported');
|
|
467
|
+
if (bytes.byteLength > maxArtifactBytes)
|
|
468
|
+
throw new PlaywrightResourceLimitError('Artifact byte limit exceeded');
|
|
469
|
+
commandBudget.admit(bytes.byteLength);
|
|
470
|
+
await invocation.writeArtifact(bytes, filename);
|
|
471
|
+
check();
|
|
472
|
+
};
|
|
473
|
+
const writeResult = async (result) => {
|
|
474
|
+
check();
|
|
475
|
+
await write(serializePlaywrightResult(configuredResult(result), parsed));
|
|
476
|
+
if (result.isError || result.sections.some(section => section.title === 'Error'))
|
|
477
|
+
reportedError = true;
|
|
478
|
+
};
|
|
460
479
|
const configuredResult = (result) => {
|
|
461
480
|
const language = active?.configuration?.codegen ?? 'typescript';
|
|
462
|
-
return { sections: result.sections.flatMap(section => section.title !== 'Ran Playwright code' ? [section] : language === 'none' ? [] : [{ ...section, codeframe: language === 'typescript' ? 'js' : language }]) };
|
|
481
|
+
return { ...result, sections: result.sections.flatMap(section => section.title !== 'Ran Playwright code' ? [section] : language === 'none' ? [] : [{ ...section, codeframe: language === 'typescript' ? 'js' : language }]) };
|
|
463
482
|
};
|
|
464
483
|
const actionCode = (session, action, fallback) => {
|
|
465
484
|
const language = session.configuration?.codegen ?? 'typescript';
|
|
@@ -516,18 +535,14 @@ export function createPlaywrightController(options = {}) {
|
|
|
516
535
|
if (!invocation.writeArtifact)
|
|
517
536
|
throw new Error('Artifact byte destination unsupported');
|
|
518
537
|
for (const download of downloads)
|
|
519
|
-
await
|
|
538
|
+
await writeArtifact(download.bytes, download.filename);
|
|
520
539
|
return [{ title: 'Events', content: downloads.map(download => `- Downloaded file [${download.filename.split('/').at(-1)}](${download.filename})`).join('\n') }];
|
|
521
540
|
};
|
|
522
541
|
const flushTrace = async (session) => {
|
|
523
542
|
if (!session.lease?.captureTrace)
|
|
524
543
|
return [];
|
|
525
544
|
return flushPlaywrightTrace(session.lease.context, session.lease.captureTrace, {
|
|
526
|
-
signal: local.signal, maxBytes: Math.min(maxArtifactBytes,
|
|
527
|
-
if (!invocation.writeArtifact)
|
|
528
|
-
throw new Error('Artifact byte destination unsupported');
|
|
529
|
-
await invocation.writeArtifact(bytes, filename);
|
|
530
|
-
},
|
|
545
|
+
signal: local.signal, maxBytes: Math.min(maxArtifactBytes, commandBudget.remaining), writeArtifact,
|
|
531
546
|
...(invocation.workspace ? { mkdir: (path) => invocation.workspace.mkdir(path) } : {}),
|
|
532
547
|
});
|
|
533
548
|
};
|
|
@@ -567,7 +582,7 @@ export function createPlaywrightController(options = {}) {
|
|
|
567
582
|
}
|
|
568
583
|
sections.push(...await downloadSections(session));
|
|
569
584
|
if (invocation.writeArtifact) {
|
|
570
|
-
const consoleLink = await flushPlaywrightConsole(session.lease.context, page, { ...(session.configuration ? { configuration: session.configuration } : {}), writeArtifact
|
|
585
|
+
const consoleLink = await flushPlaywrightConsole(session.lease.context, page, { ...(session.configuration ? { configuration: session.configuration } : {}), writeArtifact });
|
|
571
586
|
if (consoleLink)
|
|
572
587
|
sections.push({ title: 'Events', content: `- New console entries: ${consoleLink}` });
|
|
573
588
|
}
|
|
@@ -603,7 +618,7 @@ export function createPlaywrightController(options = {}) {
|
|
|
603
618
|
throw new PlaywrightResourceLimitError('Artifact byte limit exceeded');
|
|
604
619
|
if (!invocation.writeArtifact)
|
|
605
620
|
throw new Error('Artifact byte destination unsupported');
|
|
606
|
-
await
|
|
621
|
+
await writeArtifact(bytes, target);
|
|
607
622
|
sections.push({ title: 'Snapshot', content: `- [Snapshot](${target})` });
|
|
608
623
|
}
|
|
609
624
|
else
|
|
@@ -757,12 +772,12 @@ export function createPlaywrightController(options = {}) {
|
|
|
757
772
|
check();
|
|
758
773
|
if (parsed.command === 'help') {
|
|
759
774
|
const help = formatPlaywrightHelp(parsed.topic, abilities);
|
|
760
|
-
await
|
|
775
|
+
await write(parsed.json ? JSON.stringify({ help: help.trimEnd() }, null, 2) + '\n' : help);
|
|
761
776
|
check();
|
|
762
777
|
return;
|
|
763
778
|
}
|
|
764
779
|
if (parsed.command === 'version') {
|
|
765
|
-
await
|
|
780
|
+
await write(parsed.json ? JSON.stringify({ version: playwrightCliCompatibilityVersion }, null, 2) + '\n' : playwrightCliCompatibilityVersion + '\n');
|
|
766
781
|
check();
|
|
767
782
|
return;
|
|
768
783
|
}
|
|
@@ -779,7 +794,7 @@ export function createPlaywrightController(options = {}) {
|
|
|
779
794
|
const known = sessions.has(parsed.session) || (await savedSessions(local.signal)).some(session => session.name === parsed.session);
|
|
780
795
|
if (known)
|
|
781
796
|
throw new Error(parsed.json ? `session '${parsed.session}' was not attached; use close to stop it.` : `session '${parsed.session}' was not attached; use \`playwright-cli${parsed.session === 'default' ? '' : ` -s=${parsed.session}`} close\` to stop it.`);
|
|
782
|
-
await
|
|
797
|
+
await write(parsed.json ? JSON.stringify({ session: parsed.session, status: 'not-attached' }, null, 2) + '\n' : `Browser '${parsed.session}' is not attached.\n`);
|
|
783
798
|
return;
|
|
784
799
|
}
|
|
785
800
|
if (parsed.command === 'install' && !ability.execute) {
|
|
@@ -793,7 +808,7 @@ export function createPlaywrightController(options = {}) {
|
|
|
793
808
|
if (parsed.options.force || parsed.options['with-deps'])
|
|
794
809
|
throw new Error('Browser installation is managed by the configured provider');
|
|
795
810
|
if (parsed.options.list || parsed.options['dry-run'])
|
|
796
|
-
await
|
|
811
|
+
await write(`Browser: ${browser}\n Install location: provider-managed\n`);
|
|
797
812
|
return;
|
|
798
813
|
}
|
|
799
814
|
const expiryRetirement = retireExpired();
|
|
@@ -810,7 +825,7 @@ export function createPlaywrightController(options = {}) {
|
|
|
810
825
|
if (session.state === 'open')
|
|
811
826
|
known.set(session.name, { name: session.name, status: session.state });
|
|
812
827
|
const browsers = [...known.values()];
|
|
813
|
-
await
|
|
828
|
+
await write(parsed.json ? JSON.stringify({ browsers }, null, 2) + '\n' : browsers.length ? '### Browsers\n' + browsers.map(browser => `- ${browser.name}:\n - status: ${browser.status}\n`).join('') : ' (no browsers)\n');
|
|
814
829
|
check();
|
|
815
830
|
return;
|
|
816
831
|
}
|
|
@@ -838,7 +853,7 @@ export function createPlaywrightController(options = {}) {
|
|
|
838
853
|
if (errors.length)
|
|
839
854
|
throw new AggregateError(errors, 'Playwright close-all failed');
|
|
840
855
|
if (parsed.json)
|
|
841
|
-
await
|
|
856
|
+
await write(JSON.stringify({ closed }, null, 2) + '\n');
|
|
842
857
|
check();
|
|
843
858
|
return;
|
|
844
859
|
}
|
|
@@ -954,7 +969,7 @@ export function createPlaywrightController(options = {}) {
|
|
|
954
969
|
},
|
|
955
970
|
});
|
|
956
971
|
}
|
|
957
|
-
const executeAbility = () => executePlaywrightAbility(ability, parsed, invocation, { signal: local.signal, maxCommandBytes, maxArtifactBytes, actionTimeoutMs: sessionActionTimeout(active), codeExecutionTimeoutMs, navigationTimeoutMs: sessionNavigationTimeout(active), maxPages: maxTabs, ...(browserSession ? { browserSession } : {}), check: () => active ? checkSession(active) : check() });
|
|
972
|
+
const executeAbility = () => executePlaywrightAbility(ability, parsed, invocation, { signal: local.signal, maxCommandBytes, maxArtifactBytes, commandBudget, actionTimeoutMs: sessionActionTimeout(active), codeExecutionTimeoutMs, navigationTimeoutMs: sessionNavigationTimeout(active), maxPages: maxTabs, ...(browserSession ? { browserSession } : {}), check: () => active ? checkSession(active) : check() });
|
|
958
973
|
let result;
|
|
959
974
|
try {
|
|
960
975
|
result = active ? await active.snapshot.withReferences(executeAbility) : await executeAbility();
|
|
@@ -975,11 +990,11 @@ export function createPlaywrightController(options = {}) {
|
|
|
975
990
|
throw new PlaywrightResourceLimitError('Playwright tab limit exceeded');
|
|
976
991
|
await checkpoint(active, local.signal);
|
|
977
992
|
if (active.page && getPlaywrightModal(active.page))
|
|
978
|
-
result = { sections: [...result?.sections ?? [], ...(await pageResult(active, undefined)).sections] };
|
|
993
|
+
result = { ...result, sections: [...result?.sections ?? [], ...(await pageResult(active, undefined)).sections] };
|
|
979
994
|
else {
|
|
980
995
|
const downloads = await downloadSections(active);
|
|
981
996
|
if (downloads.length)
|
|
982
|
-
result = { sections: [...result?.sections ?? [], ...downloads] };
|
|
997
|
+
result = { ...result, sections: [...result?.sections ?? [], ...downloads] };
|
|
983
998
|
}
|
|
984
999
|
const traceLinks = await flushTrace(active);
|
|
985
1000
|
traceFlushed = true;
|
|
@@ -990,7 +1005,7 @@ export function createPlaywrightController(options = {}) {
|
|
|
990
1005
|
sections.push({ title: 'Result', content: traceLinks.join('\n') });
|
|
991
1006
|
else
|
|
992
1007
|
sections[index] = { ...sections[index], content: sections[index].content + '\n' + traceLinks.join('\n') };
|
|
993
|
-
result = { sections };
|
|
1008
|
+
result = { ...result, sections };
|
|
994
1009
|
}
|
|
995
1010
|
}
|
|
996
1011
|
if (result)
|
|
@@ -1020,7 +1035,7 @@ export function createPlaywrightController(options = {}) {
|
|
|
1020
1035
|
throw errors[0];
|
|
1021
1036
|
if (errors.length)
|
|
1022
1037
|
throw new AggregateError(errors, 'Playwright close failed');
|
|
1023
|
-
await
|
|
1038
|
+
await write(parsed.json ? JSON.stringify({ session: parsed.session, status: wasOpen ? 'closed' : 'not-open' }, null, 2) + '\n'
|
|
1024
1039
|
: wasOpen ? `Browser '${parsed.session}' closed\n\n` : `Browser '${parsed.session}' is not open.\n`);
|
|
1025
1040
|
check();
|
|
1026
1041
|
return;
|
|
@@ -1047,7 +1062,7 @@ export function createPlaywrightController(options = {}) {
|
|
|
1047
1062
|
throw errors[0];
|
|
1048
1063
|
if (errors.length)
|
|
1049
1064
|
throw new AggregateError(errors, 'Playwright retirement and data deletion failed');
|
|
1050
|
-
await
|
|
1065
|
+
await write(parsed.json ? JSON.stringify({ session: parsed.session, deleted: !!session || !!options.persistence }, null, 2) + '\n'
|
|
1051
1066
|
: `Deleted user data for browser '${parsed.session}'.\n`);
|
|
1052
1067
|
check();
|
|
1053
1068
|
return;
|
|
@@ -1086,7 +1101,7 @@ export function createPlaywrightController(options = {}) {
|
|
|
1086
1101
|
checkSession(session);
|
|
1087
1102
|
const result = await pageResult(session, actionCode(session, { name: 'navigate', url: parsed.url ?? 'about:blank' }, `await page.goto(${playwrightCodeString(parsed.url ?? 'about:blank')});`), 'file');
|
|
1088
1103
|
const rendered = serializePlaywrightResult(configuredResult(result), parsed);
|
|
1089
|
-
await
|
|
1104
|
+
await write(parsed.json ? JSON.stringify({ session: session.name, result: JSON.parse(rendered) }, null, 2) + '\n'
|
|
1090
1105
|
: `### Browser \`${session.name}\` opened.\n` + rendered);
|
|
1091
1106
|
checkSession(session);
|
|
1092
1107
|
session.state = 'open';
|
|
@@ -1274,7 +1289,7 @@ export function createPlaywrightController(options = {}) {
|
|
|
1274
1289
|
checkSession(session);
|
|
1275
1290
|
// Uint8Array constructor copies even when bytes is a Buffer view.
|
|
1276
1291
|
const filename = parsed.filename ?? capabilityArtifactName(parsed.ref ? 'element' : 'page', parsed.imageType, session.configuration);
|
|
1277
|
-
await
|
|
1292
|
+
await writeArtifact(new Uint8Array(bytes), filename);
|
|
1278
1293
|
const label = parsed.ref ? 'element' : parsed.fullPage ? 'full page' : 'viewport';
|
|
1279
1294
|
const screenshotTarget = parsed.ref ? targetLocators.get(parsed.ref) : 'page';
|
|
1280
1295
|
await writeResult({ sections: [
|
|
@@ -1367,6 +1382,8 @@ export function createPlaywrightController(options = {}) {
|
|
|
1367
1382
|
}
|
|
1368
1383
|
if (failure)
|
|
1369
1384
|
throw failure.error;
|
|
1385
|
+
if (reportedError)
|
|
1386
|
+
throw new PlaywrightReportedError('Playwright command error was reported');
|
|
1370
1387
|
};
|
|
1371
1388
|
const dispose = () => {
|
|
1372
1389
|
if (disposal)
|