semantic-browser 1.0.0__tar.gz

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 (106) hide show
  1. semantic_browser-1.0.0/.github/workflows/ci.yml +38 -0
  2. semantic_browser-1.0.0/.gitignore +79 -0
  3. semantic_browser-1.0.0/CHANGELOG.md +63 -0
  4. semantic_browser-1.0.0/CONTRIBUTING.md +25 -0
  5. semantic_browser-1.0.0/LICENSE +21 -0
  6. semantic_browser-1.0.0/PKG-INFO +247 -0
  7. semantic_browser-1.0.0/README.md +218 -0
  8. semantic_browser-1.0.0/SECURITY.md +22 -0
  9. semantic_browser-1.0.0/benchmarks/manifest.json +25 -0
  10. semantic_browser-1.0.0/corpus/sites.yaml +44 -0
  11. semantic_browser-1.0.0/docs/benchmark_protocol.md +29 -0
  12. semantic_browser-1.0.0/docs/getting_started.md +93 -0
  13. semantic_browser-1.0.0/docs/publishing.md +57 -0
  14. semantic_browser-1.0.0/docs/real_profiles.md +54 -0
  15. semantic_browser-1.0.0/docs/versioning.md +40 -0
  16. semantic_browser-1.0.0/pyproject.toml +70 -0
  17. semantic_browser-1.0.0/scripts/actionset_benchmark.py +1145 -0
  18. semantic_browser-1.0.0/scripts/task_harness.py +1168 -0
  19. semantic_browser-1.0.0/src/semantic_browser/__init__.py +18 -0
  20. semantic_browser-1.0.0/src/semantic_browser/browser_manager.py +128 -0
  21. semantic_browser-1.0.0/src/semantic_browser/cli/__init__.py +1 -0
  22. semantic_browser-1.0.0/src/semantic_browser/cli/commands.py +322 -0
  23. semantic_browser-1.0.0/src/semantic_browser/cli/main.py +55 -0
  24. semantic_browser-1.0.0/src/semantic_browser/config.py +56 -0
  25. semantic_browser-1.0.0/src/semantic_browser/corpus/__init__.py +1 -0
  26. semantic_browser-1.0.0/src/semantic_browser/corpus/fixtures.py +18 -0
  27. semantic_browser-1.0.0/src/semantic_browser/corpus/metrics.py +58 -0
  28. semantic_browser-1.0.0/src/semantic_browser/corpus/runner.py +18 -0
  29. semantic_browser-1.0.0/src/semantic_browser/corpus/tasks.py +38 -0
  30. semantic_browser-1.0.0/src/semantic_browser/errors.py +41 -0
  31. semantic_browser-1.0.0/src/semantic_browser/executor/__init__.py +1 -0
  32. semantic_browser-1.0.0/src/semantic_browser/executor/actions.py +155 -0
  33. semantic_browser-1.0.0/src/semantic_browser/executor/resolver.py +43 -0
  34. semantic_browser-1.0.0/src/semantic_browser/executor/results.py +62 -0
  35. semantic_browser-1.0.0/src/semantic_browser/executor/validation.py +31 -0
  36. semantic_browser-1.0.0/src/semantic_browser/extractor/__init__.py +1 -0
  37. semantic_browser-1.0.0/src/semantic_browser/extractor/ax_snapshot.py +11 -0
  38. semantic_browser-1.0.0/src/semantic_browser/extractor/blockers.py +73 -0
  39. semantic_browser-1.0.0/src/semantic_browser/extractor/classifier.py +19 -0
  40. semantic_browser-1.0.0/src/semantic_browser/extractor/diff.py +163 -0
  41. semantic_browser-1.0.0/src/semantic_browser/extractor/dom_snapshot.py +16 -0
  42. semantic_browser-1.0.0/src/semantic_browser/extractor/engine.py +552 -0
  43. semantic_browser-1.0.0/src/semantic_browser/extractor/grouping.py +121 -0
  44. semantic_browser-1.0.0/src/semantic_browser/extractor/ids.py +34 -0
  45. semantic_browser-1.0.0/src/semantic_browser/extractor/labels.py +9 -0
  46. semantic_browser-1.0.0/src/semantic_browser/extractor/page_state.py +45 -0
  47. semantic_browser-1.0.0/src/semantic_browser/extractor/redaction.py +25 -0
  48. semantic_browser-1.0.0/src/semantic_browser/extractor/semantics.py +133 -0
  49. semantic_browser-1.0.0/src/semantic_browser/extractor/settle.py +183 -0
  50. semantic_browser-1.0.0/src/semantic_browser/extractor/visibility.py +7 -0
  51. semantic_browser-1.0.0/src/semantic_browser/models.py +229 -0
  52. semantic_browser-1.0.0/src/semantic_browser/profiles/__init__.py +1 -0
  53. semantic_browser-1.0.0/src/semantic_browser/profiles/base.py +14 -0
  54. semantic_browser-1.0.0/src/semantic_browser/profiles/common_patterns.py +2 -0
  55. semantic_browser-1.0.0/src/semantic_browser/profiles/generic.py +3 -0
  56. semantic_browser-1.0.0/src/semantic_browser/profiles/registry.py +17 -0
  57. semantic_browser-1.0.0/src/semantic_browser/runtime.py +610 -0
  58. semantic_browser-1.0.0/src/semantic_browser/service/__init__.py +1 -0
  59. semantic_browser-1.0.0/src/semantic_browser/service/routes.py +134 -0
  60. semantic_browser-1.0.0/src/semantic_browser/service/schemas.py +40 -0
  61. semantic_browser-1.0.0/src/semantic_browser/service/server.py +34 -0
  62. semantic_browser-1.0.0/src/semantic_browser/service/settings.py +29 -0
  63. semantic_browser-1.0.0/src/semantic_browser/service/state.py +88 -0
  64. semantic_browser-1.0.0/src/semantic_browser/session.py +58 -0
  65. semantic_browser-1.0.0/src/semantic_browser/telemetry/__init__.py +1 -0
  66. semantic_browser-1.0.0/src/semantic_browser/telemetry/debug_dump.py +34 -0
  67. semantic_browser-1.0.0/src/semantic_browser/telemetry/replay.py +5 -0
  68. semantic_browser-1.0.0/src/semantic_browser/telemetry/trace.py +22 -0
  69. semantic_browser-1.0.0/tests/conftest.py +12 -0
  70. semantic_browser-1.0.0/tests/e2e/test_cli.py +112 -0
  71. semantic_browser-1.0.0/tests/e2e/test_service.py +187 -0
  72. semantic_browser-1.0.0/tests/integration/test_action_edge_cases.py +48 -0
  73. semantic_browser-1.0.0/tests/integration/test_blockers_unreliability.py +38 -0
  74. semantic_browser-1.0.0/tests/integration/test_cdp_attach.py +6 -0
  75. semantic_browser-1.0.0/tests/integration/test_delta_metrics.py +32 -0
  76. semantic_browser-1.0.0/tests/integration/test_delta_size.py +22 -0
  77. semantic_browser-1.0.0/tests/integration/test_google_workflow.py +27 -0
  78. semantic_browser-1.0.0/tests/integration/test_grouping_real_sites.py +31 -0
  79. semantic_browser-1.0.0/tests/integration/test_id_persistence.py +20 -0
  80. semantic_browser-1.0.0/tests/integration/test_inspect_details.py +27 -0
  81. semantic_browser-1.0.0/tests/integration/test_managed_runtime.py +30 -0
  82. semantic_browser-1.0.0/tests/integration/test_observe_sites.py +28 -0
  83. semantic_browser-1.0.0/tests/unit/test_actions_semantics.py +79 -0
  84. semantic_browser-1.0.0/tests/unit/test_blockers.py +14 -0
  85. semantic_browser-1.0.0/tests/unit/test_browser_manager.py +36 -0
  86. semantic_browser-1.0.0/tests/unit/test_corpus_metrics.py +15 -0
  87. semantic_browser-1.0.0/tests/unit/test_debug_dump.py +21 -0
  88. semantic_browser-1.0.0/tests/unit/test_delta_semantic_depth.py +59 -0
  89. semantic_browser-1.0.0/tests/unit/test_diff.py +50 -0
  90. semantic_browser-1.0.0/tests/unit/test_extractors_smoke.py +65 -0
  91. semantic_browser-1.0.0/tests/unit/test_grouping.py +20 -0
  92. semantic_browser-1.0.0/tests/unit/test_ids.py +14 -0
  93. semantic_browser-1.0.0/tests/unit/test_models.py +25 -0
  94. semantic_browser-1.0.0/tests/unit/test_profile_modes.py +25 -0
  95. semantic_browser-1.0.0/tests/unit/test_redaction.py +12 -0
  96. semantic_browser-1.0.0/tests/unit/test_resolver.py +47 -0
  97. semantic_browser-1.0.0/tests/unit/test_results.py +44 -0
  98. semantic_browser-1.0.0/tests/unit/test_runtime_attach_selection.py +37 -0
  99. semantic_browser-1.0.0/tests/unit/test_runtime_cdp_endpoint_validation.py +86 -0
  100. semantic_browser-1.0.0/tests/unit/test_runtime_ownership.py +62 -0
  101. semantic_browser-1.0.0/tests/unit/test_runtime_smoke.py +200 -0
  102. semantic_browser-1.0.0/tests/unit/test_service_state.py +30 -0
  103. semantic_browser-1.0.0/tests/unit/test_settle_layers.py +35 -0
  104. semantic_browser-1.0.0/tests/unit/test_validation.py +53 -0
  105. semantic_browser-1.0.0/tools/next_version.py +65 -0
  106. semantic_browser-1.0.0/tools/validate_benchmark_manifest.py +36 -0
