mendwright 0.3.0__py3-none-any.whl

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 (49) hide show
  1. mendwright/__init__.py +92 -0
  2. mendwright/__main__.py +6 -0
  3. mendwright/aio.py +686 -0
  4. mendwright/capture.py +162 -0
  5. mendwright/cli.py +689 -0
  6. mendwright/client.py +216 -0
  7. mendwright/coordinator.py +289 -0
  8. mendwright/demo/__init__.py +35 -0
  9. mendwright/demo/_page.py +171 -0
  10. mendwright/demo/_story.py +470 -0
  11. mendwright/demo/v1.html +29 -0
  12. mendwright/demo/v2.html +33 -0
  13. mendwright/drivers/__init__.py +25 -0
  14. mendwright/drivers/base.py +316 -0
  15. mendwright/drivers/playwright_async.py +148 -0
  16. mendwright/drivers/playwright_sync.py +193 -0
  17. mendwright/drivers/registry.py +37 -0
  18. mendwright/drivers/selenium.py +596 -0
  19. mendwright/exceptions.py +10 -0
  20. mendwright/facade.py +783 -0
  21. mendwright/gate.py +62 -0
  22. mendwright/journal.py +180 -0
  23. mendwright/limits.py +236 -0
  24. mendwright/prompt.py +67 -0
  25. mendwright/providers/__init__.py +24 -0
  26. mendwright/providers/_errors.py +376 -0
  27. mendwright/providers/anthropic.py +177 -0
  28. mendwright/providers/base.py +25 -0
  29. mendwright/providers/bedrock.py +126 -0
  30. mendwright/providers/detect.py +170 -0
  31. mendwright/providers/gateway.py +69 -0
  32. mendwright/providers/gemini.py +171 -0
  33. mendwright/providers/litellm.py +176 -0
  34. mendwright/providers/openai_compat.py +255 -0
  35. mendwright/publish.py +74 -0
  36. mendwright/py.typed +0 -0
  37. mendwright/pytest_plugin.py +505 -0
  38. mendwright/resolver.py +133 -0
  39. mendwright/roles.py +232 -0
  40. mendwright/selectors.py +181 -0
  41. mendwright/store.py +722 -0
  42. mendwright/types.py +56 -0
  43. mendwright/validation.py +98 -0
  44. mendwright-0.3.0.dist-info/METADATA +282 -0
  45. mendwright-0.3.0.dist-info/RECORD +49 -0
  46. mendwright-0.3.0.dist-info/WHEEL +5 -0
  47. mendwright-0.3.0.dist-info/entry_points.txt +5 -0
  48. mendwright-0.3.0.dist-info/licenses/LICENSE +21 -0
  49. mendwright-0.3.0.dist-info/top_level.txt +1 -0
