@honor-claw/yoyo 2026.6.9-alpha.9 → 2026.6.9-beta.2

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.
Files changed (122) hide show
  1. package/dist/apis/claw-cloud.mjs +21 -1
  2. package/dist/capabilities/admin/impl.mjs +3 -60
  3. package/dist/capabilities/admin/manager.mjs +2 -2
  4. package/dist/capabilities/cloud-invoke/index.mjs +1 -0
  5. package/dist/capabilities/cloud-invoke/invoke.mjs +43 -0
  6. package/dist/capabilities/node/invoke.mjs +3 -3
  7. package/dist/capabilities/node/list.mjs +1 -1
  8. package/dist/capabilities/routing/index.mjs +3 -0
  9. package/dist/capabilities/routing/list.mjs +27 -0
  10. package/dist/capabilities/routing/model-switch.mjs +36 -0
  11. package/dist/capabilities/routing/primary.mjs +36 -0
  12. package/dist/capabilities/routing/route.mjs +18 -0
  13. package/dist/channel/lifecycle.mjs +3 -3
  14. package/dist/cloud-channel/authorization/refresh-manager.mjs +4 -4
  15. package/dist/cloud-channel/channel.mjs +32 -30
  16. package/dist/cloud-channel/dispatcher/impl.mjs +25 -25
  17. package/dist/cloud-channel/handlers/auth.mjs +1 -1
  18. package/dist/cloud-channel/handlers/context/handler.mjs +95 -61
  19. package/dist/cloud-channel/handlers/user-message.mjs +1 -1
  20. package/dist/cloud-channel/log-summary.mjs +3 -3
  21. package/dist/cloud-channel/protocol/semantics.mjs +4 -0
  22. package/dist/cloud-channel/transport/cloud-socket.mjs +9 -6
  23. package/dist/cloud-channel/transport/event-bus.mjs +1 -1
  24. package/dist/cloud-channel/utils.mjs +19 -17
  25. package/dist/commands/debug/clean-tools.mjs +9 -12
  26. package/dist/commands/env/impl.mjs +14 -17
  27. package/dist/commands/login/impl.mjs +16 -16
  28. package/dist/commands/logout/impl.mjs +10 -9
  29. package/dist/commands/status/index.mjs +25 -24
  30. package/dist/connection/client.mjs +10 -14
  31. package/dist/connection/monitor.mjs +8 -5
  32. package/dist/connection/registry.mjs +6 -9
  33. package/dist/core/hooks/gateway-lifecycle.mjs +1 -1
  34. package/dist/core/hooks/skill-refresh.mjs +1 -1
  35. package/dist/core/prompt/builder.mjs +13 -8
  36. package/dist/core/prompt/cloud-tool.mjs +7 -0
  37. package/dist/core/prompt/skill.mjs +1 -1
  38. package/dist/core/runtime.mjs +23 -7
  39. package/dist/core/services/admin.mjs +1 -1
  40. package/dist/gateway/client/admin.mjs +0 -12
  41. package/dist/gateway/client/client.mjs +1 -1
  42. package/dist/gateway/client/node.mjs +1 -1
  43. package/dist/gateway/client/protocol.mjs +5 -5
  44. package/dist/gateway/session/forwarding.mjs +1 -1
  45. package/dist/gateway/session/manager.mjs +3 -3
  46. package/dist/honor-auth/browser/flow.mjs +1 -1
  47. package/dist/honor-auth/login/impl.mjs +10 -24
  48. package/dist/honor-auth/vault/impl.mjs +38 -41
  49. package/dist/honor-auth/vault/legacy-migration.mjs +31 -34
  50. package/dist/index.mjs +11 -11
  51. package/dist/messaging/dispatchers/command/impl.mjs +30 -39
  52. package/dist/messaging/dispatchers/stream/controller.mjs +18 -25
  53. package/dist/messaging/dispatchers/stream/error.mjs +221 -25
  54. package/dist/messaging/dispatchers/stream/hooks.mjs +34 -35
  55. package/dist/messaging/dispatchers/stream/resolvers.mjs +18 -14
  56. package/dist/messaging/dispatchers/stream/session.mjs +60 -81
  57. package/dist/messaging/dispatchers/stream/tool/trace-store.mjs +1 -1
  58. package/dist/messaging/dispose.mjs +1 -1
  59. package/dist/messaging/inbound/abort/core.mjs +1 -1
  60. package/dist/messaging/inbound/agent.mjs +4 -1
  61. package/dist/messaging/inbound/command.mjs +6 -2
  62. package/dist/messaging/inbound/context.mjs +47 -43
  63. package/dist/messaging/inbound/dispatch.mjs +32 -25
  64. package/dist/messaging/inbound/interrupt.mjs +3 -3
  65. package/dist/messaging/inbound/new-session.mjs +3 -3
  66. package/dist/messaging/inbound/user-message.mjs +24 -19
  67. package/dist/messaging/send/frame.mjs +16 -14
  68. package/dist/messaging/send/text.mjs +5 -5
  69. package/dist/messaging/session/defaults.mjs +1 -1
  70. package/dist/messaging/target/chat-id-store.mjs +1 -1
  71. package/dist/modules/configs/config-store.mjs +16 -13
  72. package/dist/modules/configs/device.mjs +1 -1
  73. package/dist/modules/configs/gateway.mjs +1 -1
  74. package/dist/modules/configs/identity-persist.mjs +1 -1
  75. package/dist/modules/configs/plugin-init.mjs +28 -23
  76. package/dist/modules/configs/plugin.mjs +1 -1
  77. package/dist/modules/configs/state-flags.mjs +1 -1
  78. package/dist/modules/device/device-info.mjs +2 -2
  79. package/dist/modules/status/storage.mjs +1 -1
  80. package/dist/modules/status/tracker.mjs +1 -1
  81. package/dist/provisioning/registration/register.mjs +9 -9
  82. package/dist/provisioning/toolset/artifacts.mjs +29 -31
  83. package/dist/provisioning/toolset/cleanup.mjs +17 -16
  84. package/dist/provisioning/toolset/consts.mjs +2 -2
  85. package/dist/provisioning/toolset/md5-index.mjs +30 -46
  86. package/dist/provisioning/toolset/normalize.mjs +3 -5
  87. package/dist/provisioning/toolset/persist.mjs +23 -39
  88. package/dist/provisioning/toolset/processor.mjs +1 -1
  89. package/dist/provisioning/toolset/skill-inject.mjs +14 -14
  90. package/dist/provisioning/toolset/skill-refresh-marker.mjs +1 -1
  91. package/dist/provisioning/toolset/versioned-store.mjs +45 -0
  92. package/dist/tools/cloud-invoke/index.mjs +1 -0
  93. package/dist/tools/cloud-invoke/tool.mjs +48 -0
  94. package/dist/tools/index.mjs +7 -5
  95. package/dist/tools/nodes-status/tool.mjs +2 -2
  96. package/dist/utils/claw-logger.mjs +67 -41
  97. package/openclaw.plugin.json +1 -1
  98. package/package.json +1 -1
  99. package/skills/yoyo-phone-control/SKILL.md +30 -16
  100. package/skills/yoyo-phone-control/configs/sub-skills.json +16 -2
  101. package/skills/yoyo-phone-control/references/alarm-create.md +356 -0
  102. package/skills/yoyo-phone-control/references/alarm-delete.md +301 -0
  103. package/skills/yoyo-phone-control/references/alarm-disable.md +309 -0
  104. package/skills/yoyo-phone-control/references/alarm-enable.md +309 -0
  105. package/skills/yoyo-phone-control/references/alarm-query.md +411 -0
  106. package/skills/yoyo-phone-control/references/alarm-update.md +386 -0
  107. package/skills/yoyo-phone-control/references/file-upload.md +0 -3
  108. package/skills/yoyo-phone-control/references/gui-task-create.md +84 -10
  109. package/skills/yoyo-phone-control/references/gui-task-pause.md +0 -3
  110. package/skills/yoyo-phone-control/references/gui-task-terminate.md +0 -3
  111. package/skills/yoyo-phone-control/references/local-search.md +0 -3
  112. package/skills/yoyo-phone-control/references/local_user_data_qa.md +360 -0
  113. package/skills/yoyo-phone-control/references/local_user_file_search.md +357 -0
  114. package/skills/yoyo-phone-control/references/schedule-create.md +483 -0
  115. package/skills/yoyo-phone-control/references/schedule-delete.md +507 -0
  116. package/skills/yoyo-phone-control/references/schedule-search.md +591 -0
  117. package/skills/yoyo-phone-control/references/schedule-update.md +556 -0
  118. package/skills/yoyo-phone-control/references/task-result-query.md +0 -3
  119. package/skills/yoyo-smart-home/SKILL.md +78 -0
  120. package/skills/yoyo-smart-home/mcptools/device_control.json +136 -0
  121. package/skills/yoyo-smart-home/mcptools/device_query.json +114 -0
  122. package/skills/yoyo-smart-home/mcptools/skill_exit.json +6 -0
