scoperail 0.3.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 (61) hide show
  1. scoperail-0.3.0/LICENSE +201 -0
  2. scoperail-0.3.0/PKG-INFO +149 -0
  3. scoperail-0.3.0/README.md +110 -0
  4. scoperail-0.3.0/bridge/__init__.py +8 -0
  5. scoperail-0.3.0/bridge/__main__.py +110 -0
  6. scoperail-0.3.0/bridge/admin.py +156 -0
  7. scoperail-0.3.0/bridge/agent_outcomes.py +156 -0
  8. scoperail-0.3.0/bridge/agents.py +838 -0
  9. scoperail-0.3.0/bridge/audit_export.py +242 -0
  10. scoperail-0.3.0/bridge/auth.py +336 -0
  11. scoperail-0.3.0/bridge/browser.py +704 -0
  12. scoperail-0.3.0/bridge/browser_broker.py +122 -0
  13. scoperail-0.3.0/bridge/coding.py +421 -0
  14. scoperail-0.3.0/bridge/config.py +173 -0
  15. scoperail-0.3.0/bridge/db.py +95 -0
  16. scoperail-0.3.0/bridge/desktop.py +245 -0
  17. scoperail-0.3.0/bridge/execution_review.py +291 -0
  18. scoperail-0.3.0/bridge/files.py +537 -0
  19. scoperail-0.3.0/bridge/gitops.py +120 -0
  20. scoperail-0.3.0/bridge/homelab.py +289 -0
  21. scoperail-0.3.0/bridge/humanize.py +188 -0
  22. scoperail-0.3.0/bridge/jobs.py +489 -0
  23. scoperail-0.3.0/bridge/outline.py +132 -0
  24. scoperail-0.3.0/bridge/pipelines.py +309 -0
  25. scoperail-0.3.0/bridge/policy.py +296 -0
  26. scoperail-0.3.0/bridge/public_cli.py +142 -0
  27. scoperail-0.3.0/bridge/semantic_ui.py +1058 -0
  28. scoperail-0.3.0/bridge/server.py +1484 -0
  29. scoperail-0.3.0/bridge/shells.py +378 -0
  30. scoperail-0.3.0/bridge/state.py +55 -0
  31. scoperail-0.3.0/bridge/stdio.py +36 -0
  32. scoperail-0.3.0/bridge/takeover.py +684 -0
  33. scoperail-0.3.0/bridge/viewport.py +111 -0
  34. scoperail-0.3.0/pyproject.toml +63 -0
  35. scoperail-0.3.0/scoperail.egg-info/PKG-INFO +149 -0
  36. scoperail-0.3.0/scoperail.egg-info/SOURCES.txt +59 -0
  37. scoperail-0.3.0/scoperail.egg-info/dependency_links.txt +1 -0
  38. scoperail-0.3.0/scoperail.egg-info/entry_points.txt +3 -0
  39. scoperail-0.3.0/scoperail.egg-info/requires.txt +17 -0
  40. scoperail-0.3.0/scoperail.egg-info/top_level.txt +1 -0
  41. scoperail-0.3.0/setup.cfg +4 -0
  42. scoperail-0.3.0/tests/test_agent_outcomes.py +327 -0
  43. scoperail-0.3.0/tests/test_audit_export.py +265 -0
  44. scoperail-0.3.0/tests/test_auth_hardening.py +208 -0
  45. scoperail-0.3.0/tests/test_browser_broker.py +208 -0
  46. scoperail-0.3.0/tests/test_cli_install.py +51 -0
  47. scoperail-0.3.0/tests/test_coding_tools.py +142 -0
  48. scoperail-0.3.0/tests/test_execution_review.py +506 -0
  49. scoperail-0.3.0/tests/test_file_batch.py +209 -0
  50. scoperail-0.3.0/tests/test_homelab_credentials.py +96 -0
  51. scoperail-0.3.0/tests/test_humanize.py +217 -0
  52. scoperail-0.3.0/tests/test_last_interaction.py +58 -0
  53. scoperail-0.3.0/tests/test_pipelines.py +111 -0
  54. scoperail-0.3.0/tests/test_policy_pure.py +101 -0
  55. scoperail-0.3.0/tests/test_profile_safety.py +176 -0
  56. scoperail-0.3.0/tests/test_security_regressions.py +93 -0
  57. scoperail-0.3.0/tests/test_semantic_ui.py +85 -0
  58. scoperail-0.3.0/tests/test_shells.py +19 -0
  59. scoperail-0.3.0/tests/test_takeover.py +322 -0
  60. scoperail-0.3.0/tests/test_tool_groups.py +110 -0
  61. scoperail-0.3.0/tests/test_workspace_doctor.py +159 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,149 @@
