diff --git a/packages/client/test/types/node-consumer.ts b/packages/client/test/types/node-consumer.ts new file mode 100644 index 0000000000..2ddc3e1154 --- /dev/null +++ b/packages/client/test/types/node-consumer.ts @@ -0,0 +1,37 @@ +import { + Browser, + BrowserDriver, + BrowserDriverError, + OpenCode, + type BrowserAttachment, + type BrowserRegistration, +} from "@opencode-ai/client/node" + +const state: Browser.State = { + url: "about:blank", + title: "", + loading: false, + canGoBack: false, + canGoForward: false, + generation: 0, +} + +const driver = BrowserDriver.define<{ readonly proxyURL: string }>((context) => ({ + resource: { proxyURL: context.proxy.url }, + state: () => state, + subscribe: () => () => undefined, + execute: async (_command, options) => { + throw new BrowserDriverError(options.signal.aborted ? "aborted" : "internal", "Command unavailable") + }, + dispose: () => undefined, +})) + +declare const client: ReturnType +const registration: Promise = client.browser.register({ + sessionID: "ses_type_fixture", + open: () => undefined, +}) +void registration.then((handle) => { + const attachment: Promise> = handle.attach({ driver }) + void attachment +})