@@ -69,6 +69,25 @@ var o = class {
69
69
  timeout: r?.timeoutMs ?? 3e4
70
70
  });
71
71
  }
72
+ async invokeCloudTool(e, n, r) {
73
+ let i = {
74
+ "x-trace-id": t(),
75
+ "x-jwt-token": n.token
76
+ }, a = {
77
+ pluginService: { serviceId: r.serviceId },
78
+ pluginParams: r.pluginParams,
79
+ device: {
80
+ deviceId: e.deviceId,
81
+ role: "yoyoclaw",
82
+ port: e.port
83
+ }
84
+ };
85
+ return this.httpClient.post("/icsplugin/execute", {
86
+ headers: i,
87
+ body: a,
88
+ timeout: r?.timeoutMs ?? 3e4
89
+ });
90
+ }
72
91
  async exchangeToken(e, r) {
73
92
  let i = t(), o = {
74
93
  "Content-Type": "application/json",
@@ -91,7 +110,8 @@ var o = class {
91
110
  timeout: 15e3
92
111
  });
93
112
  if (n(c) && c.data.data) return c.data.data;
94
- throw Error(`failed to get token: ${JSON.stringify(c.data)}, traceId: ${i}`);
113
+ let l = c.data.cnMessage || "unknown error";
114
+ throw Error(`${l} (code: ${c.data.code}, traceId: ${i})`);
95
115
  }