1
+ Metadata-Version: 2.4
2
+ Name: scoperail
3
+ Version: 0.3.0
4
+ Summary: Scoped local execution for MCP clients, with explicit workspace capabilities, persistent shells, browser control and semantic macOS UI automation.
5
+ Author: Hanpu Li
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/HanpuLi/scoperail
8
+ Project-URL: Repository, https://github.com/HanpuLi/scoperail
9
+ Project-URL: Issues, https://github.com/HanpuLi/scoperail/issues
10
+ Project-URL: Security, https://github.com/HanpuLi/scoperail/security/policy
11
+ Keywords: mcp,model-context-protocol,macos,automation,accessibility,local-first
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: MacOS X
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: MacOS :: MacOS X
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
21
+ Requires-Python: >=3.12
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: httpx<0.29,>=0.28
25
+ Requires-Dist: mcp<3,>=2.2
26
+ Requires-Dist: playwright<2,>=1.63
27
+ Requires-Dist: patchright<2,>=1.63
28
+ Requires-Dist: pydantic<3,>=2.13
29
+ Requires-Dist: starlette<2,>=1.0
30
+ Requires-Dist: uvicorn<1,>=0.53
31
+ Requires-Dist: pyobjc-framework-Quartz>=11; sys_platform == "darwin"
32
+ Requires-Dist: pyobjc-framework-Cocoa>=11; sys_platform == "darwin"
33
+ Requires-Dist: pyobjc-framework-ApplicationServices>=11; sys_platform == "darwin"
34
+ Provides-Extra: dev
35
+ Requires-Dist: build>=1.3; extra == "dev"
36
+ Requires-Dist: twine>=6.2; extra == "dev"
37
+ Requires-Dist: ruff>=0.13; extra == "dev"
38
+ Dynamic: license-file
39
+
40
+ # ScopeRail
41
+
42
+ <!-- mcp-name: io.github.hanpuli/scoperail -->
43
+
44
+ ScopeRail is a scoped local execution runtime for MCP clients that need to work on a real Mac without receiving unrestricted host access by default. Files, processes, browser sessions and native desktop UI are exposed through one workspace capability model with explicit grants and auditable actions.
45
+
46
+ It is not just a shell MCP. Shell access is one surface inside a broader permission model: a caller starts from a registered workspace, receives only the profiles and grants the operator enabled, and uses retry-safe primitives that return provenance and observable results.
47
+
48
+ **Maintainer:** [Hanpu Li / 李函璞](https://hanpuli.github.io/) · [portfolio / project index](https://hanpuli.github.io/#work)
49
+
50
+ ## Install and run
51
+
52
+ Python 3.12+ and `pipx` on macOS:
53
+
54
+ ```sh
55
+ brew install pipx # skip if pipx is already installed
56
+ pipx install "https://github.com/HanpuLi/scoperail/releases/download/v0.3.0/scoperail-0.3.0-py3-none-any.whl"
57
+ SCOPERAIL_WORKSPACE_ROOT="$PWD" scoperail stdio
58
+ ```
59
+
60
+ The tagged GitHub wheel is the current working install path and is tested with `pipx`. PyPI Trusted Publishing is prepared but the first PyPI upload still requires the maintainer's one-time PyPI login; after that, `pipx install scoperail` is equivalent.
61
+
62
+ Or register once, then start stdio:
63
+
64
+ ```sh
65
+ scoperail init "$PWD"
66
+ scoperail stdio
67
+ ```
68
+
69
+ For the full OAuth HTTP service, launchd installation and optional reverse-proxy/Tailscale deployment, see [docs/install.md](docs/install.md).
70
+
71
+ > **Security:** `sandboxed` execution is the default. `trusted-host`, desktop control, Git publishing and similar capabilities are explicit operator choices. Read [SECURITY.md](SECURITY.md) and [docs/security-model.md](docs/security-model.md) before enabling them.
72
+
73
+ ## What is different
74
+
75
+ | Surface | Boundary |
76
+ | --- | --- |
77
+ | Files | Workspace-confined paths, symlink-aware resolution, conflict-checked writes |
78
+ | Commands / PTY | macOS Seatbelt sandbox by default; explicit `trusted-host` profile for full user authority |
79
+ | Persistent shells | Named zsh sessions built on the same job/process boundary |
80
+ | Browser | Managed Playwright profile plus explicit attachment to loopback Chromium CDP sessions |
81
+ | Native UI | macOS Accessibility semantic tree and fingerprinted refs, with coordinate fallback |
82
+ | Git publish | Read operations are separate from parameter-bound publish grants |
83
+ | Audit/state | Request IDs, provenance, audit records, persistent workspace state |
84
+
85
+ ScopeRail does not embed a model. The connected client decides what to do; ScopeRail enforces and records the execution boundary.
86
+
87
+ ```text
88
+ MCP client
89
+ |
90
+ +-- local stdio --------------------------------+
91
+ | |
92
+ +-- OAuth 2.1 / remote HTTPS -- public plane ---+
93
+ v
94
+ workspace + grant policy
95
+ | | |
96
+ +----------+ | +----------+
97
+ v v v
98
+ files/git jobs/shells browser/native UI
99
+ | | |
100
+ +-------- audit + provenance --------+
101
+ ```
102
+
103
+ ## Platform and client status
104
+
105
+ ScopeRail is **macOS-first**. Native Accessibility control and the Seatbelt sandbox are macOS features. Pure policy/file/package tests may run on Linux CI, but Linux and Windows are not currently advertised as complete runtime platforms.
106
+
107
+ - **Generic MCP clients:** local stdio transport is supported.
108
+ - **ChatGPT:** remote OAuth/streamable-HTTP is the primary deployed integration and is exercised by the project.
109
+ - **Claude / Codex / other MCP clients:** the stdio server uses the standard MCP SDK transport; client-specific setup is documented as integration work rather than claimed as continuously tested compatibility.
110
+
111
+ ## Native semantic UI
112
+
113
+ The native desktop path prefers Accessibility over coordinate-only clicking. Observation returns semantic elements and bounds; element actions use fingerprinted `ax:` refs and fail closed when the target becomes stale, ambiguous or materially moves. Secure values are redacted and secure fields reject semantic value-setting.
114
+
115
+ Screenshot, mouse and keyboard primitives remain available for apps with incomplete Accessibility trees.
116
+
117
+ ## Browser sessions
118
+
119
+ The managed browser uses a ScopeRail-owned profile. A trusted-host workspace may also attach to an already-running Chromium-family browser only through an operator-configured loopback DevTools endpoint. Existing tabs are treated as external resources: detaching the bridge does not close them.
120
+
121
+ The launchd service owns one managed browser that every local client shares through a broker. Coding agents that have their own shell can ask for a browser-only tool surface (`SCOPERAIL_TOOL_GROUPS=browser`). Sign-ins and CAPTCHAs are handed to the user's phone with `browser_takeover` rather than typed by the agent. See [docs/browser.md](docs/browser.md).
122
+
123
+ ## Remote service
124
+
125
+ A source checkout can run the full HTTP service with OAuth 2.1, PKCE, dynamic client registration, token rotation/revocation and DNS-rebinding protections. The admin plane listens separately on loopback and is not exposed through the public MCP route.
126
+
127
+ See [docs/quickstart.md](docs/quickstart.md), [docs/permissions.md](docs/permissions.md), [docs/workspaces.md](docs/workspaces.md), [docs/files.md](docs/files.md), and [docs/audit.md](docs/audit.md).
128
+
129
+ ## Development
130
+
131
+ ```sh
132
+ python3 -m venv .venv
133
+ . .venv/bin/activate
134
+ pip install -e '.[dev]'
135
+ python -m unittest discover -s tests -p 'test_*.py' -v
136
+ ruff check --select E9,F63,F7,F82 bridge tests scripts
137
+ python -m build
138
+ twine check dist/*
139
+ ```
140
+
141
+ The maintainer's operational repository may contain machine-specific acceptance evidence. Release candidates are produced as an allowlisted fresh-history tree before they reach this public repository. `scripts/verify_public_tree.py`, CI secret scanning and package checks enforce the public-tree invariants; the private operational Git history is never imported here.
142
+
143
+ ## Contributing
144
+
145
+ Start with [CONTRIBUTING.md](CONTRIBUTING.md), the [architecture](docs/architecture.md) and the [security model](docs/security-model.md). Issues intended for contributors describe the problem and acceptance criteria; the project does not create trivial work to inflate contributor counts.
146
+
147
+ ## License
148
+
149
+ Apache-2.0. See `LICENSE` and `THIRD_PARTY_NOTICES.md`.
@@ -0,0 +1,110 @@
1
+ # ScopeRail
2
+
3
+ <!-- mcp-name: io.github.hanpuli/scoperail -->
4
+
5
+ ScopeRail is a scoped local execution runtime for MCP clients that need to work on a real Mac without receiving unrestricted host access by default. Files, processes, browser sessions and native desktop UI are exposed through one workspace capability model with explicit grants and auditable actions.
6
+
7
+ It is not just a shell MCP. Shell access is one surface inside a broader permission model: a caller starts from a registered workspace, receives only the profiles and grants the operator enabled, and uses retry-safe primitives that return provenance and observable results.
8
+
9
+ **Maintainer:** [Hanpu Li / 李函璞](https://hanpuli.github.io/) · [portfolio / project index](https://hanpuli.github.io/#work)
10
+
11
+ ## Install and run
12
+
13
+ Python 3.12+ and `pipx` on macOS:
14
+
15
+ ```sh
16
+ brew install pipx # skip if pipx is already installed
17
+ pipx install "https://github.com/HanpuLi/scoperail/releases/download/v0.3.0/scoperail-0.3.0-py3-none-any.whl"
18
+ SCOPERAIL_WORKSPACE_ROOT="$PWD" scoperail stdio
19
+ ```
20
+
21
+ The tagged GitHub wheel is the current working install path and is tested with `pipx`. PyPI Trusted Publishing is prepared but the first PyPI upload still requires the maintainer's one-time PyPI login; after that, `pipx install scoperail` is equivalent.
22
+
23
+ Or register once, then start stdio:
24
+
25
+ ```sh
26
+ scoperail init "$PWD"
27
+ scoperail stdio
28
+ ```
29
+
30
+ For the full OAuth HTTP service, launchd installation and optional reverse-proxy/Tailscale deployment, see [docs/install.md](docs/install.md).
31
+
32
+ > **Security:** `sandboxed` execution is the default. `trusted-host`, desktop control, Git publishing and similar capabilities are explicit operator choices. Read [SECURITY.md](SECURITY.md) and [docs/security-model.md](docs/security-model.md) before enabling them.
33
+
34
+ ## What is different
35
+
36
+ | Surface | Boundary |
37
+ | --- | --- |
38
+ | Files | Workspace-confined paths, symlink-aware resolution, conflict-checked writes |
39
+ | Commands / PTY | macOS Seatbelt sandbox by default; explicit `trusted-host` profile for full user authority |
40
+ | Persistent shells | Named zsh sessions built on the same job/process boundary |
41
+ | Browser | Managed Playwright profile plus explicit attachment to loopback Chromium CDP sessions |
42
+ | Native UI | macOS Accessibility semantic tree and fingerprinted refs, with coordinate fallback |
43
+ | Git publish | Read operations are separate from parameter-bound publish grants |
44
+ | Audit/state | Request IDs, provenance, audit records, persistent workspace state |
45
+
46
+ ScopeRail does not embed a model. The connected client decides what to do; ScopeRail enforces and records the execution boundary.
47
+
48
+ ```text
49
+ MCP client
50
+ |
51
+ +-- local stdio --------------------------------+
52
+ | |
53
+ +-- OAuth 2.1 / remote HTTPS -- public plane ---+
54
+ v
55
+ workspace + grant policy
56
+ | | |
57
+ +----------+ | +----------+
58
+ v v v
59
+ files/git jobs/shells browser/native UI
60
+ | | |
61
+ +-------- audit + provenance --------+
62
+ ```
63
+
64
+ ## Platform and client status
65
+
66
+ ScopeRail is **macOS-first**. Native Accessibility control and the Seatbelt sandbox are macOS features. Pure policy/file/package tests may run on Linux CI, but Linux and Windows are not currently advertised as complete runtime platforms.
67
+
68
+ - **Generic MCP clients:** local stdio transport is supported.
69
+ - **ChatGPT:** remote OAuth/streamable-HTTP is the primary deployed integration and is exercised by the project.
70
+ - **Claude / Codex / other MCP clients:** the stdio server uses the standard MCP SDK transport; client-specific setup is documented as integration work rather than claimed as continuously tested compatibility.
71
+
72
+ ## Native semantic UI
73
+
74
+ The native desktop path prefers Accessibility over coordinate-only clicking. Observation returns semantic elements and bounds; element actions use fingerprinted `ax:` refs and fail closed when the target becomes stale, ambiguous or materially moves. Secure values are redacted and secure fields reject semantic value-setting.
75
+
76
+ Screenshot, mouse and keyboard primitives remain available for apps with incomplete Accessibility trees.
77
+
78
+ ## Browser sessions
79
+
80
+ The managed browser uses a ScopeRail-owned profile. A trusted-host workspace may also attach to an already-running Chromium-family browser only through an operator-configured loopback DevTools endpoint. Existing tabs are treated as external resources: detaching the bridge does not close them.
81
+
82
+ The launchd service owns one managed browser that every local client shares through a broker. Coding agents that have their own shell can ask for a browser-only tool surface (`SCOPERAIL_TOOL_GROUPS=browser`). Sign-ins and CAPTCHAs are handed to the user's phone with `browser_takeover` rather than typed by the agent. See [docs/browser.md](docs/browser.md).
83
+
84
+ ## Remote service
85
+
86
+ A source checkout can run the full HTTP service with OAuth 2.1, PKCE, dynamic client registration, token rotation/revocation and DNS-rebinding protections. The admin plane listens separately on loopback and is not exposed through the public MCP route.
87
+
88
+ See [docs/quickstart.md](docs/quickstart.md), [docs/permissions.md](docs/permissions.md), [docs/workspaces.md](docs/workspaces.md), [docs/files.md](docs/files.md), and [docs/audit.md](docs/audit.md).
89
+
90
+ ## Development
91
+
92
+ ```sh
93
+ python3 -m venv .venv
94
+ . .venv/bin/activate
95
+ pip install -e '.[dev]'
96
+ python -m unittest discover -s tests -p 'test_*.py' -v
97
+ ruff check --select E9,F63,F7,F82 bridge tests scripts
98
+ python -m build
99
+ twine check dist/*
100
+ ```
101
+
102
+ The maintainer's operational repository may contain machine-specific acceptance evidence. Release candidates are produced as an allowlisted fresh-history tree before they reach this public repository. `scripts/verify_public_tree.py`, CI secret scanning and package checks enforce the public-tree invariants; the private operational Git history is never imported here.
103
+
104
+ ## Contributing
105
+
106
+ Start with [CONTRIBUTING.md](CONTRIBUTING.md), the [architecture](docs/architecture.md) and the [security model](docs/security-model.md). Issues intended for contributors describe the problem and acceptance criteria; the project does not create trivial work to inflate contributor counts.
107
+
108
+ ## License
109
+
110
+ Apache-2.0. See `LICENSE` and `THIRD_PARTY_NOTICES.md`.
@@ -0,0 +1,8 @@
1
+ """ScopeRail: local MCP runtime for the user's current ChatGPT session.
2
+
3
+ The server exposes auditable files/process/Git/browser/macOS-UI primitives plus
4
+ persistent shells, state and deterministic orchestration. It contains no model API
5
+ client: model reasoning remains in the active ChatGPT session or explicit
6
+ chatgpt.com sub-conversations.
7
+ """
8
+ __version__ = "0.3.0"
@@ -0,0 +1,110 @@
1
+ """Entry point: `python -m bridge` runs the public MCP app (loopback, proxied by Funnel) and the loopback admin app
2
+ in one asyncio loop, plus the plain-process scheduler thread. Managed by launchd (io.github.hanpuli.scoperail; the old label is accepted during upgrades)."""
3
+ from __future__ import annotations
4
+ import asyncio, logging, os, signal, subprocess, sys, threading, time
5
+ import uvicorn
6
+ from .config import load_config, LOGS_DIR, ensure_dirs
7
+ from . import jobs, db
8
+
9
+
10
+ def _activity_sidecar_supervisor(stop: threading.Event, executable: str) -> None:
11
+ """Supervise an optional operator-configured sidecar without baking machine paths into source.
12
+
13
+ This exists for integrations that need to inherit the bridge process's macOS TCC identity.
14
+ The executable path comes only from local config and is never exposed as an MCP capability.
15
+ """
16
+ path = os.path.abspath(os.path.expanduser(executable))
17
+ if not os.path.isfile(path) or not os.access(path, os.X_OK):
18
+ logging.warning("configured activity sidecar is unavailable: %s", path)
19
+ return
20
+
21
+ while not stop.is_set():
22
+ proc = None
23
+ try:
24
+ proc = subprocess.Popen(
25
+ [path],
26
+ stdin=subprocess.DEVNULL,
27
+ stdout=subprocess.DEVNULL,
28
+ stderr=subprocess.DEVNULL,
29
+ close_fds=True,
30
+ )
31
+ logging.info("activity sidecar started pid=%s", proc.pid)
32
+ while not stop.wait(1.0):
33
+ rc = proc.poll()
34
+ if rc is not None:
35
+ logging.warning("activity sidecar exited rc=%s; restarting", rc)
36
+ break
37
+ if stop.is_set() and proc.poll() is None:
38
+ proc.terminate()
39
+ try:
40
+ proc.wait(timeout=3)
41
+ except subprocess.TimeoutExpired:
42
+ proc.kill()
43
+ proc.wait(timeout=2)
44
+ break
45
+ except Exception:
46
+ logging.exception("activity sidecar supervisor error")
47
+ finally:
48
+ if proc is not None and proc.poll() is None and stop.is_set():
49
+ try:
50
+ proc.terminate()
51
+ except OSError:
52
+ pass
53
+ if not stop.wait(5.0):
54
+ continue
55
+
56
+
57
+ def main() -> None:
58
+ ensure_dirs()
59
+ cfg = load_config()
60
+ logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(name)s: %(message)s", stream=sys.stderr)
61
+ for note in jobs.recover_on_startup():
62
+ logging.info("recovered job: %s", note)
63
+ from . import agents
64
+ for note in agents.recover_on_startup():
65
+ logging.info("interrupted sub-agent run: %s", note)
66
+ from . import pipelines
67
+ for note in pipelines.recover_on_startup():
68
+ logging.info("interrupted pipeline: %s", note)
69
+ from . import coding
70
+ for note in coding.recover_on_startup():
71
+ logging.info("interrupted coding task: %s", note)
72
+ from .server import build_app, scheduler_loop
73
+ from .admin import build_admin_app
74
+ stop = threading.Event()
75
+ threading.Thread(target=scheduler_loop, args=(stop,), daemon=True).start()
76
+ sidecar_thread = None
77
+ if cfg.get("activity_sidecar"):
78
+ sidecar_thread = threading.Thread(
79
+ target=_activity_sidecar_supervisor,
80
+ args=(stop, str(cfg["activity_sidecar"])),
81
+ daemon=True,
82
+ name="scoperail-sidecar",
83
+ )
84
+ sidecar_thread.start()
85
+ public = uvicorn.Server(uvicorn.Config(build_app(), host=cfg["listen_host"], port=cfg["listen_port"], log_level="info", proxy_headers=True, access_log=False,
86
+ forwarded_allow_ips="127.0.0.1", timeout_keep_alive=75))
87
+ admin = uvicorn.Server(uvicorn.Config(build_admin_app(), host=cfg["admin_host"], port=cfg["admin_port"], log_level="warning", access_log=False))
88
+ db.audit("server", f"start pid={os.getpid()} public={cfg['listen_port']} admin={cfg['admin_port']}")
89
+
90
+ async def run():
91
+ from . import browser_broker, takeover
92
+ broker = asyncio.create_task(browser_broker.serve())
93
+ handover = asyncio.create_task(takeover.serve()) # same loop as the browser: Playwright objects belong to it
94
+ try:
95
+ await asyncio.gather(public.serve(), admin.serve())
96
+ finally:
97
+ broker.cancel()
98
+ handover.cancel()
99
+
100
+ try:
101
+ asyncio.run(run())
102
+ finally:
103
+ stop.set()
104
+ if sidecar_thread:
105
+ sidecar_thread.join(timeout=4)
106
+ db.audit("server", f"stop pid={os.getpid()}")
107
+
108
+
109
+ if __name__ == "__main__":
110
+ main()