copuppet 0.1.1__tar.gz → 0.1.2__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.
- {copuppet-0.1.1 → copuppet-0.1.2}/CHANGELOG.md +14 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/PKG-INFO +27 -1
- {copuppet-0.1.1 → copuppet-0.1.2}/README.md +26 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/docs/roadmap.md +9 -8
- {copuppet-0.1.1 → copuppet-0.1.2}/pyproject.toml +1 -1
- {copuppet-0.1.1 → copuppet-0.1.2}/src/copuppet/__init__.py +1 -1
- copuppet-0.1.2/src/copuppet/__main__.py +7 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/src/copuppet/cli.py +27 -0
- copuppet-0.1.1/tools/discover_edge.py → copuppet-0.1.2/src/copuppet/discover.py +28 -40
- copuppet-0.1.2/src/copuppet/example_skin/skin.yaml +45 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/src/copuppet/skin.py +2 -1
- copuppet-0.1.2/tests/test_first_run.py +38 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/test_notices.py +1 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/test_redteam_3.py +1 -2
- copuppet-0.1.2/tools/discover_edge.py +7 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/.gitattributes +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/.github/workflows/release.yml +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/.github/workflows/test.yml +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/.gitignore +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/CLAUDE.md +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/LICENSE +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/RELEASING.md +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/config.example/skin.yaml +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/docs/model.md +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/src/copuppet/actions.py +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/src/copuppet/backend.py +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/src/copuppet/backends/__init__.py +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/src/copuppet/backends/edge.py +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/src/copuppet/backends/edge_common.py +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/src/copuppet/backends/winapp.py +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/src/copuppet/calibrate.py +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/src/copuppet/driver.py +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/src/copuppet/fake.py +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/src/copuppet/ledger.py +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/src/copuppet/mcp_server.py +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/src/copuppet/policy.py +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/src/copuppet/protocol.py +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/src/copuppet/relay.py +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/src/copuppet/runner.py +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/src/copuppet/session.py +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/src/copuppet/tokens.py +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/README.md +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/recorded.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/copilot-000001.a.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/copilot-000001.q.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/copilot-000002.a.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/copilot-000002.q.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/copilot-000003.a.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/copilot-000003.q.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/copilot-000004.a.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/copilot-000004.q.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/copilot-000005.a.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/copilot-000005.q.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/copilot-000006.a.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/copilot-000006.q.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/copilot-000007.a.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/copilot-000007.q.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/copilot-000008.a.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/copilot-000008.q.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/copilot-000009.a.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/copilot-000009.q.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/copilot-000010.a.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/copilot-000010.q.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/copilot-000011.a.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/copilot-000011.q.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/copilot-000013.a.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/copilot-000013.q.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/person-000012.a.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/done/person-000012.q.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/run/run.json +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/work/notes/fridge.md +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/work/pantry.md +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/work/recipes/omelette.md +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/work/recipes/pancakes.md +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/work/recipes/shortbread.md +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/fixtures/pantry/work/recipes/tomato-rice.md +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/test_calibrate.py +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/test_driver.py +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/test_edge_codeblocks.py +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/test_ledger_and_fake.py +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/test_mcp_server.py +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/test_protocol_and_session.py +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/test_relay.py +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/test_replay_fixture.py +0 -0
- {copuppet-0.1.1 → copuppet-0.1.2}/tests/test_skin.py +0 -0
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.2 (2026-11-29)
|
|
4
|
+
|
|
5
|
+
First run on a managed PC (#18).
|
|
6
|
+
|
|
7
|
+
- `python -m copuppet` works: neither the Scripts folder on PATH nor the unsigned launcher is needed.
|
|
8
|
+
- The example skin ships in the package; `copuppet init-skin DIR` copies it as the start of your own.
|
|
9
|
+
- The discovery tool is part of the package: `copuppet discover` (including `--probe`, which samples the page while
|
|
10
|
+
a reply is written). `tools/discover_edge.py` remains as a shim.
|
|
11
|
+
- The no-skin error says how to start one.
|
|
12
|
+
- README: installing on a managed PC (`python -m pip`, `python -m copuppet`) and building a skin for your Copilot
|
|
13
|
+
surface (consumer Copilot and Microsoft 365 Copilot Chat are different pages).
|
|
14
|
+
- README: the `signed_in` selector as an account guard; Edge refusing a debugging port does not affect copuppet.
|
|
15
|
+
- Verified on a managed PC against Microsoft 365 Copilot Chat with a work account (a skin built there).
|
|
16
|
+
|
|
3
17
|
## 0.1.1 (2026-11-29)
|
|
4
18
|
|
|
5
19
|
Fixes from the first live runs.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: copuppet
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Drive Microsoft Copilot from a deterministic Python harness, as a normal user through its own UI.
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -89,6 +89,32 @@ Everything installs in your own user account: no admin rights, no system-wide in
|
|
|
89
89
|
If your PC blocks access to PyPI, download the wheels elsewhere (`pip download "copuppet[edge]" -d wheels`) and
|
|
90
90
|
install them with `pip install --user --no-index --find-links wheels "copuppet[edge]"`.
|
|
91
91
|
|
|
92
|
+
### On a managed PC
|
|
93
|
+
|
|
94
|
+
- Use `python -m pip install --user "copuppet[edge]"` when `pip.exe` is blocked, and `python -m copuppet ...` for
|
|
95
|
+
every command: a `--user` install puts `copuppet.exe` in a Scripts folder that is usually not on PATH, and an
|
|
96
|
+
unsigned launcher may be blocked. `python -m copuppet` needs neither.
|
|
97
|
+
- If Edge refuses automation (remote debugging disabled by policy), the `edge` backend cannot run on that PC.
|
|
98
|
+
|
|
99
|
+
## First run: a skin for your Copilot
|
|
100
|
+
|
|
101
|
+
copuppet ships no working skin: selectors depend on which Copilot you use (consumer Copilot, or Microsoft 365
|
|
102
|
+
Copilot Chat with a work account, which is a different page) and change with its updates. Build your own:
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
python -m copuppet init-skin MYSKIN # a copy of the example, with REPLACE placeholders
|
|
106
|
+
python -m copuppet discover --out MYSKIN/discovery --url URL-OF-YOUR-COPILOT # sign in once, by hand
|
|
107
|
+
python -m copuppet check --skin MYSKIN # after filling in the selectors from the discovery output
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Keep your skin outside any public repository. The discovery tool takes the same profile lock as copuppet runs,
|
|
111
|
+
so it never opens a profile that a run is using.
|
|
112
|
+
|
|
113
|
+
The `signed_in` selector is also an account guard: point it at something only the intended account shows (for a
|
|
114
|
+
work account, for example, its data-protection badge) and copuppet refuses to run in any other session. Set
|
|
115
|
+
`COPUPPET_SKIN` to your skin folder to drop the `--skin` flag. If Edge refuses a remote-debugging port on your PC,
|
|
116
|
+
that does not matter: copuppet and `copuppet discover` launch Edge through Playwright, not through a port.
|
|
117
|
+
|
|
92
118
|
## Using copuppet as an MCP server
|
|
93
119
|
|
|
94
120
|
Install with the MCP extra (`pip install --user "copuppet[edge,mcp]"`), then register the stdio command in your MCP
|
|
@@ -70,6 +70,32 @@ Everything installs in your own user account: no admin rights, no system-wide in
|
|
|
70
70
|
If your PC blocks access to PyPI, download the wheels elsewhere (`pip download "copuppet[edge]" -d wheels`) and
|
|
71
71
|
install them with `pip install --user --no-index --find-links wheels "copuppet[edge]"`.
|
|
72
72
|
|
|
73
|
+
### On a managed PC
|
|
74
|
+
|
|
75
|
+
- Use `python -m pip install --user "copuppet[edge]"` when `pip.exe` is blocked, and `python -m copuppet ...` for
|
|
76
|
+
every command: a `--user` install puts `copuppet.exe` in a Scripts folder that is usually not on PATH, and an
|
|
77
|
+
unsigned launcher may be blocked. `python -m copuppet` needs neither.
|
|
78
|
+
- If Edge refuses automation (remote debugging disabled by policy), the `edge` backend cannot run on that PC.
|
|
79
|
+
|
|
80
|
+
## First run: a skin for your Copilot
|
|
81
|
+
|
|
82
|
+
copuppet ships no working skin: selectors depend on which Copilot you use (consumer Copilot, or Microsoft 365
|
|
83
|
+
Copilot Chat with a work account, which is a different page) and change with its updates. Build your own:
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
python -m copuppet init-skin MYSKIN # a copy of the example, with REPLACE placeholders
|
|
87
|
+
python -m copuppet discover --out MYSKIN/discovery --url URL-OF-YOUR-COPILOT # sign in once, by hand
|
|
88
|
+
python -m copuppet check --skin MYSKIN # after filling in the selectors from the discovery output
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Keep your skin outside any public repository. The discovery tool takes the same profile lock as copuppet runs,
|
|
92
|
+
so it never opens a profile that a run is using.
|
|
93
|
+
|
|
94
|
+
The `signed_in` selector is also an account guard: point it at something only the intended account shows (for a
|
|
95
|
+
work account, for example, its data-protection badge) and copuppet refuses to run in any other session. Set
|
|
96
|
+
`COPUPPET_SKIN` to your skin folder to drop the `--skin` flag. If Edge refuses a remote-debugging port on your PC,
|
|
97
|
+
that does not matter: copuppet and `copuppet discover` launch Edge through Playwright, not through a port.
|
|
98
|
+
|
|
73
99
|
## Using copuppet as an MCP server
|
|
74
100
|
|
|
75
101
|
Install with the MCP extra (`pip install --user "copuppet[edge,mcp]"`), then register the stdio command in your MCP
|
|
@@ -7,21 +7,22 @@ Edge backend (headless with single sign-on), `ask`, sessions with memory checks
|
|
|
7
7
|
`drive` (driver mode under a policy), `mcp`, the hash-chained ledger, relay and replay backends. Verified live: a
|
|
8
8
|
read-only drive, a drive with one confirmed write, an MCP call, three calibration runs.
|
|
9
9
|
|
|
10
|
-
## 0.1.1
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- #2 First-token time measures the busy marker, so the latency trigger is blind.
|
|
14
|
-
- #3 Selectors for challenge and limit notices, so those stops do not rely on reply text alone.
|
|
15
|
-
- #4 One set of helpers for the discovery tool and the backend.
|
|
16
|
-
- #5 Using copuppet as an MCP server, documented.
|
|
10
|
+
## 0.1.1 (released 2026-11-29)
|
|
11
|
+
What the first live runs found: #1 stable code-block read-back, #2 first-token timing, #3 page notices,
|
|
12
|
+
#4 shared helpers, #5 MCP docs, #14 CI.
|
|
17
13
|
|
|
18
|
-
## 0.1.2:
|
|
14
|
+
## 0.1.2 (released 2026-11-29): first run on a managed PC
|
|
15
|
+
Brought forward after a first install on a managed PC: #18 `python -m copuppet`, the packaged example skin with
|
|
16
|
+
`init-skin`, and discovery in the package.
|
|
17
|
+
|
|
18
|
+
## 0.1.3: real runs become tests
|
|
19
19
|
Builds on 0.1.1: once read-back and timing are right, real runs are worth recording.
|
|
20
20
|
- #6 Record real runs in the relay format, so they replay as regression tests.
|
|
21
21
|
- #7 Resume a stopped drive from its ledger, never repeating a recorded step.
|
|
22
22
|
- #8 Find the real recall ceiling (today only a lower bound of 378,000 characters).
|
|
23
23
|
- #9 Calibrate the off-screen and visible display modes.
|
|
24
24
|
- #10 Progress and cancel for `copilot_drive` over MCP.
|
|
25
|
+
- #19 Copilot surfaces without a temporary chat (an explicit skin capability instead of failing closed).
|
|
25
26
|
|
|
26
27
|
## Later
|
|
27
28
|
- #11 winapp backend: parked until a PC blocks Edge automation.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"""copuppet: drive Microsoft Copilot from a deterministic Python harness, as a normal user through its own UI."""
|
|
2
|
-
__version__ = "0.1.
|
|
2
|
+
__version__ = "0.1.2"
|
|
@@ -20,6 +20,10 @@ from .skin import SkinError, load
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
def main(argv=None) -> int:
|
|
23
|
+
argv = list(sys.argv[1:] if argv is None else argv)
|
|
24
|
+
if argv[:1] == ["discover"]: # the discovery tool keeps its own options
|
|
25
|
+
from .discover import main as discover_main
|
|
26
|
+
return discover_main(argv[1:])
|
|
23
27
|
ap = argparse.ArgumentParser(prog="copuppet", description=__doc__.splitlines()[0])
|
|
24
28
|
ap.add_argument("--version", action="version", version=f"copuppet {__version__}")
|
|
25
29
|
sub = ap.add_subparsers(dest="cmd", required=True)
|
|
@@ -73,7 +77,13 @@ def main(argv=None) -> int:
|
|
|
73
77
|
k.add_argument("--backend", default="edge", choices=("edge",))
|
|
74
78
|
k.add_argument("--display", choices=("auto", "headless", "offscreen", "visible"))
|
|
75
79
|
k.add_argument("--verbose", action="store_true")
|
|
80
|
+
sub.add_parser("discover", help="open Copilot in copuppet's Edge profile and record the page structure "
|
|
81
|
+
"(selectors for a skin); `copuppet discover --help` for its options")
|
|
82
|
+
ini = sub.add_parser("init-skin", help="copy the packaged example skin to DIR as the start of your own")
|
|
83
|
+
ini.add_argument("dir")
|
|
76
84
|
a = ap.parse_args(argv)
|
|
85
|
+
if a.cmd == "init-skin":
|
|
86
|
+
return init_skin(a.dir)
|
|
77
87
|
if a.cmd == "relay":
|
|
78
88
|
return relay_cmd(a)
|
|
79
89
|
if a.cmd == "calibrate":
|
|
@@ -132,6 +142,23 @@ def ask(skin, a) -> int:
|
|
|
132
142
|
return 0 if r.complete else 1
|
|
133
143
|
|
|
134
144
|
|
|
145
|
+
def init_skin(target: str) -> int:
|
|
146
|
+
import shutil
|
|
147
|
+
from importlib.resources import files
|
|
148
|
+
dest = Path(target).expanduser()
|
|
149
|
+
if (dest / "skin.yaml").exists():
|
|
150
|
+
print(f"copuppet: {dest / 'skin.yaml'} already exists; not overwriting it", file=sys.stderr)
|
|
151
|
+
return 2
|
|
152
|
+
dest.mkdir(parents=True, exist_ok=True)
|
|
153
|
+
src = files("copuppet") / "example_skin" / "skin.yaml"
|
|
154
|
+
with src.open("rb") as fh, (dest / "skin.yaml").open("wb") as out:
|
|
155
|
+
shutil.copyfileobj(fh, out)
|
|
156
|
+
print(f"wrote {dest / 'skin.yaml'} (the example: every REPLACE value still has to be filled in).")
|
|
157
|
+
print(f"next: copuppet discover --out {dest / 'discovery'} (sign in once in the window that opens)")
|
|
158
|
+
print(f"then: fill in the selectors and run copuppet check --skin {dest}")
|
|
159
|
+
return 0
|
|
160
|
+
|
|
161
|
+
|
|
135
162
|
def relay_cmd(a) -> int:
|
|
136
163
|
import json
|
|
137
164
|
import time
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
"""Supervised selector discovery for the edge backend.
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
copuppet discover --out DIR [--url URL] [--profile DIR] [--wait-minutes 15]
|
|
5
5
|
|
|
6
6
|
Opens the page in the installed Microsoft Edge (Playwright channel "msedge", no browser download) with a
|
|
7
7
|
persistent profile, so the user signs in once, by hand, in that window. When a prompt box appears, it records the
|
|
@@ -17,27 +17,15 @@ import sys
|
|
|
17
17
|
import time
|
|
18
18
|
from pathlib import Path
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
)
|
|
30
|
-
except ImportError: # run from a checkout without installing
|
|
31
|
-
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))
|
|
32
|
-
from copuppet.backends.edge_common import (
|
|
33
|
-
BROWSER_ARGS,
|
|
34
|
-
LOGIN_HOSTS,
|
|
35
|
-
ProfileBusy,
|
|
36
|
-
acquire_lock,
|
|
37
|
-
mark_clean_exit,
|
|
38
|
-
release_lock,
|
|
39
|
-
visible_dialogs,
|
|
40
|
-
)
|
|
20
|
+
from .backends.edge_common import (
|
|
21
|
+
BROWSER_ARGS,
|
|
22
|
+
LOGIN_HOSTS,
|
|
23
|
+
ProfileBusy,
|
|
24
|
+
acquire_lock,
|
|
25
|
+
mark_clean_exit,
|
|
26
|
+
release_lock,
|
|
27
|
+
visible_dialogs,
|
|
28
|
+
)
|
|
41
29
|
|
|
42
30
|
PROMPT_CANDIDATES = "textarea, [contenteditable='true'], [role='textbox'], input[type='text']"
|
|
43
31
|
INTERESTING = ("textarea, [contenteditable='true'], [role='textbox'], input, button, [role='button'], "
|
|
@@ -121,7 +109,7 @@ def handle_dialogs(page, rules: list, reported: set) -> None:
|
|
|
121
109
|
k = (d["role"], d["aria_label"], d["testid"], tuple(d["buttons"]))
|
|
122
110
|
if k not in reported:
|
|
123
111
|
reported.add(k)
|
|
124
|
-
print(f"
|
|
112
|
+
print(f"copuppet discover: MODAL {d['role'] or 'dialog'} '{d['aria_label'] or d['testid'] or d['id']}' "
|
|
125
113
|
f"buttons={d['buttons']}", flush=True)
|
|
126
114
|
for r in rules:
|
|
127
115
|
try:
|
|
@@ -130,7 +118,7 @@ def handle_dialogs(page, rules: list, reported: set) -> None:
|
|
|
130
118
|
b = next((m.nth(i) for i in range(min(m.count(), 10)) if m.nth(i).is_visible()), None)
|
|
131
119
|
if b is not None:
|
|
132
120
|
b.click()
|
|
133
|
-
print(f"
|
|
121
|
+
print(f"copuppet discover: dismissed by rule ({r['when']} -> {r['click']})", flush=True)
|
|
134
122
|
time.sleep(1)
|
|
135
123
|
except Exception:
|
|
136
124
|
pass
|
|
@@ -156,7 +144,7 @@ def ensure_signed_in(page, minutes: float, click: bool, button: str) -> bool:
|
|
|
156
144
|
why = signin_needed(page)
|
|
157
145
|
if not why and page.locator(PROMPT_CANDIDATES).first.is_visible(timeout=1000):
|
|
158
146
|
if told:
|
|
159
|
-
print("
|
|
147
|
+
print("copuppet discover: signed in, continuing.", flush=True)
|
|
160
148
|
time.sleep(2)
|
|
161
149
|
return True
|
|
162
150
|
except Exception:
|
|
@@ -170,14 +158,14 @@ def ensure_signed_in(page, minutes: float, click: bool, button: str) -> bool:
|
|
|
170
158
|
if b is not None:
|
|
171
159
|
b.click()
|
|
172
160
|
clicked = True
|
|
173
|
-
print("
|
|
161
|
+
print("copuppet discover: clicked the site's Sign in button (setting click_signin); complete the "
|
|
174
162
|
"login in the Edge window yourself.", flush=True)
|
|
175
163
|
except Exception as e:
|
|
176
|
-
print(f"
|
|
164
|
+
print(f"copuppet discover: could not click the Sign in button ({e.__class__.__name__}); sign in by hand.",
|
|
177
165
|
flush=True)
|
|
178
166
|
clicked = True
|
|
179
167
|
if why and not told:
|
|
180
|
-
print(f"
|
|
168
|
+
print(f"copuppet discover: SIGN-IN NEEDED ({why}). Complete it yourself in the Edge window.", flush=True)
|
|
181
169
|
told = True
|
|
182
170
|
time.sleep(2)
|
|
183
171
|
return False
|
|
@@ -189,14 +177,14 @@ def wait_for_signin(page, minutes: float) -> bool:
|
|
|
189
177
|
why = signin_needed(page)
|
|
190
178
|
if not why:
|
|
191
179
|
return True
|
|
192
|
-
print(f"
|
|
180
|
+
print(f"copuppet discover: SIGN-IN NEEDED ({why}). Sign in yourself in the Edge window; waiting up to {minutes:g} "
|
|
193
181
|
f"min.", flush=True)
|
|
194
182
|
deadline = time.time() + minutes * 60
|
|
195
183
|
while time.time() < deadline:
|
|
196
184
|
time.sleep(3)
|
|
197
185
|
try:
|
|
198
186
|
if not signin_needed(page) and page.locator(PROMPT_CANDIDATES).first.is_visible(timeout=1000):
|
|
199
|
-
print("
|
|
187
|
+
print("copuppet discover: signed in, continuing.", flush=True)
|
|
200
188
|
time.sleep(2)
|
|
201
189
|
return True
|
|
202
190
|
except Exception:
|
|
@@ -219,7 +207,7 @@ def probe(page, out: Path, word="ready", wait_s=60):
|
|
|
219
207
|
tmp.first.click()
|
|
220
208
|
time.sleep(2)
|
|
221
209
|
if not wait_for_signin(page, 10):
|
|
222
|
-
print("
|
|
210
|
+
print("copuppet discover: probe skipped, sign-in not completed", file=sys.stderr)
|
|
223
211
|
return
|
|
224
212
|
box = page.locator(PROMPT_CANDIDATES).first
|
|
225
213
|
box.click()
|
|
@@ -239,7 +227,7 @@ def probe(page, out: Path, word="ready", wait_s=60):
|
|
|
239
227
|
handle_dialogs(page, DISMISS_RULES, REPORTED_DIALOGS)
|
|
240
228
|
why = signin_needed(page)
|
|
241
229
|
if why:
|
|
242
|
-
print(f"
|
|
230
|
+
print(f"copuppet discover: sign-in asked mid-probe ({why}); waiting for the person.", flush=True)
|
|
243
231
|
if not wait_for_signin(page, 10):
|
|
244
232
|
break
|
|
245
233
|
t0 = time.time()
|
|
@@ -255,7 +243,7 @@ def probe(page, out: Path, word="ready", wait_s=60):
|
|
|
255
243
|
"reply_ancestors": reply, "after": after}
|
|
256
244
|
f = out / "edge-probe.json"
|
|
257
245
|
f.write_text(json.dumps(data, indent=1), encoding="utf-8")
|
|
258
|
-
print(f"
|
|
246
|
+
print(f"copuppet discover: probe recorded to {f} (reply found: {bool(reply)})", flush=True)
|
|
259
247
|
|
|
260
248
|
|
|
261
249
|
STATE_JS = r"""
|
|
@@ -300,11 +288,11 @@ def states(page, out: Path, tmp_selector="button[aria-label='Temporary chat']"):
|
|
|
300
288
|
"disappeared": [json.loads(x) for x in sorted(before - after)]}
|
|
301
289
|
f = out / "edge-states.json"
|
|
302
290
|
f.write_text(json.dumps(result, indent=1), encoding="utf-8")
|
|
303
|
-
print(f"
|
|
291
|
+
print(f"copuppet discover: states recorded to {f}", flush=True)
|
|
304
292
|
|
|
305
293
|
|
|
306
294
|
def main(argv=None) -> int:
|
|
307
|
-
ap = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
|
295
|
+
ap = argparse.ArgumentParser(prog="copuppet discover", description=__doc__.splitlines()[0])
|
|
308
296
|
ap.add_argument("--out", required=True)
|
|
309
297
|
ap.add_argument("--url", default="https://copilot.microsoft.com/")
|
|
310
298
|
ap.add_argument("--profile", default=str(Path.home() / ".copuppet" / "edge-profile"))
|
|
@@ -329,7 +317,7 @@ def main(argv=None) -> int:
|
|
|
329
317
|
try:
|
|
330
318
|
from playwright.sync_api import sync_playwright
|
|
331
319
|
except ImportError:
|
|
332
|
-
print('
|
|
320
|
+
print('copuppet discover: Playwright is not installed; next: pip install --user "copuppet[edge]"', file=sys.stderr)
|
|
333
321
|
return 2
|
|
334
322
|
out = Path(a.out).expanduser()
|
|
335
323
|
out.mkdir(parents=True, exist_ok=True)
|
|
@@ -337,7 +325,7 @@ def main(argv=None) -> int:
|
|
|
337
325
|
try:
|
|
338
326
|
lock = acquire_lock(profile) # never open the profile a copuppet run is using (#4)
|
|
339
327
|
except ProfileBusy as e:
|
|
340
|
-
print(f"
|
|
328
|
+
print(f"copuppet discover: {e}", file=sys.stderr)
|
|
341
329
|
return 2
|
|
342
330
|
try:
|
|
343
331
|
return _discover(a, out, profile, sync_playwright)
|
|
@@ -352,9 +340,9 @@ def _discover(a, out, profile, sync_playwright) -> int:
|
|
|
352
340
|
headless=False, viewport=None, args=BROWSER_ARGS)
|
|
353
341
|
page = ctx.pages[0] if ctx.pages else ctx.new_page()
|
|
354
342
|
page.goto(a.url, wait_until="domcontentloaded")
|
|
355
|
-
print(f"
|
|
343
|
+
print(f"copuppet discover: Edge is open on {a.url} (waiting up to {a.wait_minutes:g} min).", flush=True)
|
|
356
344
|
if not ensure_signed_in(page, a.wait_minutes, a.click_signin, a.signin_button):
|
|
357
|
-
print("
|
|
345
|
+
print("copuppet discover: not signed in in time; nothing recorded. Next: sign in in the Edge window and "
|
|
358
346
|
"run again.", file=sys.stderr)
|
|
359
347
|
ctx.close()
|
|
360
348
|
return 1
|
|
@@ -370,7 +358,7 @@ def _discover(a, out, profile, sync_playwright) -> int:
|
|
|
370
358
|
f = out / "edge-structure.json"
|
|
371
359
|
f.write_text(json.dumps(data, indent=1), encoding="utf-8")
|
|
372
360
|
n = sum(len(fr.get("elements", [])) for fr in frames)
|
|
373
|
-
print(f"
|
|
361
|
+
print(f"copuppet discover: recorded {n} elements in {len(frames)} frame(s) to {f}", flush=True)
|
|
374
362
|
if a.states:
|
|
375
363
|
states(page, out)
|
|
376
364
|
if a.probe:
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Example skin: the shape only. Real values (selectors, window paths) are discovered in a supervised session and
|
|
2
|
+
# kept in your own, private skin directory; point copuppet at it with --skin DIR or COPUPPET_SKIN.
|
|
3
|
+
format: 1
|
|
4
|
+
name: example
|
|
5
|
+
|
|
6
|
+
backends:
|
|
7
|
+
edge:
|
|
8
|
+
url: "https://copilot.microsoft.com/" # the Copilot page the user opens in Edge
|
|
9
|
+
profile_dir: "~/.copuppet/edge-profile" # persistent profile: sign in once, by hand
|
|
10
|
+
display: auto # auto: headless, then an off-screen window, then visible (for a manual login)
|
|
11
|
+
input_mode: auto # auto: paste the text in one go (verified by read-back), then type as fallback
|
|
12
|
+
selectors: # CSS or role-based selectors
|
|
13
|
+
input: "REPLACE: the prompt box" # required
|
|
14
|
+
send: "REPLACE: the send button" # required
|
|
15
|
+
reply: "REPLACE: every reply node (one per answer)" # required
|
|
16
|
+
busy: "REPLACE: shown while a reply is still being written" # required
|
|
17
|
+
user_message: "REPLACE: every message node you sent" # binds each reply to its prompt; strongly advised
|
|
18
|
+
done: "REPLACE: appears inside a reply once it is finished" # optional, scoped to the new reply
|
|
19
|
+
temporary_chat: "REPLACE: the temporary-chat toggle" # optional: makes chats that are not kept
|
|
20
|
+
temporary_on: "REPLACE: the same toggle when it is on"
|
|
21
|
+
signed_in: "REPLACE: an element only shown when signed in"
|
|
22
|
+
model: "REPLACE: the model selector (its label is the model name)"
|
|
23
|
+
code: "REPLACE: a code block inside a reply"
|
|
24
|
+
code_text: "REPLACE: the text area inside that code block"
|
|
25
|
+
challenge_marker: "REPLACE: a captcha or throttle notice" # optional: seen means stop at once
|
|
26
|
+
limit_marker: "REPLACE: a conversation-limit notice" # optional: seen means a fresh chat
|
|
27
|
+
timeouts: {reply_seconds: 120, settle_seconds: 1.5}
|
|
28
|
+
signin:
|
|
29
|
+
click_button: false # true: copuppet presses the site's own Sign in button once; the login form
|
|
30
|
+
# itself is always completed by the person, copuppet never types into it
|
|
31
|
+
button: "button:has-text('Sign in')"
|
|
32
|
+
notices_ignore: # page notices (alerts, live regions) known to be harmless: not reported in the notes.
|
|
33
|
+
- "REPLACE: part of a harmless notice's text" # a throttle or challenge notice is never muted by this
|
|
34
|
+
dismiss: # page modals copuppet may close; unknown modals are only reported, never clicked
|
|
35
|
+
- when: "[role='dialog']:has-text('cookies')"
|
|
36
|
+
click: "button:has-text('Reject')" # prefer the button that declines optional cookies
|
|
37
|
+
|
|
38
|
+
winapp:
|
|
39
|
+
window: {title_re: "REPLACE: the Copilot window title"}
|
|
40
|
+
elements:
|
|
41
|
+
input: "REPLACE: UI Automation path of the prompt box"
|
|
42
|
+
reply: "REPLACE: UI Automation path of the reply area"
|
|
43
|
+
|
|
44
|
+
prompts:
|
|
45
|
+
summarise: "Summarise the following in three sentences:\n\n{text}"
|
|
@@ -43,7 +43,8 @@ class Skin:
|
|
|
43
43
|
def locate(explicit: str | None = None) -> Path:
|
|
44
44
|
raw = explicit or os.environ.get("COPUPPET_SKIN")
|
|
45
45
|
if not raw:
|
|
46
|
-
raise SkinError("no skin given: pass --skin DIR or set COPUPPET_SKIN
|
|
46
|
+
raise SkinError("no skin given: pass --skin DIR or set COPUPPET_SKIN; to start one: copuppet init-skin DIR, "
|
|
47
|
+
"then copuppet discover (also as python -m copuppet ...)")
|
|
47
48
|
return Path(raw).expanduser()
|
|
48
49
|
|
|
49
50
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""First run on a managed PC: python -m copuppet, the packaged example skin, init-skin, discover in the package."""
|
|
2
|
+
import os
|
|
3
|
+
import subprocess
|
|
4
|
+
import sys
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
ROOT = Path(__file__).resolve().parents[1]
|
|
8
|
+
ENV = {**os.environ, "PYTHONPATH": str(ROOT / "src"), "COPUPPET_SKIN": ""}
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def run(*args):
|
|
12
|
+
return subprocess.run([sys.executable, "-m", "copuppet", *args], capture_output=True, text=True, env=ENV)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def test_python_dash_m_works():
|
|
16
|
+
r = run("--version")
|
|
17
|
+
assert r.returncode == 0 and r.stdout.startswith("copuppet ")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_packaged_example_skin_matches_config_example():
|
|
21
|
+
assert (ROOT / "src/copuppet/example_skin/skin.yaml").read_bytes() == (ROOT / "config.example/skin.yaml").read_bytes()
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def test_init_skin_copies_once(tmp_path):
|
|
25
|
+
r = run("init-skin", str(tmp_path / "s"))
|
|
26
|
+
assert r.returncode == 0 and "copuppet discover" in r.stdout
|
|
27
|
+
assert (tmp_path / "s/skin.yaml").read_text(encoding="utf-8").startswith("# Example skin")
|
|
28
|
+
assert run("init-skin", str(tmp_path / "s")).returncode == 2 # never overwrites
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def test_no_skin_error_names_the_way_forward():
|
|
32
|
+
r = run("check")
|
|
33
|
+
assert r.returncode == 2 and "init-skin" in r.stderr and "python -m copuppet" in r.stderr
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def test_discover_is_in_the_package():
|
|
37
|
+
r = run("discover", "--help")
|
|
38
|
+
assert r.returncode == 0 and "copuppet discover" in r.stdout
|
|
@@ -38,6 +38,7 @@ def test_ignored_notices_are_muted_but_never_a_challenge():
|
|
|
38
38
|
|
|
39
39
|
def test_skin_validates_notices_ignore(tmp_path):
|
|
40
40
|
import pytest
|
|
41
|
+
|
|
41
42
|
from copuppet.skin import SkinError, load
|
|
42
43
|
base = (tmp_path / "skin.yaml")
|
|
43
44
|
text = ("format: 1\nname: t\nbackends:\n edge:\n url: https://example.invalid/\n selectors:\n"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""Regression tests for red team 3 (driver mode and MCP), one per finding that was fixed."""
|
|
2
2
|
import pytest
|
|
3
|
+
from test_driver import planner
|
|
3
4
|
|
|
4
5
|
from copuppet.actions import CATALOG, run
|
|
5
6
|
from copuppet.driver import Driver
|
|
@@ -9,8 +10,6 @@ from copuppet.policy import Policy, PolicyError
|
|
|
9
10
|
from copuppet.protocol import Action
|
|
10
11
|
from copuppet.session import Limits, Session
|
|
11
12
|
|
|
12
|
-
from test_driver import planner
|
|
13
|
-
|
|
14
13
|
_PK = "RSA PRIVATE " + "KEY-----" # built in code: no literal key header in the repository
|
|
15
14
|
KEY = "-----BEGIN " + _PK + "\n" + "\n".join("MIIE" + "A" * 60 for _ in range(20)) + "\n-----END " + _PK + "\n"
|
|
16
15
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|