@honor-claw/yoyo 2026.6.9-alpha.13 → 2026.6.9-alpha.15

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.
@@ -47,31 +47,6 @@ var n = e("capabilities"), 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("capabilities"), 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("capabilities"), 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;
@@ -34,7 +34,7 @@ var a = e("capabilities"), 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,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
+ traceId: e.traceId,
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 };
@@ -1,83 +1,117 @@
1
1
  import { clawLogger as e } from "../../../utils/claw-logger.mjs";
2
- import { useAdminCapability as t } from "../../../capabilities/admin/impl.mjs";
2
+ import { resolveEnabledYoyoAccountId as t } from "../../../modules/configs/channel.mjs";
3
+ import { useAdminCapability as n } from "../../../capabilities/admin/impl.mjs";
3
4
  import "../../../capabilities/admin/index.mjs";
4
- import { createDeviceToolSetUpdateAck as n } from "../../../provisioning/toolset/ack.mjs";
5
+ import { getModelsListWithPrimary as r } from "../../../capabilities/routing/list.mjs";
6
+ import { switchModel as i } from "../../../capabilities/routing/model-switch.mjs";
7
+ import "../../../capabilities/routing/index.mjs";
8
+ import { createDeviceToolSetUpdateAck as a } from "../../../provisioning/toolset/ack.mjs";
5
9
  import "../../../provisioning/toolset/index.mjs";
6
10
  //#region src/cloud-channel/handlers/context/handler.ts
