@honor-claw/yoyo 2026.6.9-alpha.3 → 2026.6.9-alpha.5
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/dist/apis/claw-cloud.mjs +6 -4
- package/dist/capabilities/node/index.mjs +2 -0
- package/dist/capabilities/node/invoke.mjs +39 -0
- package/dist/capabilities/node/list.mjs +25 -11
- package/dist/capabilities/node/types.mjs +6 -0
- package/dist/channel/accounts.mjs +1 -1
- package/dist/channel/consts.mjs +1 -1
- package/dist/channel/directory.mjs +5 -2
- package/dist/channel/lifecycle.mjs +9 -25
- package/dist/channel/security.mjs +2 -6
- package/dist/channel/setup-wizard.mjs +2 -4
- package/dist/channel/status.mjs +29 -42
- package/dist/cloud-channel/channel.mjs +27 -21
- package/dist/cloud-channel/dispatcher/helpers.mjs +19 -0
- package/dist/cloud-channel/dispatcher/impl.mjs +72 -0
- package/dist/cloud-channel/dispatcher/index.mjs +1 -0
- package/dist/cloud-channel/handlers/context/handler.mjs +55 -36
- package/dist/cloud-channel/log-summary.mjs +2 -2
- package/dist/cloud-channel/transport/index.mjs +3 -0
- package/dist/commands/login/impl.mjs +13 -13
- package/dist/commands/status/index.mjs +8 -8
- package/dist/connection/client.mjs +73 -7
- package/dist/connection/index.mjs +1 -2
- package/dist/connection/monitor.mjs +14 -25
- package/dist/connection/registry.mjs +25 -0
- package/dist/core/hooks/entry.mjs +7 -6
- package/dist/core/hooks/gateway-lifecycle.mjs +21 -0
- package/dist/gateway/client/client.mjs +1 -1
- package/dist/honor-auth/logout.mjs +1 -1
- package/dist/honor-auth/vault/impl.mjs +46 -57
- package/dist/honor-auth/vault/legacy-migration.mjs +8 -8
- package/dist/index.mjs +4 -4
- package/dist/messaging/dispatchers/command/impl.mjs +6 -4
- package/dist/messaging/dispatchers/stream/controller.mjs +0 -3
- package/dist/messaging/dispatchers/stream/hooks.mjs +0 -5
- package/dist/messaging/inbound/abort/detect.mjs +5 -5
- package/dist/messaging/inbound/abort/index.mjs +1 -1
- package/dist/messaging/inbound/context.mjs +14 -14
- package/dist/messaging/inbound/interrupt.mjs +22 -21
- package/dist/messaging/inbound/new-session.mjs +21 -18
- package/dist/messaging/inbound/user-message.mjs +3 -3
- package/dist/messaging/send/frame.mjs +8 -13
- package/dist/modules/configs/channel.mjs +18 -12
- package/dist/modules/configs/index.mjs +2 -2
- package/dist/modules/configs/plugin-init.mjs +32 -28
- package/dist/modules/device/device-info.mjs +7 -7
- package/dist/modules/device/index.mjs +1 -1
- package/dist/modules/status/channel.mjs +1 -17
- package/dist/provisioning/registration/register.mjs +52 -28
- package/dist/provisioning/toolset/ack.mjs +10 -15
- package/dist/provisioning/toolset/skill-refresh-marker.mjs +1 -1
- package/dist/tools/error.mjs +9 -0
- package/dist/tools/index.mjs +10 -0
- package/dist/tools/node-invoke/index.mjs +1 -0
- package/dist/tools/node-invoke/status-mapper.mjs +23 -0
- package/dist/tools/node-invoke/tool.mjs +48 -0
- package/dist/tools/nodes-status/index.mjs +2 -0
- package/dist/tools/nodes-status/mapper.mjs +19 -0
- package/dist/tools/nodes-status/tool.mjs +44 -0
- package/dist/utils/claw-logger.mjs +1 -1
- package/dist/utils/fs-safe.mjs +30 -30
- package/openclaw.plugin.json +3 -0
- package/package.json +3 -2
- package/skills/yoyo-phone-control/SKILL.md +61 -58
- package/skills/yoyo-phone-control/configs/sub-skills.json +2 -21
- package/skills/yoyo-phone-control/references/airplane-mode.md +9 -77
- package/skills/yoyo-phone-control/references/app-close.md +260 -333
- package/skills/yoyo-phone-control/references/app-open.md +261 -334
- package/skills/yoyo-phone-control/references/app-uninstall.md +182 -229
- package/skills/yoyo-phone-control/references/audio-record.md +148 -211
- package/skills/yoyo-phone-control/references/autoscreen-onnotice.md +133 -196
- package/skills/yoyo-phone-control/references/battery.md +177 -252
- package/skills/yoyo-phone-control/references/bluetooth.md +272 -338
- package/skills/yoyo-phone-control/references/brightness.md +161 -224
- package/skills/yoyo-phone-control/references/call-phone.md +142 -187
- package/skills/yoyo-phone-control/references/call-search.md +141 -207
- package/skills/yoyo-phone-control/references/camera.md +153 -216
- package/skills/yoyo-phone-control/references/capture-screenshot.md +137 -211
- package/skills/yoyo-phone-control/references/clean-dirty.md +9 -65
- package/skills/yoyo-phone-control/references/contact-search.md +163 -240
- package/skills/yoyo-phone-control/references/dark-mode.md +137 -200
- package/skills/yoyo-phone-control/references/desktop.md +9 -65
- package/skills/yoyo-phone-control/references/device-operation.md +166 -226
- package/skills/yoyo-phone-control/references/express-logistics-search.md +9 -77
- package/skills/yoyo-phone-control/references/eyecomfort.md +163 -226
- package/skills/yoyo-phone-control/references/file-upload.md +286 -362
- package/skills/yoyo-phone-control/references/flashlight.md +9 -77
- package/skills/yoyo-phone-control/references/gui-task-create.md +153 -206
- package/skills/yoyo-phone-control/references/gui-task-pause.md +125 -188
- package/skills/yoyo-phone-control/references/gui-task-terminate.md +129 -192
- package/skills/yoyo-phone-control/references/hotspot.md +113 -183
- package/skills/yoyo-phone-control/references/local-search.md +224 -307
- package/skills/yoyo-phone-control/references/location-service.md +121 -184
- package/skills/yoyo-phone-control/references/message-search.md +309 -375
- package/skills/yoyo-phone-control/references/message-send.md +184 -251
- package/skills/yoyo-phone-control/references/mobile-data.md +184 -257
- package/skills/yoyo-phone-control/references/nfc.md +133 -196
- package/skills/yoyo-phone-control/references/no-disturb.md +230 -334
- package/skills/yoyo-phone-control/references/quiet-mode.md +160 -237
- package/skills/yoyo-phone-control/references/ringing-mode.md +151 -232
- package/skills/yoyo-phone-control/references/scan-code.md +9 -65
- package/skills/yoyo-phone-control/references/status-bar-show.md +149 -211
- package/skills/yoyo-phone-control/references/task-result-query.md +49 -59
- package/skills/yoyo-phone-control/references/usb-shared-network.md +136 -198
- package/skills/yoyo-phone-control/references/vibration-mode.md +163 -239
- package/skills/yoyo-phone-control/references/wlan.md +324 -410
- package/dist/cloud-channel/transport/outbound-port.mjs +0 -38
- package/dist/connection/manager.mjs +0 -92
- package/dist/core/service/index.mjs +0 -27
- package/skills/yoyo-phone-control/references/alarm-create.md +0 -519
- package/skills/yoyo-phone-control/references/alarm-delete.md +0 -370
- package/skills/yoyo-phone-control/references/alarm-disable.md +0 -372
- package/skills/yoyo-phone-control/references/alarm-enable.md +0 -372
- package/skills/yoyo-phone-control/references/alarm-query.md +0 -565
- package/skills/yoyo-phone-control/references/alarm-update.md +0 -461
- package/skills/yoyo-phone-control/references/countdown-timer.md +0 -393
- package/skills/yoyo-phone-control/references/schedule-create.md +0 -541
- package/skills/yoyo-phone-control/references/schedule-delete.md +0 -582
- package/skills/yoyo-phone-control/references/schedule-search.md +0 -673
- package/skills/yoyo-phone-control/references/schedule-update.md +0 -630
- package/skills/yoyo-phone-control/references/screen-record.md +0 -236
- package/skills/yoyo-phone-control/references/volume-operate.md +0 -284
package/dist/apis/claw-cloud.mjs
CHANGED
|
@@ -57,13 +57,15 @@ var o = class {
|
|
|
57
57
|
"x-jwt-token": n.token,
|
|
58
58
|
"x-device-id": e.deviceId,
|
|
59
59
|
"x-udid": e.deviceId
|
|
60
|
+
}, a = {
|
|
61
|
+
businessTag: "YOYO_CLAW",
|
|
62
|
+
role: "node",
|
|
63
|
+
ignoreBizExtInfo: !0,
|
|
64
|
+
...r?.deviceIdList?.length ? { deviceIdList: r.deviceIdList } : {}
|
|
60
65
|
};
|
|
61
66
|
return this.httpClient.post("/v1/user/devicelist", {
|
|
62
67
|
headers: i,
|
|
63
|
-
body:
|
|
64
|
-
businessTag: "YOYO_CLAW",
|
|
65
|
-
role: "node"
|
|
66
|
-
},
|
|
68
|
+
body: a,
|
|
67
69
|
timeout: r?.timeoutMs ?? 3e4
|
|
68
70
|
});
|
|
69
71
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { clawLogger as e } from "../../utils/claw-logger.mjs";
|
|
2
|
+
import { buildEndpoint as t } from "../../cloud-channel/protocol/target.mjs";
|
|
3
|
+
import { ClawClient as n } from "../../connection/registry.mjs";
|
|
4
|
+
//#region src/capabilities/node/invoke.ts
|
|
5
|
+
var r = e("capabilities/node-invoke");
|
|
6
|
+
async function i(e) {
|
|
7
|
+
let r = {
|
|
8
|
+
to: t("node", e.nodeId),
|
|
9
|
+
msgType: "nodeInvokeRequest",
|
|
10
|
+
data: { node: {
|
|
11
|
+
toolCallId: e.toolCallId,
|
|
12
|
+
nodeId: e.nodeId,
|
|
13
|
+
name: e.name,
|
|
14
|
+
params: e.params
|
|
15
|
+
} }
|
|
16
|
+
};
|
|
17
|
+
return n.request(e.accountId, r, {
|
|
18
|
+
timeoutMs: e.timeoutMs,
|
|
19
|
+
matchResult: a
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function a(e) {
|
|
23
|
+
if (e.payload.msgType !== "nodeInvokeResult") return { matched: !1 };
|
|
24
|
+
let t = e.data?.node;
|
|
25
|
+
return !t || typeof t.runStatus != "number" || !t.nodeId || !t.toolCallId ? (r.warn("nodeInvokeResult missing required fields", { node: t }), {
|
|
26
|
+
matched: !0,
|
|
27
|
+
error: "missing required fields in invoke result"
|
|
28
|
+
}) : {
|
|
29
|
+
matched: !0,
|
|
30
|
+
result: {
|
|
31
|
+
nodeId: t.nodeId,
|
|
32
|
+
toolCallId: t.toolCallId,
|
|
33
|
+
runStatus: t.runStatus,
|
|
34
|
+
result: t.result
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { i as invokeNodeTool };
|
|
@@ -3,23 +3,37 @@ import { clawLogger as t } from "../../utils/claw-logger.mjs";
|
|
|
3
3
|
import { getCurrentUser as n } from "../../honor-auth/vault/impl.mjs";
|
|
4
4
|
import { isOKResponse as r } from "../../apis/helpers.mjs";
|
|
5
5
|
import { createClawCloudClient as i } from "../../apis/claw-cloud.mjs";
|
|
6
|
-
import "../../apis/index.mjs";
|
|
7
6
|
import { getDeviceInfo as a } from "../../modules/device/device-info.mjs";
|
|
8
7
|
import "../../modules/device/index.mjs";
|
|
9
8
|
import "../../honor-auth/vault/index.mjs";
|
|
9
|
+
import "../../apis/index.mjs";
|
|
10
|
+
import { ToolError as o } from "../../tools/error.mjs";
|
|
10
11
|
//#region src/capabilities/node/list.ts
|
|
11
|
-
var
|
|
12
|
-
async function
|
|
13
|
-
let
|
|
14
|
-
if (!
|
|
12
|
+
var s = t("capabilities/node");
|
|
13
|
+
async function c(t) {
|
|
14
|
+
let c = await n();
|
|
15
|
+
if (!c?.token || !c.userId) throw s.error("node device list skipped: no current user"), new o("unauthorized", "missing current user token");
|
|
16
|
+
let l;
|
|
17
|
+
try {
|
|
18
|
+
l = await a();
|
|
19
|
+
} catch (e) {
|
|
20
|
+
throw s.error("node device list failed to get device info", e), new o("device_info", "failed to get device info", { cause: e });
|
|
21
|
+
}
|
|
15
22
|
try {
|
|
16
|
-
let e = await
|
|
17
|
-
if (!r(
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
let e = await i().getDeviceList(l, c, { deviceIdList: t?.deviceIdList });
|
|
24
|
+
if (!r(e)) {
|
|
25
|
+
let t = e.data?.code, n = e.data?.cnMessage;
|
|
26
|
+
throw s.error("node device list response not ok", null, {
|
|
27
|
+
status: e.status,
|
|
28
|
+
code: t,
|
|
29
|
+
cnMessage: n
|
|
30
|
+
}), new o("api_failed", `code=${t} message=${n}`);
|
|
31
|
+
}
|
|
32
|
+
let n = e.data.data?.deviceList;
|
|
33
|
+
return { devices: Array.isArray(n) ? n : [] };
|
|
20
34
|
} catch (t) {
|
|
21
|
-
|
|
35
|
+
throw t instanceof o ? t : (s.error("node device list failed", t), new o("network_error", e(t), { cause: t }));
|
|
22
36
|
}
|
|
23
37
|
}
|
|
24
38
|
//#endregion
|
|
25
|
-
export {
|
|
39
|
+
export { c as listNodeDevices };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
//#region src/capabilities/node/types.ts
|
|
2
|
+
var e = /* @__PURE__ */ function(e) {
|
|
3
|
+
return e[e.Processing = 0] = "Processing", e[e.ProcessingAlt = 100] = "ProcessingAlt", e[e.Suspended = 101] = "Suspended", e[e.Success = 200] = "Success", e[e.InternalError = 300] = "InternalError", e[e.CompensationFailed = 400] = "CompensationFailed", e;
|
|
4
|
+
}({});
|
|
5
|
+
//#endregion
|
|
6
|
+
export { e as NodeInvokeRunStatusE };
|
package/dist/channel/consts.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
//#region src/channel/consts.ts
|
|
2
|
-
var e = "YOYO控虾", t = "
|
|
2
|
+
var e = "YOYO控虾", t = "HONOR/yoyo (YOYO控虾)", n = "/channels/yoyo", r = "yoyo", i = "Connect OpenClaw to Honor YOYO Assistant.";
|
|
3
3
|
//#endregion
|
|
4
4
|
export { i as YOYO_CHANNEL_BLURB, r as YOYO_CHANNEL_DOCS_LABEL, n as YOYO_CHANNEL_DOCS_PATH, e as YOYO_CHANNEL_LABEL, t as YOYO_CHANNEL_SELECTION_LABEL };
|
|
@@ -2,8 +2,11 @@ import { listNodeDevices as e } from "../capabilities/node/list.mjs";
|
|
|
2
2
|
import "../capabilities/node/index.mjs";
|
|
3
3
|
//#region src/channel/directory.ts
|
|
4
4
|
async function t(t) {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
try {
|
|
6
|
+
return i((await e()).devices.filter((e) => r(e)).map((e) => n(e)), t);
|
|
7
|
+
} catch {
|
|
8
|
+
return [];
|
|
9
|
+
}
|
|
7
10
|
}
|
|
8
11
|
function n(e) {
|
|
9
12
|
let t = e.deviceId.trim(), n = e.deviceName?.trim() || t;
|
|
@@ -1,37 +1,21 @@
|
|
|
1
1
|
import { clawLogger as e } from "../utils/claw-logger.mjs";
|
|
2
2
|
import { disposeAccountMessaging as t } from "../messaging/dispose.mjs";
|
|
3
3
|
import "../messaging/index.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import "../modules/status/index.mjs";
|
|
6
|
-
import { monitorAccount as r } from "../connection/monitor.mjs";
|
|
4
|
+
import { monitorAccount as n } from "../connection/monitor.mjs";
|
|
7
5
|
import "../connection/index.mjs";
|
|
8
6
|
//#region src/channel/lifecycle.ts
|
|
9
|
-
var
|
|
7
|
+
var r = e("channel/lifecycle"), i = {
|
|
10
8
|
async startAccount(e) {
|
|
11
9
|
let t = e.accountId;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
abortSignal: e.abortSignal
|
|
17
|
-
});
|
|
18
|
-
} catch (e) {
|
|
19
|
-
throw await n(t, {
|
|
20
|
-
running: !1,
|
|
21
|
-
connected: !1,
|
|
22
|
-
lastStartAt: null,
|
|
23
|
-
lastError: "account not ready"
|
|
24
|
-
}), e;
|
|
25
|
-
}
|
|
10
|
+
r.info("start account channel", { accountId: t }), await n({
|
|
11
|
+
accountId: t,
|
|
12
|
+
abortSignal: e.abortSignal
|
|
13
|
+
});
|
|
26
14
|
},
|
|
27
15
|
async stopAccount(e) {
|
|
28
|
-
let
|
|
29
|
-
await t(
|
|
30
|
-
running: !1,
|
|
31
|
-
connected: !1,
|
|
32
|
-
lastStopAt: Date.now()
|
|
33
|
-
}), i.info("stop account channel", { accountId: r });
|
|
16
|
+
let n = e.accountId;
|
|
17
|
+
await t(n), r.info("stop account channel", { accountId: n });
|
|
34
18
|
}
|
|
35
19
|
};
|
|
36
20
|
//#endregion
|
|
37
|
-
export {
|
|
21
|
+
export { i as yoyoChannelGateway };
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import { ClawClient as e } from "../connection/client.mjs";
|
|
2
|
-
import { getCurrentUser as t } from "../honor-auth/vault/impl.mjs";
|
|
3
|
-
import "../honor-auth/vault/index.mjs";
|
|
4
|
-
import "../connection/index.mjs";
|
|
5
1
|
//#region src/channel/security.ts
|
|
6
|
-
var
|
|
2
|
+
var e = { collectWarnings: async ({ account: e }) => e.configured === !1 ? ["YOYO channel has not been configured. Run `openclaw configure (channel/yoyo)`."] : e.enabled === !1 ? ["YOYO channel is disabled. Run `openclaw configure (channel/yoyo)` to enable it."] : [] };
|
|
7
3
|
//#endregion
|
|
8
|
-
export {
|
|
4
|
+
export { e as yoyoChannelSecurity };
|
|
@@ -8,12 +8,10 @@ import "../honor-auth/index.mjs";
|
|
|
8
8
|
var s = {
|
|
9
9
|
channel: e,
|
|
10
10
|
async getStatus(n) {
|
|
11
|
-
let r = a(n.cfg) !== t;
|
|
12
11
|
return {
|
|
13
12
|
channel: e,
|
|
14
|
-
configured:
|
|
15
|
-
statusLines: [
|
|
16
|
-
selectionHint: r ? "Ready" : "Login Required"
|
|
13
|
+
configured: a(n.cfg) !== t,
|
|
14
|
+
statusLines: []
|
|
17
15
|
};
|
|
18
16
|
},
|
|
19
17
|
configure: async (e) => {
|
package/dist/channel/status.mjs
CHANGED
|
@@ -1,46 +1,33 @@
|
|
|
1
1
|
import { YOYO_DEFAULT_ACCOUNT_ID as e } from "../consts.mjs";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
configured: !1,
|
|
9
|
-
running: !1,
|
|
10
|
-
connected: !1
|
|
11
|
-
}, r = {
|
|
12
|
-
defaultRuntime: n,
|
|
13
|
-
buildChannelSummary: async ({ account: e, defaultAccountId: n, snapshot: r }) => {
|
|
14
|
-
let i = await t(e.accountId);
|
|
15
|
-
return {
|
|
16
|
-
accountId: e.accountId,
|
|
17
|
-
defaultAccountId: n,
|
|
18
|
-
configured: e.configured,
|
|
19
|
-
enabled: e.enabled,
|
|
20
|
-
brand: "honor",
|
|
21
|
-
running: r.running ?? i.running,
|
|
22
|
-
connected: r.connected ?? i.connected,
|
|
23
|
-
lastStartAt: r.lastStartAt ?? i.lastStartAt,
|
|
24
|
-
lastStopAt: r.lastStopAt ?? i.lastStopAt,
|
|
25
|
-
lastError: r.lastError ?? i.lastError
|
|
26
|
-
};
|
|
2
|
+
var t = {
|
|
3
|
+
defaultRuntime: {
|
|
4
|
+
accountId: e,
|
|
5
|
+
enabled: !1,
|
|
6
|
+
configured: !1,
|
|
7
|
+
running: !1
|
|
27
8
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
9
|
+
buildChannelSummary: async ({ snapshot: e }) => ({
|
|
10
|
+
configured: e.configured ?? !1,
|
|
11
|
+
running: e.running ?? !1,
|
|
12
|
+
brand: "honor",
|
|
13
|
+
lastStartAt: e.lastStartAt ?? null,
|
|
14
|
+
lastStopAt: e.lastStopAt ?? null,
|
|
15
|
+
lastError: e.lastError ?? null,
|
|
16
|
+
port: e.port ?? null,
|
|
17
|
+
probe: e.probe,
|
|
18
|
+
lastProbeAt: e.lastProbeAt ?? null
|
|
19
|
+
}),
|
|
20
|
+
buildAccountSnapshot: async ({ account: e, runtime: t }) => ({
|
|
21
|
+
accountId: e.accountId,
|
|
22
|
+
enabled: e.enabled,
|
|
23
|
+
configured: e.configured,
|
|
24
|
+
brand: "honor",
|
|
25
|
+
running: t?.running ?? !1,
|
|
26
|
+
lastStartAt: t?.lastStartAt ?? null,
|
|
27
|
+
lastStopAt: t?.lastStopAt ?? null,
|
|
28
|
+
lastError: t?.lastError ?? null,
|
|
29
|
+
port: t?.port ?? null
|
|
30
|
+
})
|
|
44
31
|
};
|
|
45
32
|
//#endregion
|
|
46
|
-
export {
|
|
33
|
+
export { t as yoyoChannelStatus };
|
|
@@ -4,19 +4,21 @@ import { AdminCapabilityImpl as n } from "../capabilities/admin/impl.mjs";
|
|
|
4
4
|
import { GatewaySessionManager as r } from "../gateway/session/manager.mjs";
|
|
5
5
|
import { RecurringTimer as i } from "../utils/recurring-timer.mjs";
|
|
6
6
|
import { AuthorizationRefreshManager as a } from "./authorization/refresh-manager.mjs";
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
7
|
+
import { createCloudDispatcher as o } from "./dispatcher/impl.mjs";
|
|
8
|
+
import "./dispatcher/index.mjs";
|
|
9
|
+
import { registerAuthHandler as s } from "./handlers/auth.mjs";
|
|
10
|
+
import { registerContextHandler as c } from "./handlers/context/handler.mjs";
|
|
9
11
|
import "./handlers/context/index.mjs";
|
|
10
|
-
import { registerPairingHandler as
|
|
11
|
-
import { registerUserMessageHandler as
|
|
12
|
-
import { summarizeServiceEvent as
|
|
13
|
-
import { V1Adapter as
|
|
14
|
-
import { V2Adapter as
|
|
12
|
+
import { registerPairingHandler as l } from "./handlers/pairing.mjs";
|
|
13
|
+
import { registerUserMessageHandler as u } from "./handlers/user-message.mjs";
|
|
14
|
+
import { summarizeServiceEvent as d } from "./log-summary.mjs";
|
|
15
|
+
import { V1Adapter as f } from "./protocol/v1-adapter.mjs";
|
|
16
|
+
import { V2Adapter as p } from "./protocol/v2-adapter.mjs";
|
|
15
17
|
import "./protocol/index.mjs";
|
|
16
|
-
import { CloudSocket as
|
|
17
|
-
import { CloudEventBus as
|
|
18
|
-
import { MessageHandler as
|
|
19
|
-
import
|
|
18
|
+
import { CloudSocket as m } from "./transport/cloud-socket.mjs";
|
|
19
|
+
import { CloudEventBus as h } from "./transport/event-bus.mjs";
|
|
20
|
+
import { MessageHandler as g } from "./transport/message-handler.mjs";
|
|
21
|
+
import "./transport/index.mjs";
|
|
20
22
|
import { buildCloudSocketConnectParams as _ } from "./utils.mjs";
|
|
21
23
|
//#region src/cloud-channel/channel.ts
|
|
22
24
|
var v = e("channel"), y = 3e4, b = "v2", x = class {
|
|
@@ -27,28 +29,32 @@ var v = e("channel"), y = 3e4, b = "v2", x = class {
|
|
|
27
29
|
authorizationRefreshManager;
|
|
28
30
|
messageHandler;
|
|
29
31
|
adapter;
|
|
30
|
-
|
|
32
|
+
dispatcher;
|
|
31
33
|
protocol;
|
|
32
34
|
businessPingTimer = new i("recurring");
|
|
33
35
|
constructor(e) {
|
|
34
36
|
this.config = e;
|
|
35
|
-
let t = new
|
|
36
|
-
this.protocol = e.protocol ?? b, this.messageHandler = new
|
|
37
|
+
let t = new h();
|
|
38
|
+
this.protocol = e.protocol ?? b, this.messageHandler = new g(t), this.adapter = S(this.protocol), this.cloudSocket = new m({
|
|
37
39
|
connectParamsProvider: this.provideConnectParams,
|
|
38
40
|
onFrame: this.handleCloudFrame,
|
|
39
41
|
onOpen: this.handleCloudOpen,
|
|
40
42
|
onClose: this.handleCloudClose,
|
|
41
43
|
onError: this.handleSocketError
|
|
42
|
-
}), this.
|
|
44
|
+
}), this.dispatcher = o({
|
|
45
|
+
adapter: this.adapter,
|
|
46
|
+
cloudSocket: this.cloudSocket,
|
|
47
|
+
deviceInfo: e.deviceInfo
|
|
48
|
+
}), this.authorizationRefreshManager = new a({ outbound: this.dispatcher }), this.gatewaySessions = new r(this.adminCapability, this.dispatcher), l(this.gatewaySessions, t), u(this.gatewaySessions, t), c(this.adminCapability, this.dispatcher, t), s(this.authorizationRefreshManager, t);
|
|
43
49
|
}
|
|
44
50
|
start() {
|
|
45
51
|
v.info("starting connection"), this.adminCapability.start(), this.cloudSocket.start();
|
|
46
52
|
}
|
|
47
53
|
destroy() {
|
|
48
|
-
v.info("closing connection"), this.businessPingTimer.stop(), this.authorizationRefreshManager.destroy(), this.gatewaySessions.closeAll(), this.adminCapability.destroy(), this.cloudSocket.stop();
|
|
54
|
+
v.info("closing connection"), this.businessPingTimer.stop(), this.authorizationRefreshManager.destroy(), this.gatewaySessions.closeAll(), this.adminCapability.destroy(), this.dispatcher.destroy(), this.cloudSocket.stop();
|
|
49
55
|
}
|
|
50
56
|
getOutboundPort() {
|
|
51
|
-
return this.
|
|
57
|
+
return this.dispatcher;
|
|
52
58
|
}
|
|
53
59
|
provideConnectParams = async () => {
|
|
54
60
|
let e = await this.config.credentialProvider();
|
|
@@ -61,7 +67,7 @@ var v = e("channel"), y = 3e4, b = "v2", x = class {
|
|
|
61
67
|
v.info("cloud connection closed"), this.businessPingTimer.stop(), this.config.onClose?.();
|
|
62
68
|
};
|
|
63
69
|
sendBusinessPing = () => {
|
|
64
|
-
this.
|
|
70
|
+
this.dispatcher.send({
|
|
65
71
|
to: t("yoyoclawservice"),
|
|
66
72
|
msgType: "pingMessage",
|
|
67
73
|
silent: !0
|
|
@@ -79,10 +85,10 @@ var v = e("channel"), y = 3e4, b = "v2", x = class {
|
|
|
79
85
|
case "SUCCESS": {
|
|
80
86
|
let e = t.serviceEvent;
|
|
81
87
|
if (e.payload.msgType === "pingMessage") {
|
|
82
|
-
v.debug("ignored inbound pingMessage",
|
|
88
|
+
v.debug("ignored inbound pingMessage", d(e));
|
|
83
89
|
return;
|
|
84
90
|
}
|
|
85
|
-
v.debug("normalized cloud message",
|
|
91
|
+
v.debug("normalized cloud message", d(e)), this.dispatcher.consume(e), this.messageHandler.handleCloudMessage(e);
|
|
86
92
|
return;
|
|
87
93
|
}
|
|
88
94
|
case "TARGET_OFFLINE":
|
|
@@ -108,7 +114,7 @@ var v = e("channel"), y = 3e4, b = "v2", x = class {
|
|
|
108
114
|
};
|
|
109
115
|
};
|
|
110
116
|
function S(e) {
|
|
111
|
-
return e === "v1" ? new
|
|
117
|
+
return e === "v1" ? new f() : new p();
|
|
112
118
|
}
|
|
113
119
|
//#endregion
|
|
114
120
|
export { x as ClawChannel };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/cloud-channel/dispatcher/helpers.ts
|
|
2
|
+
var e = 3e4, t = 6e5;
|
|
3
|
+
function n(n) {
|
|
4
|
+
return typeof n != "number" || n <= 0 ? e : Math.min(n, t);
|
|
5
|
+
}
|
|
6
|
+
function r(e, t, n, r, i, a) {
|
|
7
|
+
return {
|
|
8
|
+
from: e,
|
|
9
|
+
to: t,
|
|
10
|
+
payload: {
|
|
11
|
+
msgType: n,
|
|
12
|
+
traceInfo: r,
|
|
13
|
+
...a ? { bizExtInfo: a } : {}
|
|
14
|
+
},
|
|
15
|
+
...i ? { data: i } : {}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { r as buildServiceEvent, n as resolveTimeoutMs };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { clawLogger as e } from "../../utils/claw-logger.mjs";
|
|
2
|
+
import { buildEndpoint as t } from "../protocol/target.mjs";
|
|
3
|
+
import { uuid as n } from "../../utils/id.mjs";
|
|
4
|
+
import { buildServiceEvent as r, resolveTimeoutMs as i } from "./helpers.mjs";
|
|
5
|
+
//#region src/cloud-channel/dispatcher/impl.ts
|
|
6
|
+
var a = e("dispatcher/outbound");
|
|
7
|
+
function o(e) {
|
|
8
|
+
let { adapter: o, cloudSocket: s, deviceInfo: c } = e, l = /* @__PURE__ */ new Map(), u = t("yoyoclaw", c.deviceId, c.port), d = (e) => {
|
|
9
|
+
let t = e.replyTo, i = !!t, c = i && t ? t.from : e.to;
|
|
10
|
+
if (!c) return a.warn("missing 'to' and no replyTo", { msgType: e.msgType }), !1;
|
|
11
|
+
if (i && t && !t.payload.traceInfo) return a.warn("replyTo missing traceInfo", { msgType: e.msgType }), !1;
|
|
12
|
+
let l = e.traceInfo ?? (i && t ? t.payload.traceInfo : {
|
|
13
|
+
traceId: n(),
|
|
14
|
+
timestamp: Date.now()
|
|
15
|
+
}), d = r(u, c, e.msgType, l, e.data, e.bizExtInfo);
|
|
16
|
+
return s.send(o.serialize(d), e.silent);
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
send: d,
|
|
20
|
+
async request(e, t) {
|
|
21
|
+
let { matchResult: r, timeoutMs: o } = t, s = n(), c = {
|
|
22
|
+
...e,
|
|
23
|
+
traceInfo: {
|
|
24
|
+
traceId: s,
|
|
25
|
+
timestamp: Date.now()
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return new Promise((e, t) => {
|
|
29
|
+
let n = setTimeout(() => {
|
|
30
|
+
l.has(s) && (l.delete(s), a.warn("request timeout", { traceId: s }), t(/* @__PURE__ */ Error("request timeout")));
|
|
31
|
+
}, i(o));
|
|
32
|
+
l.set(s, {
|
|
33
|
+
timeout: n,
|
|
34
|
+
resolve: e,
|
|
35
|
+
reject: t,
|
|
36
|
+
matchResult: r
|
|
37
|
+
}), d(c) || (l.delete(s), clearTimeout(n), t(/* @__PURE__ */ Error("send failed")));
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
consume(e) {
|
|
41
|
+
let t = e.payload.traceInfo?.traceId;
|
|
42
|
+
if (!t) return;
|
|
43
|
+
let n = l.get(t);
|
|
44
|
+
if (n) {
|
|
45
|
+
try {
|
|
46
|
+
let r = n.matchResult(e);
|
|
47
|
+
if (r.matched) {
|
|
48
|
+
if (l.delete(t), clearTimeout(n.timeout), "error" in r) {
|
|
49
|
+
n.reject(r.error);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
n.resolve(r.result);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
} catch (e) {
|
|
56
|
+
a.error("match request result failed", e);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
a.warn("response shape not matched, keep pending", { traceId: t });
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
destroy() {
|
|
63
|
+
if (l.size !== 0) {
|
|
64
|
+
a.warn("rejected all pending requests", { count: l.size });
|
|
65
|
+
for (let e of l.values()) clearTimeout(e.timeout), e.reject(/* @__PURE__ */ Error("connection closed"));
|
|
66
|
+
l.clear();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { o as createCloudDispatcher };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./impl.mjs";
|