@zhin.js/adapter-milky 7.0.0 → 7.0.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/CHANGELOG.md +31 -0
- package/README.md +24 -3
- package/adapters/milky.js +0 -11
- package/adapters/milky.ts +0 -11
- package/lib/client.d.ts +21 -0
- package/lib/client.js +33 -0
- package/lib/endpoint.d.ts +1 -1
- package/lib/endpoint.js +1 -1
- package/lib/index.d.ts +5 -2
- package/lib/index.js +3 -2
- package/lib/milky-auth.d.ts +0 -1
- package/lib/milky-auth.js +0 -14
- package/lib/milky-endpoint-commands.d.ts +1 -1
- package/lib/protocol.d.ts +3 -3
- package/lib/protocol.js +2 -5
- package/lib/sse-endpoint.d.ts +5 -23
- package/lib/sse-endpoint.js +24 -87
- package/lib/webhook-endpoint.d.ts +5 -23
- package/lib/webhook-endpoint.js +28 -97
- package/lib/ws-endpoint.d.ts +5 -24
- package/lib/ws-endpoint.js +35 -116
- package/lib/wss-endpoint.d.ts +8 -23
- package/lib/wss-endpoint.js +64 -149
- package/package.json +16 -13
- package/src/client.ts +80 -0
- package/src/endpoint.ts +1 -1
- package/src/index.ts +17 -7
- package/src/milky-auth.ts +0 -15
- package/src/protocol.ts +4 -7
- package/src/sse-endpoint.ts +27 -102
- package/src/webhook-endpoint.ts +31 -110
- package/src/ws-endpoint.ts +43 -128
- package/src/wss-endpoint.ts +67 -158
- package/lib/milky-agent-deps.d.ts +0 -24
- package/lib/milky-agent-deps.js +0 -30
- package/src/milky-agent-deps.ts +0 -53
package/src/milky-agent-deps.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent tool deps for milky (scene management / callApi).
|
|
3
|
-
* Endpoints register themselves on start; tools look up by config name / endpoint id.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export interface MilkyAgentEndpoint {
|
|
7
|
-
callApi(action: string, params?: Record<string, unknown>): Promise<unknown>;
|
|
8
|
-
kickMember(groupId: number, userId: number, rejectAddRequest?: boolean): Promise<boolean>;
|
|
9
|
-
muteMember(groupId: number, userId: number, duration?: number): Promise<boolean>;
|
|
10
|
-
muteAll(groupId: number, enable?: boolean): Promise<boolean>;
|
|
11
|
-
setAdmin(groupId: number, userId: number, enable?: boolean): Promise<boolean>;
|
|
12
|
-
setCard(groupId: number, userId: number, card: string): Promise<boolean>;
|
|
13
|
-
setTitle(groupId: number, userId: number, title: string): Promise<boolean>;
|
|
14
|
-
setGroupName(groupId: number, name: string): Promise<boolean>;
|
|
15
|
-
getMemberList(groupId: number): Promise<unknown[]>;
|
|
16
|
-
getGroupInfo(groupId: number): Promise<unknown>;
|
|
17
|
-
recallMessage?(id: string): Promise<void>;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface MilkyAgentDeps {
|
|
21
|
-
getEndpoint: (endpointKey: string) => MilkyAgentEndpoint;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const endpoints = new Map<string, MilkyAgentEndpoint>();
|
|
25
|
-
let override: MilkyAgentDeps | null = null;
|
|
26
|
-
|
|
27
|
-
export function registerMilkyAgentEndpoint(
|
|
28
|
-
endpointKey: string,
|
|
29
|
-
endpoint: MilkyAgentEndpoint,
|
|
30
|
-
): () => void {
|
|
31
|
-
endpoints.set(endpointKey, endpoint);
|
|
32
|
-
return () => {
|
|
33
|
-
if (endpoints.get(endpointKey) === endpoint) {
|
|
34
|
-
endpoints.delete(endpointKey);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/** Optional override used by tests / transitional callers. Pass `null` to clear. */
|
|
40
|
-
export function setMilkyAgentDeps(deps: MilkyAgentDeps | null): void {
|
|
41
|
-
override = deps;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function getMilkyAgentDeps(): MilkyAgentDeps {
|
|
45
|
-
if (override) return override;
|
|
46
|
-
return {
|
|
47
|
-
getEndpoint(endpointKey: string): MilkyAgentEndpoint {
|
|
48
|
-
const registered = endpoints.get(endpointKey);
|
|
49
|
-
if (!registered) throw new Error(`Endpoint ${endpointKey} 不存在`);
|
|
50
|
-
return registered;
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
}
|