7
- var r = e("cloud-handlers"), i = {
11
+ var o = e("cloud-handlers"), s = {
8
12
  style: "SOUL.md",
9
13
  soul: "SOUL.md"
10
- }, a = new Set(["DeviceToolSet", "UniversalToolSet"]);
11
- function o(e, n) {
12
- let r = t(), i = {
14
+ }, c = new Set(["DeviceToolSet", "UniversalToolSet"]);
15
+ function l(e, t) {
16
+ let r = n(), i = {
13
17
  adminCapability: r,
14
18
  outbound: e,
15
- updateHandlers: s(r),
16
- fetchHandlers: c(r)
17
- }, a = (e) => l(e, i);
18
- n.register("fetchContexts", a), n.register("updateContexts", a);
19
+ updateHandlers: u(r),
20
+ fetchHandlers: d(r)
21
+ }, a = (e) => m(e, i);
22
+ t.register("fetchContexts", a), t.register("updateContexts", a);
19
23
  }
20
- function s(e) {
24
+ function u(e) {
21
25
  return {
22
- style: (t) => e.setAgentFile(i.style, typeof t?.content == "string" ? t.content : ""),
23
- soul: (t) => m(e, t),
24
- "model.primary": (t) => e.switchPrimaryModel(typeof t?.provider == "string" ? t.provider : "", typeof t?.id == "string" ? t.id : ""),
25
- DeviceToolSet: h,
26
- UniversalToolSet: h
26
+ style: ({ payload: t }) => e.setAgentFile(s.style, typeof t?.content == "string" ? t.content : ""),
27
+ soul: ({ payload: t }) => y(e, t),
28
+ "model.primary": ({ payload: e, event: t }) => f(e, t),
29
+ DeviceToolSet: ({ payload: e, context: t }) => b(e, t),
30
+ UniversalToolSet: ({ payload: e, context: t }) => b(e, t)
27
31
  };
28
32
  }
29
- function c(e) {
33
+ function d(e) {
30
34
  return {
31
35
  skills: () => e.getSkillsStatus(),
32
- "models.list": () => e.getModelList()
36
+ "models.list": ({ event: e }) => p(e)
37
+ };
38
+ }
39
+ async function f(e, n) {
40
+ let r = typeof e?.provider == "string" ? e.provider : "", a = typeof e?.id == "string" ? e.id : "", o = await i({
41
+ accountId: t(),
42
+ deviceId: n.from.deviceId,
43
+ provider: r,
44
+ model: a,
45
+ traceId: n.payload.traceInfo.traceId
46
+ });
47
+ return {
48
+ ok: !0,
49
+ data: {
50
+ provider: o.provider,
51
+ model: o.model
52
+ }
33
53
  };
34
54
  }
35
- async function l(e, t) {
36
- let { from: n, payload: i } = e, o = i.msgType, s = o === "updateContexts", c = n.deviceId;
37
- r.info("handling context request", {
38
- msgType: o,
39
- sourceDeviceId: c
55
+ async function p(e) {
56
+ let n = await r(t(), e.from.deviceId ?? "");
57
+ return n.ok ? {
58
+ ok: !0,
59
+ data: { models: n.data?.models }
60
+ } : {
61
+ ok: !1,
62
+ error: n.error
63
+ };
64
+ }
65
+ async function m(e, t) {
66
+ let { from: n, payload: r } = e, i = r.msgType, a = i === "updateContexts", s = n.deviceId;
67
+ o.info("handling context request", {
68
+ msgType: i,
69
+ sourceDeviceId: s
40
70
  });
41
- let l = e.data?.contexts?.[0], m = u(l);
42
- if (!m.valid || !m.context) {
43
- await d(t.outbound, o, e, l, m.error ?? "Invalid context");
71
+ let l = e.data?.contexts?.[0], u = h(l);
72
+ if (!u.valid || !u.context) {
73
+ await g(t.outbound, i, e, l, u.error ?? "Invalid context");
44
74
  return;
45
75
  }
46
- let h = m.context, g = h.header.name;
47
- s && a.has(g) && (h.payload = {
48
- ...h.payload,
49
- nodeId: c
76
+ let d = u.context, f = d.header.name;
77
+ a && c.has(f) && (d.payload = {
78
+ ...d.payload,
79
+ nodeId: s
50
80
  });
51
81
  try {
52
- let n = s ? t.updateHandlers[g] : t.fetchHandlers[g];
82
+ let n = a ? t.updateHandlers[f] : t.fetchHandlers[f];
53
83
  if (!n) {
54
- await d(t.outbound, o, e, l, `Unsupported context name: ${g}`);
84
+ await g(t.outbound, i, e, l, `Unsupported context name: ${f}`);
55
85
  return;
56
86
  }
57
- if (p(s, g) && !await t.adminCapability.waitForReady()) {
58
- await d(t.outbound, o, e, h, "Admin gateway client not ready");
87
+ if (v(a, f) && !await t.adminCapability.waitForReady()) {
88
+ await g(t.outbound, i, e, d, "Admin gateway client not ready");
59
89
  return;
60
90
  }
61
- let i = s ? await n(h.payload, h) : await n();
62
- if (i.noReply) {
63
- r.info(`${s ? "update" : "fetch"} context processed (no reply)`, { contextName: g });
91
+ let r = a ? await n({
92
+ payload: d.payload,
93
+ context: d,
94
+ event: e
95
+ }) : await n({ event: e });
96
+ if (r.noReply) {
97
+ o.info(`${a ? "update" : "fetch"} context processed (no reply)`, { contextName: f });
64
98
  return;
65
99
  }
66
- i.ok ? (r.info(`${s ? "update" : "fetch"} context successfully`), await f(t.outbound, o, e, l, i.responsePayload ?? {
100
+ r.ok ? (o.info(`${a ? "update" : "fetch"} context successfully`), await _(t.outbound, i, e, l, r.responsePayload ?? {
67
101
  ok: !0,
68
- ...i.data
69
- })) : (r.error(`failed to ${s ? "update" : "fetch"} context`, i.error, { contextName: g }), await f(t.outbound, o, e, l, i.responsePayload ?? {
102
+ ...r.data
103
+ })) : (o.error(`failed to ${a ? "update" : "fetch"} context`, r.error, { contextName: f }), await _(t.outbound, i, e, l, r.responsePayload ?? {
70
104
  ok: !1,
71
- error: i.error,
72
- ...i.data,
73
- ...s && { name: g }
105
+ error: r.error,
106
+ ...r.data,
107
+ ...a && { name: f }
74
108
  }));
75
109
  } catch (n) {
76
- let i = n instanceof Error ? n.message : String(n);
77
- r.error(`error ${s ? "updating" : "fetching"} context`, n, { contextName: g }), await d(t.outbound, o, e, l, i);
110
+ let r = n instanceof Error ? n.message : String(n);
111
+ o.error(`error ${a ? "updating" : "fetching"} context`, n, { contextName: f }), await g(t.outbound, i, e, l, r);
78
112
  }
79
113
  }
80
- function u(e) {
114
+ function h(e) {
81
115
  return e?.header?.name ? {
82
116
  valid: !0,
83
117
  context: e
@@ -86,13 +120,13 @@ function u(e) {
86
120
  error: "Missing context name"
87
121
  };
88
122
  }
89
- async function d(e, t, n, i, a) {
90
- r.error(a), await f(e, t, n, i, {
123
+ async function g(e, t, n, r, i) {
124
+ o.error(i), await _(e, t, n, r, {
91
125
  ok: !1,
92
- error: a
126
+ error: i
93
127
  });
94
128
  }
95
- async function f(e, t, n, r, i) {
129
+ async function _(e, t, n, r, i) {
96
130
  let a = [{
97
131
  header: r?.header ?? {
98
132
  name: "unknown",
@@ -106,11 +140,11 @@ async function f(e, t, n, r, i) {
106
140
  data: { contexts: a }
107
141
  });
108
142
  }
109
- function p(e, t) {
110
- return !e || !a.has(t);
143
+ function v(e, t) {
144
+ return !e || !c.has(t);
111
145
  }
112
- async function m(e, t) {
113
- let n = await e.setAgentFile(i.soul, typeof t?.md == "string" ? t.md : ""), r = t?.id;
146
+ async function y(e, t) {
147
+ let n = await e.setAgentFile(s.soul, typeof t?.md == "string" ? t.md : ""), r = t?.id;
114
148
  return r === void 0 ? n : {
115
149
  ...n,
116
150
  data: {
@@ -119,16 +153,16 @@ async function m(e, t) {
119
153
  }
120
154
  };
121
155
  }
122
- async function h(e, t) {
123
- let r = await n({
156
+ async function b(e, t) {
157
+ let n = await a({
124
158
  namespace: t?.header.namespace,
125
159
  payload: e
126
160
  });
127
161
  return {
128
- ok: r.ok,
129
- error: r.error,
130
- responsePayload: r.payload
162
+ ok: n.ok,
163
+ error: n.error,
164
+ responsePayload: n.payload
131
165
  };
132
166
  }
133
167
  //#endregion
134
- export { o as registerContextHandler };
168
+ export { l as registerContextHandler };
@@ -31,18 +31,6 @@ var r = {
31
31
  async getModelList() {
32
32
  return this.sendRequest("models.list", {});
33
33
  }
34
- async switchPrimaryModel(e, t) {
35
- return this.sendRequest("sessions.patch", {
36
- key: "agent:main:main",
37
- model: `${e}/${t}`
38
- });
39
- }
40
- async getMainSession() {
41
- return (await this.sendRequest("sessions.list", {
42
- includeGlobal: !0,
43
- includeUnknown: !0
44
- })).sessions?.find((e) => e?.key === "agent:main:main") ?? {};
45
- }
46
34
  async devicePairList() {
47
35
  return this.sendRequest("device.pair.list", {});
48
36
  }
@@ -17,7 +17,7 @@ var r = class {
17
17
  return this.ws !== null && this.ws.readyState === n.OPEN;
18
18
  }
19
19
  connect() {
20
- if (this.closed) return;
20
+ if (this.closed || this.ws !== null) return;
21
21
  let e = this.getUrl();
22
22
  this.ws = new n(e, { maxPayload: 25 * 1024 * 1024 }), this.ws.on("open", () => {
23
23
  this.opts.onOpen?.(), this.onOpen();
@@ -47,7 +47,7 @@ var u = t("gateway"), d = {
47
47
  }
48
48
  }
49
49
  onClose(e, t) {
50
- this.connected = !1, this.authenticated = !1, this.helloOk = null, this.resetConnectNonce(), this.clearAllPending(), this.protocolOpts.onClose?.(t), this.scheduleReconnect();
50
+ this.connected = !1, this.authenticated = !1, this.helloOk = null, this.resetConnectNonce(), this.clearAllPending(), this.scheduleReconnect();
51
51
  }
52
52
  handleEvent(e) {
53
53
  if (e.event === "connect.challenge") {
@@ -103,7 +103,7 @@ var u = t("gateway"), d = {
103
103
  device: a
104
104
  };
105
105
  this.sendRequest("connect", l).then((e) => {
106
- this.helloOk = e, this.connected = !0, this.authenticated = !0, this.protocolOpts.onAuthenticated?.();
106
+ this.helloOk = e, this.connected = !0, this.authenticated = !0, this.reconnectAttempts = 0, this.isReconnecting = !1, this.protocolOpts.onAuthenticated?.();
107
107
  }).catch((e) => {
108
108
  this.authenticated = !1;
109
109
  let t = e instanceof c ? `auth failed: [${e.code}] ${e.message}` : `auth failed: ${e.message}`;
@@ -167,7 +167,7 @@ var u = t("gateway"), d = {
167
167
  });
168
168
  }
169
169
  connect() {
170
- this.closed || (this.isReconnecting = !1, super.connect());
170
+ this.closed || (this.reconnectTimer &&= (clearTimeout(this.reconnectTimer), null), this.isReconnecting = !1, super.connect());
171
171
  }
172
172
  stop() {
173
173
  this.isReconnecting = !1, this.reconnectTimer &&= (clearTimeout(this.reconnectTimer), null), this.reconnectAttempts = 0, super.stop();
@@ -182,7 +182,7 @@ var u = t("gateway"), d = {
182
182
  attempt: this.reconnectAttempts,
183
183
  max: h
184
184
  }), this.reconnectTimer = setTimeout(() => {
185
- this.isReconnecting = !1, this.closed || super.connect();
185
+ this.reconnectTimer = null, this.isReconnecting = !1, this.closed || super.connect();
186
186
  }, g);
187
187
  }
188
188
  }
@@ -1,49 +1,51 @@
1
1
  import { clawLogger as e } from "../../utils/claw-logger.mjs";
2
2
  import { getPersistedIdentity as t, updatePersistedIdentity as n } from "../../modules/configs/identity-persist.mjs";
3
- import { clearUserConfig as r, getUserConfig as i } from "../../modules/configs/plugin.mjs";
3
+ import { loadConfig as r, saveConfig as i } from "../../modules/configs/config-store.mjs";
4
+ import { clearUserConfig as a, getUserConfig as o } from "../../modules/configs/plugin.mjs";
5
+ import { patchYoyoChannelConfig as s, setAllYoyoChannelAccountsEnabled as c, setYoyoChannelAccountEnabled as l } from "../../modules/configs/channel.mjs";
4
6
  import "../../modules/configs/index.mjs";
5
- import { parseTokenExpireMs as a } from "./token-expiry.mjs";
6
- import { HonorAccount as o } from "./impl.mjs";
7
- import { createClawCloudClient as s } from "../../apis/claw-cloud.mjs";
8
- import { loadDeviceInfo as c } from "../../modules/device/device-info.mjs";
7
+ import { parseTokenExpireMs as u } from "./token-expiry.mjs";
8
+ import { HonorAccount as d } from "./impl.mjs";
9
+ import { createClawCloudClient as f } from "../../apis/claw-cloud.mjs";
10
+ import { loadDeviceInfo as p } from "../../modules/device/device-info.mjs";
9
11
  import "../../modules/device/index.mjs";
10
12
  //#region src/honor-auth/vault/legacy-migration.ts
11
- var l = e("auth");
12
- async function u() {
13
+ var m = e("auth");
14
+ async function h() {
13
15
  try {
14
- let e = i(), u = e?.token, d = e?.userId, f = (await t())?.authorizationCache, p = f?.jwtToken, m = f?.receivedAtMs, h = f?.expireMs, g = p ?? u;
15
- if (!g) {
16
- l.debug("no legacy token to migrate");
16
+ let e = o(), h = e?.token, g = e?.userId, _ = (await t())?.authorizationCache, v = _?.jwtToken, y = _?.receivedAtMs, b = _?.expireMs, x = v ?? h;
17
+ if (!x) {
18
+ m.debug("no legacy token to migrate");
17
19
  return;
18
20
  }
19
- let _ = d, v = g, y = a(h), b = m;
20
- if (!_ || !y) try {
21
- let e = await c(), t = await s().exchangeToken(e, { token: g });
22
- _ ||= t.userId, y || (v = t.jwtToken ?? v, y = t.expire ?? y, b = Date.now()), l.info("exchanged legacy token for missing fields", {
23
- hasUserId: !!_,
24
- hasExpire: !!y
21
+ let S = g, C = x, w = u(b), T = y;
22
+ if (!S || !w) try {
23
+ let e = await p(), t = await f().exchangeToken(e, { token: x });
24
+ S ||= t.userId, w || (C = t.jwtToken ?? C, w = t.expire ?? w, T = Date.now()), m.info("exchanged legacy token for missing fields", {
25
+ hasUserId: !!S,
26
+ hasExpire: !!w
25
27
  });
26
28
  } catch (e) {
27
- l.warn("failed to exchange legacy token for missing fields", e);
29
+ m.warn("failed to exchange legacy token for missing fields", e);
28
30
  }
29
- if (!_) {
30
- l.warn("legacy token missing userId and exchange failed, skip migration");
31
+ if (!S) {
32
+ m.warn("legacy token missing userId and exchange failed, skip migration");
31
33
  return;
32
34
  }
33
- let x = a(y), S = {
34
- accessToken: v,
35
- expire: x,
36
- grantedAt: b,
35
+ let E = u(w), D = {
36
+ accessToken: C,
37
+ expire: E,
38
+ grantedAt: T,
37
39
  metadata: {
38
- userInfo: { userId: _ },
39
- legacyReceivedAtMs: m,
40
- legacyExpireMs: h
40
+ userInfo: { userId: S },
41
+ legacyReceivedAtMs: y,
42
+ legacyExpireMs: b
41
43
  }
42
44
  };
43
- await o.fromUser(_).save(S), l.info("migrated legacy token to vault", { accountKey: _ }), (u || d) && await r(), f && await n({ authorizationCache: void 0 });
45
+ await d.fromUser(S).save(D), m.info("migrated legacy token to vault", { accountKey: S }), (h || g) && await a(), _ && await n({ authorizationCache: void 0 }), await i(s(l(c(r(), !1), S, !0), { enabled: !0 })), m.info("enabled migrated legacy account in yoyo channel", { accountKey: S });
44
46
  } catch (e) {
45
- l.warn("legacy token migration failed", e);
47
+ m.warn("legacy token migration failed", e);
46
48
  }
47
49
  }
48
50
  //#endregion
49
- export { u as migrateLegacyHonorToken };
51
+ export { h as migrateLegacyHonorToken };
@@ -4,7 +4,7 @@ import { stringifyValue as n } from "../../../utils/stringify.mjs";
4
4
  import { clearToolTraceSession as r } from "./tool/trace-store.mjs";
5
5
  //#region src/messaging/dispatchers/stream/session.ts
6
6
  function i(e) {
7
- return e.finished || e.abortController.signal.aborted;
7
+ return e.silent || e.finished || e.abortController.signal.aborted;
8
8
  }
9
9
  function a(t) {
10
10
  return r(t.sessionKey), {
@@ -15,6 +15,7 @@ function a(t) {
15
15
  turnId: e(),
16
16
  finished: !1,
17
17
  abortController: t.abortController,
18
+ silent: t.silent ?? !1,
18
19
  answerSnapshot: "",
19
20
  thinkingSnapshot: "",
20
21
  latestAnswerSnapshot: "",
@@ -111,7 +112,7 @@ async function d(e) {
111
112
  r(e.sessionKey);
112
113
  return;
113
114
  }
114
- e.finished = !0, await t({
115
+ e.finished = !0, e.silent || await t({
115
116
  period: "completed",
116
117
  isFinish: !0
117
118
  }, {
@@ -14,7 +14,8 @@ async function o(o) {
14
14
  replyToMessageId: s.messageId,
15
15
  abortController: c,
16
16
  streamOptions: s.streamOptions,
17
- traceId: s.traceId
17
+ traceId: s.traceId,
18
+ silent: o.silent
18
19
  });
19
20
  e(u, { abortController: c });
20
21
  try {
@@ -21,7 +21,8 @@ async function c(e) {
21
21
  },
22
22
  replyToMessageId: c.messageId,
23
23
  abortController: l,
24
- traceId: c.traceId
24
+ traceId: c.traceId,
25
+ silent: e.silent
25
26
  });
26
27
  t(d, { abortController: l });
27
28
  try {
@@ -1,13 +1,15 @@
1
1
  import { YOYO_CHANNEL_ID as e } from "../../consts.mjs";
2
2
  import { getYoyoRuntime as t } from "../../core/runtime.mjs";
3
3
  import { uuid as n } from "../../utils/id.mjs";
4
- import { buildChatTo as r, buildFrom as i } from "../target/address.mjs";
5
- import { buildChatId as a } from "../target/chat-id.mjs";
4
+ import { resolveYoyoRoute as r } from "../../capabilities/routing/route.mjs";
5
+ import { buildChatTo as i, buildFrom as a } from "../target/address.mjs";
6
+ import { buildChatId as o } from "../target/chat-id.mjs";
6
7
  import "../target/index.mjs";
7
- import { extractRawTextFromEvent as o, extractResourcesFromEvent as s } from "./extracts.mjs";
8
- import { getRuntimeConfig as c } from "openclaw/plugin-sdk/config-runtime";
8
+ import "../../capabilities/routing/index.mjs";
9
+ import { extractRawTextFromEvent as s, extractResourcesFromEvent as c } from "./extracts.mjs";
10
+ import { getRuntimeConfig as l } from "openclaw/plugin-sdk/config-runtime";
9
11
  //#region src/messaging/inbound/context.ts
10
- async function l(e, t) {
12
+ async function u(e, t) {
11
13
  let r = e.from.deviceId ?? "";
12
14
  if (!r) throw Error("no sender device id found");
13
15
  return {
@@ -15,41 +17,37 @@ async function l(e, t) {
15
17
  traceId: e.payload.traceInfo.traceId,
16
18
  senderId: r,
17
19
  accountId: t.accountId,
18
- chatId: await a(t.accountId, r),
19
- content: o(e),
20
- resources: s(e),
20
+ chatId: await o(t.accountId, r),
21
+ content: s(e),
22
+ resources: c(e),
21
23
  streamOptions: e.data?.userMessage?.streamOptions
22
24
  };
23
25
  }
24
- function u(n) {
25
- let i = t(), a = c(), o = r(n.chatId);
26
+ function d(e) {
27
+ let n = t(), a = l(), o = i(e.chatId);
26
28
  return {
27
- ctx: n,
29
+ ctx: e,
28
30
  cfg: a,
29
- core: i,
30
- route: i.channel.routing.resolveAgentRoute({
31
- cfg: a,
32
- channel: e,
33
- accountId: n.accountId,
34
- peer: {
35
- kind: "direct",
36
- id: n.chatId
37
- }
31
+ core: n,
32
+ route: r({
33
+ accountId: e.accountId,
34
+ chatId: e.chatId
38
35
  }),
39
- replyTarget: o
36
+ replyTarget: o,
37
+ silent: e.silent ?? !1
40
38
  };
41
39
  }
42
- function d(t) {
43
- let { ctx: n, core: r, route: a, replyTarget: o } = t;
40
+ function f(t) {
41
+ let { ctx: n, core: r, route: i, replyTarget: o } = t;
44
42
  return r.channel.reply.finalizeInboundContext({
45
43
  Body: n.content,
46
44
  BodyForAgent: n.content,
47
45
  RawBody: n.content,
48
46
  CommandBody: n.content,
49
47
  CommandAuthorized: !0,
50
- From: i(n.chatId),
48
+ From: a(n.chatId),
51
49
  To: o,
52
- SessionKey: a.sessionKey,
50
+ SessionKey: i.sessionKey,
53
51
  AccountId: n.accountId,
54
52
  ChatType: "direct",
55
53
  SenderId: n.senderId,
@@ -62,4 +60,4 @@ function d(t) {
62
60
  });
63
61
  }
64
62
  //#endregion
65
- export { u as buildDispatchContext, d as buildInboundContextPayload, l as buildMessageContext };
63
+ export { d as buildDispatchContext, f as buildInboundContextPayload, u as buildMessageContext };
@@ -6,32 +6,36 @@ import { dispatchInboundToAgent as r } from "./agent.mjs";
6
6
  import { dispatchSystemCommand as i } from "./command.mjs";
7
7
  //#region src/messaging/inbound/dispatch.ts
8
8
  var a = e("inbound");
9
- async function o(e) {
10
- if (e.content.trim() === "" && e.resources.length === 0) {
11
- a.info("empty inbound message, skipping", {
12
- messageId: e.messageId,
13
- chatId: e.chatId
14
- });
15
- return;
16
- }
17
- let o = t(e);
18
- if (o.core.channel.commands.isControlCommandMessage(e.content, o.cfg)) {
19
- await i(o);
20
- return;
21
- }
22
- await n(o.route.agentId, o.route.sessionKey), a.info("dispatching inbound message to agent", {
23
- messageId: e.messageId,
24
- chatId: e.chatId,
25
- contentLength: e.content.length,
26
- resources: e.resources.length
27
- });
9
+ async function o(e, o) {
28
10
  try {
29
- await r(o);
30
- } catch (t) {
31
- throw a.error("agent inbound dispatch failed", t, {
11
+ if (e.content.trim() === "" && e.resources.length === 0) {
12
+ a.info("empty inbound message, skipping", {
13
+ messageId: e.messageId,
14
+ chatId: e.chatId
15
+ });
16
+ return;
17
+ }
18
+ let o = t(e);
19
+ if (o.core.channel.commands.isControlCommandMessage(e.content, o.cfg)) {
20
+ await i(o);
21
+ return;
22
+ }
23
+ await n(o.route.agentId, o.route.sessionKey), a.info("dispatching inbound message to agent", {
32
24
  messageId: e.messageId,
33
- chatId: e.chatId
34
- }), t;
25
+ chatId: e.chatId,
26
+ contentLength: e.content.length,
27
+ resources: e.resources.length
28
+ });
29
+ try {
30
+ await r(o);
31
+ } catch (t) {
32
+ throw a.error("agent inbound dispatch failed", t, {
33
+ messageId: e.messageId,
34
+ chatId: e.chatId
35
+ }), t;
36
+ }
37
+ } finally {
38
+ o?.onEnd?.();
35
39
  }
36
40
  }
37
41
  //#endregion
@@ -7,25 +7,30 @@ import { buildMessageContext as i } from "./context.mjs";
7
7
  import { dispatchMessageContext as a } from "./dispatch.mjs";
8
8
  //#region src/messaging/inbound/user-message.ts
9
9
  var o = e("inbound");
10
- async function s(e, s) {
11
- let c = await i(e, s);
12
- c.content && n(c.content) && r(c.chatId);
13
- let { status: l, queueId: u, promise: d } = t({
14
- chatId: c.chatId,
15
- task: () => a(c)
16
- });
17
- o.info("enqueued user message", {
18
- sender: c.senderId,
19
- traceId: c.traceId,
20
- queueId: u,
21
- status: l
22
- }), d.catch((e) => {
23
- o.error("queued user message task failed", e, {
24
- sender: c.senderId,
25
- traceId: c.traceId,
26
- queueId: u
10
+ async function s(e) {
11
+ return e.content && n(e.content) && r(e.chatId), new Promise((n, r) => {
12
+ let { status: i, queueId: s, promise: c } = t({
13
+ chatId: e.chatId,
14
+ task: () => a(e, { onEnd: () => n() })
27
15
  });
16
+ o.info("enqueued user message", {
17
+ sender: e.senderId,
18
+ traceId: e.traceId,
19
+ queueId: s,
20
+ status: i
21
+ }), c.catch((t) => {
22
+ o.error("queued user message task failed", t, {
23
+ sender: e.senderId,
24
+ traceId: e.traceId,
25
+ queueId: s
26
+ }), r(t);
27
+ }).finally(() => {
28
+ n();
29
+ }), e.silent || n();
28
30
  });
29
31
  }
32
+ async function c(e, t) {
33
+ return s(await i(e, t));
34
+ }
30
35
  //#endregion
31
- export { s as dispatchUserMessage };
36
+ export { s as dispatchInboundContext, c as dispatchUserMessage };
@@ -1,18 +1,18 @@
1
1
  import { YOYO_CHANNEL_ID as e } from "../../consts.mjs";
2
- import { sendAgentReplyFrame as t } from "./frame.mjs";
3
- import { buildChatId as n } from "../target/chat-id.mjs";
4
- import { resolveOutboundTarget as r } from "../target/outbound.mjs";
2
+ import { buildChatId as t } from "../target/chat-id.mjs";
3
+ import { resolveOutboundTarget as n } from "../target/outbound.mjs";
5
4
  import "../target/index.mjs";
5
+ import { sendAgentReplyFrame as r } from "./frame.mjs";
6
6
  //#region src/messaging/send/text.ts
7
7
  async function i(i) {
8
- let a = await r(i.to, i.accountId), o = await n(a.accountId, a.deviceId), s = i.text;
8
+ let a = await n(i.to, i.accountId), o = await t(a.accountId, a.deviceId), s = i.text;
9
9
  return s.trim().length === 0 ? {
10
10
  channel: e,
11
11
  messageId: "",
12
12
  chatId: o
13
13
  } : {
14
14
  channel: e,
15
- messageId: await t({
15
+ messageId: await r({
16
16
  period: "message",
17
17
  isFinish: !0,
18
18
  content: [{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@honor-claw/yoyo",
3
- "version": "2026.6.9-alpha.13",
3
+ "version": "2026.6.9-alpha.15",
4
4
  "description": "OpenClaw Honor Yoyo connection plugin",
5
5
  "keywords": [
6
6
  "ai",