poe-code 15.0.45 → 15.0.46

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 (70) hide show
  1. package/dist/{chunk-CY4U3TS5.js → chunk-LRADNPMZ.js} +2 -2
  2. package/dist/{dist-QQ5MXLNA.js → dist-SHPG7RKD.js} +6 -6
  3. package/dist/{dist-QQ5MXLNA.js.map → dist-SHPG7RKD.js.map} +3 -3
  4. package/dist/index.js +2 -2
  5. package/dist/metafile.json +1 -1
  6. package/dist/{program-2K6HLD6K.js → program-XHHZOF7U.js} +3 -3
  7. package/package.json +15 -3
  8. package/packages/safe-bash/dist/chunks/{chunk-GPV7ZFYS.js → chunk-IX6VL7KM.js} +6 -6
  9. package/packages/safe-bash/dist/chunks/chunk-IX6VL7KM.js.map +7 -0
  10. package/packages/safe-bash/dist/chunks/{chunk-WECHUK3Y.js → chunk-MQJRBELV.js} +2 -2
  11. package/packages/safe-bash/dist/chunks/{chunk-WECHUK3Y.js.map → chunk-MQJRBELV.js.map} +1 -1
  12. package/packages/safe-bash/dist/commands/node/index.browser.js +1 -1
  13. package/packages/safe-bash/dist/commands/python/execution.d.ts +1 -1
  14. package/packages/safe-bash/dist/commands/python/execution.d.ts.map +1 -1
  15. package/packages/safe-bash/dist/commands/python/execution.js +5 -1
  16. package/packages/safe-bash/dist/commands/python/execution.js.map +1 -1
  17. package/packages/safe-bash/dist/commands/python/index.browser.js +1 -1
  18. package/packages/safe-bash/dist/commands/python/index.d.ts +1 -0
  19. package/packages/safe-bash/dist/commands/python/index.d.ts.map +1 -1
  20. package/packages/safe-bash/dist/commands/python/index.js +1 -1
  21. package/packages/safe-bash/dist/commands/python/index.js.map +1 -1
  22. package/packages/safe-bash/dist/commands/python/provisioning-runtime.d.ts.map +1 -1
  23. package/packages/safe-bash/dist/commands/python/provisioning-runtime.js +22 -11
  24. package/packages/safe-bash/dist/commands/python/provisioning-runtime.js.map +1 -1
  25. package/packages/safe-bash/dist/commands/python/provisioning.js +5 -5
  26. package/packages/safe-bash/dist/commands/python/provisioning.js.map +1 -1
  27. package/packages/safe-bash/dist/commands/python/worker.browser.js +23 -11
  28. package/packages/safe-bash/dist/commands/python/worker.browser.js.map +2 -2
  29. package/packages/safe-bash/dist/core.browser.js +2 -2
  30. package/packages/safe-bash/dist/playwright/controller.d.ts.map +1 -1
  31. package/packages/safe-bash/dist/playwright/controller.js +18 -11
  32. package/packages/safe-bash/dist/playwright/controller.js.map +1 -1
  33. package/packages/safe-bash/dist/playwright/snapshot.d.ts +2 -1
  34. package/packages/safe-bash/dist/playwright/snapshot.d.ts.map +1 -1
  35. package/packages/safe-bash/dist/playwright/snapshot.js +53 -5
  36. package/packages/safe-bash/dist/playwright/snapshot.js.map +1 -1
  37. package/packages/safe-js/dist/browser/chunks/{chunk-RILLSV3Z.js → chunk-PYPO2PBZ.js} +8 -3
  38. package/packages/safe-js/dist/browser/chunks/{chunk-RILLSV3Z.js.map → chunk-PYPO2PBZ.js.map} +3 -3
  39. package/packages/safe-js/dist/browser/safe-fs-core.js +1 -1
  40. package/packages/safe-js/dist/browser/safe-fs.js +1 -1
  41. package/packages/safe-js/dist/chunks/{chunk-WP6R5BZQ.js → chunk-DVYZSFT7.js} +3 -3
  42. package/packages/safe-js/dist/chunks/{chunk-DDSELQBK.js → chunk-QARR7XB6.js} +8 -3
  43. package/packages/safe-js/dist/chunks/{chunk-DDSELQBK.js.map → chunk-QARR7XB6.js.map} +3 -3
  44. package/packages/safe-js/dist/chunks/{chunk-IRUPW4G6.js → chunk-RRT5HCYW.js} +2 -2
  45. package/packages/safe-js/dist/chunks/{cli-runtime-ZT6JZOYI.js → cli-runtime-SROZP6VJ.js} +6 -6
  46. package/packages/safe-js/dist/chunks/{fs-2EQSFSKI.js → fs-MQRFZI4E.js} +2 -2
  47. package/packages/safe-js/dist/cli.js +2 -2
  48. package/packages/safe-js/dist/index.js +3 -3
  49. package/packages/safe-js/dist/safe-fs-core.js +1 -1
  50. package/packages/safe-js/dist/safe-fs-node.js +2 -2
  51. package/packages/safe-js/dist/safe-fs.js +2 -2
  52. package/packages/safe-playwright/dist/adapter.d.ts +96 -0
  53. package/packages/safe-playwright/dist/adapter.js +122 -0
  54. package/packages/safe-playwright/dist/billing.d.ts +70 -0
  55. package/packages/safe-playwright/dist/billing.js +1 -0
  56. package/packages/safe-playwright/dist/controller.d.ts +20 -0
  57. package/packages/safe-playwright/dist/controller.js +368 -0
  58. package/packages/safe-playwright/dist/index.d.ts +4 -0
  59. package/packages/safe-playwright/dist/index.js +3 -0
  60. package/packages/safe-playwright/dist/invocation.d.ts +25 -0
  61. package/packages/safe-playwright/dist/invocation.js +111 -0
  62. package/packages/safe-playwright/dist/snapshot.d.ts +14 -0
  63. package/packages/safe-playwright/dist/snapshot.js +95 -0
  64. package/packages/safe-bash/dist/chunks/chunk-GPV7ZFYS.js.map +0 -7
  65. /package/dist/{chunk-CY4U3TS5.js.map → chunk-LRADNPMZ.js.map} +0 -0
  66. /package/dist/{program-2K6HLD6K.js.map → program-XHHZOF7U.js.map} +0 -0
  67. /package/packages/safe-js/dist/chunks/{chunk-WP6R5BZQ.js.map → chunk-DVYZSFT7.js.map} +0 -0
  68. /package/packages/safe-js/dist/chunks/{chunk-IRUPW4G6.js.map → chunk-RRT5HCYW.js.map} +0 -0
  69. /package/packages/safe-js/dist/chunks/{cli-runtime-ZT6JZOYI.js.map → cli-runtime-SROZP6VJ.js.map} +0 -0
  70. /package/packages/safe-js/dist/chunks/{fs-2EQSFSKI.js.map → fs-MQRFZI4E.js.map} +0 -0
