@honor-claw/yoyo 2026.9.3-alpha.1 → 2026.9.3-alpha.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.
- package/dist/capabilities/cloud-invoke/invoke.mjs +11 -11
- package/dist/capabilities/node/invoke.mjs +4 -4
- package/dist/capabilities/node/list.mjs +9 -9
- package/dist/capabilities/remote-file/remote-file.mjs +11 -11
- package/dist/channel/lifecycle.mjs +1 -1
- package/dist/cli/login/impl.mjs +12 -11
- package/dist/core/hooks/gateway-lifecycle.mjs +12 -11
- package/dist/core/prompt/builder.mjs +11 -9
- package/dist/core/prompt/location.mjs +7 -0
- package/dist/diagnose/collectors/account.mjs +1 -1
- package/dist/honor-auth/browser/flow.mjs +13 -13
- package/dist/honor-auth/login/impl.mjs +4 -4
- package/dist/honor-auth/logout.mjs +7 -7
- package/dist/honor-auth/vault/legacy-migration.mjs +8 -8
- package/dist/messaging/dispatchers/stream/controller.mjs +29 -29
- package/dist/messaging/dispatchers/stream/session.mjs +25 -25
- package/dist/messaging/inbound/context.mjs +17 -17
- package/dist/modules/configs/agent-defaults.mjs +15 -12
- package/dist/modules/configs/index.mjs +1 -0
- package/dist/modules/configs/owner-allow-from.mjs +53 -0
- package/dist/modules/configs/plugin-init.mjs +1 -1
- package/dist/modules/device/device-info.mjs +1 -1
- package/dist/provisioning/registration/register.mjs +8 -8
- package/dist/tools/remote-file-upload/run.mjs +19 -19
- package/dist/tools/send-message/tool.mjs +9 -9
- package/package.json +1 -1
- package/skills/yoyo-phone-control/SKILL.md +319 -0
- package/skills/yoyo-phone-control/mcptools/create_schedule.json +3 -3
- package/skills/yoyo-phone-control/mcptools/modify_schedule.json +0 -8
- package/skills/yoyo-phone-control/mcptools/search_message.json +21 -5
- package/skills/yoyo-phone-control/mcptools/volume.json +12 -12
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { toErrorMessage as e } from "../../utils/error.mjs";
|
|
2
2
|
import { clawLogger as t } from "../../utils/claw-logger.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
3
|
+
import { createClawCloudClient as n } from "../../apis/claw-cloud.mjs";
|
|
4
|
+
import "../../apis/index.mjs";
|
|
5
|
+
import { HonorAccount as r } from "../../honor-auth/vault/impl.mjs";
|
|
5
6
|
import { loadDeviceInfo as i } from "../../modules/device/device-info.mjs";
|
|
6
7
|
import "../../modules/device/index.mjs";
|
|
7
8
|
import "../../honor-auth/vault/index.mjs";
|
|
8
|
-
import "../../apis/index.mjs";
|
|
9
9
|
import { ToolError as a } from "../../tools/error.mjs";
|
|
10
10
|
//#region src/capabilities/cloud-invoke/invoke.ts
|
|
11
11
|
var o = t("capabilities");
|
|
12
12
|
async function s(t) {
|
|
13
|
-
let s = await
|
|
13
|
+
let s = await r.fromUser().current();
|
|
14
14
|
if (!s?.token || !s.userId) throw o.error("cloud invoke skipped: no current user"), new a("unauthorized", "missing current user token");
|
|
15
15
|
let c;
|
|
16
16
|
try {
|
|
@@ -19,19 +19,19 @@ async function s(t) {
|
|
|
19
19
|
throw o.error("cloud invoke failed to get device info", e), new a("ctx missing", "failed to get device info", { cause: e });
|
|
20
20
|
}
|
|
21
21
|
try {
|
|
22
|
-
let e = await
|
|
22
|
+
let e = await n().invokeCloudTool(c, s, {
|
|
23
23
|
serviceId: t.toolId,
|
|
24
24
|
pluginParams: t.params ?? {},
|
|
25
25
|
...t.timeoutMs === void 0 ? {} : { timeoutMs: t.timeoutMs }
|
|
26
|
-
}),
|
|
26
|
+
}), r = e.data, i = e.status >= 200 && e.status < 300, l = r?.code === "0", u = r?.code === "ICS-500";
|
|
27
27
|
if (!i || !l && !u) throw o.error("cloud invoke response not ok", null, {
|
|
28
28
|
status: e.status,
|
|
29
|
-
code:
|
|
30
|
-
cnMessage:
|
|
31
|
-
cpErrorCode:
|
|
32
|
-
}), new a("api_failed", `code=${
|
|
29
|
+
code: r?.code,
|
|
30
|
+
cnMessage: r?.cnMessage,
|
|
31
|
+
cpErrorCode: r?.data?.cpErrorCode
|
|
32
|
+
}), new a("api_failed", `code=${r?.code ?? "-"} cpErrorCode=${r?.data?.cpErrorCode ?? "-"} message=${r?.cnMessage ?? "-"}`);
|
|
33
33
|
return {
|
|
34
|
-
...
|
|
34
|
+
...r.data === void 0 ? {} : { pluginResponse: r.data },
|
|
35
35
|
code: e.data.code,
|
|
36
36
|
cnMessage: e.data.cnMessage
|
|
37
37
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { clawLogger as e } from "../../utils/claw-logger.mjs";
|
|
2
2
|
import { buildEndpoint as t } from "../../cloud-channel/protocol/target.mjs";
|
|
3
3
|
import { resolveEnabledYoyoAccountId as n } from "../../modules/configs/channel.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import { resolveOutboundTraceInfo as i } from "../../messaging/trace/tool-context.mjs";
|
|
4
|
+
import { resolveOutboundTraceInfo as r } from "../../messaging/trace/tool-context.mjs";
|
|
6
5
|
import "../../messaging/trace/index.mjs";
|
|
6
|
+
import { ClawClient as i } from "../../connection/registry.mjs";
|
|
7
7
|
//#region src/capabilities/node/invoke.ts
|
|
8
8
|
var a = e("capabilities");
|
|
9
9
|
async function o(e) {
|
|
10
|
-
let a =
|
|
10
|
+
let a = r(e.toolCallId), o = {
|
|
11
11
|
to: t("node", e.nodeId),
|
|
12
12
|
msgType: "nodeInvokeRequest",
|
|
13
13
|
data: { node: {
|
|
@@ -18,7 +18,7 @@ async function o(e) {
|
|
|
18
18
|
} },
|
|
19
19
|
...a ? { traceInfo: a } : {}
|
|
20
20
|
}, c = n();
|
|
21
|
-
return
|
|
21
|
+
return i.forAccount(c).request(o, {
|
|
22
22
|
timeoutMs: e.timeoutMs,
|
|
23
23
|
matchResult: s(e.toolCallId)
|
|
24
24
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { toErrorMessage as e } from "../../utils/error.mjs";
|
|
2
2
|
import { clawLogger as t } from "../../utils/claw-logger.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
3
|
+
import { isOKResponse as n } from "../../apis/helpers.mjs";
|
|
4
|
+
import { createClawCloudClient as r } from "../../apis/claw-cloud.mjs";
|
|
5
|
+
import "../../apis/index.mjs";
|
|
6
|
+
import { HonorAccount as i } from "../../honor-auth/vault/impl.mjs";
|
|
6
7
|
import { loadDeviceInfo as a } from "../../modules/device/device-info.mjs";
|
|
7
8
|
import "../../modules/device/index.mjs";
|
|
8
9
|
import "../../honor-auth/vault/index.mjs";
|
|
9
|
-
import "../../apis/index.mjs";
|
|
10
10
|
import { ToolError as o } from "../../tools/error.mjs";
|
|
11
11
|
import { DeviceStatus as s } from "../../types.mjs";
|
|
12
12
|
//#region src/capabilities/node/list.ts
|
|
@@ -21,7 +21,7 @@ function l(e) {
|
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
async function u(t) {
|
|
24
|
-
let s = await
|
|
24
|
+
let s = await i.fromUser().current();
|
|
25
25
|
if (!s?.token || !s.userId) throw c.error("node device list skipped: no current user"), new o("unauthorized", "missing current user token");
|
|
26
26
|
let u;
|
|
27
27
|
try {
|
|
@@ -30,8 +30,8 @@ async function u(t) {
|
|
|
30
30
|
throw c.error("node device list failed to get device info", e), new o("device_info", "failed to get device info", { cause: e });
|
|
31
31
|
}
|
|
32
32
|
try {
|
|
33
|
-
let e = await
|
|
34
|
-
if (!
|
|
33
|
+
let e = await r().getDeviceList(u, s, { deviceIdList: t?.deviceIdList });
|
|
34
|
+
if (!n(e)) {
|
|
35
35
|
let t = e.data?.code, n = e.data?.cnMessage;
|
|
36
36
|
throw c.error("node device list response not ok", null, {
|
|
37
37
|
status: e.status,
|
|
@@ -39,8 +39,8 @@ async function u(t) {
|
|
|
39
39
|
cnMessage: n
|
|
40
40
|
}), new o("api_failed", `code=${t} message=${n}`);
|
|
41
41
|
}
|
|
42
|
-
let
|
|
43
|
-
return { devices: Array.isArray(
|
|
42
|
+
let i = e.data.data?.deviceList;
|
|
43
|
+
return { devices: Array.isArray(i) ? i.map(l) : [] };
|
|
44
44
|
} catch (t) {
|
|
45
45
|
throw t instanceof o ? t : (c.error("node device list failed", t), new o("network_error", e(t), { cause: t }));
|
|
46
46
|
}
|
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
import { clawLogger as e } from "../../utils/claw-logger.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
2
|
+
import { isClawResponseOk as t } from "../../apis/helpers.mjs";
|
|
3
|
+
import { createClawCloudClient as n } from "../../apis/claw-cloud.mjs";
|
|
4
|
+
import "../../apis/index.mjs";
|
|
5
|
+
import { HonorAccount as r } from "../../honor-auth/vault/impl.mjs";
|
|
5
6
|
import { loadDeviceInfo as i } from "../../modules/device/device-info.mjs";
|
|
6
7
|
import "../../modules/device/index.mjs";
|
|
7
8
|
import "../../honor-auth/vault/index.mjs";
|
|
8
|
-
import "../../apis/index.mjs";
|
|
9
9
|
import { ToolError as a } from "../../tools/error.mjs";
|
|
10
10
|
import { errorLogMeta as o, normalizeNetworkError as s, normalizeUploadLinkError as c } from "./normalize.mjs";
|
|
11
11
|
//#region src/capabilities/remote-file/remote-file.ts
|
|
12
12
|
var l = e("capabilities");
|
|
13
13
|
async function u() {
|
|
14
|
-
let e = await
|
|
14
|
+
let e = await r.fromUser().current();
|
|
15
15
|
if (!e?.token || !e.userId) throw l.error("remote file skipped: no current user"), new a("unauthorized", "missing current user token");
|
|
16
|
-
let
|
|
16
|
+
let t;
|
|
17
17
|
try {
|
|
18
|
-
|
|
18
|
+
t = await i();
|
|
19
19
|
} catch (e) {
|
|
20
20
|
throw l.error("remote file failed to get device info", e), new a("device_info", "failed to get device info", { cause: e });
|
|
21
21
|
}
|
|
22
22
|
return {
|
|
23
|
-
deviceInfo:
|
|
23
|
+
deviceInfo: t,
|
|
24
24
|
token: e.token,
|
|
25
25
|
userId: e.userId
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
async function d(e,
|
|
28
|
+
async function d(e, r) {
|
|
29
29
|
let { deviceInfo: i, token: d } = await u(), f = { token: d }, p;
|
|
30
30
|
try {
|
|
31
|
-
p = await
|
|
31
|
+
p = await n().getUploadLink(i, f, { fileList: e }, { signal: r });
|
|
32
32
|
} catch (t) {
|
|
33
33
|
throw t instanceof a ? t : (l.error("upload link request failed", t, {
|
|
34
34
|
fileCount: e.length,
|
|
35
35
|
...o(t)
|
|
36
36
|
}), s(t));
|
|
37
37
|
}
|
|
38
|
-
if (
|
|
38
|
+
if (t(p)) {
|
|
39
39
|
let e = p.data.data;
|
|
40
40
|
return {
|
|
41
41
|
code: "OK",
|
|
@@ -2,9 +2,9 @@ import { clawLogger as e } from "../utils/claw-logger.mjs";
|
|
|
2
2
|
import { disposeAccountMessaging as t } from "../messaging/dispose.mjs";
|
|
3
3
|
import { loadConfig as n, saveConfig as r } from "../modules/configs/config-store.mjs";
|
|
4
4
|
import { resolveEnabledYoyoAccountId as i, setYoyoChannelAccountEnabled as a } from "../modules/configs/channel.mjs";
|
|
5
|
-
import "../modules/configs/index.mjs";
|
|
6
5
|
import { HonorAccount as o } from "../honor-auth/vault/impl.mjs";
|
|
7
6
|
import "../honor-auth/vault/index.mjs";
|
|
7
|
+
import "../modules/configs/index.mjs";
|
|
8
8
|
import "../messaging/index.mjs";
|
|
9
9
|
import { monitorAccount as s } from "../connection/monitor.mjs";
|
|
10
10
|
import "../connection/index.mjs";
|
package/dist/cli/login/impl.mjs
CHANGED
|
@@ -2,20 +2,21 @@ import { withCommandRuntime as e } from "../../core/runtime.mjs";
|
|
|
2
2
|
import { clawLogger as t } from "../../utils/claw-logger.mjs";
|
|
3
3
|
import { loadConfig as n, saveConfig as r } from "../../modules/configs/config-store.mjs";
|
|
4
4
|
import { patchYoyoChannelConfig as i, resolveEnabledYoyoAccountId as a, setAllYoyoChannelAccountsEnabled as o, setYoyoChannelAccountEnabled as s } from "../../modules/configs/channel.mjs";
|
|
5
|
+
import { refreshOwnerAllowFrom as c } from "../../modules/configs/owner-allow-from.mjs";
|
|
5
6
|
import "../../modules/configs/index.mjs";
|
|
6
|
-
import { performLogin as
|
|
7
|
+
import { performLogin as l } from "../../honor-auth/login/impl.mjs";
|
|
7
8
|
import "../../honor-auth/index.mjs";
|
|
8
9
|
//#region src/cli/login/impl.ts
|
|
9
|
-
var
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
let { token: e } =
|
|
13
|
-
|
|
14
|
-
let t = a(),
|
|
15
|
-
if (!
|
|
16
|
-
let
|
|
17
|
-
t && t ===
|
|
10
|
+
var u = t("login-cli");
|
|
11
|
+
function d(t, d) {
|
|
12
|
+
d.command("login").description("login to Honor and register devices").option("-u, --uid <userId>", "login with a specific user ID").option("--token <token>", "login with a specific token").action(async (d) => e(t.runtime, async () => {
|
|
13
|
+
let { token: e } = d;
|
|
14
|
+
u.debug("login CLI command called");
|
|
15
|
+
let t = a(), f = await l({ token: e });
|
|
16
|
+
if (!f) return;
|
|
17
|
+
let p = o((await c(n())).config, !1);
|
|
18
|
+
t && t === f.userId && await r(p), await r(i(s(p, f.userId, !0), { enabled: !0 })), console.log("✅ yoyo channel account enabled.");
|
|
18
19
|
}));
|
|
19
20
|
}
|
|
20
21
|
//#endregion
|
|
21
|
-
export {
|
|
22
|
+
export { d as registerLoginCommand };
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { clawLogger as e } from "../../utils/claw-logger.mjs";
|
|
2
2
|
import { cleanupDeviceConfig as t } from "../../modules/configs/device.mjs";
|
|
3
3
|
import { initializePluginConfig as n } from "../../modules/configs/plugin-init.mjs";
|
|
4
|
-
import "../../modules/configs/index.mjs";
|
|
5
4
|
import { migrateLegacyHonorToken as r } from "../../honor-auth/vault/legacy-migration.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
5
|
+
import { syncOwnerAllowFromConfig as i } from "../../modules/configs/owner-allow-from.mjs";
|
|
6
|
+
import "../../modules/configs/index.mjs";
|
|
7
|
+
import { ensureDeviceToolSetArtifactsOnStartup as a } from "../../provisioning/toolset/artifacts.mjs";
|
|
8
|
+
import { captureCronService as o, releaseCronService as s } from "../../capabilities/cron/service.mjs";
|
|
8
9
|
import "../../capabilities/cron/index.mjs";
|
|
9
|
-
import { ClawClient as
|
|
10
|
+
import { ClawClient as c } from "../../connection/registry.mjs";
|
|
10
11
|
//#region src/core/hooks/gateway-lifecycle.ts
|
|
11
|
-
var
|
|
12
|
-
function
|
|
13
|
-
e.on("gateway_start", async (e,
|
|
14
|
-
|
|
12
|
+
var l = e("hooks");
|
|
13
|
+
function u(e) {
|
|
14
|
+
e.on("gateway_start", async (e, s) => {
|
|
15
|
+
l.info("gateway starting"), await n(), await r(), await i(), await a(), await t(), o(s.getCron?.()), l.info("gateway bootstrap complete");
|
|
15
16
|
});
|
|
16
17
|
}
|
|
17
|
-
function
|
|
18
|
+
function d(e) {
|
|
18
19
|
e.on("gateway_stop", async () => {
|
|
19
|
-
|
|
20
|
+
l.info("gateway stopping; draining clients"), s(), await c.closeAll(), l.info("gateway stop complete");
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
23
|
//#endregion
|
|
23
|
-
export {
|
|
24
|
+
export { u as registerGatewayStartHook, d as registerGatewayStopHook };
|
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
import { resolveAgentPromptContribution as e } from "./agent.mjs";
|
|
2
2
|
import { resolveCloudToolPromptContribution as t } from "./cloud-tool.mjs";
|
|
3
3
|
import { resolveCronDeliveryPromptContribution as n } from "./cron.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { resolveLocationPromptContribution as r } from "./location.mjs";
|
|
5
|
+
import { resolveSkillPromptContribution as i } from "./skill.mjs";
|
|
5
6
|
//#region src/core/prompt/builder.ts
|
|
6
|
-
function
|
|
7
|
+
function a(e) {
|
|
7
8
|
let t = e.filter((e) => !!e);
|
|
8
9
|
return t.length > 0 ? t.join("\n\n") : void 0;
|
|
9
10
|
}
|
|
10
|
-
function
|
|
11
|
-
let t =
|
|
11
|
+
function o(e) {
|
|
12
|
+
let t = a(e.map((e) => e.prependSystemContext)), n = a(e.map((e) => e.prependContext));
|
|
12
13
|
return {
|
|
13
14
|
...t ? { prependSystemContext: t } : {},
|
|
14
15
|
...n ? { prependContext: n } : {}
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
|
-
async function
|
|
18
|
-
return
|
|
18
|
+
async function s(a) {
|
|
19
|
+
return o([
|
|
19
20
|
t(),
|
|
20
21
|
e(),
|
|
21
|
-
n(
|
|
22
|
-
await
|
|
22
|
+
n(a),
|
|
23
|
+
await i(),
|
|
24
|
+
r()
|
|
23
25
|
]);
|
|
24
26
|
}
|
|
25
27
|
//#endregion
|
|
26
|
-
export {
|
|
28
|
+
export { s as resolvePromptBuildContribution };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/core/prompt/location.ts
|
|
2
|
+
var e = "## 位置前置获取规则(get_user_location)\n\n用户指令需要当前位置而未提供地点时(如查天气、空气质量、找附近美食/加油站、本地资讯、规划路线),必须先路由到 yoyo_phone_control 技能调用 get_user_location 获取位置,再以返回的城市/经纬度继续执行原任务,一次性输出最终答复。\n1. 中间步骤静默,位置信息仅以工具真实返回为准,禁止编造。\n2. 禁止向用户追问所在城市,禁止以\"需要你的城市\"为由拒绝执行。\n3. 用户已提供地点则直接执行;获取失败时说明原因并请用户告知城市,可执行部分继续。";
|
|
3
|
+
function t() {
|
|
4
|
+
return { prependSystemContext: e };
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { t as resolveLocationPromptContribution };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getPersistedIdentity as e } from "../../modules/configs/identity-persist.mjs";
|
|
2
|
-
import "../../modules/configs/index.mjs";
|
|
3
2
|
import { HonorAccount as t } from "../../honor-auth/vault/impl.mjs";
|
|
4
3
|
import "../../honor-auth/vault/index.mjs";
|
|
4
|
+
import "../../modules/configs/index.mjs";
|
|
5
5
|
//#region src/diagnose/collectors/account.ts
|
|
6
6
|
async function n(n, r, i) {
|
|
7
7
|
let a = new Set(n.enabledAccountIds), o = n.configuredAccountIds.map((e) => ({
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { wrapError as e } from "../../utils/error.mjs";
|
|
2
2
|
import { clawLogger as t } from "../../utils/claw-logger.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { OAUTH_CALLBACK as n, buildAuthorizationUrl as r } from "../../apis/oauth.mjs";
|
|
4
|
+
import { createClawCloudClient as i } from "../../apis/claw-cloud.mjs";
|
|
5
|
+
import { HonorAccount as a } from "../vault/impl.mjs";
|
|
6
6
|
import "../vault/index.mjs";
|
|
7
7
|
import { createCallbackListener as o } from "./listener.mjs";
|
|
8
8
|
import { generateCodeChallenge as s, generateCodeVerifier as c } from "./pkce.mjs";
|
|
@@ -11,9 +11,9 @@ import l from "open";
|
|
|
11
11
|
var u = t("auth"), d = 6e5;
|
|
12
12
|
async function f(t, f) {
|
|
13
13
|
u.debug("starting browser login flow");
|
|
14
|
-
let p = c(), m =
|
|
15
|
-
port:
|
|
16
|
-
callbackPath:
|
|
14
|
+
let p = c(), m = r(s(p)), h = await o({
|
|
15
|
+
port: n.port,
|
|
16
|
+
callbackPath: n.path,
|
|
17
17
|
timeoutMs: d
|
|
18
18
|
}).catch((t) => {
|
|
19
19
|
throw e(t, "Port 8081 is in use; close the process occupying it and retry");
|
|
@@ -37,17 +37,17 @@ async function f(t, f) {
|
|
|
37
37
|
await h.close();
|
|
38
38
|
}
|
|
39
39
|
try {
|
|
40
|
-
let e = await
|
|
40
|
+
let e = await i().exchangeToken(t, { code: _.code });
|
|
41
41
|
if (!e.jwtToken) throw Error("failed to get jwt token");
|
|
42
|
-
let
|
|
43
|
-
if (!
|
|
44
|
-
let
|
|
45
|
-
return await
|
|
42
|
+
let n = e.userId;
|
|
43
|
+
if (!n) throw Error("token exchange response missing userId");
|
|
44
|
+
let r = Date.now();
|
|
45
|
+
return await a.fromUser(n).save({
|
|
46
46
|
accessToken: e.jwtToken,
|
|
47
47
|
expire: e.expire,
|
|
48
|
-
grantedAt:
|
|
48
|
+
grantedAt: r,
|
|
49
49
|
metadata: {
|
|
50
|
-
userInfo: { userId:
|
|
50
|
+
userInfo: { userId: n },
|
|
51
51
|
deviceId: t.deviceId
|
|
52
52
|
}
|
|
53
53
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { toErrorMessage as e } from "../../utils/error.mjs";
|
|
2
2
|
import { clawLogger as t } from "../../utils/claw-logger.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { createClawCloudClient as n } from "../../apis/claw-cloud.mjs";
|
|
4
|
+
import { HonorAccount as r } from "../vault/impl.mjs";
|
|
5
5
|
import { loadDeviceInfo as i } from "../../modules/device/device-info.mjs";
|
|
6
6
|
import "../../modules/device/index.mjs";
|
|
7
7
|
import "../vault/index.mjs";
|
|
@@ -12,10 +12,10 @@ import "../browser/index.mjs";
|
|
|
12
12
|
//#region src/honor-auth/login/impl.ts
|
|
13
13
|
var s = t("auth");
|
|
14
14
|
async function c(e, t) {
|
|
15
|
-
let i = await
|
|
15
|
+
let i = await n().exchangeToken(t, { token: e });
|
|
16
16
|
if (!i.jwtToken || !i.userId) throw Error("failed to exchange token for userId");
|
|
17
17
|
let a = Date.now();
|
|
18
|
-
return await
|
|
18
|
+
return await r.fromUser(i.userId).save({
|
|
19
19
|
accessToken: i.jwtToken,
|
|
20
20
|
expire: i.expire,
|
|
21
21
|
grantedAt: a,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { isOKResponse as e } from "../apis/helpers.mjs";
|
|
2
|
+
import { createClawCloudClient as t } from "../apis/claw-cloud.mjs";
|
|
3
|
+
import "../apis/index.mjs";
|
|
4
|
+
import { HonorAccount as n } from "./vault/impl.mjs";
|
|
4
5
|
import { loadDeviceInfo as r } from "../modules/device/device-info.mjs";
|
|
5
6
|
import "./vault/index.mjs";
|
|
6
|
-
import "../apis/index.mjs";
|
|
7
7
|
//#region src/honor-auth/logout.ts
|
|
8
8
|
async function i(i) {
|
|
9
|
-
let a =
|
|
9
|
+
let a = n.fromUser(i), o = await a.current();
|
|
10
10
|
if (!o) throw Error("Not logged in, please login first!");
|
|
11
|
-
let s = await r(), c = await
|
|
12
|
-
if (!
|
|
11
|
+
let s = await r(), c = await t().logoutDevice(s, o);
|
|
12
|
+
if (!e(c)) throw Error(c.data?.cnMessage || "Unknown error");
|
|
13
13
|
await a.clear();
|
|
14
14
|
}
|
|
15
15
|
//#endregion
|
|
@@ -3,12 +3,12 @@ import { getPersistedIdentity as t, updatePersistedIdentity as n } from "../../m
|
|
|
3
3
|
import { loadConfig as r, saveConfig as i } from "../../modules/configs/config-store.mjs";
|
|
4
4
|
import { clearUserConfig as a, getUserConfig as o } from "../../modules/configs/plugin.mjs";
|
|
5
5
|
import { patchYoyoChannelConfig as s, setAllYoyoChannelAccountsEnabled as c, setYoyoChannelAccountEnabled as l } from "../../modules/configs/channel.mjs";
|
|
6
|
-
import "../../
|
|
7
|
-
import { parseTokenExpireMs as
|
|
8
|
-
import { HonorAccount as
|
|
9
|
-
import { createClawCloudClient as f } from "../../apis/claw-cloud.mjs";
|
|
6
|
+
import { createClawCloudClient as u } from "../../apis/claw-cloud.mjs";
|
|
7
|
+
import { parseTokenExpireMs as d } from "./token-expiry.mjs";
|
|
8
|
+
import { HonorAccount as f } from "./impl.mjs";
|
|
10
9
|
import { loadDeviceInfo as p } from "../../modules/device/device-info.mjs";
|
|
11
10
|
import "../../modules/device/index.mjs";
|
|
11
|
+
import "../../modules/configs/index.mjs";
|
|
12
12
|
//#region src/honor-auth/vault/legacy-migration.ts
|
|
13
13
|
var m = e("auth");
|
|
14
14
|
async function h() {
|
|
@@ -18,9 +18,9 @@ async function h() {
|
|
|
18
18
|
m.debug("no legacy token to migrate");
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
let S = g, C = x, w =
|
|
21
|
+
let S = g, C = x, w = d(b), T = y;
|
|
22
22
|
if (!S || !w) try {
|
|
23
|
-
let e = await p(), t = await
|
|
23
|
+
let e = await p(), t = await u().exchangeToken(e, { token: x });
|
|
24
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
25
|
hasUserId: !!S,
|
|
26
26
|
hasExpire: !!w
|
|
@@ -32,7 +32,7 @@ async function h() {
|
|
|
32
32
|
m.warn("legacy token missing userId and exchange failed, skip migration");
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
-
let E =
|
|
35
|
+
let E = d(w), D = {
|
|
36
36
|
accessToken: C,
|
|
37
37
|
expire: E,
|
|
38
38
|
grantedAt: T,
|
|
@@ -42,7 +42,7 @@ async function h() {
|
|
|
42
42
|
legacyExpireMs: b
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
|
-
await
|
|
45
|
+
await f.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 });
|
|
46
46
|
} catch (e) {
|
|
47
47
|
m.warn("legacy token migration failed", e);
|
|
48
48
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { toErrorMessage as e } from "../../../utils/error.mjs";
|
|
2
2
|
import { clawLogger as t } from "../../../utils/claw-logger.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { getToolUseTraceSteps as o } from "../../trace/tool.mjs";
|
|
3
|
+
import { recordLifecycleEvent as n, updateActiveTurnRunId as r } from "../../trace/lifecycle.mjs";
|
|
4
|
+
import { getToolUseTraceSteps as i } from "../../trace/tool.mjs";
|
|
6
5
|
import "../../trace/index.mjs";
|
|
6
|
+
import { clipTextForLog as a, describeDivergence as o } from "../../../utils/stringify.mjs";
|
|
7
7
|
import { normalizeAnswerPartial as s, normalizeFinalVisibleText as c } from "../../guard/content.mjs";
|
|
8
8
|
import "../../guard/index.mjs";
|
|
9
9
|
import { finishThinking as l, pushStreamDelta as u, pushThinkingDelta as d, pushToolEvent as f, pushToolStatus as p } from "./session.mjs";
|
|
@@ -85,7 +85,7 @@ var C = class {
|
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
findLatestFinishedStep(e) {
|
|
88
|
-
let t =
|
|
88
|
+
let t = i(this.session.chatId);
|
|
89
89
|
if (e) for (let n = t.length - 1; n >= 0; --n) {
|
|
90
90
|
let r = t[n];
|
|
91
91
|
if (r.status !== "running" && r.toolCallId === e) return r;
|
|
@@ -157,7 +157,7 @@ var C = class {
|
|
|
157
157
|
turnId: this.session.traceInfo.turnId,
|
|
158
158
|
itemId: e.itemId,
|
|
159
159
|
textLen: t.length,
|
|
160
|
-
textHead:
|
|
160
|
+
textHead: a(t)
|
|
161
161
|
}), this.rescueCommentaryText(t, "item"));
|
|
162
162
|
};
|
|
163
163
|
rescueCommentaryProgress(e) {
|
|
@@ -168,16 +168,16 @@ var C = class {
|
|
|
168
168
|
}), this.rescueCommentaryText(e.slice(2).trimStart(), "chat"));
|
|
169
169
|
}
|
|
170
170
|
rescueCommentaryText(e, t) {
|
|
171
|
-
let
|
|
172
|
-
if (!
|
|
173
|
-
let
|
|
174
|
-
if (
|
|
171
|
+
let n = e.trim();
|
|
172
|
+
if (!n) return;
|
|
173
|
+
let r = this.session.answerSnapshot.replace(/\s+/g, " ").trim();
|
|
174
|
+
if (r.startsWith(n)) {
|
|
175
175
|
b.debug("commentary rescue deduped", {
|
|
176
176
|
sessionKey: this.session.sessionKey,
|
|
177
177
|
turnId: this.session.traceInfo.turnId,
|
|
178
178
|
source: t,
|
|
179
|
-
textLen:
|
|
180
|
-
snapshotLen:
|
|
179
|
+
textLen: n.length,
|
|
180
|
+
snapshotLen: r.length
|
|
181
181
|
});
|
|
182
182
|
return;
|
|
183
183
|
}
|
|
@@ -190,34 +190,34 @@ var C = class {
|
|
|
190
190
|
});
|
|
191
191
|
return;
|
|
192
192
|
}
|
|
193
|
-
let
|
|
194
|
-
_(this.session,
|
|
193
|
+
let i = n.startsWith(r) ? "tail" : "full", s = i === "tail" ? n.slice(r.length) : n;
|
|
194
|
+
_(this.session, n), b.debug("commentary rescue push", {
|
|
195
195
|
sessionKey: this.session.sessionKey,
|
|
196
196
|
turnId: this.session.traceInfo.turnId,
|
|
197
197
|
source: t,
|
|
198
|
-
mode:
|
|
199
|
-
textLen:
|
|
200
|
-
snapshotLen:
|
|
198
|
+
mode: i,
|
|
199
|
+
textLen: n.length,
|
|
200
|
+
snapshotLen: r.length,
|
|
201
201
|
deltaLen: s.length,
|
|
202
|
-
textHead: n
|
|
203
|
-
...
|
|
202
|
+
textHead: a(n),
|
|
203
|
+
...i === "full" && r ? { divergence: o(r, n) } : {}
|
|
204
204
|
}), u(this.session, s);
|
|
205
205
|
}
|
|
206
206
|
async pushFinalAnswerDiff(e) {
|
|
207
207
|
if (!e) return;
|
|
208
|
-
let t = 0,
|
|
209
|
-
for (let
|
|
210
|
-
if (
|
|
208
|
+
let t = 0, n = "none";
|
|
209
|
+
for (let r of [this.session.answerSnapshot, this.session.prevAnswerSnapshot]) if (r) {
|
|
210
|
+
if (r.startsWith(e)) {
|
|
211
211
|
b.debug("final fully covered, skip", {
|
|
212
212
|
sessionKey: this.session.sessionKey,
|
|
213
213
|
turnId: this.session.traceInfo.turnId,
|
|
214
214
|
textLen: e.length,
|
|
215
|
-
segmentLen:
|
|
216
|
-
segment:
|
|
215
|
+
segmentLen: r.length,
|
|
216
|
+
segment: r === this.session.answerSnapshot ? "snapshot" : "prev"
|
|
217
217
|
});
|
|
218
218
|
return;
|
|
219
219
|
}
|
|
220
|
-
for (let
|
|
220
|
+
for (let i of [r, r.trim()]) i && e.startsWith(i) && i.length > t && (t = i.length, n = r === this.session.answerSnapshot ? "snapshot" : "prev");
|
|
221
221
|
}
|
|
222
222
|
t >= e.length || (t === 0 ? b.debug("final diff full push, no covered segment", {
|
|
223
223
|
sessionKey: this.session.sessionKey,
|
|
@@ -225,14 +225,14 @@ var C = class {
|
|
|
225
225
|
textLen: e.length,
|
|
226
226
|
snapshotLen: this.session.answerSnapshot.length,
|
|
227
227
|
prevLen: this.session.prevAnswerSnapshot.length,
|
|
228
|
-
textHead:
|
|
229
|
-
...this.session.answerSnapshot ? { divergence:
|
|
228
|
+
textHead: a(e),
|
|
229
|
+
...this.session.answerSnapshot ? { divergence: o(this.session.answerSnapshot, e) } : {}
|
|
230
230
|
}) : b.debug("final tail push", {
|
|
231
231
|
sessionKey: this.session.sessionKey,
|
|
232
232
|
turnId: this.session.traceInfo.turnId,
|
|
233
233
|
textLen: e.length,
|
|
234
234
|
covered: t,
|
|
235
|
-
coveredBy:
|
|
235
|
+
coveredBy: n,
|
|
236
236
|
deltaLen: e.length - t
|
|
237
237
|
}), _(this.session, e), await u(this.session, e.slice(t)));
|
|
238
238
|
}
|
|
@@ -258,7 +258,7 @@ var C = class {
|
|
|
258
258
|
}
|
|
259
259
|
};
|
|
260
260
|
onError = (t) => {
|
|
261
|
-
|
|
261
|
+
n(this.session.chatId, "reply_error", { error: e(t) }), b.warn("reply dispatcher error", {
|
|
262
262
|
sender: this.session.target.deviceId,
|
|
263
263
|
turnId: this.session.traceInfo.turnId,
|
|
264
264
|
error: t
|
|
@@ -280,7 +280,7 @@ var C = class {
|
|
|
280
280
|
onPartialReply: this.onPartialReply,
|
|
281
281
|
onItemEvent: this.onItemEvent,
|
|
282
282
|
onAgentRunStart: (e) => {
|
|
283
|
-
|
|
283
|
+
n(this.session.chatId, "dispatched"), r(this.session.chatId, e);
|
|
284
284
|
},
|
|
285
285
|
suppressToolErrorWarnings: !0,
|
|
286
286
|
suppressDefaultToolProgressMessages: !0,
|