@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.
- package/dist/capabilities/admin/impl.mjs +2 -59
- package/dist/capabilities/admin/manager.mjs +1 -1
- package/dist/capabilities/routing/index.mjs +3 -0
- package/dist/capabilities/routing/list.mjs +27 -0
- package/dist/capabilities/routing/model-switch.mjs +36 -0
- package/dist/capabilities/routing/primary.mjs +36 -0
- package/dist/capabilities/routing/route.mjs +18 -0
- package/dist/cloud-channel/handlers/context/handler.mjs +94 -60
- package/dist/gateway/client/admin.mjs +0 -12
- package/dist/gateway/client/client.mjs +1 -1
- package/dist/gateway/client/protocol.mjs +4 -4
- package/dist/honor-auth/vault/legacy-migration.mjs +31 -29
- package/dist/messaging/dispatchers/stream/session.mjs +3 -2
- package/dist/messaging/inbound/agent.mjs +2 -1
- package/dist/messaging/inbound/command.mjs +2 -1
- package/dist/messaging/inbound/context.mjs +24 -26
- package/dist/messaging/inbound/dispatch.mjs +28 -24
- package/dist/messaging/inbound/user-message.mjs +23 -18
- package/dist/messaging/send/text.mjs +5 -5
- package/package.json +1 -1
|
@@ -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
|
-
|
|
98
|
-
return n.info("current primary model", {
|
|
99
|
-
provider: r,
|
|
100
|
-
id: i
|
|
101
|
-
}), {
|
|
72
|
+
return {
|
|
102
73
|
ok: !0,
|
|
103
|
-
data: { models:
|
|
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,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 {
|
|
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 {
|
|
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
|
|
11
|
+
var o = e("cloud-handlers"), s = {
|
|
8
12
|
style: "SOUL.md",
|
|
9
13
|
soul: "SOUL.md"
|
|
10
|
-
},
|
|
11
|
-
function
|
|
12
|
-
let r =
|
|
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:
|
|
16
|
-
fetchHandlers:
|
|
17
|
-
}, a = (e) =>
|
|
18
|
-
|
|
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
|
|
24
|
+
function u(e) {
|
|
21
25
|
return {
|
|
22
|
-
style: (t) => e.setAgentFile(
|
|
23
|
-
soul: (t) =>
|
|
24
|
-
"model.primary": (
|
|
25
|
-
DeviceToolSet:
|
|
26
|
-
UniversalToolSet:
|
|
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
|
|
33
|
+
function d(e) {
|
|
30
34
|
return {
|
|
31
35
|
skills: () => e.getSkillsStatus(),
|
|
32
|
-
"models.list": () => e
|
|
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
|
|
36
|
-
let
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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],
|
|
42
|
-
if (!
|
|
43
|
-
await
|
|
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
|
|
47
|
-
|
|
48
|
-
...
|
|
49
|
-
nodeId:
|
|
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 =
|
|
82
|
+
let n = a ? t.updateHandlers[f] : t.fetchHandlers[f];
|
|
53
83
|
if (!n) {
|
|
54
|
-
await
|
|
84
|
+
await g(t.outbound, i, e, l, `Unsupported context name: ${f}`);
|
|
55
85
|
return;
|
|
56
86
|
}
|
|
57
|
-
if (
|
|
58
|
-
await
|
|
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
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
100
|
+
r.ok ? (o.info(`${a ? "update" : "fetch"} context successfully`), await _(t.outbound, i, e, l, r.responsePayload ?? {
|
|
67
101
|
ok: !0,
|
|
68
|
-
...
|
|
69
|
-
})) : (
|
|
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:
|
|
72
|
-
...
|
|
73
|
-
...
|
|
105
|
+
error: r.error,
|
|
106
|
+
...r.data,
|
|
107
|
+
...a && { name: f }
|
|
74
108
|
}));
|
|
75
109
|
} catch (n) {
|
|
76
|
-
let
|
|
77
|
-
|
|
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
|
|
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
|
|
90
|
-
|
|
123
|
+
async function g(e, t, n, r, i) {
|
|
124
|
+
o.error(i), await _(e, t, n, r, {
|
|
91
125
|
ok: !1,
|
|
92
|
-
error:
|
|
126
|
+
error: i
|
|
93
127
|
});
|
|
94
128
|
}
|
|
95
|
-
async function
|
|
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
|
|
110
|
-
return !e || !
|
|
143
|
+
function v(e, t) {
|
|
144
|
+
return !e || !c.has(t);
|
|
111
145
|
}
|
|
112
|
-
async function
|
|
113
|
-
let n = await e.setAgentFile(
|
|
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
|
|
123
|
-
let
|
|
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:
|
|
129
|
-
error:
|
|
130
|
-
responsePayload:
|
|
162
|
+
ok: n.ok,
|
|
163
|
+
error: n.error,
|
|
164
|
+
responsePayload: n.payload
|
|
131
165
|
};
|
|
132
166
|
}
|
|
133
167
|
//#endregion
|
|
134
|
-
export {
|
|
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.
|
|
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 {
|
|
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
|
|
6
|
-
import { HonorAccount as
|
|
7
|
-
import { createClawCloudClient as
|
|
8
|
-
import { loadDeviceInfo as
|
|
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
|
|
12
|
-
async function
|
|
13
|
+
var m = e("auth");
|
|
14
|
+
async function h() {
|
|
13
15
|
try {
|
|
14
|
-
let e =
|
|
15
|
-
if (!
|
|
16
|
-
|
|
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
|
|
20
|
-
if (!
|
|
21
|
-
let e = await
|
|
22
|
-
|
|
23
|
-
hasUserId: !!
|
|
24
|
-
hasExpire: !!
|
|
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
|
-
|
|
29
|
+
m.warn("failed to exchange legacy token for missing fields", e);
|
|
28
30
|
}
|
|
29
|
-
if (!
|
|
30
|
-
|
|
31
|
+
if (!S) {
|
|
32
|
+
m.warn("legacy token missing userId and exchange failed, skip migration");
|
|
31
33
|
return;
|
|
32
34
|
}
|
|
33
|
-
let
|
|
34
|
-
accessToken:
|
|
35
|
-
expire:
|
|
36
|
-
grantedAt:
|
|
35
|
+
let E = u(w), D = {
|
|
36
|
+
accessToken: C,
|
|
37
|
+
expire: E,
|
|
38
|
+
grantedAt: T,
|
|
37
39
|
metadata: {
|
|
38
|
-
userInfo: { userId:
|
|
39
|
-
legacyReceivedAtMs:
|
|
40
|
-
legacyExpireMs:
|
|
40
|
+
userInfo: { userId: S },
|
|
41
|
+
legacyReceivedAtMs: y,
|
|
42
|
+
legacyExpireMs: b
|
|
41
43
|
}
|
|
42
44
|
};
|
|
43
|
-
await
|
|
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
|
-
|
|
47
|
+
m.warn("legacy token migration failed", e);
|
|
46
48
|
}
|
|
47
49
|
}
|
|
48
50
|
//#endregion
|
|
49
|
-
export {
|
|
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
|
}, {
|
|
@@ -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 {
|
|
5
|
-
import {
|
|
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
|
|
8
|
-
import {
|
|
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
|
|
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
|
|
19
|
-
content:
|
|
20
|
-
resources:
|
|
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
|
|
25
|
-
let
|
|
26
|
+
function d(e) {
|
|
27
|
+
let n = t(), a = l(), o = i(e.chatId);
|
|
26
28
|
return {
|
|
27
|
-
ctx:
|
|
29
|
+
ctx: e,
|
|
28
30
|
cfg: a,
|
|
29
|
-
core:
|
|
30
|
-
route:
|
|
31
|
-
|
|
32
|
-
|
|
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
|
|
43
|
-
let { ctx: n, core: r, route:
|
|
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:
|
|
48
|
+
From: a(n.chatId),
|
|
51
49
|
To: o,
|
|
52
|
-
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 {
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
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
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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 {
|
|
3
|
-
import {
|
|
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
|
|
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
|
|
15
|
+
messageId: await r({
|
|
16
16
|
period: "message",
|
|
17
17
|
isFinish: !0,
|
|
18
18
|
content: [{
|