@largezhou/ddingtalk 1.3.1 → 1.3.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/package.json +1 -1
- package/src/monitor.ts +22 -28
package/package.json
CHANGED
package/src/monitor.ts
CHANGED
|
@@ -540,10 +540,7 @@ export interface MonitorOptions {
|
|
|
540
540
|
abortSignal?: AbortSignal;
|
|
541
541
|
}
|
|
542
542
|
|
|
543
|
-
export
|
|
544
|
-
account: ResolvedDingTalkAccount;
|
|
545
|
-
stop: () => void;
|
|
546
|
-
}
|
|
543
|
+
export type MonitorResult = Promise<void>;
|
|
547
544
|
|
|
548
545
|
// Track runtime state in memory
|
|
549
546
|
const runtimeState = new Map<
|
|
@@ -1064,29 +1061,26 @@ export function monitorDingTalkProvider(options: MonitorOptions): MonitorResult
|
|
|
1064
1061
|
|
|
1065
1062
|
client.connect();
|
|
1066
1063
|
|
|
1067
|
-
//
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1064
|
+
// 返回一个在 abort/disconnect 之前一直 pending 的 Promise。
|
|
1065
|
+
// OpenClaw 框架将 startAccount 返回的 Promise resolve 视为 "channel 已退出",
|
|
1066
|
+
// 会触发 auto-restart。因此需要保持 pending 直到 abort。
|
|
1067
|
+
return new Promise<void>((resolve) => {
|
|
1068
|
+
const stopHandler = () => {
|
|
1069
|
+
logger.log(`[${accountId}] 停止 provider`);
|
|
1070
|
+
client.disconnect();
|
|
1071
|
+
recordChannelRuntimeState({
|
|
1072
|
+
channel: PLUGIN_ID,
|
|
1073
|
+
accountId,
|
|
1074
|
+
state: {
|
|
1075
|
+
running: false,
|
|
1076
|
+
lastStopAt: Date.now(),
|
|
1077
|
+
},
|
|
1078
|
+
});
|
|
1079
|
+
resolve();
|
|
1080
|
+
};
|
|
1084
1081
|
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
abortSignal?.removeEventListener("abort", stopHandler);
|
|
1090
|
-
},
|
|
1091
|
-
};
|
|
1082
|
+
if (abortSignal) {
|
|
1083
|
+
abortSignal.addEventListener("abort", stopHandler);
|
|
1084
|
+
}
|
|
1085
|
+
});
|
|
1092
1086
|
}
|