@@ -14,7 +14,7 @@ import {
14
14
  registerEntryAuthority,
15
15
  registerS3EntryOwner,
16
16
  toByteSource
17
- } from "./chunk-DDSELQBK.js";
17
+ } from "./chunk-QARR7XB6.js";
18
18
  import {
19
19
  FsError,
20
20
  composeAbortSignals,
@@ -3031,4 +3031,4 @@ export {
3031
3031
  createS3HttpTransport,
3032
3032
  createNodeFileSystemAdapterRegistry
3033
3033
  };
3034
- //# sourceMappingURL=chunk-IRUPW4G6.js.map
3034
+ //# sourceMappingURL=chunk-RRT5HCYW.js.map
@@ -12,7 +12,7 @@ import {
12
12
  parseFsConfig,
13
13
  resolveFsConfig,
14
14
  splitFrontmatter
15
- } from "./chunk-WP6R5BZQ.js";
15
+ } from "./chunk-DVYZSFT7.js";
16
16
  import {
17
17
  parseMcpConfig
18
18
  } from "./chunk-YPVGFXBW.js";
@@ -28,8 +28,8 @@ import {
28
28
  import {
29
29
  hasOwnErrorCode
30
30
  } from "./chunk-SJZWSPWD.js";
31
- import "./chunk-IRUPW4G6.js";
32
- import "./chunk-DDSELQBK.js";
31
+ import "./chunk-RRT5HCYW.js";
32
+ import "./chunk-QARR7XB6.js";
33
33
  import "./chunk-LT32O3X4.js";
34
34
  import "./chunk-OI54IWV5.js";
35
35
  import {
@@ -280,7 +280,7 @@ async function runScriptFile(filepath, parsed, options) {
280
280
  import("./restore-6NP4IKO4.js"),
281
281
  import("./dump-O5NEJE33.js"),
282
282
  import("./runtime-modules-6SIMTBZ7.js"),
283
- import("./fs-2EQSFSKI.js"),
283
+ import("./fs-MQRFZI4E.js"),
284
284
  import("./mcp-3IZFGURR.js")
285
285
  ]);
286
286
  const loaded = loadExecutableSource(filepath, await options.readFile(filepath, "utf8"));
@@ -518,7 +518,7 @@ async function createRuntime(frontmatter, meta, options) {
518
518
  }
519
519
  const [{ makeHarnessModule }, { makeFsModule }] = await Promise.all([
520
520
  import("./harness-QWJKQR2D.js"),
521
- import("./fs-2EQSFSKI.js")
521
+ import("./fs-MQRFZI4E.js")
522
522
  ]);
523
523
  const state = {
524
524
  metricCalls: /* @__PURE__ */ new Map(),
@@ -708,4 +708,4 @@ export {
708
708
  exitCodeForError,
709
709
  runCli
710
710
  };
711
- //# sourceMappingURL=cli-runtime-ZT6JZOYI.js.map
711
+ //# sourceMappingURL=cli-runtime-SROZP6VJ.js.map
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-3J7C4LRD.js";
5
5
  import "./chunk-SJZWSPWD.js";
6
6
  import "./chunk-ZQ2JGB2O.js";
7
- import "./chunk-DDSELQBK.js";
7
+ import "./chunk-QARR7XB6.js";
8
8
  import "./chunk-LT32O3X4.js";
9
9
  import "./chunk-OI54IWV5.js";
10
10
  import "./chunk-F5PSQI5A.js";
@@ -14,4 +14,4 @@ export {
14
14
  FS_OPTION_SURFACE,
15
15
  makeFsModule
16
16
  };
17
- //# sourceMappingURL=fs-2EQSFSKI.js.map
17
+ //# sourceMappingURL=fs-MQRFZI4E.js.map
@@ -13,7 +13,7 @@ import path from "node:path";
13
13
  import { fileURLToPath } from "node:url";
14
14
  async function runCli(argv, options = {}) {
15
15
  if (!argv.includes("--help") && !argv.includes("-h")) {
16
- const runtime = await import("./chunks/cli-runtime-ZT6JZOYI.js");
16
+ const runtime = await import("./chunks/cli-runtime-SROZP6VJ.js");
17
17
  return runtime.runCli(argv, options, createUsage());
18
18
  }
19
19
  const brokenPipe = createBrokenPipeState();
@@ -32,7 +32,7 @@ async function runCli(argv, options = {}) {
32
32
  stderr.write(`${error instanceof Error ? error.message : String(error)}
33
33
  `);
34
34
  if (brokenPipe.closed) return 0;
35
- const { exitCodeForError } = await import("./chunks/cli-runtime-ZT6JZOYI.js");
35
+ const { exitCodeForError } = await import("./chunks/cli-runtime-SROZP6VJ.js");
36
36
  return exitCodeForError(error);
37
37
  }
38
38
  }
@@ -21,7 +21,7 @@ import {
21
21
  runWithSpawnUsageAccumulator,
22
22
  splitFrontmatter,
23
23
  supportsSpawnMode
24
- } from "./chunks/chunk-WP6R5BZQ.js";
24
+ } from "./chunks/chunk-DVYZSFT7.js";
25
25
  import {
26
26
  parseMcpConfig
27
27
  } from "./chunks/chunk-YPVGFXBW.js";
@@ -60,8 +60,8 @@ import {
60
60
  hasOwnErrorCode
61
61
  } from "./chunks/chunk-SJZWSPWD.js";
62
62
  import "./chunks/chunk-ZQ2JGB2O.js";
63
- import "./chunks/chunk-IRUPW4G6.js";
64
- import "./chunks/chunk-DDSELQBK.js";
63
+ import "./chunks/chunk-RRT5HCYW.js";
64
+ import "./chunks/chunk-QARR7XB6.js";
65
65
  import "./chunks/chunk-LT32O3X4.js";
66
66
  import "./chunks/chunk-OI54IWV5.js";
67
67
  import {
@@ -37,7 +37,7 @@ import {
37
37
  toByteSource,
38
38
  translatePythonOpenFlags,
39
39
  withFileSystemQuota
40
- } from "./chunks/chunk-DDSELQBK.js";
40
+ } from "./chunks/chunk-QARR7XB6.js";
41
41
  import {
42
42
  FsError,
43
43
  assertPathWithin,
@@ -15,7 +15,7 @@ import {
15
15
  isAbsolutePath,
16
16
  joinPath,
17
17
  posixPath
18
- } from "./chunks/chunk-IRUPW4G6.js";
18
+ } from "./chunks/chunk-RRT5HCYW.js";
19
19
  import {
20
20
  ACCESS_MODES,
21
21
  DeviceFileSystem,
@@ -45,7 +45,7 @@ import {
45
45
  translatePythonOpenFlags,
46
46
  validateFileSystemConfig,
47
47
  withFileSystemQuota
48
- } from "./chunks/chunk-DDSELQBK.js";
48
+ } from "./chunks/chunk-QARR7XB6.js";
49
49
  import {
50
50
  createNodeFsBridge
51
51
  } from "./chunks/chunk-LT32O3X4.js";
@@ -15,7 +15,7 @@ import {
15
15
  isAbsolutePath,
16
16
  joinPath,
17
17
  posixPath
18
- } from "./chunks/chunk-IRUPW4G6.js";
18
+ } from "./chunks/chunk-RRT5HCYW.js";
19
19
  import {
20
20
  ACCESS_MODES,
21
21
  DeviceFileSystem,
@@ -45,7 +45,7 @@ import {
45
45
  translatePythonOpenFlags,
46
46
  validateFileSystemConfig,
47
47
  withFileSystemQuota
48
- } from "./chunks/chunk-DDSELQBK.js";
48
+ } from "./chunks/chunk-QARR7XB6.js";
49
49
  import {
50
50
  createNodeFsBridge
51
51
  } from "./chunks/chunk-LT32O3X4.js";
@@ -0,0 +1,96 @@
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;
@@ -0,0 +1,122 @@
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
+ }
@@ -0,0 +1,70 @@
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
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
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
+ };