@poe-platform/safe-bash 0.1.634 → 0.1.636

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 (33) hide show
  1. package/dist/safe-bash/commands/playwright/index.d.ts +12 -0
  2. package/dist/safe-bash/commands/playwright/index.d.ts.map +1 -0
  3. package/dist/safe-bash/commands/playwright/index.js +47 -0
  4. package/dist/safe-bash/commands/playwright/index.js.map +1 -0
  5. package/dist/safe-bash/contracts/playwright.d.ts +71 -0
  6. package/dist/safe-bash/contracts/playwright.d.ts.map +1 -0
  7. package/dist/safe-bash/contracts/playwright.js +2 -0
  8. package/dist/safe-bash/contracts/playwright.js.map +1 -0
  9. package/dist/safe-bash/playwright/adapter.d.ts +97 -0
  10. package/dist/safe-bash/playwright/adapter.d.ts.map +1 -0
  11. package/dist/safe-bash/playwright/adapter.js +123 -0
  12. package/dist/safe-bash/playwright/adapter.js.map +1 -0
  13. package/dist/safe-bash/playwright/billing.d.ts +71 -0
  14. package/dist/safe-bash/playwright/billing.d.ts.map +1 -0
  15. package/dist/safe-bash/playwright/billing.js +2 -0
  16. package/dist/safe-bash/playwright/billing.js.map +1 -0
  17. package/dist/safe-bash/playwright/controller.d.ts +21 -0
  18. package/dist/safe-bash/playwright/controller.d.ts.map +1 -0
  19. package/dist/safe-bash/playwright/controller.js +369 -0
  20. package/dist/safe-bash/playwright/controller.js.map +1 -0
  21. package/dist/safe-bash/playwright/index.d.ts +5 -0
  22. package/dist/safe-bash/playwright/index.d.ts.map +1 -0
  23. package/dist/safe-bash/playwright/index.js +4 -0
  24. package/dist/safe-bash/playwright/index.js.map +1 -0
  25. package/dist/safe-bash/playwright/invocation.d.ts +26 -0
  26. package/dist/safe-bash/playwright/invocation.d.ts.map +1 -0
  27. package/dist/safe-bash/playwright/invocation.js +112 -0
  28. package/dist/safe-bash/playwright/invocation.js.map +1 -0
  29. package/dist/safe-bash/playwright/snapshot.d.ts +15 -0
  30. package/dist/safe-bash/playwright/snapshot.d.ts.map +1 -0
  31. package/dist/safe-bash/playwright/snapshot.js +96 -0
  32. package/dist/safe-bash/playwright/snapshot.js.map +1 -0
  33. package/package.json +12 -2
