@mearl/cloud-types 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 ADDED
@@ -0,0 +1,89 @@
1
+ # @mearl/cloud-types
2
+
3
+ [简体中文](README.md) | [English](README.en.md)
4
+
5
+ Shared types and constants for Mearl's cloud communication links.
6
+
7
+ `@mearl/client`, `cloud-server`, and `cloud-connector` communicate over WebSocket. This package defines their **shared wire protocol**: message structures, heartbeats, buffer limits, and default timeouts, keeping all three participants consistent.
8
+
9
+ > For internal monorepo use only.
10
+
11
+ ## Exports
12
+
13
+ ### Message types
14
+
15
+ ```typescript
16
+ interface CloudMessage {
17
+ id: string;
18
+ action: string;
19
+ data: Record<string, any>;
20
+ connector?: string;
21
+ browser?: string;
22
+ timeoutSec?: number;
23
+ }
24
+
25
+ interface CloudResponse {
26
+ id: string;
27
+ success: boolean;
28
+ data?: any;
29
+ error?: string;
30
+ versionWarning?: string;
31
+ }
32
+
33
+ interface HeartbeatMessage {
34
+ type: 'ping' | 'pong';
35
+ timestamp: number;
36
+ }
37
+
38
+ interface AgentHelloMessage {
39
+ type: 'agent_hello';
40
+ }
41
+
42
+ interface ConnectorHelloMessage {
43
+ type: 'connector_hello';
44
+ connectorId: string;
45
+ name: string;
46
+ version?: string;
47
+ }
48
+ ```
49
+
50
+ ### Type guards
51
+
52
+ ```typescript
53
+ isAgentHelloMessage(msg): msg is AgentHelloMessage
54
+ isConnectorHelloMessage(msg): msg is ConnectorHelloMessage
55
+ isHeartbeatMessage(msg): msg is HeartbeatMessage
56
+ isCloudMessage(msg): msg is CloudMessage
57
+ isCloudResponse(msg): msg is CloudResponse
58
+ ```
59
+
60
+ `resolveCloudConnectorSelector(connectors, selector)` resolves a connector by exact ID, exact name, then unique fuzzy match,
61
+ distinguishing a match, ambiguity, and no match.
62
+
63
+ ### Constants
64
+
65
+ ```typescript
66
+ MAX_BUFFER_SIZE; // 10 MB, maximum buffer per message
67
+ DEFAULT_REQUEST_TIMEOUT; // 60s
68
+ DEFAULT_CONNECT_TIMEOUT; // 30s
69
+ DEFAULT_HEARTBEAT_INTERVAL; // 30s
70
+ DEFAULT_HEARTBEAT_TIMEOUT; // 90s
71
+ ```
72
+
73
+ ## Usage
74
+
75
+ ```typescript
76
+ import { type CloudMessage, isCloudResponse, DEFAULT_REQUEST_TIMEOUT } from '@mearl/cloud-types';
77
+ ```
78
+
79
+ ## Build
80
+
81
+ ```bash
82
+ pnpm build # Compile with tsc into dist/
83
+ pnpm dev # tsc --watch
84
+ pnpm typecheck # Type checking only
85
+ ```
86
+
87
+ ## License
88
+
89
+ Apache-2.0
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @mearl/cloud-types
2
2
 
3
+ [简体中文](README.md) | [English](README.en.md)
4
+
3
5
  Mearl 云端通信链路的共享类型与常量。
4
6
 
5
7
  `@mearl/client`、`cloud-server`、`cloud-connector` 三端通过 WebSocket 互通,本包定义它们之间消息的**统一协议**(消息结构、心跳、缓冲区上限、各类超时默认值),确保三端对线上格式始终一致。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mearl/cloud-types",
3
- "version": "3.0.0-beta.8",
3
+ "version": "3.0.0",
4
4
  "description": "Shared types for Mearl cloud communication packages",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -12,6 +12,7 @@
12
12
  }
13
13
  },
14
14
  "files": [
15
+ "README.en.md",
15
16
  "dist",
16
17
  "!dist/**/*.map"
17
18
  ],