@xmanrui/dsh-im 4.9.0 → 4.9.1
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/lib/client.js +70 -18
- package/lib/index.js +235 -235
- package/package.json +10 -6
- package/plugin-src/client/channels/dingtalk/api.js +23 -6
- package/plugin-src/client/channels/dingtalk/index.js +33 -6
- package/plugin-src/client/channels/dingtalk/styles.js +2 -0
- package/plugin-src/client/i18n.js +4 -0
- package/plugin-src/host/channels/dingtalk/rpc.mjs +24 -0
- package/plugin-src/host/modern-harness-api.mjs +17 -8
- package/src/channels/dingtalk/connection-error.mjs +299 -0
- package/src/channels/dingtalk/dingtalk-controller.mjs +79 -34
- package/src/channels/dingtalk/dingtalk-runtime.mjs +9 -2
- package/src/channels/shared/i18n-en/dingtalk.mjs +23 -0
package/lib/client.js
CHANGED
|
@@ -571,7 +571,7 @@ var React23 = __toESM(require("react"), 1);
|
|
|
571
571
|
// package.json
|
|
572
572
|
var package_default = {
|
|
573
573
|
name: "@xmanrui/dsh-im",
|
|
574
|
-
version: "4.9.
|
|
574
|
+
version: "4.9.1",
|
|
575
575
|
description: "\u628A\u4E5D\u79CD IM \u673A\u5668\u4EBA\u548C\u516C\u7F51 AI Office \u63A5\u5165\u672C\u673A DeepSeek Harness\u3002 Connect nine IM channels and a public AI Office to a local DeepSeek Harness.",
|
|
576
576
|
keywords: [
|
|
577
577
|
"deepseek-harness",
|
|
@@ -593,10 +593,7 @@ var package_default = {
|
|
|
593
593
|
"whatsapp",
|
|
594
594
|
"ai-office"
|
|
595
595
|
],
|
|
596
|
-
author:
|
|
597
|
-
name: "xmanrui",
|
|
598
|
-
url: "https://github.com/xmanrui"
|
|
599
|
-
},
|
|
596
|
+
author: "xmanrui (https://github.com/xmanrui)",
|
|
600
597
|
contributors: [
|
|
601
598
|
{
|
|
602
599
|
name: "C3H3-AI",
|
|
@@ -618,7 +615,9 @@ var package_default = {
|
|
|
618
615
|
url: "git+https://github.com/xmanrui/dsh-im.git"
|
|
619
616
|
},
|
|
620
617
|
homepage: "https://github.com/xmanrui/dsh-im#readme",
|
|
621
|
-
bugs:
|
|
618
|
+
bugs: {
|
|
619
|
+
url: "https://github.com/xmanrui/dsh-im/issues"
|
|
620
|
+
},
|
|
622
621
|
publishConfig: {
|
|
623
622
|
access: "public"
|
|
624
623
|
},
|
|
@@ -687,6 +686,11 @@ var package_default = {
|
|
|
687
686
|
"react-dom": "18.3.1",
|
|
688
687
|
"react-test-renderer": "18.3.1",
|
|
689
688
|
semver: "7.8.5"
|
|
689
|
+
},
|
|
690
|
+
directories: {
|
|
691
|
+
doc: "docs",
|
|
692
|
+
lib: "lib",
|
|
693
|
+
test: "test"
|
|
690
694
|
}
|
|
691
695
|
};
|
|
692
696
|
|
|
@@ -1189,6 +1193,8 @@ var EN = Object.freeze({
|
|
|
1189
1193
|
"\u68C0\u67E5\u8FDE\u63A5": "Check connection",
|
|
1190
1194
|
"\u68C0\u67E5\u4E2D\u2026": "Checking\u2026",
|
|
1191
1195
|
"\u8FDE\u63A5\u68C0\u67E5\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002": "Connection check failed. Try again later.",
|
|
1196
|
+
"\u673A\u5668\u4EBA\u5DF2\u4FDD\u5B58\uFF0C\u4F46\u8FDE\u63A5\u672A\u5C31\u7EEA": "The bot was saved, but the connection is not ready",
|
|
1197
|
+
"\u67E5\u770B\u5DF2\u4FDD\u5B58\u7684\u673A\u5668\u4EBA": "View saved bot",
|
|
1192
1198
|
"\u6D4B\u8BD5\u6D88\u606F\u5DF2\u53D1\u9001\uFF0C\u8BF7\u5230\u5BF9\u5E94\u673A\u5668\u4EBA\u4F1A\u8BDD\u4E2D\u786E\u8BA4\u3002": "Test message sent. Check the matching bot conversation.",
|
|
1193
1199
|
"\u8FDE\u63A5\u68C0\u67E5\u5B8C\u6210\u3002\u673A\u5668\u4EBA\u5C1A\u672A\u6536\u5230\u53EF\u7528\u4E8E\u6D4B\u8BD5\u7684\u79C1\u804A\u6D88\u606F\u3002": "Connection check completed. The bot has not received a direct message it can use for testing.",
|
|
1194
1200
|
"\u8FDE\u63A5\u68C0\u67E5\u5B8C\u6210\uFF0C\u4F46\u6D4B\u8BD5\u6D88\u606F\u53D1\u9001\u5931\u8D25\u3002": "Connection check completed, but the test message could not be sent.",
|
|
@@ -1753,6 +1759,8 @@ function translateDynamic(text6) {
|
|
|
1753
1759
|
if (match) return `Automatic status refresh failed: ${match[1]}`;
|
|
1754
1760
|
match = /^操作失败:(.+)$/.exec(text6);
|
|
1755
1761
|
if (match) return `Operation failed: ${match[1]}`;
|
|
1762
|
+
match = /^连接检查失败:(.+)(参考号:(.+))$/.exec(text6);
|
|
1763
|
+
if (match) return `Connection check failed: ${localizeText(match[1])} (reference: ${match[2]})`;
|
|
1756
1764
|
match = /^连接检查失败:(.+)$/.exec(text6);
|
|
1757
1765
|
if (match) return `Connection check failed: ${match[1]}`;
|
|
1758
1766
|
match = /^移除失败:(.+)$/.exec(text6);
|
|
@@ -2252,11 +2260,19 @@ function sanitizeMessage(value, fallback) {
|
|
|
2252
2260
|
if (FORBIDDEN_ERROR_FIELDS.test(message)) return fallback;
|
|
2253
2261
|
return message.replace(/([=:]\s*)[^\s,;,。]+/g, "$1\u2022\u2022\u2022\u2022\u2022\u2022").slice(0, 240);
|
|
2254
2262
|
}
|
|
2263
|
+
function safeReferenceId(value) {
|
|
2264
|
+
const referenceId = optionalString(value, 40);
|
|
2265
|
+
return referenceId && /^DT-CONN-[A-F0-9]{8}$/.test(referenceId) ? referenceId : void 0;
|
|
2266
|
+
}
|
|
2255
2267
|
function normalizeError(value, fallbackCode, fallbackMessage) {
|
|
2256
2268
|
if (!isRecord(value)) return void 0;
|
|
2269
|
+
const hint = sanitizeMessage(value.hint, "");
|
|
2270
|
+
const referenceId = safeReferenceId(value.referenceId);
|
|
2257
2271
|
return {
|
|
2258
2272
|
code: safeErrorCode(value.code, fallbackCode),
|
|
2259
|
-
message: sanitizeMessage(value.message, fallbackMessage)
|
|
2273
|
+
message: sanitizeMessage(value.message, fallbackMessage),
|
|
2274
|
+
...hint ? { hint } : {},
|
|
2275
|
+
...referenceId ? { referenceId } : {}
|
|
2260
2276
|
};
|
|
2261
2277
|
}
|
|
2262
2278
|
function normalizeTestMessage(value) {
|
|
@@ -2271,8 +2287,15 @@ function unwrapRpcResult(result) {
|
|
|
2271
2287
|
throw new Error("\u9489\u9489\u670D\u52A1\u8FD4\u56DE\u4E86\u65E0\u6CD5\u8BC6\u522B\u7684\u54CD\u5E94");
|
|
2272
2288
|
}
|
|
2273
2289
|
if (!result.ok) {
|
|
2274
|
-
const
|
|
2275
|
-
|
|
2290
|
+
const visible = normalizeError(
|
|
2291
|
+
result.error,
|
|
2292
|
+
"DINGTALK_RPC_ERROR",
|
|
2293
|
+
"\u9489\u9489\u64CD\u4F5C\u5931\u8D25"
|
|
2294
|
+
) ?? { code: "DINGTALK_RPC_ERROR", message: "\u9489\u9489\u64CD\u4F5C\u5931\u8D25" };
|
|
2295
|
+
const error = new Error(visible.message);
|
|
2296
|
+
error.code = visible.code;
|
|
2297
|
+
if (visible.hint) error.hint = visible.hint;
|
|
2298
|
+
if (visible.referenceId) error.referenceId = visible.referenceId;
|
|
2276
2299
|
throw error;
|
|
2277
2300
|
}
|
|
2278
2301
|
return result.value;
|
|
@@ -2377,10 +2400,11 @@ function connectionTestFeedback(result) {
|
|
|
2377
2400
|
return result ? "\u9489\u9489\u8FDE\u63A5\u68C0\u67E5\u5B8C\u6210\uFF0C\u4F46\u6D4B\u8BD5\u6D88\u606F\u53D1\u9001\u5931\u8D25\u3002" : null;
|
|
2378
2401
|
}
|
|
2379
2402
|
function presentError(error) {
|
|
2380
|
-
return
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2403
|
+
return normalizeError(
|
|
2404
|
+
error,
|
|
2405
|
+
"DINGTALK_ERROR",
|
|
2406
|
+
"\u9489\u9489\u64CD\u4F5C\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"
|
|
2407
|
+
) ?? { code: "DINGTALK_ERROR", message: "\u9489\u9489\u64CD\u4F5C\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5" };
|
|
2384
2408
|
}
|
|
2385
2409
|
function formatRemaining(milliseconds) {
|
|
2386
2410
|
const seconds = Math.max(0, Math.ceil(Number(milliseconds) / 1e3) || 0);
|
|
@@ -3680,6 +3704,8 @@ var CSS = String.raw`
|
|
|
3680
3704
|
.ddt-inlineError h3 { font-size: 17px; }
|
|
3681
3705
|
.ddt-inlineError p { line-height: 1.55; }
|
|
3682
3706
|
.ddt-errorCode { font: 11px ui-monospace, SFMono-Regular, monospace; opacity: .8; }
|
|
3707
|
+
.ddt-errorDiagnostic { display: grid; gap: 5px; color: var(--ddt-error); }
|
|
3708
|
+
.ddt-errorHint { margin: 0; color: var(--dsw-alias-label-secondary, #646a73); font-size: 12px; line-height: 1.55; }
|
|
3683
3709
|
.ddt-listHeading { display: flex; align-items: center; justify-content: space-between; margin: 2px 0 9px; }
|
|
3684
3710
|
.ddt-listHeading h3 { margin: 0; font-size: 14px; }
|
|
3685
3711
|
.ddt-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
|
|
@@ -3936,25 +3962,45 @@ function ProgressPanel({ status, busy, onCancel }) {
|
|
|
3936
3962
|
)
|
|
3937
3963
|
);
|
|
3938
3964
|
}
|
|
3965
|
+
function ConnectionErrorDiagnostic({ error }) {
|
|
3966
|
+
if (!error) return null;
|
|
3967
|
+
return h2(
|
|
3968
|
+
"div",
|
|
3969
|
+
{ className: "ddt-errorDiagnostic" },
|
|
3970
|
+
error.hint ? h2("p", { className: "ddt-errorHint" }, error.hint) : null,
|
|
3971
|
+
h2(
|
|
3972
|
+
"span",
|
|
3973
|
+
{ className: "ddt-errorCode" },
|
|
3974
|
+
h2("span", null, "\u9519\u8BEF\u7801"),
|
|
3975
|
+
`: ${error.code}`,
|
|
3976
|
+
error.referenceId ? h2(React10.Fragment, null, " \xB7 ", h2("span", null, "\u53C2\u8003\u53F7"), `: ${error.referenceId}`) : null
|
|
3977
|
+
)
|
|
3978
|
+
);
|
|
3979
|
+
}
|
|
3939
3980
|
function ProvisionError({ provision, busy, onRetry, onClose }) {
|
|
3940
3981
|
const error = provision.error ?? {
|
|
3941
3982
|
code: "DINGTALK_PROVISION_FAILED",
|
|
3942
3983
|
message: "\u9489\u9489\u673A\u5668\u4EBA\u6CA1\u6709\u63A5\u5165\u5B8C\u6210"
|
|
3943
3984
|
};
|
|
3985
|
+
const connectionFailed = Boolean(error.referenceId);
|
|
3944
3986
|
return h2(
|
|
3945
3987
|
"div",
|
|
3946
3988
|
{ className: "ddt-card dim-surfaceCard" },
|
|
3947
3989
|
h2(
|
|
3948
3990
|
"div",
|
|
3949
3991
|
{ className: "ddt-inlineError dim-inlineError", role: "alert" },
|
|
3950
|
-
h2("h3", null, provision.status === "expired" ? "\u4E8C\u7EF4\u7801\u5DF2\u8FC7\u671F" : "\u9489\u9489\u673A\u5668\u4EBA\u6CA1\u6709\u63A5\u5165\u5B8C\u6210"),
|
|
3992
|
+
h2("h3", null, provision.status === "expired" ? "\u4E8C\u7EF4\u7801\u5DF2\u8FC7\u671F" : connectionFailed ? "\u673A\u5668\u4EBA\u5DF2\u4FDD\u5B58\uFF0C\u4F46\u8FDE\u63A5\u672A\u5C31\u7EEA" : "\u9489\u9489\u673A\u5668\u4EBA\u6CA1\u6709\u63A5\u5165\u5B8C\u6210"),
|
|
3951
3993
|
h2("p", null, error.message),
|
|
3952
|
-
h2(
|
|
3994
|
+
h2(ConnectionErrorDiagnostic, { error }),
|
|
3953
3995
|
h2(
|
|
3954
3996
|
"div",
|
|
3955
3997
|
{ className: "ddt-actions dim-viewActions" },
|
|
3956
|
-
h2(Button, { kind: "primary", onClick:
|
|
3957
|
-
|
|
3998
|
+
connectionFailed ? h2(Button, { kind: "primary", onClick: onClose, disabled: busy }, "\u67E5\u770B\u5DF2\u4FDD\u5B58\u7684\u673A\u5668\u4EBA") : h2(
|
|
3999
|
+
React10.Fragment,
|
|
4000
|
+
null,
|
|
4001
|
+
h2(Button, { kind: "primary", onClick: onRetry, disabled: busy }, "\u91CD\u65B0\u751F\u6210\u4E8C\u7EF4\u7801"),
|
|
4002
|
+
h2(Button, { onClick: onClose, disabled: busy }, "\u5173\u95ED")
|
|
4003
|
+
)
|
|
3958
4004
|
)
|
|
3959
4005
|
)
|
|
3960
4006
|
);
|
|
@@ -4091,6 +4137,7 @@ function AccountCard({
|
|
|
4091
4137
|
)
|
|
4092
4138
|
),
|
|
4093
4139
|
summary2 ? h2("div", { className: "ddt-summary dim-cardSummary" }, summary2) : null,
|
|
4140
|
+
account.error ? h2(ConnectionErrorDiagnostic, { error: account.error }) : null,
|
|
4094
4141
|
account.lastMessageError ? h2(LastMessageErrorSummary, {
|
|
4095
4142
|
className: "ddt-summary",
|
|
4096
4143
|
error: account.lastMessageError
|
|
@@ -4416,6 +4463,10 @@ function DingtalkSettingsTab({ rpcCall }) {
|
|
|
4416
4463
|
if (!canCommit()) return;
|
|
4417
4464
|
const account = result.botId ? snapshot?.bots.find((bot) => bot.botId === result.botId) : snapshot?.bots.find((bot) => bot.connected);
|
|
4418
4465
|
if (!account?.connected) {
|
|
4466
|
+
if (account?.error) {
|
|
4467
|
+
setProvision((current) => current?.attemptId === attemptId ? { ...current, ...result, status: "failed", error: account.error } : current);
|
|
4468
|
+
return;
|
|
4469
|
+
}
|
|
4419
4470
|
setProvision((current) => current?.attemptId === attemptId ? { ...current, ...result, status: "connecting" } : current);
|
|
4420
4471
|
schedule(result.pollIntervalMs);
|
|
4421
4472
|
return;
|
|
@@ -4490,7 +4541,8 @@ function DingtalkSettingsTab({ rpcCall }) {
|
|
|
4490
4541
|
return snapshot;
|
|
4491
4542
|
} catch (error) {
|
|
4492
4543
|
if (!mountedRef.current) return void 0;
|
|
4493
|
-
const
|
|
4544
|
+
const visibleError = presentError(error);
|
|
4545
|
+
const failureMessage = operation === "reconnect" ? visibleError.referenceId ? `\u8FDE\u63A5\u68C0\u67E5\u5931\u8D25\uFF1A${visibleError.message}\uFF08\u53C2\u8003\u53F7\uFF1A${visibleError.referenceId}\uFF09` : "\u8FDE\u63A5\u68C0\u67E5\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002" : `\u64CD\u4F5C\u5931\u8D25\uFF1A${visibleError.message}`;
|
|
4494
4546
|
if (operation === "reconnect") {
|
|
4495
4547
|
setFeedbackByBot((current) => ({
|
|
4496
4548
|
...current,
|