@@ -0,0 +1,12 @@
1
+ import { type PlaywrightControllerOptions } from '../../playwright/index.js';
2
+ import type { VirtualShellPlugin } from '../../contracts/plugin.js';
3
+ export type PlaywrightCliOptions = PlaywrightControllerOptions & {
4
+ readonly replace?: boolean;
5
+ };
6
+ /** Host-owned qualified agent subset; never installed by agentCommands. */
7
+ export declare function createPlaywrightCli(options: PlaywrightCliOptions): {
8
+ readonly plugin: VirtualShellPlugin;
9
+ dispose(): Promise<void>;
10
+ };
11
+ export * from '../../playwright/index.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/playwright/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AACzG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAIpE,MAAM,MAAM,oBAAoB,GAAG,2BAA2B,GAAG;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEhG,2EAA2E;AAC3E,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAoCpI;AAED,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { createPlaywrightController } from '../../playwright/index.js';
2
+ import { resolvePath } from '../../contracts/path.js';
3
+ import { writeBytes } from '../../contracts/io.js';
4
+ /** Host-owned qualified agent subset; never installed by agentCommands. */
5
+ export function createPlaywrightCli(options) {
6
+ if (options?.replace !== undefined && typeof options.replace !== 'boolean')
7
+ throw new TypeError('Invalid Playwright replacement option');
8
+ const { replace, ...controllerOptions } = options;
9
+ const controller = createPlaywrightController(controllerOptions);
10
+ const plugin = {
11
+ name: 'playwright-cli',
12
+ setup(host) {
13
+ host.commands.register({
14
+ name: 'playwright-cli',
15
+ description: 'Qualified injected subset: sessions, DOM snapshot refs, click/fill/press, screenshots, tabs',
16
+ async execute(context) {
17
+ try {
18
+ await controller.run({
19
+ args: context.args,
20
+ env: context.env,
21
+ signal: context.signal,
22
+ registerCleanup: context.registerCleanup,
23
+ writeArtifact: async (bytes, filename) => {
24
+ context.signal.throwIfAborted();
25
+ if (filename === undefined)
26
+ await writeBytes(context.stdout, bytes, context.signal);
27
+ else
28
+ await context.fs.writeFile(resolvePath(context.cwd, filename), bytes, { signal: context.signal });
29
+ },
30
+ write: text => writeBytes(context.stdout, new TextEncoder().encode(text), context.signal),
31
+ });
32
+ return { exitCode: 0 };
33
+ }
34
+ catch (error) {
35
+ context.signal.throwIfAborted();
36
+ await writeBytes(context.stderr, new TextEncoder().encode(`playwright-cli: ${error instanceof Error ? error.message : String(error)}\n`), context.signal);
37
+ return { exitCode: 1 };
38
+ }
39
+ },
40
+ }, { replace: replace ?? false });
41
+ },
42
+ dispose: controller.dispose,
43
+ };
44
+ return { plugin, dispose: controller.dispose };
45
+ }
46
+ export * from '../../playwright/index.js';
47
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/playwright/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAoC,MAAM,2BAA2B,CAAC;AAEzG,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAInD,2EAA2E;AAC3E,MAAM,UAAU,mBAAmB,CAAC,OAA6B;IAC/D,IAAI,OAAO,EAAE,OAAO,KAAK,SAAS,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,SAAS;QAAE,M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AAC;oBACzB,CAAC;oBAAC,OAAO,KAAK,EAAE,CAAC;wBACf,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;wBAChC,MAAM,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,mBAAmB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;wBAC1J,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;oBACzB,CAAC;gBACH,CAAC;aACF,EAAE,EAAE,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,EAAE,UAAU,CAAC,OAAO;KAC5B,CAAC;IACF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC;AACjD,CAAC;AAED,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,71 @@
1
+ import type { PlaywrightAcquireOptions, PlaywrightAdapter, PlaywrightLease } from "../playwright/adapter.js";
2
+ export type { BrowserEngine, PlaywrightAcquireOptions, PlaywrightAdapter, PlaywrightBrowser, PlaywrightContext, PlaywrightLease, PlaywrightLocator, PlaywrightPage, } from "../playwright/adapter.js";
3
+ /** Live browser milliseconds including idle time. See playwright.md for obligations. */
4
+ export type BrowserUsageEvent = {
5
+ /** Stable across delivery retries. */
6
+ readonly eventId: string;
7
+ readonly acquisitionId: string;
8
+ /** Billable browser identity, stable across reconnects; not a tab or lease ID. */
9
+ readonly resourceId: string;
10
+ /** Positive integer ordered per resource; corrections advance it. */
11
+ readonly revision: number;
12
+ /** UTC ISO observation timestamp, distinct from resource timestamps. */
13
+ readonly observedAt: string;
14
+ } & ({
15
+ readonly type: "started";
16
+ readonly startedAt: string;
17
+ readonly accuracy: "provider" | "estimated";
18
+ } | {
19
+ readonly type: "usage";
20
+ /** Finite nonnegative, unrounded duration from resource start. */
21
+ readonly cumulativeBrowserMs: number;
22
+ readonly through: string;
23
+ readonly accuracy: "provider" | "estimated";
24
+ /** True only after confirmed resource end, including the last partial interval. */
25
+ readonly final: boolean;
26
+ } | {
27
+ readonly type: "ended";
28
+ readonly endedAt: string;
29
+ /** Final cumulative duration after confirmed end; not another charge quantity. */
30
+ readonly cumulativeBrowserMs: number;
31
+ readonly accuracy: "provider" | "estimated";
32
+ } | {
33
+ readonly type: "unknown";
34
+ readonly reason: "acquisition-failed" | "connection-lost" | "cleanup-failed";
35
+ });
36
+ /** Trusted injected host hooks; identity, pricing and charging remain external. */
37
+ export interface PlaywrightBillingHooks {
38
+ /** Caller-selected finite positive integer; validate before effects. No default. */
39
+ readonly intervalMs: number;
40
+ /** Await before allocation. Rejection prevents browser effects. */
41
+ beforeAcquire?(request: PlaywrightAcquireOptions): Promise<void>;
42
+ /** Await serialized cumulative/lifecycle reports; rejection requires owned cleanup. */
43
+ onUsage(event: BrowserUsageEvent): Promise<void>;
44
+ }
45
+ export interface PlaywrightUsageConfiguration {
46
+ /** Caller-selected finite positive integer, validated before allocation. */
47
+ readonly intervalMs: number;
48
+ /** Await per resource; coalesce slow ticks and preserve final/lifecycle facts. */
49
+ report(event: BrowserUsageEvent): Promise<void>;
50
+ }
51
+ export interface PlaywrightUsageAcquireOptions extends PlaywrightAcquireOptions {
52
+ /** Adapter reporting continues between commands, including partial acquisition. */
53
+ readonly usage?: PlaywrightUsageConfiguration;
54
+ }
55
+ /**
56
+ * Injection obligation only; the current adapter factory does not implement it.
57
+ * Must honor playwright.md, without keep-alives or extending service lifetime.
58
+ */
59
+ export interface PlaywrightUsageAdapter extends PlaywrightAdapter {
60
+ readonly liveBrowserUsage: true;
61
+ acquire(options: PlaywrightUsageAcquireOptions): Promise<PlaywrightLease>;
62
+ }
63
+ /** Billing requires an explicitly reporting-capable injected adapter. */
64
+ export type PlaywrightInjectionOptions = {
65
+ readonly adapter: PlaywrightAdapter;
66
+ readonly billing?: undefined;
67
+ } | {
68
+ readonly adapter: PlaywrightUsageAdapter;
69
+ readonly billing: PlaywrightBillingHooks;
70
+ };
71
+ //# sourceMappingURL=playwright.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playwright.d.ts","sourceRoot":"","sources":["../../src/contracts/playwright.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE7G,YAAY,EACV,aAAa,EACb,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,cAAc,GACf,MAAM,0BAA0B,CAAC;AAElC,wFAAwF;AACxF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,sCAAsC;IACtC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,kFAAkF;IAClF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,qEAAqE;IACrE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,wEAAwE;IACxE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,GAAG,CACA;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,UAAU,GAAG,WAAW,CAAC;CAC7C,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,kEAAkE;IAClE,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,UAAU,GAAG,WAAW,CAAC;IAC5C,mFAAmF;IACnF,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB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AAC,OAAO,CAAC,EAAE,SAAS,CAAA;CAAE,GACrE;IAAE,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAA;CAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=playwright.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playwright.js","sourceRoot":"","sources":["../../src/contracts/playwright.ts"],"names":[],"mappings":""}
@@ -0,0 +1,97 @@
1
+ export type BrowserEngine = "chromium" | "firefox" | "webkit";
2
+ export interface PlaywrightLocator {
3
+ click(options?: {
4
+ timeout?: number;
5
+ }): Promise<void>;
6
+ fill(value: string, options?: {
7
+ timeout?: number;
8
+ }): Promise<void>;
9
+ ariaSnapshot(options?: {
10
+ timeout?: number;
11
+ }): Promise<string>;
12
+ }
13
+ export interface SnapshotNode {
14
+ readonly tagName: string;
15
+ readonly textContent: string | null;
16
+ readonly isConnected: boolean;
17
+ readonly ownerDocument?: {
18
+ readonly defaultView: {
19
+ readonly document: unknown;
20
+ } | null;
21
+ };
22
+ getAttribute(name: string): string | null;
23
+ }
24
+ export interface PlaywrightElementHandle {
25
+ evaluate<T>(callback: (node: SnapshotNode) => T): Promise<T>;
26
+ click(options?: {
27
+ timeout?: number;
28
+ }): Promise<void>;
29
+ fill(value: string, options?: {
30
+ timeout?: number;
31
+ }): Promise<void>;
32
+ dispose(): Promise<void>;
33
+ }
34
+ export interface PlaywrightFrame {
35
+ locator(selector: string): {
36
+ elementHandles?: () => Promise<PlaywrightElementHandle[]>;
37
+ };
38
+ }
39
+ export interface PlaywrightPage {
40
+ frames?(): PlaywrightFrame[];
41
+ on?(event: 'framenavigated' | 'close', listener: () => void): unknown;
42
+ off?(event: 'framenavigated' | 'close', listener: () => void): unknown;
43
+ goto(url: string, options?: {
44
+ timeout?: number;
45
+ }): Promise<unknown>;
46
+ url(): string;
47
+ locator(selector: string): PlaywrightLocator;
48
+ readonly keyboard: {
49
+ press(key: string): Promise<void>;
50
+ };
51
+ screenshot(options?: {
52
+ type?: "png" | "jpeg";
53
+ fullPage?: boolean;
54
+ timeout?: number;
55
+ }): Promise<Uint8Array>;
56
+ close(): Promise<void>;
57
+ }
58
+ export interface PlaywrightContext {
59
+ newPage(): Promise<PlaywrightPage>;
60
+ pages(): PlaywrightPage[];
61
+ close(): Promise<void>;
62
+ on(event: "close", listener: () => void): unknown;
63
+ off(event: "close", listener: () => void): unknown;
64
+ }
65
+ export interface PlaywrightBrowser {
66
+ isConnected(): boolean;
67
+ newContext(): Promise<PlaywrightContext>;
68
+ on(event: "disconnected", listener: () => void): unknown;
69
+ off(event: "disconnected", listener: () => void): unknown;
70
+ }
71
+ export interface PlaywrightAcquireOptions {
72
+ readonly acquisitionId: string;
73
+ readonly session: string;
74
+ readonly browser: BrowserEngine;
75
+ readonly headless: boolean;
76
+ readonly signal: AbortSignal;
77
+ }
78
+ export interface PlaywrightBrowserSource {
79
+ readonly headed?: boolean;
80
+ acquireBrowser(options: PlaywrightAcquireOptions): Promise<{
81
+ readonly browser: PlaywrightBrowser;
82
+ release(): Promise<void>;
83
+ }>;
84
+ }
85
+ export interface PlaywrightLease {
86
+ readonly context: PlaywrightContext;
87
+ onClosed(listener: () => void): () => void;
88
+ release(): Promise<void>;
89
+ }
90
+ export interface PlaywrightAdapter {
91
+ readonly browsers: Readonly<Partial<Record<BrowserEngine, {
92
+ readonly headed: boolean;
93
+ }>>>;
94
+ acquire(options: PlaywrightAcquireOptions): Promise<PlaywrightLease>;
95
+ }
96
+ export declare function createPlaywrightAdapter(sources: Partial<Record<BrowserEngine, PlaywrightBrowserSource>>): PlaywrightAdapter;
97
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/playwright/adapter.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC;A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AAE;QAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC,CAAC,CAAC;IAC1F,OAAO,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CACtE;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,uBAAuB,CAAC,CAAC,GAAG,iBAAiB,CAsF3H"}
@@ -0,0 +1,123 @@
1
+ export function createPlaywrightAdapter(sources) {
2
+ if (!sources || typeof sources !== 'object' || Object.keys(sources).some(engine => !['chromium', 'firefox', 'webkit'].includes(engine)))
3
+ throw new TypeError('Invalid Playwright browser sources');
4
+ const configured = new Map();
5
+ const browsers = {};
6
+ for (const engine of ["chromium", "firefox", "webkit"]) {
7
+ const source = sources[engine];
8
+ if (source === undefined)
9
+ continue;
10
+ if (!source || typeof source !== 'object' || typeof source.acquireBrowser !== 'function'
11
+ || source.headed !== undefined && typeof source.headed !== 'boolean'
12
+ || Object.keys(source).some(key => !['headed', 'acquireBrowser'].includes(key)))
13
+ throw new TypeError('Invalid Playwright browser capability');
14
+ configured.set(engine, { headed: source.headed === true, acquireBrowser: source.acquireBrowser.bind(source) });
15
+ browsers[engine] = Object.freeze({ headed: source.headed === true });
16
+ }
17
+ return {
18
+ browsers: Object.freeze(browsers),
19
+ async acquire(options) {
20
+ if (!options || typeof options !== 'object' || Object.keys(options).some(key => !['acquisitionId', 'session', 'browser', 'headless', 'signal'].includes(key))
21
+ || typeof options.headless !== 'boolean' || typeof options.acquisitionId !== 'string' || !options.acquisitionId
22
+ || typeof options.session !== 'string' || !options.session
23
+ || typeof options.signal?.throwIfAborted !== 'function')
24
+ throw new TypeError('Invalid Playwright acquisition options');
25
+ const source = configured.get(options.browser);
26
+ if (!source)
27
+ throw new Error(`Unsupported browser: ${options.browser}`);
28
+ if (!options.headless && !source.headed)
29
+ throw new Error(`Headed mode is unsupported for ${options.browser}`);
30
+ options.signal.throwIfAborted();
31
+ // No race against abort: opaque host acquisition must settle so its late
32
+ // resource can be retired. Hosts may cooperatively honor the signal.
33
+ const resource = await source.acquireBrowser(options);
34
+ let context;
35
+ let closed = false;
36
+ let releasing;
37
+ const listeners = new Set();
38
+ const detach = () => {
39
+ resource.browser.off("disconnected", notify);
40
+ context?.off("close", notify);
41
+ };
42
+ const notify = () => {
43
+ if (closed)
44
+ return;
45
+ closed = true;
46
+ detach();
47
+ const pending = [...listeners];
48
+ listeners.clear();
49
+ for (const listener of pending)
50
+ listener();
51
+ };
52
+ const release = () => {
53
+ releasing ??= Promise.resolve().then(async () => {
54
+ const errors = [];
55
+ if (context) {
56
+ try {
57
+ await context.close();
58
+ notify();
59
+ }
60
+ catch (error) {
61
+ errors.push(error);
62
+ }
63
+ }
64
+ try {
65
+ await resource.release();
66
+ }
67
+ catch (error) {
68
+ errors.push(error);
69
+ }
70
+ // Retirement invalidates the local lease even if context closure
71
+ // failed or the host merely returned a borrowed browser to its owner.
72
+ // This notification does not establish remote browser termination.
73
+ notify();
74
+ if (errors.length === 1)
75
+ throw errors[0];
76
+ if (errors.length > 1)
77
+ throw new AggregateError(errors, "Playwright lease release failed");
78
+ });
79
+ return releasing;
80
+ };
81
+ try {
82
+ resource.browser.on("disconnected", notify);
83
+ options.signal.throwIfAborted();
84
+ if (!resource.browser.isConnected())
85
+ notify();
86
+ if (closed)
87
+ throw new Error("Playwright browser is closed");
88
+ context = await resource.browser.newContext();
89
+ context.on("close", notify);
90
+ options.signal.throwIfAborted();
91
+ if (!resource.browser.isConnected())
92
+ notify();
93
+ if (closed)
94
+ throw new Error("Playwright browser closed during context acquisition");
95
+ return {
96
+ context,
97
+ onClosed(listener) {
98
+ if (closed) {
99
+ listener();
100
+ return () => { };
101
+ }
102
+ listeners.add(listener);
103
+ return () => { listeners.delete(listener); };
104
+ },
105
+ release,
106
+ };
107
+ }
108
+ catch (error) {
109
+ try {
110
+ await release();
111
+ }
112
+ catch (cleanupError) {
113
+ throw new AggregateError([error, cleanupError], "Playwright acquisition and cleanup failed");
114
+ }
115
+ finally {
116
+ detach();
117
+ }
118
+ throw error;
119
+ }
120
+ },
121
+ };
122
+ }
123
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/playwright/adapter.ts"],"names":[],"mappings":"AAqFA,MAAM,UAAU,uBAAuB,CAAC,OAAgE;IACtG,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,oCAAoC,CAAC,CAAC;IACnM,MAAM,UAAU,GAAG,IAAI,GAAG,EAA0C,CAAC;IACrE,MAAM,QAAQ,GAAiE,EAAE,CAAC;IAClF,KAAK,MAAM,MAAM,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,CAAU,EAAE,CAAC;QAChE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QAC/B,IAAI,MAAM,KAAK,SAAS;YAAE,SAAS;QACnC,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,cAAc,KAAK,UAAU;eACnF,MAAM,CAAC,MAAM,KAAK,SAAS,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,SAAS;eACjE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YAAE,MAAM,IAAI,SAAS,CAAC,uCAAuC,CAAC,CAAC;QAChJ,UAAU,CAAC,GAAG,CA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AAG,EAAE,GAAE,CAAC,CAAC;wBAAC,CAAC;wBAC5C,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;wBACxB,OAAO,GAAG,EAAE,GAAG,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC/C,CAAC;oBACD,OAAO;iBACR,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC;oBAAC,MAAM,OAAO,EAAE,CAAC;gBAAC,CAAC;gBAAC,OAAO,YAAY,EAAE,CAAC;oBAC7C,MAAM,IAAI,cAAc,CAAC,CAAC,KAAK,EAAE,YAAY,CAAC,EAAE,2CAA2C,CAAC,CAAC;gBAC/F,CAAC;wBAAS,CAAC;oBAAC,MAAM,EAAE,CAAC;gBAAC,CAAC;gBACvB,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,71 @@
1
+ import type { PlaywrightAcquireOptions, PlaywrightAdapter, PlaywrightLease } from "./adapter.js";
2
+ export type { BrowserEngine, PlaywrightAcquireOptions, PlaywrightAdapter, PlaywrightBrowser, PlaywrightContext, PlaywrightLease, PlaywrightLocator, PlaywrightPage, } from "./adapter.js";
3
+ /** Live browser milliseconds including idle time. See playwright.md for obligations. */
4
+ export type BrowserUsageEvent = {
5
+ /** Stable across delivery retries. */
6
+ readonly eventId: string;
7
+ readonly acquisitionId: string;
8
+ /** Billable browser identity, stable across reconnects; not a tab or lease ID. */
9
+ readonly resourceId: string;
10
+ /** Positive integer ordered per resource; corrections advance it. */
11
+ readonly revision: number;
12
+ /** UTC ISO observation timestamp, distinct from resource timestamps. */
13
+ readonly observedAt: string;
14
+ } & ({
15
+ readonly type: "started";
16
+ readonly startedAt: string;
17
+ readonly accuracy: "provider" | "estimated";
18
+ } | {
19
+ readonly type: "usage";
20
+ /** Finite nonnegative, unrounded duration from resource start. */
21
+ readonly cumulativeBrowserMs: number;
22
+ readonly through: string;
23
+ readonly accuracy: "provider" | "estimated";
24
+ /** True only after confirmed resource end, including the last partial interval. */
25
+ readonly final: boolean;
26
+ } | {
27
+ readonly type: "ended";
28
+ readonly endedAt: string;
29
+ /** Final cumulative duration after confirmed end; not another charge quantity. */
30
+ readonly cumulativeBrowserMs: number;
31
+ readonly accuracy: "provider" | "estimated";
32
+ } | {
33
+ readonly type: "unknown";
34
+ readonly reason: "acquisition-failed" | "connection-lost" | "cleanup-failed";
35
+ });
36
+ /** Trusted injected host hooks; identity, pricing and charging remain external. */
37
+ export interface PlaywrightBillingHooks {
38
+ /** Caller-selected finite positive integer; validate before effects. No default. */
39
+ readonly intervalMs: number;
40
+ /** Await before allocation. Rejection prevents browser effects. */
41
+ beforeAcquire?(request: PlaywrightAcquireOptions): Promise<void>;
42
+ /** Await serialized cumulative/lifecycle reports; rejection requires owned cleanup. */
43
+ onUsage(event: BrowserUsageEvent): Promise<void>;
44
+ }
45
+ export interface PlaywrightUsageConfiguration {
46
+ /** Caller-selected finite positive integer, validated before allocation. */
47
+ readonly intervalMs: number;
48
+ /** Await per resource; coalesce slow ticks and preserve final/lifecycle facts. */
49
+ report(event: BrowserUsageEvent): Promise<void>;
50
+ }
51
+ export interface PlaywrightUsageAcquireOptions extends PlaywrightAcquireOptions {
52
+ /** Adapter reporting continues between commands, including partial acquisition. */
53
+ readonly usage?: PlaywrightUsageConfiguration;
54
+ }
55
+ /**
56
+ * Injection obligation only; the current adapter factory does not implement it.
57
+ * Must honor playwright.md, without keep-alives or extending service lifetime.
58
+ */
59
+ export interface PlaywrightUsageAdapter extends PlaywrightAdapter {
60
+ readonly liveBrowserUsage: true;
61
+ acquire(options: PlaywrightUsageAcquireOptions): Promise<PlaywrightLease>;
62
+ }
63
+ /** Billing requires an explicitly reporting-capable injected adapter. */
64
+ export type PlaywrightInjectionOptions = {
65
+ readonly adapter: PlaywrightAdapter;
66
+ readonly billing?: undefined;
67
+ } | {
68
+ readonly adapter: PlaywrightUsageAdapter;
69
+ readonly billing: PlaywrightBillingHooks;
70
+ };
71
+ //# sourceMappingURL=billing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../../src/playwright/billing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEjG,YAAY,EACV,aAAa,EACb,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,cAAc,GACf,MAAM,cAAc,CAAC;AAEtB,wFAAwF;AACxF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,sCAAsC;IACtC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,kFAAkF;IAClF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,qEAAqE;IACrE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,wEAAwE;IACxE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,GAAG,CACA;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,UAAU,GAAG,WAAW,CAAC;CAC7C,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,kEAAkE;IAClE,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,UAAU,GAAG,WAAW,CAAC;IAC5C,mFAAmF;IACnF,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,EAA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,sBAAsB,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAA;CAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=billing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing.js","sourceRoot":"","sources":["../../src/playwright/billing.ts"],"names":[],"mappings":""}
@@ -0,0 +1,21 @@
1
+ import type { PlaywrightAdapter } from './adapter.js';
2
+ import { type PlaywrightInvocation } from './invocation.js';
3
+ export interface PlaywrightControllerOptions {
4
+ readonly adapter: PlaywrightAdapter;
5
+ readonly limits?: {
6
+ readonly maxSessions?: number;
7
+ readonly actionTimeoutMs?: number;
8
+ readonly maxSnapshotBytes?: number;
9
+ readonly maxSnapshotRefs?: number;
10
+ readonly maxArtifactBytes?: number;
11
+ readonly maxTabs?: number;
12
+ };
13
+ /** Billing declarations are separate; reporting/charging is not implemented. */
14
+ readonly billing?: never;
15
+ }
16
+ export type PlaywrightSessionState = 'acquiring' | 'open' | 'closing' | 'closed';
17
+ export declare function createPlaywrightController(options: PlaywrightControllerOptions): {
18
+ run: (invocation: PlaywrightInvocation) => Promise<void>;
19
+ dispose: () => Promise<void>;
20
+ };
21
+ //# sourceMappingURL=controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/playwright/controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAmC,MAAM,cAAc,CAAC;AAEvF,OAAO,EAAmB,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAE7E,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC;IACpC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7N,gFAAgF;IAChF,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC;CAC1B;AACD,MAAM,MAAM,sBAAsB,GAAG,WAAW,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAC;AAcjF,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,2BAA2B;sBA4D9C,oBAAoB,KAAG,OAAO,CAAC,IAAI,CAAC;mBAsN/C,OAAO,CAAC,IAAI,CAAC;EAclC"}