Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion js/src/types/modcdp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,20 @@ export const ModCDPAddMiddlewareParamsSchema = z.object({
});
export type ModCDPAddMiddlewareParams = z.infer<typeof ModCDPAddMiddlewareParamsSchema>;

export const ModCDPLauncherOptionsSchema = z.object({}).passthrough();
export const ModCDPLauncherOptionsSchema = z
.object({
launcher_mode: z.enum(["local", "remote", "bb", "none"]).optional(),
launcher_executable_path: z.string().nullable().optional(),
launcher_user_data_dir: z.string().nullable().optional(),
launcher_options: z.record(z.string(), z.unknown()).optional(),
})
.passthrough();
export type ModCDPLauncherOptions = z.infer<typeof ModCDPLauncherOptionsSchema>;

export const ModCDPUpstreamOptionsSchema = z
.object({
upstream_mode: z.enum(["ws", "pipe", "nativemessaging", "reversews", "nats"]).optional(),
upstream_cdp_url: z.string().nullable().optional(),
upstream_nats_url: z.string().nullable().optional(),
upstream_nats_subject_prefix: z.string().nullable().optional(),
upstream_nats_wait_timeout_ms: z.number().positive().optional(),
Expand All @@ -158,6 +166,7 @@ export const ModCDPUpstreamOptionsSchema = z
upstream_nativemessaging_manifests: z.array(z.string()).nullable().optional(),
upstream_nativemessaging_host_name: z.string().nullable().optional(),
upstream_nativemessaging_wait_timeout_ms: z.number().positive().optional(),
upstream_ws_connect_error_settle_timeout_ms: z.number().positive().optional(),
})
.passthrough();
export type ModCDPUpstreamOptions = z.infer<typeof ModCDPUpstreamOptionsSchema>;
Expand Down
14 changes: 9 additions & 5 deletions python/modcdp/client/ModCDPClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,15 @@
ModCDPAddCustomEventParams,
ModCDPAddMiddlewareParams,
ModCDPCommandTiming,
ModCDPClientConfig,
ModCDPConnectTiming,
ModCDPInjectorConfig,
ModCDPLauncherConfig,
ModCDPPingLatency,
ModCDPRawTiming,
ModCDPRoutes,
ModCDPServerConfig,
ModCDPUpstreamConfig,
CdpMessage,
ExtensionInfo,
MessageParams,
Expand Down Expand Up @@ -216,11 +220,11 @@ def _json_object(value: JsonValue | None) -> ProtocolResult:
class ModCDPClient(CDPSurfaceMixin):
def __init__(
self,
launcher: Mapping[str, Any] | None = None,
upstream: Mapping[str, Any] | None = None,
injector: Mapping[str, Any] | None = None,
client: Mapping[str, Any] | None = None,
server: Mapping[str, JsonValue] | None | object = DEFAULT_SERVER,
launcher: ModCDPLauncherConfig | Mapping[str, Any] | None = None,
upstream: ModCDPUpstreamConfig | Mapping[str, Any] | None = None,
injector: ModCDPInjectorConfig | Mapping[str, Any] | None = None,
client: ModCDPClientConfig | Mapping[str, Any] | None = None,
server: ModCDPServerConfig | Mapping[str, JsonValue] | None | object = DEFAULT_SERVER,
custom_commands: Sequence[ModCDPAddCustomCommandParams] | None = None,
custom_events: Sequence[ModCDPAddCustomEventParams] | None = None,
custom_middlewares: Sequence[ModCDPAddMiddlewareParams] | None = None,
Expand Down
49 changes: 49 additions & 0 deletions python/modcdp/types/modcdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
ProtocolPayload: TypeAlias = dict[str, JsonValue]
MessageParams: TypeAlias = Mapping[str, object]
ModCDPRoutes: TypeAlias = dict[str, str]
ModCDPLauncherMode: TypeAlias = Literal["local", "remote", "bb", "none"]
ModCDPUpstreamMode: TypeAlias = Literal["ws", "pipe", "nativemessaging", "reversews", "nats"]


class _ModCDPAddCustomCommandRequired(TypedDict):
Expand Down Expand Up @@ -111,6 +113,53 @@ class ModCDPTopology(TypedDict):
contexts: dict[str, ModCDPTopologyExecutionContext]


class ModCDPLauncherConfig(TypedDict, total=False):
launcher_mode: ModCDPLauncherMode
launcher_executable_path: str | None
launcher_user_data_dir: str | None
launcher_options: dict[str, JsonValue]


class ModCDPUpstreamConfig(TypedDict, total=False):
upstream_mode: ModCDPUpstreamMode
upstream_cdp_url: str | None
upstream_nats_url: str | None
upstream_nats_subject_prefix: str | None
upstream_nats_wait_timeout_ms: int
upstream_reversews_bind: str | None
upstream_reversews_wait_timeout_ms: int
upstream_nativemessaging_manifest: str | None
upstream_nativemessaging_manifests: list[str] | None
upstream_nativemessaging_host_name: str | None
upstream_nativemessaging_wait_timeout_ms: int
upstream_ws_connect_error_settle_timeout_ms: int


class ModCDPInjectorConfig(TypedDict, total=False):
injector_mode: Literal["auto", "discover", "inject", "borrow", "none"]
injector_extension_path: str | None
injector_extension_id: str | None
injector_service_worker_url_includes: list[str]
injector_service_worker_url_suffixes: list[str]
injector_trust_service_worker_target: bool
injector_require_service_worker_target: bool
injector_service_worker_ready_expression: str | None
injector_execution_context_timeout_ms: int
injector_service_worker_probe_timeout_ms: int
injector_service_worker_ready_timeout_ms: int
injector_service_worker_poll_interval_ms: int
injector_target_session_poll_interval_ms: int


class ModCDPClientConfig(TypedDict, total=False):
client_routes: ModCDPRoutes
client_hydrate_aliases: bool
client_mirror_upstream_events: bool
client_cdp_send_timeout_ms: int
client_event_wait_timeout_ms: int
client_heartbeat_interval_ms: int


class ModCDPConnectTiming(TypedDict):
started_at: int
upstream_mode: str | None
Expand Down
Loading