Wire validated core bridge, migrate daemon to it, verify live

This commit is contained in:
Fisto
2026-09-11 14:15:03 +02:00
parent e62d3007d8
commit 7d6650ce4e
27 changed files with 754 additions and 266 deletions
+6 -6
View File
@@ -46,14 +46,14 @@ when the action list changes.
| --- | --- | --- |
| Action protocol | `src/shared/puppetProtocol.ts` | Implemented |
| Validated actions | `src/renderer/puppet/actions.ts` | Implemented |
| Event push | `src/renderer/puppet/events.ts` | Pending |
| Main bridge | `src/main/puppetBridge.ts` | Pending |
| Core hooks | `src/main/main.ts`, `src/renderer/ipcCommands.ts`, `src/shared/IpcEvents.ts`, `src/preload/VesktopNative.ts` | Pending |
| Daemon (CDP transport) | `poc/src/` | Implemented and verified live |
| Daemon (core-bridge transport) | `poc/src/core-client.ts` | Pending |
| Event push | `src/renderer/puppet/events.ts` | Implemented |
| Main bridge | `src/main/puppetBridge.ts` | Implemented |
| Core hooks | `src/main/main.ts`, `src/renderer/ipcCommands.ts`, `src/shared/IpcEvents.ts`, `src/preload/VesktopNative.ts` | Implemented |
| Daemon (core-bridge transport) | `poc/src/core-client.ts` | Implemented and verified live |
| Daemon (CDP transport) | `poc/src/cdp-client.ts` | Kept as a development fallback |
| QR login | `poc/src/qr-login.ts` | Implemented and verified live |
| Pacing | `poc/src/pacing.ts` | Implemented |
| Trigger log and trust list | `poc/src/communication.ts`, `poc/src/puppet.ts` | Implemented on the CDP transport |
| Trigger log and trust list | `poc/src/communication.ts`, `poc/src/puppet.ts` | Implemented and verified live |
| Voice, audio, video | Not started | Not started |
## Data flow
+7 -3
View File
@@ -9,9 +9,13 @@ describes the protocol, the validation rules, and the hooks into upstream files.
| --- | --- | --- |
| `src/shared/puppetProtocol.ts` | Action names, error codes, limits, and shared types | Implemented |
| `src/renderer/puppet/actions.ts` | Validated action handlers and the core rate limit | Implemented |
| `src/renderer/puppet/events.ts` | Event normalization and push to main | Pending |
| `src/renderer/puppet/index.ts` | Renderer initialization | Pending |
| `src/main/puppetBridge.ts` | Unix socket server, request forwarding, event fan-out | Pending |
| `src/renderer/puppet/events.ts` | Event normalization and push to main | Implemented |
| `src/renderer/puppet/index.ts` | Renderer initialization | Implemented |
| `src/main/puppetBridge.ts` | Unix socket server, request forwarding, event fan-out | Implemented |
**Event subscription timing.** The event module must wait for the flux dispatcher with
`waitFor(filters.byProps("dispatch", "subscribe"), ...)`. A direct subscribe at module load can run
before Vencord registers the dispatcher. That mistake crashes the whole renderer bundle.
## Transport
+21 -16
View File
@@ -6,29 +6,27 @@ The daemon runs outside Vesktop. It holds all logic. It talks to the core bridge
| File | Role | Status |
| --- | --- | --- |
| `poc/src/control-bridge.ts` | MCP server, tool list, health endpoint | Implemented on CDP |
| `poc/src/control-bridge.ts` | MCP server, tool list, health endpoint | Implemented |
| `poc/src/puppet.ts` | Trust list, command handling, trigger log | Implemented |
| `poc/src/communication.ts` | Pure log and parser logic | Implemented |
| `poc/src/pacing.ts` | Paced queue and query coalescing | Implemented |
| `poc/src/cdp-client.ts` | Chrome DevTools Protocol client | Implemented (current transport) |
| `poc/src/discord.ts` | Client actions over CDP | Implemented (current transport) |
| `poc/src/core-client.ts` | Client actions over the core bridge | Pending (target transport) |
| `poc/src/core-client.ts` | Client actions over the core bridge | Implemented (primary transport) |
| `poc/src/cdp-client.ts` | Chrome DevTools Protocol client | Development fallback |
| `poc/src/qr-login.ts` | Terminal QR login | Implemented and verified |
| `poc/src/test-communication.ts` | Unit tests for the pure logic | Implemented |
| `poc/src/cdp-probe.ts` | CDP feasibility probe | Implemented (dev tool) |
| `poc/src/mock-core.ts` | Mock core bridge for daemon tests | Implemented |
| `poc/src/test-trigger.ts` | Inject a trigger event into the mock core | Implemented |
| `poc/src/cdp-probe.ts` | CDP feasibility probe | Development tool |
| `poc/src/cdp-dispatch.ts` | Run one CDP expression in the client | Development tool |
## Transport
The daemon supports two transports.
The primary transport is the validated core bridge. The daemon connects to
`vesktop-puppet.sock`. All actions go through the validated capability layer. See
[core-bridge.md](core-bridge.md).
1. **CDP (current)** — the daemon starts Vesktop with `--remote-debugging-port=9222`. The daemon
connects to the Discord page target. It evaluates the action code in the page and receives
events through a CDP binding. This transport needs no Vesktop patch. The project used it to
prove the concept and to test the client.
2. **Core bridge (target)** — the daemon connects to `vesktop-puppet.sock`. All actions go through
the validated capability layer. This transport gives the core-side guardrails.
The daemon logic is the same on both transports. Only the client class changes.
The CDP transport is a development fallback. It needs no Vesktop patch. It evaluates raw code in
the page, so it has no core-side guardrails. Use it for debugging only.
## Pacing
@@ -56,17 +54,24 @@ The daemon exposes MCP over Streamable HTTP. The default address is `http://127.
## Run commands
```sh
# Start the daemon. It connects to the client on CDP port 9222.
# Start the daemon. It connects to the core bridge.
pnpm control:bridge
# Start a mock core for tests without Electron.
VESKSLOP_SOCKET=/tmp/vesktop-puppet-mock.sock pnpm control:mock
# Inject a trigger event into the mock core.
VESKSLOP_SOCKET=/tmp/vesktop-puppet-mock.sock pnpm test:trigger
# Send one test DM. The only permitted live target is zzib.
pnpm poc:dm
# Run the pure-logic unit tests.
pnpm test:comm
# Probe CDP access and events.
# Development tools for the CDP fallback.
pnpm cdp:probe
CDP_EXPRESSION='...' pnpm cdp:dispatch
```
## Health endpoint
+30 -7
View File
@@ -31,14 +31,35 @@ pnpm build
The build writes the application to `dist/`.
## Mock core test
The mock core runs the daemon without Electron.
```sh
# Terminal 1: mock core
VESKSLOP_SOCKET=/tmp/vesktop-puppet-mock.sock pnpm control:mock
# Terminal 2: daemon
VESKSLOP_SOCKET=/tmp/vesktop-puppet-mock.sock pnpm control:bridge
# Terminal 3: inject an owner command
VESKSLOP_SOCKET=/tmp/vesktop-puppet-mock.sock TEST_TRIGGER_CONTENT="whitelist list" pnpm test:trigger
```
Expected result: the daemon log shows one trusted entry with the parsed command. The mock log shows
the reply (`message.send`). The reply wait is inside the 500 to 2800 ms window.
## CDP probe
The probe checks the current CDP transport. Start the client with
The probe checks the CDP fallback transport. Start the client with
`--remote-debugging-port=9222` first.
```sh
cd poc
pnpm cdp:probe
# Run one expression in the client.
CDP_EXPRESSION='Vencord.Webpack.Common.FluxDispatcher.dispatch({...})' pnpm cdp:dispatch
```
A good result shows the Vencord global, the Flux dispatcher, the current user, and one binding
@@ -82,20 +103,22 @@ cd poc
pnpm poc:dm
```
## CDP live results
## Live results
The CDP transport was verified on 2026-09-11:
The core bridge was verified live on 2026-09-11:
- `get_state` returned the real account and 7 guilds.
- `send_dm` delivered a real DM to zzib.
- The client ran headless under Xvfb.
- The token was seeded from the token file.
- A synthetic owner message flowed through the real event path. The daemon log held the entry with
the parsed command.
- The client ran headless under Xvfb with the token seeded from the token file.
The CDP transport was verified earlier with the same checks.
## Known gaps
| Gap | Effect |
| --- | --- |
| Mock core is not in the tree. | The daemon tests need the real client. |
| The trigger event path needs an incoming message. | Use zzib's account for a live test. |
| Live trigger tests need an incoming message. | Use the mock core, or send from zzib's account. |
| `message.read` is cache-only. | A channel that the client never opened returns zero messages. |
| Voice, audio, and video are not started. | No test coverage. |