@cocorograph/hub-agent 0.6.81 → 0.6.82
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/package.json +1 -1
- package/src/config.mjs +25 -1
- package/src/enroll.mjs +2 -1
- package/src/main.mjs +2 -1
- package/src/ws-client.mjs +2 -0
package/package.json
CHANGED
package/src/config.mjs
CHANGED
|
@@ -7,10 +7,34 @@
|
|
|
7
7
|
* られるように)。`$HUB_AGENT_CONFIG_DIR` を export しておくと、その値が
|
|
8
8
|
* 優先される (mosh / 専用ユーザー用)。
|
|
9
9
|
*/
|
|
10
|
-
import { promises as fs, constants as fsConsts } from "node:fs"
|
|
10
|
+
import { promises as fs, constants as fsConsts, readFileSync } from "node:fs"
|
|
11
11
|
import path from "node:path"
|
|
12
12
|
import os from "node:os"
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* 実行プラットフォームを返す。Hub の UI が OS 別コマンドを出し分けるために使う。
|
|
16
|
+
*
|
|
17
|
+
* 重要: Windows のエージェントは WSL2 内で動くため `process.platform` は "linux" を
|
|
18
|
+
* 返す。素の Linux と区別するため、WSL を検出して "wsl" を返す。
|
|
19
|
+
*
|
|
20
|
+
* @returns {"darwin"|"wsl"|"linux"|"win32"|string}
|
|
21
|
+
*/
|
|
22
|
+
export function detectPlatform() {
|
|
23
|
+
if (process.platform === "darwin") return "darwin"
|
|
24
|
+
if (process.platform === "win32") return "win32"
|
|
25
|
+
if (process.platform === "linux") {
|
|
26
|
+
if (process.env.WSL_DISTRO_NAME || process.env.WSL_INTEROP) return "wsl"
|
|
27
|
+
try {
|
|
28
|
+
const v = readFileSync("/proc/version", "utf-8").toLowerCase()
|
|
29
|
+
if (v.includes("microsoft") || v.includes("wsl")) return "wsl"
|
|
30
|
+
} catch {
|
|
31
|
+
/* /proc/version が読めない環境は素の linux 扱い */
|
|
32
|
+
}
|
|
33
|
+
return "linux"
|
|
34
|
+
}
|
|
35
|
+
return process.platform || "unknown"
|
|
36
|
+
}
|
|
37
|
+
|
|
14
38
|
function resolveConfigDir() {
|
|
15
39
|
if (process.env.HUB_AGENT_CONFIG_DIR) return process.env.HUB_AGENT_CONFIG_DIR
|
|
16
40
|
return path.join(os.homedir(), ".hub")
|
package/src/enroll.mjs
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import os from "node:os"
|
|
10
10
|
|
|
11
|
-
import { hasConfig, writeConfig } from "./config.mjs"
|
|
11
|
+
import { detectPlatform, hasConfig, writeConfig } from "./config.mjs"
|
|
12
12
|
|
|
13
13
|
const DEFAULT_HUB_URL = process.env.HUB_URL || "https://hub.cocorograph.com"
|
|
14
14
|
|
|
@@ -41,6 +41,7 @@ export async function enroll(enrollmentToken, opts = {}) {
|
|
|
41
41
|
enrollment_token: enrollmentToken,
|
|
42
42
|
hostname,
|
|
43
43
|
version,
|
|
44
|
+
platform: detectPlatform(),
|
|
44
45
|
}),
|
|
45
46
|
})
|
|
46
47
|
|
package/src/main.mjs
CHANGED
|
@@ -19,7 +19,7 @@ import path from "node:path"
|
|
|
19
19
|
|
|
20
20
|
import pino from "pino"
|
|
21
21
|
|
|
22
|
-
import { readConfig, writeConfig } from "./config.mjs"
|
|
22
|
+
import { detectPlatform, readConfig, writeConfig } from "./config.mjs"
|
|
23
23
|
import { loadPlugins, runHookBroadcast, runHookChain } from "./plugin-loader.mjs"
|
|
24
24
|
import { WsClient } from "./ws-client.mjs"
|
|
25
25
|
import { PtyBridge } from "./pty-bridge.mjs"
|
|
@@ -405,6 +405,7 @@ export async function startDaemon({ version, ptyModule, claudeSdk } = {}) {
|
|
|
405
405
|
const client = new WsClient(config, {
|
|
406
406
|
logger,
|
|
407
407
|
version,
|
|
408
|
+
platform: detectPlatform(),
|
|
408
409
|
bundleVersion,
|
|
409
410
|
bundleVersionProvider: readBundleVersionSync,
|
|
410
411
|
bundleManifestPath: BUNDLE_MANIFEST_PATH,
|
package/src/ws-client.mjs
CHANGED
|
@@ -84,6 +84,7 @@ export class WsClient extends EventEmitter {
|
|
|
84
84
|
this.bundleWatcher = null
|
|
85
85
|
this.bundleWatchDebounceTimer = null
|
|
86
86
|
this.hostname = opts.hostname || os.hostname()
|
|
87
|
+
this.platform = opts.platform || "unknown"
|
|
87
88
|
this.ws = null
|
|
88
89
|
this.heartbeatTimer = null
|
|
89
90
|
this.reconnectTimer = null
|
|
@@ -190,6 +191,7 @@ export class WsClient extends EventEmitter {
|
|
|
190
191
|
hostname: this.hostname,
|
|
191
192
|
version: this.version,
|
|
192
193
|
bundle_version: this.bundleVersion,
|
|
194
|
+
platform: this.platform,
|
|
193
195
|
})
|
|
194
196
|
// Plan ε: 毎回 reconnect 直後に backend ↔ agent の stream_id を能動同期する
|
|
195
197
|
// (orphan stream の即時 kill 用)。response は main.mjs の dispatch が拾い、
|