@@ -0,0 +1,38 @@
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches: [main]
7
+
8
+ jobs:
9
+ quality:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Checkout
13
+ uses: actions/checkout@v4
14
+
15
+ - name: Set up Python
16
+ uses: actions/setup-python@v5
17
+ with:
18
+ python-version: "3.11"
19
+
20
+ - name: Install dependencies
21
+ run: |
22
+ python -m pip install --upgrade pip
23
+ pip install -e ".[full]"
24
+
25
+ - name: Lint
26
+ run: ruff check src tests --select F,B
27
+
28
+ - name: Type check
29
+ run: mypy src
30
+
31
+ - name: Unit, integration, and e2e tests
32
+ run: pytest tests/unit tests/integration tests/e2e
33
+
34
+ - name: Validate benchmark metadata
35
+ run: python tools/validate_benchmark_manifest.py
36
+
37
+ - name: Dependency audit
38
+ run: pip-audit
@@ -0,0 +1,79 @@
1
+ # Python caches and artifacts
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.pyo
5
+ *.pyd
6
+ *.so
7
+ .Python
8
+ .pytest_cache/
9
+ .mypy_cache/
10
+ .ruff_cache/
11
+ .coverage
12
+ htmlcov/
13
+
14
+ # Virtual environments
15
+ .venv/
16
+ venv/
17
+ env/
18
+
19
+ # Local secrets / credentials
20
+ .env
21
+ .env.*
22
+ !.env.example
23
+ *.pem
24
+ *.key
25
+ credentials*.json
26
+ secrets*.json
27
+ *password*
28
+
29
+ # Build outputs
30
+ build/
31
+ dist/
32
+ *.egg-info/
33
+ pip-wheel-metadata/
34
+
35
+ # IDE / OS
36
+ .DS_Store
37
+ .idea/
38
+ .vscode/
39
+
40
+ # Runtime traces and local outputs
41
+ *.trace.json
42
+ *-trace.json
43
+ dogfood-trace.json
44
+ porthole-validation-trace.json
45
+ trace-*.json
46
+ *dump*.json
47
+ *debug*.json
48
+ *.log
49
+ corpus-report.json
50
+
51
+ # Benchmark/test-run generated artefacts
52
+ benchmark-outputs/
53
+ benchmark-results/
54
+ benchmark-runs/
55
+ benchmarks/raw/
56
+ benchmarks/tmp/
57
+
58
+ # Local benchmark scratch + journals (keep canonical benchmark docs manually)
59
+ docs/benchmarks/
60
+ docs/benchmarks/journals/
61
+ docs/benchmarks/tmp/
62
+ docs/benchmarks/scratch/
63
+ docs/harness/journals/
64
+ docs/harness/*.json
65
+ docs/harness/*.md
66
+
67
+ # Browser/test harness leftovers
68
+ playwright-report/
69
+ test-results/
70
+ *.har
71
+ *.webm
72
+
73
+ # CLI/agent transient outputs
74
+ .codex/
75
+ .tmp/
76
+ scripts/docs/
77
+ *.pid
78
+ *.tmp
79
+ *.bak
@@ -0,0 +1,63 @@
1
+ # Changelog
2
+
3
+ ## 1.1.0
4
+
5
+ - Added explicit runtime ownership modes:
6
+ - `owned_ephemeral`
7
+ - `owned_persistent_profile`
8
+ - `attached_context`
9
+ - `attached_cdp`
10
+ - Refactored close lifecycle semantics:
11
+ - non-destructive `close()` defaults for attached modes
12
+ - explicit `force_close_browser()` override
13
+ - Promoted profile handling to first-class launch API:
14
+ - `profile_mode` (`persistent|clone|ephemeral`)
15
+ - `profile_dir`
16
+ - `storage_state_path`
17
+ - profile health diagnostics (lock/writable/version warnings)
18
+ - Expanded delta semantics with materiality scoring:
19
+ - interaction/content/workflow/reliability/classification transitions
20
+ - `delta.materiality = minor|moderate|major`
21
+ - Hardened settle loop and tracing:
22
+ - layered settle phases with instability classification
23
+ - enriched trace payloads (effect, evidence, URL history, tab creation)
24
+ - Added docs for real profile workflows:
25
+ - `docs/real_profiles.md`
26
+ - updated `README.md` and `docs/getting_started.md`
27
+ - Expanded test coverage and CI gate to include integration tests.
28
+
29
+ ## 1.0.0 (Alpha) - 2026-03-12
30
+
31
+ - First open-source alpha release.
32
+ - Repository cleaned for third-party consumption:
33
+ - removed internal planning/working docs
34
+ - removed tracked bytecode artifacts
35
+ - removed internal benchmark journals and snapshots
36
+ - Hardened service defaults:
37
+ - optional token auth
38
+ - localhost-focused CORS defaults
39
+ - session TTL cleanup
40
+ - Improved runtime reliability and observability:
41
+ - frame-aware extraction path
42
+ - stable action/element ID behavior improvements
43
+ - structured action/observe trace timing and warning events
44
+ - trace export redaction of sensitive values
45
+ - Added release and community docs:
46
+ - `docs/versioning.md`
47
+ - `docs/publishing.md`
48
+ - `CONTRIBUTING.md`
49
+ - `SECURITY.md`
50
+
51
+ ## 0.1.0 - 2026-03-10
52
+
53
+ - Initial end-to-end implementation:
54
+ - Managed + attached runtime modes
55
+ - Deterministic extraction engine
56
+ - Action execution pipeline with validation
57
+ - Stable ID matching and delta generation
58
+ - Optional FastAPI local service
59
+ - CLI for launch/attach/observe/act/inspect + portal interaction loop
60
+ - Global runtime operations (`navigate`, `back`, `forward`, `reload`, `wait`)
61
+ - Corpus harness baseline (`eval-corpus`) with YAML fixtures and scoring
62
+ - Telemetry + debug trace export
63
+ - Initial test coverage for core functionality
@@ -0,0 +1,25 @@
1
+ # Contributing
2
+
3
+ Thanks for contributing to Semantic Browser.
4
+
5
+ ## Development setup
6
+
7
+ ```bash
8
+ pip install -e ".[full]"
9
+ semantic-browser install-browser
10
+ ```
11
+
12
+ ## Local quality checks
13
+
14
+ ```bash
15
+ ruff check src tests --select F,B
16
+ mypy src
17
+ pytest tests/unit tests/e2e
18
+ ```
19
+
20
+ ## Pull request expectations
21
+
22
+ - Keep changes focused and well-scoped.
23
+ - Add or update tests for behavior changes.
24
+ - Update docs when user-facing behavior changes.
25
+ - Do not commit secrets or local trace artifacts.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Matt Visser
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,247 @@
1
+ Metadata-Version: 2.4
2
+ Name: semantic-browser
3
+ Version: 1.0.0
4
+ Summary: Deterministic semantic runtime over live Chromium for LLM planners
5
+ Author: Matt Visser
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.11
9
+ Requires-Dist: click>=8.1.7
10
+ Requires-Dist: pydantic>=2.8.0
11
+ Requires-Dist: pyyaml>=6.0.2
12
+ Provides-Extra: full
13
+ Requires-Dist: fastapi>=0.116.0; extra == 'full'
14
+ Requires-Dist: httpx>=0.28.0; extra == 'full'
15
+ Requires-Dist: mypy>=1.11.0; extra == 'full'
16
+ Requires-Dist: pip-audit>=2.7.0; extra == 'full'
17
+ Requires-Dist: playwright>=1.52.0; extra == 'full'
18
+ Requires-Dist: pytest-asyncio>=0.24.0; extra == 'full'
19
+ Requires-Dist: pytest-cov>=5.0.0; extra == 'full'
20
+ Requires-Dist: pytest>=8.3.0; extra == 'full'
21
+ Requires-Dist: ruff>=0.6.0; extra == 'full'
22
+ Requires-Dist: uvicorn>=0.35.0; extra == 'full'
23
+ Provides-Extra: managed
24
+ Requires-Dist: playwright>=1.52.0; extra == 'managed'
25
+ Provides-Extra: server
26
+ Requires-Dist: fastapi>=0.116.0; extra == 'server'
27
+ Requires-Dist: uvicorn>=0.35.0; extra == 'server'
28
+ Description-Content-Type: text/markdown
29
+
30
+ # Semantic Browser
31
+ <p align="left">
32
+ <img src="https://github.com/user-attachments/assets/dac79ee0-6ebb-48b3-a27d-2e339ea16961" alt="Semantic Browser mascot" width="240" align="right" />
33
+ </p>
34
+ Semantic Browser turns live Chromium pages into compact semantic "rooms" for LLM planners.
35
+
36
+ **Release:** [`v1.1.0` (Alpha)](https://github.com/visser23/semantic-browser/releases/tag/v1.1.0)
37
+ **Latest release tag format:** see `docs/versioning.md`
38
+
39
+ Make browser automation feel less like parsing soup and more like an old BBC Micro text adventure.
40
+
41
+ - Live page -> structured room state
42
+ - DOM distilled into meaningful objects, not soup
43
+ - Built for agentic browser automation
44
+ - Token-efficient, deterministic, inspectable
45
+
46
+ ```
47
+ @ BBC News (bbc.co.uk)
48
+ > Home page. Main content: "Top stories". Navigation: News, Sport, Weather.
49
+ 1 open "News" [act-8f2a2d1c-0]
50
+ 2 open "Sport" [act-c3e119fa-0]
51
+ 3 fill Search BBC [act-0b9411de-0] *value
52
+ + 28 more [more]
53
+ ```
54
+
55
+ The planner replies with one action ID and the runtime executes deterministically. This means less confusion, less hallucination and ultimately significantly less cost.
56
+
57
+ ## Why this is different (and why it now works)
58
+
59
+ Other browser tools give the LLM the same data in a different wrapper. Semantic Browser gives it a fundamentally different view.
60
+
61
+ - **Plain-text room descriptions** - prose, not JSON.
62
+ - **Curated actions first** - top 15 useful actions, then `more` if needed.
63
+ - **Progressive disclosure** - `more` gives full action list without flooding every step.
64
+ - **Tiny action replies** - action IDs, `nav`, `back`, `done`.
65
+ - **Narrative history** - readable previous steps, not noisy machine dump.
66
+ - **Guardrails for reality** - anti-repeat fallback, nav hardening, transient extract retry.
67
+ - **Honest failure mode** - if a site throws anti-bot gates, we say so and show evidence.
68
+
69
+ #### Cross-method comparator (shared 25-task pack)
70
+
71
+ | Method | Success rate | Failures | Median speed (ms) | Planner input median (billable) | Planner output median (billable) | Payload token-est median (estimated) | Total effective context median (estimated) | Median browser/runtime calls | Indicative planner cost/request (USD) |
72
+ |---|---|---:|---:|---:|---:|---:|---:|---:|---:|
73
+ | Standard browser tooling | 24% (6/25) | 19 | 11,819.8 | 10,118 | 74 | 6,918 | 17,224 | 6.0 | 0.041005 |
74
+ | OpenClaw browser tooling | 72% (18/25) | 7 | 10,514.2 | 6,833 | 66 | 5,219 | 12,078 | 6.0 | 0.022053 |
75
+ | Semantic Browser | 100% (25/25) | 0 | 9,353.3 | 540 | 14 | 310 | 879 | 5.0 | 0.004036 |
76
+
77
+ To put costs into context, at 5 complex browser tasks/day over a year (1,825 tasks), the estimated planner cost is about **$74.83/year** for the standard browser approach vs **$7.37/year** for Semantic Browser, a difference of about **$67.47/year**.
78
+
79
+ This is a dramatic jump in a reference harness run, not a universal guarantee.
80
+
81
+ The last anti-bot loop in this pack now has a robust recovery path:
82
+ - capture challenge evidence (screenshot),
83
+ - try direct same-origin query route,
84
+ - then use a public read-only fallback endpoint when the primary UI is hard-blocked.
85
+
86
+ 25 tasks across navigation, search, multi-step interaction, resilience, and speed.
87
+
88
+ If challenge/captcha is detected, the harness captures screenshot evidence and includes it in the LLM call.
89
+
90
+ Reproducibility artifacts:
91
+ - Protocol: `docs/benchmark_protocol.md`
92
+ - Manifest: `benchmarks/manifest.json`
93
+
94
+ ## Why Semantic Browser
95
+
96
+ - Semantic room output instead of DOM/JSON soup.
97
+ - Curated action surface for token-efficient planning.
98
+ - Deterministic action execution loop (`observe` -> `act` -> `observe delta`).
99
+ - Built-in blocker signaling and confidence reporting.
100
+ - Python API, CLI, and local service interfaces.
101
+
102
+ ## Install
103
+
104
+ ```bash
105
+ pip install semantic-browser
106
+ ```
107
+
108
+ Managed mode (recommended first run):
109
+
110
+ ```bash
111
+ pip install "semantic-browser[managed]"
112
+ semantic-browser install-browser
113
+ ```
114
+
115
+ Service mode:
116
+
117
+ ```bash
118
+ pip install "semantic-browser[server]"
119
+ ```
120
+
121
+ ## Quickstart
122
+
123
+ ```bash
124
+ semantic-browser portal --url https://example.com --headless
125
+ ```
126
+
127
+ Inside portal:
128
+
129
+ - `observe summary`
130
+ - `actions`
131
+ - `act <action_id>`
132
+ - `back` / `forward` / `reload`
133
+ - `trace run-trace.json`
134
+ - `quit`
135
+
136
+ More examples: `docs/getting_started.md`
137
+
138
+ ## Profile-Aware Runtime Modes
139
+
140
+ Persistent profiles are first-class in this release. Use them for serious long-running agent tasks where session continuity matters (SSO, cookies, extension state, trust signals).
141
+
142
+ - `profile_mode=ephemeral`: disposable context, best for stateless tasks.
143
+ - `profile_mode=persistent`: real reusable Chromium profile directory.
144
+ - `profile_mode=clone`: copy profile into temporary sandbox before run.
145
+
146
+ CLI launch examples:
147
+
148
+ ```bash
149
+ # Ephemeral (default)
150
+ semantic-browser launch --headless
151
+
152
+ # Persistent profile (recommended agent mode)
153
+ semantic-browser launch --headless --profile-mode persistent --profile-dir "/path/to/chrome-profile"
154
+
155
+ # Clone mode (safe experimentation)
156
+ semantic-browser launch --headless --profile-mode clone --profile-dir "/path/to/chrome-profile"
157
+ ```
158
+
159
+ Storage state can still be used in ephemeral mode:
160
+
161
+ ```bash
162
+ semantic-browser launch --headless --profile-mode ephemeral --storage-state-path state.json
163
+ ```
164
+
165
+ Note: storage state bootstrap is not equivalent to a real profile.
166
+
167
+ ## Breaking API Change (v1.1+)
168
+
169
+ Launch config no longer accepts `user_data_dir`.
170
+
171
+ - removed: `user_data_dir`
172
+ - added: `profile_mode`, `profile_dir`, `storage_state_path`
173
+
174
+ If you previously passed `user_data_dir` for storage state, migrate to `storage_state_path` in `ephemeral` mode.
175
+ If you intended a true browser profile, use `profile_mode=persistent` with `profile_dir`.
176
+
177
+ ## Python Usage
178
+
179
+ ```python
180
+ import asyncio
181
+ from semantic_browser import ManagedSession
182
+ from semantic_browser.models import ActionRequest
183
+
184
+ async def demo() -> None:
185
+ session = await ManagedSession.launch(headful=False)
186
+ runtime = session.runtime
187
+ await runtime.navigate("https://example.com")
188
+ obs = await runtime.observe(mode="summary")
189
+ first_open = next((a for a in obs.available_actions if a.op == "open"), None)
190
+ if first_open:
191
+ result = await runtime.act(ActionRequest(action_id=first_open.id))
192
+ print(result.status, result.observation.page.url)
193
+ await session.close()
194
+
195
+ asyncio.run(demo())
196
+ ```
197
+
198
+ ## CLI Reference
199
+
200
+ ```bash
201
+ semantic-browser version
202
+ semantic-browser doctor
203
+ semantic-browser install-browser
204
+ semantic-browser launch --headless
205
+ semantic-browser attach --cdp ws://127.0.0.1:9222/devtools/browser/<id>
206
+ semantic-browser observe --session <id> --mode summary
207
+ semantic-browser act --session <id> --action <action_id>
208
+ semantic-browser inspect --session <id> --target <target_id>
209
+ semantic-browser navigate --session <id> --url https://example.com
210
+ semantic-browser export-trace --session <id> --out trace.json
211
+ semantic-browser serve --host 127.0.0.1 --port 8765 --api-token dev-token
212
+ ```
213
+
214
+ ## Ownership and Attach Safety
215
+
216
+ Runtime sessions now carry explicit ownership semantics:
217
+
218
+ - `owned_ephemeral`: runtime may close browser/context/page.
219
+ - `owned_persistent_profile`: runtime closes browser process only; never deletes profile data.
220
+ - `attached_context`: runtime does not close external browser/context by default.
221
+ - `attached_cdp`: runtime does not close external Chrome by default.
222
+
223
+ If you explicitly want destructive close behavior in attached modes, use `force_close_browser()`.
224
+
225
+ ## Service Security Defaults
226
+
227
+ - Localhost-focused CORS defaults.
228
+ - Optional token auth via `SEMANTIC_BROWSER_API_TOKEN` / `X-API-Token`.
229
+ - Idle session TTL cleanup.
230
+
231
+ ## Benchmarks
232
+
233
+ Benchmark numbers are reference harness runs, not universal guarantees.
234
+
235
+ - Protocol: `docs/benchmark_protocol.md`
236
+ - Manifest: `benchmarks/manifest.json`
237
+
238
+ ## Open Source Docs
239
+
240
+ - `docs/getting_started.md`
241
+ - `docs/real_profiles.md`
242
+ - `docs/versioning.md`
243
+ - `docs/publishing.md`
244
+ - `CHANGELOG.md`
245
+ - `LICENSE`
246
+ - `CONTRIBUTING.md`
247
+ - `SECURITY.md`
@@ -0,0 +1,218 @@
1
+ # Semantic Browser
2
+ <p align="left">
3
+ <img src="https://github.com/user-attachments/assets/dac79ee0-6ebb-48b3-a27d-2e339ea16961" alt="Semantic Browser mascot" width="240" align="right" />
4
+ </p>
5
+ Semantic Browser turns live Chromium pages into compact semantic "rooms" for LLM planners.
6
+
7
+ **Release:** [`v1.1.0` (Alpha)](https://github.com/visser23/semantic-browser/releases/tag/v1.1.0)
8
+ **Latest release tag format:** see `docs/versioning.md`
9
+
10
+ Make browser automation feel less like parsing soup and more like an old BBC Micro text adventure.
11
+
12
+ - Live page -> structured room state
13
+ - DOM distilled into meaningful objects, not soup
14
+ - Built for agentic browser automation
15
+ - Token-efficient, deterministic, inspectable
16
+
17
+ ```
18
+ @ BBC News (bbc.co.uk)
19
+ > Home page. Main content: "Top stories". Navigation: News, Sport, Weather.
20
+ 1 open "News" [act-8f2a2d1c-0]
21
+ 2 open "Sport" [act-c3e119fa-0]
22
+ 3 fill Search BBC [act-0b9411de-0] *value
23
+ + 28 more [more]
24
+ ```
25
+
26
+ The planner replies with one action ID and the runtime executes deterministically. This means less confusion, less hallucination and ultimately significantly less cost.
27
+
28
+ ## Why this is different (and why it now works)
29
+
30
+ Other browser tools give the LLM the same data in a different wrapper. Semantic Browser gives it a fundamentally different view.
31
+
32
+ - **Plain-text room descriptions** - prose, not JSON.
33
+ - **Curated actions first** - top 15 useful actions, then `more` if needed.
34
+ - **Progressive disclosure** - `more` gives full action list without flooding every step.
35
+ - **Tiny action replies** - action IDs, `nav`, `back`, `done`.
36
+ - **Narrative history** - readable previous steps, not noisy machine dump.
37
+ - **Guardrails for reality** - anti-repeat fallback, nav hardening, transient extract retry.
38
+ - **Honest failure mode** - if a site throws anti-bot gates, we say so and show evidence.
39
+
40
+ #### Cross-method comparator (shared 25-task pack)
41
+
42
+ | Method | Success rate | Failures | Median speed (ms) | Planner input median (billable) | Planner output median (billable) | Payload token-est median (estimated) | Total effective context median (estimated) | Median browser/runtime calls | Indicative planner cost/request (USD) |
43
+ |---|---|---:|---:|---:|---:|---:|---:|---:|---:|
44
+ | Standard browser tooling | 24% (6/25) | 19 | 11,819.8 | 10,118 | 74 | 6,918 | 17,224 | 6.0 | 0.041005 |
45
+ | OpenClaw browser tooling | 72% (18/25) | 7 | 10,514.2 | 6,833 | 66 | 5,219 | 12,078 | 6.0 | 0.022053 |
46
+ | Semantic Browser | 100% (25/25) | 0 | 9,353.3 | 540 | 14 | 310 | 879 | 5.0 | 0.004036 |
47
+
48
+ To put costs into context, at 5 complex browser tasks/day over a year (1,825 tasks), the estimated planner cost is about **$74.83/year** for the standard browser approach vs **$7.37/year** for Semantic Browser, a difference of about **$67.47/year**.
49
+
50
+ This is a dramatic jump in a reference harness run, not a universal guarantee.
51
+
52
+ The last anti-bot loop in this pack now has a robust recovery path:
53
+ - capture challenge evidence (screenshot),
54
+ - try direct same-origin query route,
55
+ - then use a public read-only fallback endpoint when the primary UI is hard-blocked.
56
+
57
+ 25 tasks across navigation, search, multi-step interaction, resilience, and speed.
58
+
59
+ If challenge/captcha is detected, the harness captures screenshot evidence and includes it in the LLM call.
60
+
61
+ Reproducibility artifacts:
62
+ - Protocol: `docs/benchmark_protocol.md`
63
+ - Manifest: `benchmarks/manifest.json`
64
+
65
+ ## Why Semantic Browser
66
+
67
+ - Semantic room output instead of DOM/JSON soup.
68
+ - Curated action surface for token-efficient planning.
69
+ - Deterministic action execution loop (`observe` -> `act` -> `observe delta`).
70
+ - Built-in blocker signaling and confidence reporting.
71
+ - Python API, CLI, and local service interfaces.
72
+
73
+ ## Install
74
+
75
+ ```bash
76
+ pip install semantic-browser
77
+ ```
78
+
79
+ Managed mode (recommended first run):
80
+
81
+ ```bash
82
+ pip install "semantic-browser[managed]"
83
+ semantic-browser install-browser
84
+ ```
85
+
86
+ Service mode:
87
+
88
+ ```bash
89
+ pip install "semantic-browser[server]"
90
+ ```
91
+
92
+ ## Quickstart
93
+
94
+ ```bash
95
+ semantic-browser portal --url https://example.com --headless
96
+ ```
97
+
98
+ Inside portal:
99
+
100
+ - `observe summary`
101
+ - `actions`
102
+ - `act <action_id>`
103
+ - `back` / `forward` / `reload`
104
+ - `trace run-trace.json`
105
+ - `quit`
106
+
107
+ More examples: `docs/getting_started.md`
108
+
109
+ ## Profile-Aware Runtime Modes
110
+
111
+ Persistent profiles are first-class in this release. Use them for serious long-running agent tasks where session continuity matters (SSO, cookies, extension state, trust signals).
112
+
113
+ - `profile_mode=ephemeral`: disposable context, best for stateless tasks.
114
+ - `profile_mode=persistent`: real reusable Chromium profile directory.
115
+ - `profile_mode=clone`: copy profile into temporary sandbox before run.
116
+
117
+ CLI launch examples:
118
+
119
+ ```bash
120
+ # Ephemeral (default)
121
+ semantic-browser launch --headless
122
+
123
+ # Persistent profile (recommended agent mode)
124
+ semantic-browser launch --headless --profile-mode persistent --profile-dir "/path/to/chrome-profile"
125
+
126
+ # Clone mode (safe experimentation)
127
+ semantic-browser launch --headless --profile-mode clone --profile-dir "/path/to/chrome-profile"
128
+ ```
129
+
130
+ Storage state can still be used in ephemeral mode:
131
+
132
+ ```bash
133
+ semantic-browser launch --headless --profile-mode ephemeral --storage-state-path state.json
134
+ ```
135
+
136
+ Note: storage state bootstrap is not equivalent to a real profile.
137
+
138
+ ## Breaking API Change (v1.1+)
139
+
140
+ Launch config no longer accepts `user_data_dir`.
141
+
142
+ - removed: `user_data_dir`
143
+ - added: `profile_mode`, `profile_dir`, `storage_state_path`
144
+
145
+ If you previously passed `user_data_dir` for storage state, migrate to `storage_state_path` in `ephemeral` mode.
146
+ If you intended a true browser profile, use `profile_mode=persistent` with `profile_dir`.
147
+
148
+ ## Python Usage
149
+
150
+ ```python
151
+ import asyncio
152
+ from semantic_browser import ManagedSession
153
+ from semantic_browser.models import ActionRequest
154
+
155
+ async def demo() -> None:
156
+ session = await ManagedSession.launch(headful=False)
157
+ runtime = session.runtime
158
+ await runtime.navigate("https://example.com")
159
+ obs = await runtime.observe(mode="summary")
160
+ first_open = next((a for a in obs.available_actions if a.op == "open"), None)
161
+ if first_open:
162
+ result = await runtime.act(ActionRequest(action_id=first_open.id))
163
+ print(result.status, result.observation.page.url)
164
+ await session.close()
165
+
166
+ asyncio.run(demo())
167
+ ```
168
+
169
+ ## CLI Reference
170
+
171
+ ```bash
172
+ semantic-browser version
173
+ semantic-browser doctor
174
+ semantic-browser install-browser
175
+ semantic-browser launch --headless
176
+ semantic-browser attach --cdp ws://127.0.0.1:9222/devtools/browser/<id>
177
+ semantic-browser observe --session <id> --mode summary
178
+ semantic-browser act --session <id> --action <action_id>
179
+ semantic-browser inspect --session <id> --target <target_id>
180
+ semantic-browser navigate --session <id> --url https://example.com
181
+ semantic-browser export-trace --session <id> --out trace.json
182
+ semantic-browser serve --host 127.0.0.1 --port 8765 --api-token dev-token
183
+ ```
184
+
185
+ ## Ownership and Attach Safety
186
+
187
+ Runtime sessions now carry explicit ownership semantics:
188
+
189
+ - `owned_ephemeral`: runtime may close browser/context/page.
190
+ - `owned_persistent_profile`: runtime closes browser process only; never deletes profile data.
191
+ - `attached_context`: runtime does not close external browser/context by default.
192
+ - `attached_cdp`: runtime does not close external Chrome by default.
193
+
194
+ If you explicitly want destructive close behavior in attached modes, use `force_close_browser()`.
195
+
196
+ ## Service Security Defaults
197
+
198
+ - Localhost-focused CORS defaults.
199
+ - Optional token auth via `SEMANTIC_BROWSER_API_TOKEN` / `X-API-Token`.
200
+ - Idle session TTL cleanup.
201
+
202
+ ## Benchmarks
203
+
204
+ Benchmark numbers are reference harness runs, not universal guarantees.
205
+
206
+ - Protocol: `docs/benchmark_protocol.md`
207
+ - Manifest: `benchmarks/manifest.json`
208
+
209
+ ## Open Source Docs
210
+
211
+ - `docs/getting_started.md`
212
+ - `docs/real_profiles.md`
213
+ - `docs/versioning.md`
214
+ - `docs/publishing.md`
215
+ - `CHANGELOG.md`
216
+ - `LICENSE`
217
+ - `CONTRIBUTING.md`
218
+ - `SECURITY.md`