96
116
  };
97
117
  function s() {
@@ -1,7 +1,7 @@
1
1
  import { clawLogger as e } from "../../utils/claw-logger.mjs";
2
2
  import { AdminClientManager as t } from "./manager.mjs";
3
3
  //#region src/capabilities/admin/impl.ts
4
- var n = e("admin"), r = null, i = class {
4
+ var n = e("capabilities"), r = null, i = class {
5
5
  manager = new t();
6
6
  constructor() {
7
7
  this.manager.init();
@@ -47,31 +47,6 @@ var n = e("admin"), r = null, i = class {
47
47
  error: `update context failed, ${JSON.stringify(i.error)}`
48
48
  };
49
49
  }
50
- async switchPrimaryModel(e, t) {
51
- let r = this.manager.getClient();
52
- if (!r) return {
53
- ok: !1,
54
- error: "Admin gateway client not ready"
55
- };
56
- if (!e || !t) return {
57
- ok: !1,
58
- error: "Missing provider or id in context payload"
59
- };
60
- try {
61
- return (await r.switchPrimaryModel(e, t)).ok ? (n.info("switchPrimaryModel success", {
62
- provider: e,
63
- id: t
64
- }), {
65
- ok: !0,
66
- data: { resolved: {
67
- provider: e,
68
- id: t
69
- } }
70
- }) : (n.error("switchPrimaryModel failed, try to fallback main session model"), this.getMainSessionModel());
71
- } catch (e) {
72
- return n.error("updatePrimaryModel error, try to fallback main session model", e), this.getMainSessionModel();
73
- }
74
- }
75
50
  async getSkillsStatus() {
76
51
  let e = this.manager.getClient();
77
52
  return e ? {
@@ -94,13 +69,9 @@ var n = e("admin"), r = null, i = class {
94
69
  error: "Admin gateway client not ready"
95
70
  };
96
71
  try {
97
- let t = await e.getModelList(), { modelProvider: r = "", model: i = "" } = await e.getMainSession();
98
- return n.info("current primary model", {
99
- provider: r,
100
- id: i
101
- }), {
72
+ return {
102
73
  ok: !0,
103
- data: { models: t?.models?.map((e) => Object.assign({}, e, { primary: e.provider === r && e.id === i })) ?? [] }
74
+ data: { models: (await e.getModelList())?.models ?? [] }
104
75
  };
105
76
  } catch (e) {
106
77
  let t = e instanceof Error ? e.message : String(e);
@@ -110,34 +81,6 @@ var n = e("admin"), r = null, i = class {
110
81
  };
111
82
  }
112
83
  }
113
- async getMainSessionModel() {
114
- let e = this.manager.getClient();
115
- if (!e) return {
116
- ok: !1,
117
- error: "Admin gateway client not ready"
118
- };
119
- try {
120
- let t = await e.getMainSession(), { modelProvider: r = "", model: i = "" } = t;
121
- return n.warn("switchPrimaryModel failed, fallback to current", {
122
- provider: r,
123
- id: i
124
- }), !r || !i ? {
125
- ok: !1,
126
- error: `Missing primary model: mainSession-${JSON.stringify(t)}`
127
- } : {
128
- ok: !1,
129
- data: { resolved: {
130
- provider: r,
131
- id: i
132
- } }
133
- };
134
- } catch (e) {
135
- return {
136
- ok: !1,
137
- error: `getMainSessionModel error: ${e instanceof Error ? e.message : String(e)}`
138
- };
139
- }
140
- }
141
84
  };
142
85
  function a() {
143
86
  return r === null && (r = new i()), r;
@@ -5,7 +5,7 @@ import n from "../../gateway/client/admin.mjs";
5
5
  import { StatusEventTypeE as r } from "../../modules/status/events.mjs";
6
6
  import { emitStatusEvent as i } from "../../modules/status/global.mjs";
7
7
  //#region src/capabilities/admin/manager.ts
8
- var a = e("admin"), o = class {
8
+ var a = e("capabilities"), o = class {
9
9
  client = null;
10
10
  ready = !1;
11
11
  pendingReadyRequests = /* @__PURE__ */ new Map();
@@ -34,7 +34,7 @@ var a = e("admin"), o = class {
34
34
  this.client &&= (this.client.stop(), null), this.ready = !1, this.cancelAllPending(), a.info("admin client destroyed");
35
35
  }
36
36
  getClient() {
37
- return this.client;
37
+ return this.ready && this.client?.isAuthenticated() ? this.client : null;
38
38
  }
39
39
  ensureConnected() {
40
40
  return this.client === null && (a.info("admin gateway client is null, initializing"), this.init()), this.ready || (a.info("admin gateway client not ready, connecting"), this.client?.connect()), this.client !== null && this.ready;
@@ -0,0 +1 @@
1
+ import "./invoke.mjs";
@@ -0,0 +1,43 @@
1
+ import { toErrorMessage as e } from "../../utils/error.mjs";
2
+ import { clawLogger as t } from "../../utils/claw-logger.mjs";
3
+ import { HonorAccount as n } from "../../honor-auth/vault/impl.mjs";
4
+ import { createClawCloudClient as r } from "../../apis/claw-cloud.mjs";
5
+ import { loadDeviceInfo as i } from "../../modules/device/device-info.mjs";
6
+ import "../../modules/device/index.mjs";
7
+ import "../../honor-auth/vault/index.mjs";
8
+ import "../../apis/index.mjs";
9
+ import { ToolError as a } from "../../tools/error.mjs";
10
+ //#region src/capabilities/cloud-invoke/invoke.ts
11
+ var o = t("capabilities");
12
+ async function s(t) {
13
+ let s = await n.fromUser().current();
14
+ if (!s?.token || !s.userId) throw o.error("cloud invoke skipped: no current user"), new a("unauthorized", "missing current user token");
15
+ let c;
16
+ try {
17
+ c = await i();
18
+ } catch (e) {
19
+ throw o.error("cloud invoke failed to get device info", e), new a("ctx missing", "failed to get device info", { cause: e });
20
+ }
21
+ try {
22
+ let e = await r().invokeCloudTool(c, s, {
23
+ serviceId: t.toolId,
24
+ pluginParams: t.params ?? {},
25
+ ...t.timeoutMs === void 0 ? {} : { timeoutMs: t.timeoutMs }
26
+ }), n = e.data, i = e.status >= 200 && e.status < 300, l = n?.code === "0", u = n?.code === "ICS-500";
27
+ if (!i || !l && !u) throw o.error("cloud invoke response not ok", null, {
28
+ status: e.status,
29
+ code: n?.code,
30
+ cnMessage: n?.cnMessage,
31
+ cpErrorCode: n?.data?.cpErrorCode
32
+ }), new a("api_failed", `code=${n?.code ?? "-"} cpErrorCode=${n?.data?.cpErrorCode ?? "-"} message=${n?.cnMessage ?? "-"}`);
33
+ return {
34
+ ...n.data === void 0 ? {} : { pluginResponse: n.data },
35
+ code: e.data.code,
36
+ cnMessage: e.data.cnMessage
37
+ };
38
+ } catch (t) {
39
+ throw t instanceof a ? t : (o.error("cloud invoke failed", t), new a("network_error", e(t), { cause: t }));
40
+ }
41
+ }
42
+ //#endregion
43
+ export { s as invokeCloudToolService };
@@ -3,7 +3,7 @@ import { buildEndpoint as t } from "../../cloud-channel/protocol/target.mjs";
3
3
  import { resolveEnabledYoyoAccountId as n } from "../../modules/configs/channel.mjs";
4
4
  import { ClawClient as r } from "../../connection/registry.mjs";
5
5
  //#region src/capabilities/node/invoke.ts
6
- var i = e("capabilities/node-invoke");
6
+ var i = e("capabilities");
7
7
  async function a(e) {
8
8
  let i = {
9
9
  to: t("node", e.nodeId),
@@ -12,10 +12,10 @@ async function a(e) {
12
12
  toolCallId: e.toolCallId,
13
13
  nodeId: e.nodeId,
14
14
  name: e.name,
15
- params: e.params
15
+ ...e.params ? { params: { arguments: JSON.stringify(e.params) } } : {}
16
16
  } }
17
17
  }, a = n();
18
- return r.request(a, i, {
18
+ return r.forAccount(a).request(i, {
19
19
  timeoutMs: e.timeoutMs,
20
20
  matchResult: o
21
21
  });
@@ -9,7 +9,7 @@ import "../../honor-auth/vault/index.mjs";
9
9
  import "../../apis/index.mjs";
10
10
  import { ToolError as o } from "../../tools/error.mjs";
11
11
  //#region src/capabilities/node/list.ts
12
- var s = t("capabilities/node");
12
+ var s = t("capabilities");
13
13
  async function c(t) {
14
14
  let c = await n.fromUser().current();
15
15
  if (!c?.token || !c.userId) throw s.error("node device list skipped: no current user"), new o("unauthorized", "missing current user token");
@@ -0,0 +1,3 @@
1
+ import "./route.mjs";
2
+ import "./list.mjs";
3
+ import "./model-switch.mjs";
@@ -0,0 +1,27 @@
1
+ import { clawLogger as e } from "../../utils/claw-logger.mjs";
2
+ import { useAdminCapability as t } from "../admin/impl.mjs";
3
+ import "../admin/index.mjs";
4
+ import { resolvePrimaryModel as n } from "./primary.mjs";
5
+ import { getRuntimeConfig as r } from "openclaw/plugin-sdk/config-runtime";
6
+ //#region src/capabilities/routing/list.ts
7
+ var i = e("routing");
8
+ async function a(e, a) {
9
+ let o = await t().getModelList();
10
+ if (!o.ok || !o.data?.models) return {
11
+ ok: !1,
12
+ error: o.error ?? "no models"
13
+ };
14
+ let s = await n(r(), e, a);
15
+ return i.info("resolved primary for model list", {
16
+ provider: s.provider,
17
+ id: s.id
18
+ }), {
19
+ ok: !0,
20
+ data: {
21
+ models: o.data.models.map((e) => Object.assign({}, e, { primary: s.provider !== "" && e.provider === s.provider && e.id === s.id })),
22
+ primary: s
23
+ }
24
+ };
25
+ }
26
+ //#endregion
27
+ export { a as getModelsListWithPrimary };
@@ -0,0 +1,36 @@
1
+ import { clawLogger as e } from "../../utils/claw-logger.mjs";
2
+ import { uuid as t } from "../../utils/id.mjs";
3
+ import { buildChatId as n } from "../../messaging/target/chat-id.mjs";
4
+ import { resolvePrimaryModel as r } from "./primary.mjs";
5
+ import { dispatchInboundContext as i } from "../../messaging/inbound/user-message.mjs";
6
+ import "../../messaging/index.mjs";
7
+ import { getRuntimeConfig as a } from "openclaw/plugin-sdk/config-runtime";
8
+ //#region src/capabilities/routing/model-switch.ts
9
+ var o = e("routing");
10
+ async function s(e) {
11
+ let s = await n(e.accountId, e.deviceId);
12
+ await i({
13
+ messageId: t(),
14
+ senderId: e.deviceId,
15
+ chatId: s,
16
+ accountId: e.accountId,
17
+ traceInfo: e.traceInfo,
18
+ content: `/model ${e.provider}/${e.model}`,
19
+ resources: [],
20
+ silent: !0
21
+ });
22
+ let c = await r(a(), e.accountId, e.deviceId);
23
+ return o.info("model switch completed", {
24
+ requested: {
25
+ provider: e.provider,
26
+ model: e.model
27
+ },
28
+ resolved: c
29
+ }), {
30
+ ok: !0,
31
+ provider: c.provider,
32
+ model: c.id
33
+ };
34
+ }
35
+ //#endregion
36
+ export { s as switchModel };
@@ -0,0 +1,36 @@
1
+ import { canHandleAgentSessionEntry as e, getYoyoRuntime as t } from "../../core/runtime.mjs";
2
+ import { resolveYoyoRoute as n } from "./route.mjs";
3
+ import { buildChatId as r } from "../../messaging/target/chat-id.mjs";
4
+ import "../../messaging/target/index.mjs";
5
+ import { resolveDefaultModelForAgent as i } from "openclaw/plugin-sdk/agent-runtime";
6
+ //#region src/capabilities/routing/primary.ts
7
+ function a(n, r) {
8
+ if (e()) return t().agent.session.getSessionEntry({
9
+ agentId: n,
10
+ sessionKey: r
11
+ });
12
+ }
13
+ async function o(e, t, o) {
14
+ let s = n({
15
+ accountId: t,
16
+ chatId: await r(t, o)
17
+ }), c = a(s.agentId, s.sessionKey);
18
+ if (c?.providerOverride && c?.modelOverride) return {
19
+ provider: c.providerOverride,
20
+ id: c.modelOverride
21
+ };
22
+ if (c?.modelProvider && c?.model) return {
23
+ provider: c.modelProvider,
24
+ id: c.model
25
+ };
26
+ let l = i({
27
+ cfg: e,
28
+ agentId: s.agentId
29
+ });
30
+ return {
31
+ provider: l.provider,
32
+ id: l.model
33
+ };
34
+ }
35
+ //#endregion
36
+ export { o as resolvePrimaryModel };
@@ -0,0 +1,18 @@
1
+ import { YOYO_CHANNEL_ID as e } from "../../consts.mjs";
2
+ import { getYoyoRuntime as t } from "../../core/runtime.mjs";
3
+ import { getRuntimeConfig as n } from "openclaw/plugin-sdk/config-runtime";
4
+ //#region src/capabilities/routing/route.ts
5
+ function r(r) {
6
+ let i = t(), a = n();
7
+ return i.channel.routing.resolveAgentRoute({
8
+ cfg: a,
9
+ channel: e,
10
+ accountId: r.accountId,
11
+ peer: {
12
+ kind: "direct",
13
+ id: r.chatId
14
+ }
15
+ });
16
+ }
17
+ //#endregion
18
+ export { r as resolveYoyoRoute };
@@ -9,17 +9,17 @@ import "../messaging/index.mjs";
9
9
  import { monitorAccount as s } from "../connection/monitor.mjs";
10
10
  import "../connection/index.mjs";
11
11
  //#region src/channel/lifecycle.ts
12
- var c = e("channel/lifecycle"), l = {
12
+ var c = e("channel"), l = {
13
13
  async startAccount(e) {
14
14
  let t = e.accountId;
15
- c.info("start account channel", { accountId: t }), await u(e), await s({
15
+ c.report("start account channel", { accountId: t }), await u(e), await s({
16
16
  accountId: t,
17
17
  abortSignal: e.abortSignal
18
18
  });
19
19
  },
20
20
  async stopAccount(e) {
21
21
  let n = e.accountId;
22
- await t(n), c.info("stop account channel", { accountId: n });
22
+ await t(n), c.report("account channel stopped", { accountId: n });
23
23
  }
24
24
  };
25
25
  async function u(e) {
@@ -3,7 +3,7 @@ import { buildEndpoint as t } from "../protocol/target.mjs";
3
3
  import { HonorAccount as n } from "../../honor-auth/vault/impl.mjs";
4
4
  import "../../honor-auth/vault/index.mjs";
5
5
  //#region src/cloud-channel/authorization/refresh-manager.ts
6
- var r = e("auth-refresh"), i = class {
6
+ var r = e("cloud-auth"), i = class {
7
7
  options;
8
8
  timer = null;
9
9
  scheduleVersion = 0;
@@ -24,7 +24,7 @@ var r = e("auth-refresh"), i = class {
24
24
  let e = ++this.scheduleVersion;
25
25
  this.clearTimer();
26
26
  let t = await this.account.refreshSchedule();
27
- this.destroyed || e !== this.scheduleVersion || (t.requestNow && this.sendUpdateAuthorizationRequest(), t.delayMs > 0 ? this.scheduleTimer(t.delayMs) : r.warn("token expired, skip refresh scheduling"));
27
+ this.destroyed || e !== this.scheduleVersion || (t.requestNow && await this.sendUpdateAuthorizationRequest(), t.delayMs > 0 ? this.scheduleTimer(t.delayMs) : r.warn("token expired, skip refresh scheduling"));
28
28
  }
29
29
  pauseForUnauthorized() {
30
30
  this.destroyed || this.pausedForExpiredToken || !this.timer || (this.pausedForExpiredToken = !0, this.scheduleVersion++, this.clearTimer(), r.warn("paused refresh because cloud reported current device is unauthorized"));
@@ -46,8 +46,8 @@ var r = e("auth-refresh"), i = class {
46
46
  return r.error("failed to cache new token", e), !1;
47
47
  }
48
48
  }
49
- sendUpdateAuthorizationRequest() {
50
- let e = this.options.outbound.send({
49
+ async sendUpdateAuthorizationRequest() {
50
+ let e = await this.options.outbound.send({
51
51
  to: t("yoyoclawservice"),
52
52
  msgType: "updateAuthorization"
53
53
  });
@@ -14,13 +14,14 @@ import { summarizeServiceEvent as u } from "./log-summary.mjs";
14
14
  import { V1Adapter as d } from "./protocol/v1-adapter.mjs";
15
15
  import { V2Adapter as f } from "./protocol/v2-adapter.mjs";
16
16
  import "./protocol/index.mjs";
17
- import { CloudSocket as p } from "./transport/cloud-socket.mjs";
18
- import { CloudEventBus as m } from "./transport/event-bus.mjs";
19
- import { MessageHandler as h } from "./transport/message-handler.mjs";
17
+ import { UNEXPECTED_RAW_CODE_SEMANTICS as p } from "./protocol/semantics.mjs";
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";
20
21
  import "./transport/index.mjs";
21
- import { buildCloudSocketConnectParams as g } from "./utils.mjs";
22
+ import { buildCloudSocketConnectParams as _ } from "./utils.mjs";
22
23
  //#region src/cloud-channel/channel.ts
23
- var _ = e("channel"), v = 3e4, y = "v2", b = class {
24
+ var v = e("cloud-channel"), y = 3e4, b = "v2", x = class {
24
25
  config;
25
26
  cloudSocket;
26
27
  gatewaySessions;
@@ -33,8 +34,8 @@ var _ = e("channel"), v = 3e4, y = "v2", b = class {
33
34
  businessPingTimer = new r("recurring");
34
35
  constructor(e) {
35
36
  this.config = e;
36
- let t = new m();
37
- this.protocol = e.protocol ?? y, this.context = { accountId: e.accountId }, this.messageHandler = new h(t, this.context), this.adapter = x(this.protocol), this.cloudSocket = new p({
37
+ let t = new h();
38
+ this.protocol = e.protocol ?? b, this.context = { accountId: e.accountId }, this.messageHandler = new g(t, this.context), this.adapter = S(this.protocol), this.cloudSocket = new m({
38
39
  loadConnectParams: this.provideConnectParams,
39
40
  onFrame: this.handleCloudFrame,
40
41
  onOpen: this.handleCloudOpen,
@@ -42,81 +43,82 @@ var _ = e("channel"), v = 3e4, y = "v2", b = class {
42
43
  onError: this.handleSocketError
43
44
  }), this.dispatcher = a({
44
45
  adapter: this.adapter,
45
- cloudSocket: this.cloudSocket,
46
- deviceInfo: e.deviceInfo
46
+ cloudSocket: this.cloudSocket
47
47
  }), this.authorizationRefreshManager = new i({
48
48
  accountId: e.accountId,
49
49
  outbound: this.dispatcher
50
50
  }), this.gatewaySessions = new n(this.dispatcher), c(this.gatewaySessions, t), l(this.gatewaySessions, t), s(this.dispatcher, t), o(this.authorizationRefreshManager, t);
51
51
  }
52
52
  start() {
53
- _.info("starting connection"), this.cloudSocket.start();
53
+ v.info("starting connection"), this.cloudSocket.start();
54
54
  }
55
55
  destroy() {
56
- _.info("closing connection"), this.businessPingTimer.stop(), this.authorizationRefreshManager.destroy(), this.gatewaySessions.closeAll(), this.dispatcher.destroy(), this.cloudSocket.stop();
56
+ v.info("closing connection"), this.businessPingTimer.stop(), this.authorizationRefreshManager.destroy(), this.gatewaySessions.closeAll(), this.dispatcher.destroy(), this.cloudSocket.stop();
57
57
  }
58
58
  getOutboundPort() {
59
59
  return this.dispatcher;
60
60
  }
61
61
  provideConnectParams = async () => {
62
62
  let e = await this.config.credentialProvider();
63
- return e ? g(this.config.deviceInfo, e.token, this.protocol) : null;
63
+ return e ? _(e.token, this.protocol) : null;
64
64
  };
65
65
  handleCloudOpen = () => {
66
- _.info("cloud connection established"), this.businessPingTimer.start(this.sendBusinessPing, v), this.authorizationRefreshManager.start(), this.config.onOpen?.();
66
+ v.info("cloud connection established"), this.businessPingTimer.start(this.sendBusinessPing, y), this.authorizationRefreshManager.start(), this.config.onOpen?.();
67
67
  };
68
68
  handleCloudClose = () => {
69
- _.info("cloud connection closed"), this.businessPingTimer.stop(), this.config.onClose?.();
69
+ v.info("cloud connection closed"), this.businessPingTimer.stop(), this.config.onClose?.();
70
70
  };
71
- sendBusinessPing = () => {
72
- this.dispatcher.send({
71
+ sendBusinessPing = async () => {
72
+ await this.dispatcher.send({
73
73
  to: t("yoyoclawservice"),
74
74
  msgType: "pingMessage",
75
75
  silent: !0
76
- }) || _.warn("failed to send pingMessage");
76
+ }) || v.warn("failed to send pingMessage");
77
77
  };
78
78
  handleCloudFrame = (e) => {
79
79
  let t;
80
80
  try {
81
81
  t = this.adapter.normalize(e);
82
82
  } catch (e) {
83
- _.error("protocol adapter failed", e);
83
+ v.error("protocol adapter failed", e);
84
84
  return;
85
85
  }
86
86
  switch (t.kind) {
87
87
  case "SUCCESS": {
88
88
  let e = t.serviceEvent;
89
89
  if (e.payload.msgType === "pingMessage") {
90
- _.debug("ignored inbound pingMessage", u(e));
90
+ v.debug("ignored inbound pingMessage", u(e));
91
91
  return;
92
92
  }
93
- _.debug("normalized cloud message", u(e)), this.dispatcher.consume(e), this.messageHandler.handleCloudMessage(e);
93
+ v.debug("normalized cloud message", u(e)), this.dispatcher.consume(e), this.messageHandler.handleCloudMessage(e);
94
94
  return;
95
95
  }
96
96
  case "TARGET_OFFLINE":
97
- _.info("remote device offline", { session: t.offlineSocketId }), this.gatewaySessions.closeSession(t.offlineSocketId);
97
+ v.info("remote device offline", { session: t.offlineSocketId }), this.gatewaySessions.closeSession(t.offlineSocketId);
98
98
  return;
99
99
  case "DEVICE_NOT_REGISTERED":
100
- _.info("device not registered, notifying connection layer"), this.config.onError?.({ type: "device-not-registered" });
100
+ v.info("device not registered, notifying connection layer"), this.config.onError?.({ type: "device-not-registered" });
101
101
  return;
102
102
  case "TOKEN_EXPIRED":
103
- _.warn("unauthorized by cloud, pausing refresh"), this.authorizationRefreshManager.pauseForUnauthorized();
103
+ v.warn("unauthorized by cloud, pausing refresh"), this.authorizationRefreshManager.pauseForUnauthorized();
104
104
  return;
105
- case "UNEXPECTED":
106
- _.warn("unexpected message", { rawCode: t.rawCode });
105
+ case "UNEXPECTED": {
106
+ let e = p[t.rawCode];
107
+ e ? v.warn(e, { rawCode: t.rawCode }) : v.warn("unexpected message", { rawCode: t.rawCode });
107
108
  return;
109
+ }
108
110
  case "INVALID":
109
- _.error("failed to parse message", t.error);
111
+ v.error("failed to parse message", t.error);
110
112
  return;
111
- default: _.warn("non-success control code", { kind: t.kind });
113
+ default: v.warn("non-success control code", { kind: t.kind });
112
114
  }
113
115
  };
114
116
  handleSocketError = (e) => {
115
- _.info("cloud socket error, notifying connection layer", { type: e.type }), this.config.onError?.(e);
117
+ v.info("cloud socket error, notifying connection layer", { type: e.type }), this.config.onError?.(e);
116
118
  };
117
119
  };
118
- function x(e) {
120
+ function S(e) {
119
121
  return e === "v1" ? new d() : new f();
120
122
  }
121
123
  //#endregion
122
- export { b as ClawChannel };
124
+ export { x as ClawChannel };
@@ -1,40 +1,40 @@
1
1
  import { clawLogger as e } from "../../utils/claw-logger.mjs";
2
2
  import { buildEndpoint as t } from "../protocol/target.mjs";
3
3
  import { uuid as n } from "../../utils/id.mjs";
4
- import { buildServiceEvent as r, resolveTimeoutMs as i } from "./helpers.mjs";
4
+ import { loadDeviceInfo as r } from "../../modules/device/device-info.mjs";
5
+ import "../../modules/device/index.mjs";
6
+ import { buildServiceEvent as i, resolveTimeoutMs as a } from "./helpers.mjs";
5
7
  //#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(),
8
+ var o = e("cloud-channel");
9
+ function s(e) {
10
+ let { adapter: s, cloudSocket: c } = e, l = /* @__PURE__ */ new Map(), u = async (e) => {
11
+ let a = e.replyTo, l = !!a, u = l && a ? a.from : e.to;
12
+ if (!u) return o.warn("missing 'to' and no replyTo", { msgType: e.msgType }), !1;
13
+ if (l && a && !a.payload.traceInfo) return o.warn("replyTo missing traceInfo", { msgType: e.msgType }), !1;
14
+ let d = {
15
+ ...e.traceInfo ?? (l && a ? a.payload.traceInfo : { traceId: n() }),
14
16
  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
+ }, { deviceId: f, port: p } = await r(), m = i(t("yoyoclaw", f, p), u, e.msgType, d, e.data, e.bizExtInfo);
18
+ return c.send(s.serialize(m), e.silent);
17
19
  };
18
20
  return {
19
- send: d,
21
+ send: u,
20
22
  async request(e, t) {
21
- let { matchResult: r, timeoutMs: o } = t, s = n(), c = {
23
+ let { matchResult: r, timeoutMs: i } = t, s = n();
24
+ if (!await u({
22
25
  ...e,
23
- traceInfo: {
24
- traceId: s,
25
- timestamp: Date.now()
26
- }
27
- };
26
+ traceInfo: { traceId: s }
27
+ })) throw Error("send failed");
28
28
  return new Promise((e, t) => {
29
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));
30
+ l.has(s) && (l.delete(s), o.warn("request timeout", { traceId: s }), t(/* @__PURE__ */ Error("request timeout")));
31
+ }, a(i));
32
32
  l.set(s, {
33
33
  timeout: n,
34
34
  resolve: e,
35
35
  reject: t,
36
36
  matchResult: r
37
- }), d(c) || (l.delete(s), clearTimeout(n), t(/* @__PURE__ */ Error("send failed")));
37
+ });
38
38
  });
39
39
  },
40
40
  consume(e) {
@@ -53,15 +53,15 @@ function o(e) {
53
53
  return;
54
54
  }
55
55
  } catch (e) {
56
- a.error("match request result failed", e);
56
+ o.error("match request result failed", e);
57
57
  return;
58
58
  }
59
- a.warn("response shape not matched, keep pending", { traceId: t });
59
+ o.warn("response shape not matched, keep pending", { traceId: t });
60
60
  }
61
61
  },
62
62
  destroy() {
63
63
  if (l.size !== 0) {
64
- a.warn("rejected all pending requests", { count: l.size });
64
+ o.warn("rejected all pending requests", { count: l.size });
65
65
  for (let e of l.values()) clearTimeout(e.timeout), e.reject(/* @__PURE__ */ Error("connection closed"));
66
66
  l.clear();
67
67
  }
@@ -69,4 +69,4 @@ function o(e) {
69
69
  };
70
70
  }
71
71
  //#endregion
72
- export { o as createCloudDispatcher };
72
+ export { s as createCloudDispatcher };
@@ -1,6 +1,6 @@
1
1
  import { clawLogger as e } from "../../utils/claw-logger.mjs";
2
2
  //#region src/cloud-channel/handlers/auth.ts
3
- var t = e("auth-handler");
3
+ var t = e("cloud-handlers");
4
4
  function n(e, t) {
5
5
  t.register("updateAuthorization", (t) => r(t, e));
6
6
  }