@mearl/cloud-connector 3.0.0-beta.8 → 3.0.0
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.
- package/README.en.md +178 -0
- package/README.md +3 -1
- package/dist/chunks/{chunk-QOO7GAHM.js → chunk-TFV2PE4T.js} +1 -1
- package/dist/cli.js +2 -2
- package/dist/index.js +1 -1
- package/package.json +5 -4
package/README.en.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# @mearl/cloud-connector
|
|
2
|
+
|
|
3
|
+
[简体中文](README.md) | [English](README.en.md)
|
|
4
|
+
|
|
5
|
+
A local connector forwarding cloud Agent operations to local native-host. WebSocket is built in; other protocols load from installed capability packages. Qoder credentials, pairing, and SSE are provided by the optional [`@mearl/plugin-qoder`](../../plugin-qoder/README.en.md).
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @mearl/cloud-connector
|
|
11
|
+
# Or
|
|
12
|
+
pnpm add -g @mearl/cloud-connector
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Two management modes
|
|
16
|
+
|
|
17
|
+
The connector supports two lifecycle modes sharing the same registry (see [runtime files](#runtime-files)), preventing duplicate connections to the same `server-url`:
|
|
18
|
+
|
|
19
|
+
1. **Managed by native-host** — Clicking Connect in the extension panel automatically launches the connector as a **foreground process** and monitors its status. No manual operation is needed.
|
|
20
|
+
2. **Self-managed daemon** — Use terminal subcommands such as `start` / `stop` to manage a background daemon with its own log file, useful without the extension panel, such as on remote machines or during troubleshooting.
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
mearl-cloud-connector <server-url> [options] # Run in foreground
|
|
26
|
+
mearl-cloud-connector <command> [server-url|pid] [options] # Manage background daemons
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Arguments:**
|
|
30
|
+
|
|
31
|
+
- `server-url` — `ws://` / `wss://`, or a URI declared by an installed capability. The core does not interpret pairing parameters in plugin URIs.
|
|
32
|
+
|
|
33
|
+
**Subcommands:**
|
|
34
|
+
|
|
35
|
+
- `start <server-url>` — Start a daemon in the background (idempotent: reuse an existing live connector).
|
|
36
|
+
- `stop <server-url|pid>` — Stop a background connector by endpoint or a PID shown by `list` / `status`;
|
|
37
|
+
the PID must match its current registration record, so a replaced instance is not stopped.
|
|
38
|
+
- `stop --all` — Stop all background connectors.
|
|
39
|
+
- `restart <server-url>` — Restart a connector.
|
|
40
|
+
- `status [server-url]` — Show connector health, recent heartbeats, and retry information;
|
|
41
|
+
omit `server-url` to summarize all connectors.
|
|
42
|
+
- `list` — List running connectors.
|
|
43
|
+
- `logs <server-url>` — Print the end of a connector's log.
|
|
44
|
+
|
|
45
|
+
**Options:**
|
|
46
|
+
|
|
47
|
+
- `--foreground` / `-f` — Run in foreground without daemonizing.
|
|
48
|
+
- `--heartbeat <seconds>` — Heartbeat interval (default 30 seconds).
|
|
49
|
+
- `--reconnect <ms>` — Reconnection interval (default 5000 milliseconds).
|
|
50
|
+
- `--max-reconnect <n>` — Maximum reconnect attempts; -1 means unlimited (default -1).
|
|
51
|
+
- `--connector-id <id>` — Override the machine's stable connector ID.
|
|
52
|
+
- `--name <name>` — Set a recognizable connector name (default: hostname).
|
|
53
|
+
- `--fail-fast` — Exit on the first connection failure (used by native-host to detect startup results).
|
|
54
|
+
|
|
55
|
+
**Examples:**
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Start a self-managed background connector with its own log file (recommended)
|
|
59
|
+
mearl-cloud-connector start "wss://cloud.example.com/ws?token=xxx" --name work-mac
|
|
60
|
+
|
|
61
|
+
# Optional protocol: install @mearl/plugin-qoder and generate a URL as described in its README
|
|
62
|
+
mearl-cloud-connector start "qoder://pair/pairing-code-1234?created=1786723200000"
|
|
63
|
+
|
|
64
|
+
# Foreground mode for troubleshooting or external managers such as systemd / PM2
|
|
65
|
+
mearl-cloud-connector "ws://localhost:8080/ws?token=xxx"
|
|
66
|
+
|
|
67
|
+
# Status / list / logs
|
|
68
|
+
mearl-cloud-connector status
|
|
69
|
+
mearl-cloud-connector list
|
|
70
|
+
mearl-cloud-connector logs "wss://cloud.example.com/ws?token=xxx"
|
|
71
|
+
|
|
72
|
+
# Stop
|
|
73
|
+
mearl-cloud-connector stop "wss://cloud.example.com/ws?token=xxx"
|
|
74
|
+
mearl-cloud-connector stop 12345
|
|
75
|
+
mearl-cloud-connector stop --all
|
|
76
|
+
|
|
77
|
+
# Custom heartbeat and reconnect settings
|
|
78
|
+
mearl-cloud-connector start "ws://localhost:8080/ws?token=xxx" --heartbeat 60 --max-reconnect 10
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
`status` reports `starting`, `healthy`, `reconnecting`, `degraded`, `failed`,
|
|
82
|
+
or `unknown`. `healthy` means the process is alive, the transport is connected, and WebSocket has recently received a valid heartbeat.
|
|
83
|
+
Records without connection-state fields report `unknown`; restarting the connector fills in those fields.
|
|
84
|
+
Tokens are hidden in output.
|
|
85
|
+
|
|
86
|
+
`start` returns after connecting; the background process continues running. For optional pairing protocols, follow the plugin instructions to submit the generated
|
|
87
|
+
`pair` tool call. If the pairing tool call has ended, been cancelled, or expired, generate a new pairing URL;
|
|
88
|
+
old URLs cannot be reused.
|
|
89
|
+
|
|
90
|
+
### Programmatic usage
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { CloudConnector } from '@mearl/cloud-connector';
|
|
94
|
+
|
|
95
|
+
const connector = new CloudConnector({
|
|
96
|
+
serverUrl: 'wss://cloud.example.com/ws?token=xxx',
|
|
97
|
+
connectorName: 'work-mac',
|
|
98
|
+
heartbeatInterval: 30,
|
|
99
|
+
reconnectInterval: 5000,
|
|
100
|
+
maxReconnectAttempts: -1,
|
|
101
|
+
onConnected: url => console.log('connected to', url),
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
connector.connect();
|
|
105
|
+
|
|
106
|
+
// Graceful shutdown
|
|
107
|
+
process.on('SIGINT', () => {
|
|
108
|
+
connector.disconnect();
|
|
109
|
+
process.exit(0);
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Runtime files
|
|
114
|
+
|
|
115
|
+
The first run generates a stable connector ID and stores it in
|
|
116
|
+
`~/.mearl/cloud-connector-identity.json`. The name defaults to the hostname and can be set with `--name` or
|
|
117
|
+
`MEARL_CONNECTOR_NAME`; set the ID with `--connector-id` or
|
|
118
|
+
`MEARL_CONNECTOR_ID`. A new connection with the same ID replaces the old one, supporting process restarts and network reconnections.
|
|
119
|
+
|
|
120
|
+
Each connector instance creates two files under `~/.mearl/connectors/`, keyed by a hash of `server-url`:
|
|
121
|
+
|
|
122
|
+
- `<hash>.json` — Registration record containing identity, process, connection state, recent heartbeats, and retries. The daemon
|
|
123
|
+
manager writes a `starting` placeholder immediately after spawning the child, which then updates its own status.
|
|
124
|
+
Removal checks the PID so an exiting process cannot delete a replacement's record. Readers automatically clean up crash remnants
|
|
125
|
+
by checking PID liveness.
|
|
126
|
+
- `<hash>.log` — Daemon log, read with `logs` or followed with `tail -f`. Logs over 5MB rotate to `<hash>.log.1` on the next start.
|
|
127
|
+
|
|
128
|
+
native-host and the daemon CLI read this registry through shared paths derived by [`@mearl/daemon-core`](../../daemon-core/README.en.md). Each can discover, reuse, or stop connectors started by the other.
|
|
129
|
+
|
|
130
|
+
> Foreground execution, including native-host management, logs to stdout/stderr without a separate log file. Only daemon mode writes `<hash>.log`.
|
|
131
|
+
|
|
132
|
+
See the corresponding capability package documentation for optional protocol authentication and pairing. The core does not read their credentials.
|
|
133
|
+
|
|
134
|
+
## Prerequisites
|
|
135
|
+
|
|
136
|
+
1. **Install and initialize the local Mearl environment**
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
npx @mearl/setup
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
setup installs `@mearl/native-host` and `@mearl/client` together and initializes Native Messaging.
|
|
143
|
+
|
|
144
|
+
Monorepo build outputs still require manual initialization:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
mearl-native-host --init
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
2. **Keep Chrome running**, with either:
|
|
151
|
+
- The Mearl browser extension installed, or
|
|
152
|
+
- Remote debugging enabled at `chrome://inspect/#remote-debugging` (Chrome 145+).
|
|
153
|
+
|
|
154
|
+
## Architecture
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
Cloud Agent
|
|
158
|
+
↓
|
|
159
|
+
@mearl/client
|
|
160
|
+
↓
|
|
161
|
+
@mearl/cloud-server
|
|
162
|
+
↓ (WebSocket)
|
|
163
|
+
@mearl/cloud-connector (this process)
|
|
164
|
+
↓ (Unix Socket)
|
|
165
|
+
@mearl/native-host
|
|
166
|
+
↓
|
|
167
|
+
Chrome Extension / CDP
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Installed connection protocols share the same lifecycle and status callbacks; their plugins describe the specific topology.
|
|
171
|
+
|
|
172
|
+
## Notes
|
|
173
|
+
|
|
174
|
+
- The connector must stay running to forward cloud requests. native-host launches it with `detached`, so it **survives extension reloads and updates**. Self-managed lifecycles use `start`/`stop`.
|
|
175
|
+
- When using an external process manager such as systemd / PM2, add `--foreground` and let the manager handle supervision and restarts.
|
|
176
|
+
- Automatic reconnection is configurable. Records persist across transient disconnects and are removed only when the process exits.
|
|
177
|
+
- Oversized cloud responses return a structured error while keeping the connection open. For large screenshots, select an element region
|
|
178
|
+
or retry with `format: "jpeg"` and a lower `quality`.
|
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @mearl/cloud-connector
|
|
2
2
|
|
|
3
|
+
[简体中文](README.md) | [English](README.en.md)
|
|
4
|
+
|
|
3
5
|
本地连接器,用于把云端 Agent 的操作转发到本地 native-host。内置传输为 WebSocket;其他协议通过已安装的能力包加载。Qoder 的凭据、配对和 SSE 实现在可选的 [`@mearl/plugin-qoder`](../../plugin-qoder/README.md) 中。
|
|
4
6
|
|
|
5
7
|
## 安装
|
|
@@ -123,7 +125,7 @@ process.on('SIGINT', () => {
|
|
|
123
125
|
存活性自动清理。
|
|
124
126
|
- `<hash>.log` —— 守护进程日志(`logs` 子命令读取,或 `tail -f` 跟踪);超过 5MB 会在下次启动时滚动为 `<hash>.log.1`。
|
|
125
127
|
|
|
126
|
-
native-host 与守护进程 CLI 都通过这套共享路径(由 [`@mearl/daemon-core`](../../daemon-core) 派生)读取注册表,因此一方启动的连接器另一方也能发现、复用或停止。
|
|
128
|
+
native-host 与守护进程 CLI 都通过这套共享路径(由 [`@mearl/daemon-core`](../../daemon-core/README.md) 派生)读取注册表,因此一方启动的连接器另一方也能发现、复用或停止。
|
|
127
129
|
|
|
128
130
|
> 前台运行(含 native-host 托管)时日志输出到 stdout/stderr,不写独立日志文件;只有守护进程模式才落盘到 `<hash>.log`。
|
|
129
131
|
|
|
@@ -77,7 +77,7 @@ async function loadConnectorPlugin(scheme, options) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
// src/index.ts
|
|
80
|
-
var CLOUD_CONNECTOR_VERSION = true ? "3.0.0
|
|
80
|
+
var CLOUD_CONNECTOR_VERSION = true ? "3.0.0" : "unknown";
|
|
81
81
|
var DEFAULT_RECONNECT_INTERVAL = 5e3;
|
|
82
82
|
var BACKOFF_BASE_MS = 1e3;
|
|
83
83
|
var BACKOFF_MAX_MS = 3e4;
|
package/dist/cli.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
CloudConnector,
|
|
4
4
|
isConnectorEndpoint,
|
|
5
5
|
resolveConnectorIdentity
|
|
6
|
-
} from "./chunks/chunk-
|
|
6
|
+
} from "./chunks/chunk-TFV2PE4T.js";
|
|
7
7
|
|
|
8
8
|
// src/cli.ts
|
|
9
9
|
import { Command, CommanderError, InvalidArgumentError } from "commander";
|
|
@@ -311,7 +311,7 @@ function runForeground(options) {
|
|
|
311
311
|
}
|
|
312
312
|
|
|
313
313
|
// src/cli.ts
|
|
314
|
-
var CLOUD_CONNECTOR_VERSION = true ? "3.0.0
|
|
314
|
+
var CLOUD_CONNECTOR_VERSION = true ? "3.0.0" : "unknown";
|
|
315
315
|
var SUBCOMMANDS = ["start", "stop", "restart", "status", "list", "logs"];
|
|
316
316
|
var CONNECTION_OPTION_NAMES = /* @__PURE__ */ new Set([
|
|
317
317
|
"foreground",
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mearl/cloud-connector",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Cloud connector for Mearl — bridges cloud agents to a local native-host",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"mearl-cloud-connector": "./dist/cli.js"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
|
+
"README.en.md",
|
|
22
23
|
"dist",
|
|
23
24
|
"!dist/**/*.map",
|
|
24
25
|
"!dist/**/__tests__/**",
|
|
@@ -39,9 +40,9 @@
|
|
|
39
40
|
"dependencies": {
|
|
40
41
|
"commander": "^14.0.3",
|
|
41
42
|
"ws": "^8.18.0",
|
|
42
|
-
"@mearl/client": "3.0.0
|
|
43
|
-
"@mearl/cloud-types": "3.0.0
|
|
44
|
-
"@mearl/daemon-core": "3.0.0
|
|
43
|
+
"@mearl/client": "3.0.0",
|
|
44
|
+
"@mearl/cloud-types": "3.0.0",
|
|
45
|
+
"@mearl/daemon-core": "3.0.0"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@types/node": "^24.9.1",
|