mendwright/__init__.py ADDED
@@ -0,0 +1,92 @@
1
+ """mendwright: repair broken selectors in Playwright and Selenium scripts while they run.
2
+
3
+ When a selector stops matching, a model provider suggests a new XPath. mendwright checks
4
+ it against the captured HTML and the live page before saving it, then retries the step.
5
+ A key you mark as destructive (a pay, submit or delete control) is never healed.
6
+
7
+ The pipeline: resolve the candidate selectors (resolver) -> when none matches, capture a
8
+ redacted page bundle (capture) -> ask a provider for a fix (providers, prompt) -> check it
9
+ against the captured HTML and the live page (validation, gate) -> save it to the writable
10
+ override store (store) and retry the same step (coordinator) -> optionally publish
11
+ confirmed fixes to a seed file (publish).
12
+
13
+ Two extension points. Drivers (drivers/) talk to a browser library and are chosen by the
14
+ methods the page object has, not its module: sync Playwright (also camoufox and
15
+ patchright), async Playwright through mendwright.aio, and Selenium are built in, and
16
+ `register_driver` adds your own. Providers (providers/) talk to a model: mendwright.open()
17
+ picks one from the environment with auto_provider(), and GatewayProvider keeps the model
18
+ key on a server. The gateway URL, auth header, destructive keys, HTML and inventory
19
+ sources and the transaction guard are all passed in, never hardcoded.
20
+ """
21
+
22
+ # mendwright logs to the 'mendwright' logger and adds no handler of its own. A heal that
23
+ # is applied or declined is a WARNING, so with no logging configured Python's last-resort
24
+ # handler prints that one line to stderr: a heal is never silent. Configure logging (for
25
+ # example logging.basicConfig(level=logging.INFO)) to format or route it, or raise the
26
+ # level (logging.getLogger('mendwright').setLevel(logging.ERROR)) to hide it.
27
+
28
+ from .capture import build_bundle, redact
29
+ from .client import DEFAULT_AUTH_HEADER, apply, report_outcome, request_heal
30
+ from .coordinator import HealCoordinator, resolve_with_heal
31
+ from .exceptions import AttentionRequired
32
+ from .publish import publish, republish_bundle
33
+ from .resolver import present, resolve
34
+ from .selectors import InvalidSelector
35
+ from .store import (
36
+ SelectorStore,
37
+ infer_role,
38
+ load_store,
39
+ merge,
40
+ migrate_schema1,
41
+ )
42
+ from .validation import Result, validate
43
+ from .drivers import (
44
+ Driver,
45
+ PlaywrightSyncDriver,
46
+ SeleniumDriver,
47
+ register_driver,
48
+ register_driver_front,
49
+ wrap,
50
+ )
51
+ from .providers import (
52
+ AnthropicProvider,
53
+ BedrockProvider,
54
+ GatewayProvider,
55
+ GeminiProvider,
56
+ HealProvider,
57
+ LiteLLMProvider,
58
+ OpenAICompatibleProvider,
59
+ auto_provider,
60
+ )
61
+ from .facade import HealEvent, Healer, open # noqa: A004 (mendwright.open is the zero-config entry)
62
+ from . import aio # noqa: E402,F401 (async Playwright: await mendwright.aio.open(page))
63
+
64
+ # 'open' is left out on purpose: `from mendwright import *` must not shadow builtins.open.
65
+ # Call it as mendwright.open(page).
66
+ __all__ = [
67
+ 'AttentionRequired', 'InvalidSelector',
68
+ 'Driver', 'PlaywrightSyncDriver', 'SeleniumDriver', 'wrap', 'register_driver', 'register_driver_front',
69
+ 'HealProvider', 'GatewayProvider', 'AnthropicProvider', 'OpenAICompatibleProvider',
70
+ 'GeminiProvider', 'BedrockProvider', 'LiteLLMProvider', 'auto_provider',
71
+ 'Healer', 'HealEvent',
72
+ 'SelectorStore', 'load_store', 'merge', 'migrate_schema1', 'infer_role',
73
+ 'validate', 'Result',
74
+ 'build_bundle', 'redact',
75
+ 'request_heal', 'apply', 'report_outcome', 'DEFAULT_AUTH_HEADER',
76
+ 'HealCoordinator', 'resolve_with_heal',
77
+ 'resolve', 'present',
78
+ 'publish', 'republish_bundle',
79
+ ]
80
+
81
+ # Single source of truth is pyproject's [project].version; read it from the installed
82
+ # distribution metadata so this constant never drifts. The literal fallback (kept in sync
83
+ # with pyproject, and pinned by tests/test_version.py) covers running straight from a source
84
+ # tree that was never installed.
85
+ try:
86
+ from importlib.metadata import PackageNotFoundError, version as _dist_version
87
+ try:
88
+ __version__ = _dist_version('mendwright')
89
+ except PackageNotFoundError:
90
+ __version__ = '0.3.0'
91
+ except Exception: # pragma: no cover - importlib.metadata is stdlib on 3.10+
92
+ __version__ = '0.3.0'
mendwright/__main__.py ADDED
@@ -0,0 +1,6 @@
1
+ """python -m mendwright: the same command line as `mendwright`."""
2
+
3
+ from .cli import main
4
+
5
+ if __name__ == '__main__':
6
+ raise SystemExit(main())