@im-more/dsh-milky 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/cordis.patch.yml +11 -0
- package/lib/index.js +2311 -0
- package/lib/index.js.map +1 -0
- package/lib/types/bot.d.ts +127 -0
- package/lib/types/bot.d.ts.map +1 -0
- package/lib/types/bot.js +303 -0
- package/lib/types/bot.js.map +1 -0
- package/lib/types/config.d.ts +24 -0
- package/lib/types/config.d.ts.map +1 -0
- package/lib/types/config.js +39 -0
- package/lib/types/config.js.map +1 -0
- package/lib/types/decode.d.ts +43 -0
- package/lib/types/decode.d.ts.map +1 -0
- package/lib/types/decode.js +277 -0
- package/lib/types/decode.js.map +1 -0
- package/lib/types/errors.d.ts +66 -0
- package/lib/types/errors.d.ts.map +1 -0
- package/lib/types/errors.js +170 -0
- package/lib/types/errors.js.map +1 -0
- package/lib/types/identity.d.ts +24 -0
- package/lib/types/identity.d.ts.map +1 -0
- package/lib/types/identity.js +33 -0
- package/lib/types/identity.js.map +1 -0
- package/lib/types/ids.d.ts +110 -0
- package/lib/types/ids.d.ts.map +1 -0
- package/lib/types/ids.js +166 -0
- package/lib/types/ids.js.map +1 -0
- package/lib/types/index.d.ts +10 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +9 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/internal.d.ts +2002 -0
- package/lib/types/internal.d.ts.map +1 -0
- package/lib/types/internal.js +408 -0
- package/lib/types/internal.js.map +1 -0
- package/lib/types/modes/text.d.ts +66 -0
- package/lib/types/modes/text.d.ts.map +1 -0
- package/lib/types/modes/text.js +275 -0
- package/lib/types/modes/text.js.map +1 -0
- package/lib/types/reads.d.ts +57 -0
- package/lib/types/reads.d.ts.map +1 -0
- package/lib/types/reads.js +219 -0
- package/lib/types/reads.js.map +1 -0
- package/lib/types/request.d.ts +55 -0
- package/lib/types/request.d.ts.map +1 -0
- package/lib/types/request.js +174 -0
- package/lib/types/request.js.map +1 -0
- package/lib/types/send.d.ts +34 -0
- package/lib/types/send.d.ts.map +1 -0
- package/lib/types/send.js +99 -0
- package/lib/types/send.js.map +1 -0
- package/lib/types/types/schema.d.ts +11726 -0
- package/lib/types/types/schema.d.ts.map +1 -0
- package/lib/types/types/schema.js +1422 -0
- package/lib/types/types/schema.js.map +1 -0
- package/lib/types/ws.d.ts +60 -0
- package/lib/types/ws.d.ts.map +1 -0
- package/lib/types/ws.js +335 -0
- package/lib/types/ws.js.map +1 -0
- package/package.json +62 -3
- package/src/bot.ts +431 -0
- package/src/config.ts +61 -0
- package/src/decode.ts +367 -0
- package/src/errors.ts +195 -0
- package/src/identity.ts +43 -0
- package/src/ids.ts +226 -0
- package/src/index.ts +44 -0
- package/src/internal.ts +657 -0
- package/src/modes/text.ts +368 -0
- package/src/reads.ts +315 -0
- package/src/request.ts +230 -0
- package/src/send.ts +175 -0
- package/src/types/schema.ts +1827 -0
- package/src/ws.ts +383 -0
- package/README.md +0 -3
package/lib/types/bot.js
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Milky adapter: an application-side client of one protocol endpoint (LLOneBot, NapCat, …).
|
|
3
|
+
*
|
|
4
|
+
* The endpoint is a plain HTTP server with `/api` for calls and `/event` for the event stream. This adapter is an HTTP
|
|
5
|
+
* client and a WebSocket client; it never serves anything and registers no `webServer` route. Its only inbound surface
|
|
6
|
+
* is the `satori:` media routes it defines for the host to fetch lazily.
|
|
7
|
+
*/
|
|
8
|
+
import { Adapter, PlatformError, } from '@deepseek-ai/cordis-plugin-im-core';
|
|
9
|
+
import { Config } from "./config.js";
|
|
10
|
+
import { classifyMilkyError, MilkyApiError, MilkyConfigError, } from "./errors.js";
|
|
11
|
+
import { implementsMilky1, verifyIdentity, versionWarning } from "./identity.js";
|
|
12
|
+
import { Internal } from "./internal.js";
|
|
13
|
+
import { createMilkyTextMode, } from "./modes/text.js";
|
|
14
|
+
import { createReaction, deleteReaction, getMessage, members } from "./reads.js";
|
|
15
|
+
import { createMilkyRequest, eventUrl, milkyOrigin, normalizeEndpoint, } from "./request.js";
|
|
16
|
+
import { deletePart, sendPayload } from "./send.js";
|
|
17
|
+
import { MilkyWs } from "./ws.js";
|
|
18
|
+
/**
|
|
19
|
+
* Milky adapter for one protocol endpoint.
|
|
20
|
+
*
|
|
21
|
+
* Identity comes from the required `selfId`, verified against `get_login_info.uin` on every connection; events arrive
|
|
22
|
+
* over a reconnecting client WebSocket, while every write is an independent HTTP call.
|
|
23
|
+
*/
|
|
24
|
+
export class MilkyBot extends Adapter {
|
|
25
|
+
/** The adapter waits for the Satori service; the Loader row isolates `http` for this adapter. */
|
|
26
|
+
static inject = ['satori', 'http'];
|
|
27
|
+
/** The Loader applies this schema to a profile row's `config` before the constructor runs. */
|
|
28
|
+
static Config = Config;
|
|
29
|
+
modes = { text: createMilkyTextMode() };
|
|
30
|
+
modeOrder = ['text'];
|
|
31
|
+
/** API endpoints derived from the origin of `endpoint`. */
|
|
32
|
+
request;
|
|
33
|
+
/** The whole Milky API surface, including the methods the DSH host does not call. */
|
|
34
|
+
internal;
|
|
35
|
+
endpointError;
|
|
36
|
+
ws;
|
|
37
|
+
/**
|
|
38
|
+
* @param ctx - plugin context.
|
|
39
|
+
* @param config - validated configuration; the constructor still asserts `selfId` against a config that bypassed the
|
|
40
|
+
* schema, because `bot.id` must be stable before any connection.
|
|
41
|
+
* @throws MilkyConfigError when `selfId` is not a QQ number.
|
|
42
|
+
*/
|
|
43
|
+
constructor(ctx, config) {
|
|
44
|
+
const selfId = String(config.selfId);
|
|
45
|
+
if (!/^\d+$/.test(selfId)) {
|
|
46
|
+
throw new MilkyConfigError(`milky: selfId must be the bot QQ number (digits only), got "${config.selfId}"`);
|
|
47
|
+
}
|
|
48
|
+
const endpoint = normalizeEndpoint(config.endpoint);
|
|
49
|
+
let origin = '';
|
|
50
|
+
let endpointError;
|
|
51
|
+
try {
|
|
52
|
+
origin = milkyOrigin(endpoint);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
endpointError = error instanceof Error ? error : new Error(String(error));
|
|
56
|
+
}
|
|
57
|
+
super(ctx, { ...config, endpoint }, { id: `milky:${selfId}`, platform: 'milky', adapter: 'milky' });
|
|
58
|
+
this.selfId = selfId;
|
|
59
|
+
this.request = createMilkyRequest(ctx, config.token, origin);
|
|
60
|
+
this.internal = new Internal(this.request);
|
|
61
|
+
this.endpointError = endpointError;
|
|
62
|
+
// Inbound media becomes a `satori:` route; the host fetches it only when it needs the bytes.
|
|
63
|
+
this.defineInternalRoute('/resources/:resourceId', async ({ params }) => this.serveResource(params.resourceId));
|
|
64
|
+
this.defineInternalRoute('/files/:scene/:peer/:fileId', async ({ params, query }) => this.serveFile(params.scene, params.peer, params.fileId, query.get('hash')));
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Validate the endpoint and start the reconnect loop. Returns immediately: the loop dials in the background, so a
|
|
68
|
+
* protocol endpoint that starts later does not hold up the plugin row.
|
|
69
|
+
* @throws MilkyConfigError when `endpoint` is not an http(s) URL.
|
|
70
|
+
*/
|
|
71
|
+
async connect() {
|
|
72
|
+
if (this.endpointError !== undefined) {
|
|
73
|
+
this.ctx.logger.error('milky: %s', this.endpointError.message);
|
|
74
|
+
throw this.endpointError;
|
|
75
|
+
}
|
|
76
|
+
const ws = new MilkyWs(this);
|
|
77
|
+
this.ws = ws;
|
|
78
|
+
ws.start();
|
|
79
|
+
}
|
|
80
|
+
/** Stop the event stream and wait for the frame being handled. */
|
|
81
|
+
async disconnect() {
|
|
82
|
+
const ws = this.ws;
|
|
83
|
+
this.ws = undefined;
|
|
84
|
+
await ws?.stop();
|
|
85
|
+
}
|
|
86
|
+
/** Address of the event socket (`ws(s)://<origin>/event`) with the configured bearer token. */
|
|
87
|
+
openEventSocket() {
|
|
88
|
+
return this.ctx.http.ws(eventUrl(this.request), {
|
|
89
|
+
...(this.config.token === ''
|
|
90
|
+
? {}
|
|
91
|
+
: { headers: { authorization: `Bearer ${this.config.token}` } }),
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Read and verify the endpoint identity, then report an unexpected protocol version.
|
|
96
|
+
* @throws MilkyIdentityError when the endpoint is logged into another account.
|
|
97
|
+
* @throws MilkyApiError when `get_login_info` itself fails (a transport failure, retried by the loop).
|
|
98
|
+
*/
|
|
99
|
+
async identify() {
|
|
100
|
+
const login = await this.internal.getLoginInfo();
|
|
101
|
+
if (login === undefined ||
|
|
102
|
+
login === null ||
|
|
103
|
+
typeof login.uin !== 'number') {
|
|
104
|
+
// A 200 answer without the required field: the call ran, the receipt is incomplete.
|
|
105
|
+
throw new MilkyApiError('milky: get_login_info answered without a uin', {
|
|
106
|
+
api: 'get_login_info',
|
|
107
|
+
httpStatus: 200,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
this.user = verifyIdentity(this.selfId, login);
|
|
111
|
+
try {
|
|
112
|
+
const info = await this.internal.getImplInfo();
|
|
113
|
+
if (!implementsMilky1(info.milky_version))
|
|
114
|
+
this.ctx.logger.warn('%s', versionWarning(info));
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
// The compatibility policy is forward-compatible, so a version read failure only costs the diagnostic.
|
|
118
|
+
this.ctx.logger.warn('milky: reading the endpoint implementation failed: %s', messageOf(error));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Turn a media source into a URI the protocol endpoint can read.
|
|
123
|
+
*
|
|
124
|
+
* Milky has no message-media upload endpoint: image / record / video segments take a `file://`, `http(s)://` or
|
|
125
|
+
* `base64://` URI and the endpoint fetches it itself. No size limit is applied here; the endpoint decides what it
|
|
126
|
+
* accepts.
|
|
127
|
+
*
|
|
128
|
+
* @param ref - the resource placeholder produced by the mode.
|
|
129
|
+
* @param _scope - cache scope from {@link resourceScope} (unused: the key is the source itself).
|
|
130
|
+
* @param ctx - prepare context (byte fetch for `data:` / `satori:` sources).
|
|
131
|
+
* @returns the URI to place in the segment.
|
|
132
|
+
*/
|
|
133
|
+
async upload(ref, _scope, ctx) {
|
|
134
|
+
const src = ref.src;
|
|
135
|
+
if (/^https?:/i.test(src) ||
|
|
136
|
+
src.startsWith('file:') ||
|
|
137
|
+
src.startsWith('base64:'))
|
|
138
|
+
return { key: src };
|
|
139
|
+
if (/^data:/i.test(src)) {
|
|
140
|
+
const base64 = /^data:[^,]*;base64,([\s\S]*)$/.exec(src);
|
|
141
|
+
if (base64 !== null)
|
|
142
|
+
return { key: `base64://${base64[1]}` };
|
|
143
|
+
return await this.fetchAsBase64(src, ctx);
|
|
144
|
+
}
|
|
145
|
+
if (src.startsWith('satori:'))
|
|
146
|
+
return await this.fetchAsBase64(src, ctx);
|
|
147
|
+
throw new PlatformError('invalid', `milky: unsupported media source "${preview(src)}"`, { published: 'no' });
|
|
148
|
+
}
|
|
149
|
+
/** No platform-side resource is reused by this adapter; the scope only separates bots in the prepare cache. */
|
|
150
|
+
resourceScope(_target, _kind) {
|
|
151
|
+
return this.id;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Publish one serialized payload: a segment message, or one file uploaded to the QQ file area.
|
|
155
|
+
* @param payload - the payload `serialize` produced.
|
|
156
|
+
* @param target - destination chat.
|
|
157
|
+
* @param ctx - core send context.
|
|
158
|
+
* @returns the published part.
|
|
159
|
+
*/
|
|
160
|
+
async sendPayload(payload, target, ctx) {
|
|
161
|
+
return await sendPayload({ internal: this.internal }, payload, target, ctx);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Delete one published part: recall a message, or delete a group file.
|
|
165
|
+
* @param part - the published part.
|
|
166
|
+
* @param handle - the message handle (carries the target chat).
|
|
167
|
+
*/
|
|
168
|
+
async deletePart(part, handle) {
|
|
169
|
+
await deletePart({ internal: this.internal }, part, handle);
|
|
170
|
+
}
|
|
171
|
+
classify(error) {
|
|
172
|
+
return classifyMilkyError(error);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* List the people a chat lists as its members.
|
|
176
|
+
* @param chat - chat to list.
|
|
177
|
+
* @param cursor - `next` of the previous page.
|
|
178
|
+
* @param limit - page-size hint from the host.
|
|
179
|
+
* @returns one page.
|
|
180
|
+
*/
|
|
181
|
+
async members(chat, cursor, limit) {
|
|
182
|
+
return await members(this.internal, chat, cursor, limit);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Read one message by id, expanding a merged forward placeholder.
|
|
186
|
+
* @param chat - chat the caller asks about.
|
|
187
|
+
* @param id - platform message id.
|
|
188
|
+
* @returns the message.
|
|
189
|
+
*/
|
|
190
|
+
async getMessage(chat, id) {
|
|
191
|
+
return await getMessage(this, chat, id);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Add one reaction (group chats only).
|
|
195
|
+
* @param message - the reacted message.
|
|
196
|
+
* @param emoji - `<reaction_type>|<reaction_id>`, or a bare face id.
|
|
197
|
+
*/
|
|
198
|
+
async createReaction(message, emoji) {
|
|
199
|
+
await createReaction(this.internal, message, emoji);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Remove one reaction (group chats only).
|
|
203
|
+
* @param message - the reacted message.
|
|
204
|
+
* @param emoji - `<reaction_type>|<reaction_id>`, or a bare face id.
|
|
205
|
+
*/
|
|
206
|
+
async deleteReaction(message, emoji) {
|
|
207
|
+
await deleteReaction(this.internal, message, emoji);
|
|
208
|
+
}
|
|
209
|
+
/** Fetch a source into a `base64://` URI, keeping the name the source reported. */
|
|
210
|
+
async fetchAsBase64(src, ctx) {
|
|
211
|
+
const fetched = await ctx.fetch(src, ctx.signal);
|
|
212
|
+
return {
|
|
213
|
+
key: `base64://${Buffer.from(fetched.data).toString('base64')}`,
|
|
214
|
+
...(fetched.name === undefined || fetched.name === ''
|
|
215
|
+
? {}
|
|
216
|
+
: { extra: { name: fetched.name } }),
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
/** Serve one `resource_id` by resolving it to a temporary URL when the host reads it. */
|
|
220
|
+
async serveResource(resourceId) {
|
|
221
|
+
const id = decodeURIComponentOrUndefined(resourceId);
|
|
222
|
+
if (id === undefined)
|
|
223
|
+
return new Response(null, { status: 400 });
|
|
224
|
+
try {
|
|
225
|
+
const result = await this.internal.getResourceTempUrl(id);
|
|
226
|
+
const url = result?.url;
|
|
227
|
+
if (typeof url !== 'string' || url === '')
|
|
228
|
+
return new Response(null, { status: 502 });
|
|
229
|
+
return await this.proxy(url);
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
// The upstream error can carry a CDN URL with its token, so only the failure class is logged.
|
|
233
|
+
this.ctx.logger.warn('milky: resource %s could not be served (%s)', id, failureOf(error));
|
|
234
|
+
return new Response(null, { status: 502 });
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/** Serve one file of the file area through `get_*_file_download_url`. */
|
|
238
|
+
async serveFile(scene, peer, fileId, hash) {
|
|
239
|
+
const file = decodeURIComponentOrUndefined(fileId);
|
|
240
|
+
if (file === undefined)
|
|
241
|
+
return new Response(null, { status: 400 });
|
|
242
|
+
const peerId = Number(peer);
|
|
243
|
+
if (!Number.isSafeInteger(peerId) || peerId <= 0)
|
|
244
|
+
return new Response(null, { status: 400 });
|
|
245
|
+
try {
|
|
246
|
+
let url;
|
|
247
|
+
if (scene === 'group') {
|
|
248
|
+
url = (await this.internal.getGroupFileDownloadUrl(peerId, file))
|
|
249
|
+
?.download_url;
|
|
250
|
+
}
|
|
251
|
+
else if (scene === 'private' || scene === 'temp') {
|
|
252
|
+
if (hash === null || hash === '')
|
|
253
|
+
return new Response(null, { status: 400 });
|
|
254
|
+
url = (await this.internal.getPrivateFileDownloadUrl(peerId, file, hash))?.download_url;
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
return new Response(null, { status: 400 });
|
|
258
|
+
}
|
|
259
|
+
if (typeof url !== 'string' || url === '')
|
|
260
|
+
return new Response(null, { status: 502 });
|
|
261
|
+
return await this.proxy(url);
|
|
262
|
+
}
|
|
263
|
+
catch (error) {
|
|
264
|
+
this.ctx.logger.warn('milky: file %s could not be served (%s)', file, failureOf(error));
|
|
265
|
+
return new Response(null, { status: 502 });
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
/** Fetch an upstream URL and pass its status, body and content type through. */
|
|
269
|
+
async proxy(url) {
|
|
270
|
+
const response = await this.ctx.http(url, {});
|
|
271
|
+
const headers = new Headers();
|
|
272
|
+
const contentType = response.headers.get('content-type');
|
|
273
|
+
if (contentType !== null)
|
|
274
|
+
headers.set('content-type', contentType);
|
|
275
|
+
return new Response(response.body, { status: response.status, headers });
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/** Decode one URL path parameter, or refuse a malformed escape. */
|
|
279
|
+
function decodeURIComponentOrUndefined(value) {
|
|
280
|
+
try {
|
|
281
|
+
return decodeURIComponent(value);
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
void error;
|
|
285
|
+
return undefined;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
/** A short, token-free description of a caught failure for a log line. */
|
|
289
|
+
function failureOf(error) {
|
|
290
|
+
if (error instanceof MilkyApiError)
|
|
291
|
+
return `${error.api} failed (${error.httpStatus ?? error.retcode ?? 'no status'})`;
|
|
292
|
+
return error instanceof Error ? error.name : 'unknown error';
|
|
293
|
+
}
|
|
294
|
+
/** Describe a caught value for a log line. */
|
|
295
|
+
function messageOf(error) {
|
|
296
|
+
return error instanceof Error ? error.message : String(error);
|
|
297
|
+
}
|
|
298
|
+
/** A source shortened for a diagnostic (a data: URL can be megabytes long). */
|
|
299
|
+
function preview(src) {
|
|
300
|
+
return src.length <= 120 ? src : `${src.slice(0, 120)}…`;
|
|
301
|
+
}
|
|
302
|
+
export default MilkyBot;
|
|
303
|
+
//# sourceMappingURL=bot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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protocol endpoint, its optional access token, the bot account and the WS budget. */
|
|
2
|
+
import z from '@deepseek-ai/schemastery';
|
|
3
|
+
/** Reconnect budget of the client WebSocket. */
|
|
4
|
+
export interface MilkyWsConfig {
|
|
5
|
+
/** Consecutive failures retried at `retryIntervalMs` before the loop switches to `retryLazyMs`; the loop never gives up. */
|
|
6
|
+
retryTimes: number;
|
|
7
|
+
/** Delay between two quickly retried connection attempts (ms). */
|
|
8
|
+
retryIntervalMs: number;
|
|
9
|
+
/** Delay of a connection attempt after the quick budget is spent (ms). */
|
|
10
|
+
retryLazyMs: number;
|
|
11
|
+
}
|
|
12
|
+
/** One Milky protocol endpoint (LLOneBot, NapCat, …) serving API and event sockets. */
|
|
13
|
+
export interface Config {
|
|
14
|
+
/** Root URL of the protocol endpoint, e.g. `http://127.0.0.1:3000`; only its origin is used. */
|
|
15
|
+
endpoint: string;
|
|
16
|
+
/** `access_token` of the protocol endpoint; an empty string means none is configured. */
|
|
17
|
+
token: string;
|
|
18
|
+
/** QQ number of the bot account; `get_login_info.uin` must match it. */
|
|
19
|
+
selfId: string;
|
|
20
|
+
ws: MilkyWsConfig;
|
|
21
|
+
}
|
|
22
|
+
/** Validated Milky adapter configuration. */
|
|
23
|
+
export declare const Config: z<Config>;
|
|
24
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,wHAAwH;AAExH,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAExC,gDAAgD;AAChD,MAAM,WAAW,aAAa;IAC5B,4HAA4H;IAC5H,UAAU,EAAE,MAAM,CAAA;IAClB,kEAAkE;IAClE,eAAe,EAAE,MAAM,CAAA;IACvB,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,uFAAuF;AACvF,MAAM,WAAW,MAAM;IACrB,gGAAgG;IAChG,QAAQ,EAAE,MAAM,CAAA;IAChB,yFAAyF;IACzF,KAAK,EAAE,MAAM,CAAA;IACb,wEAAwE;IACxE,MAAM,EAAE,MAAM,CAAA;IACd,EAAE,EAAE,aAAa,CAAA;CAClB;AAED,6CAA6C;AAC7C,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,MAAM,CAkC3B,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** Milky adapter configuration: the protocol endpoint, its optional access token, the bot account and the WS budget. */
|
|
2
|
+
import z from '@deepseek-ai/schemastery';
|
|
3
|
+
/** Validated Milky adapter configuration. */
|
|
4
|
+
export const Config = z.object({
|
|
5
|
+
endpoint: z
|
|
6
|
+
.string()
|
|
7
|
+
.role('url')
|
|
8
|
+
.required()
|
|
9
|
+
.description('协议端根 URL,例如 http://127.0.0.1:3000;只使用其 origin。'),
|
|
10
|
+
token: z
|
|
11
|
+
.string()
|
|
12
|
+
.role('secret')
|
|
13
|
+
.default('')
|
|
14
|
+
.description('协议端 access_token;留空表示未设置。'),
|
|
15
|
+
selfId: z
|
|
16
|
+
.string()
|
|
17
|
+
.pattern(/^\d+$/)
|
|
18
|
+
.required()
|
|
19
|
+
.description('机器人 QQ 号,必须与 get_login_info.uin 一致。'),
|
|
20
|
+
ws: z
|
|
21
|
+
.object({
|
|
22
|
+
retryTimes: z
|
|
23
|
+
.natural()
|
|
24
|
+
.default(6)
|
|
25
|
+
.description('快重试预算;用完后改用惰性间隔,但永不放弃。'),
|
|
26
|
+
retryIntervalMs: z
|
|
27
|
+
.natural()
|
|
28
|
+
.role('ms')
|
|
29
|
+
.default(5_000)
|
|
30
|
+
.description('快重试间隔。'),
|
|
31
|
+
retryLazyMs: z
|
|
32
|
+
.natural()
|
|
33
|
+
.role('ms')
|
|
34
|
+
.default(60_000)
|
|
35
|
+
.description('快重试预算用完后的惰性间隔。'),
|
|
36
|
+
})
|
|
37
|
+
.default({}),
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,wHAAwH;AAExH,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAuBxC,6CAA6C;AAC7C,MAAM,CAAC,MAAM,MAAM,GAAc,CAAC,CAAC,MAAM,CAAC;IACxC,QAAQ,EAAE,CAAC;SACR,MAAM,EAAE;SACR,IAAI,CAAC,KAAK,CAAC;SACX,QAAQ,EAAE;SACV,WAAW,CAAC,gDAAgD,CAAC;IAChE,KAAK,EAAE,CAAC;SACL,MAAM,EAAE;SACR,IAAI,CAAC,QAAQ,CAAC;SACd,OAAO,CAAC,EAAE,CAAC;SACX,WAAW,CAAC,2BAA2B,CAAC;IAC3C,MAAM,EAAE,CAAC;SACN,MAAM,EAAE;SACR,OAAO,CAAC,OAAO,CAAC;SAChB,QAAQ,EAAE;SACV,WAAW,CAAC,qCAAqC,CAAC;IACrD,EAAE,EAAE,CAAC;SACF,MAAM,CAAC;QACN,UAAU,EAAE,CAAC;aACV,OAAO,EAAE;aACT,OAAO,CAAC,CAAC,CAAC;aACV,WAAW,CAAC,wBAAwB,CAAC;QACxC,eAAe,EAAE,CAAC;aACf,OAAO,EAAE;aACT,IAAI,CAAC,IAAI,CAAC;aACV,OAAO,CAAC,KAAK,CAAC;aACd,WAAW,CAAC,QAAQ,CAAC;QACxB,WAAW,EAAE,CAAC;aACX,OAAO,EAAE;aACT,IAAI,CAAC,IAAI,CAAC;aACV,OAAO,CAAC,MAAM,CAAC;aACf,WAAW,CAAC,gBAAgB,CAAC;KACjC,CAAC;SACD,OAAO,CAAC,EAAE,CAAC;CACf,CAAC,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inbound decoding: one Milky event or message becomes a DSH session without any platform I/O.
|
|
3
|
+
*
|
|
4
|
+
* Media never carries bytes or a `temp_url` into the session: both expire, so a segment decodes to a `satori:` route
|
|
5
|
+
* of this bot (`/resources/:resourceId`, `/files/:scene/:peer/:fileId`) that the host fetches when it needs the bytes.
|
|
6
|
+
*/
|
|
7
|
+
import { type InboundMessage, type Session } from '@deepseek-ai/cordis-plugin-im-core';
|
|
8
|
+
import type { MilkyBot } from './bot.ts';
|
|
9
|
+
import { type MilkyScene } from './ids.ts';
|
|
10
|
+
import type { Event, IncomingMessage } from './types/schema.ts';
|
|
11
|
+
/** Adapter-private reply context stored on `InboundMessage.referrer` and handed back as `Target.referrer`. */
|
|
12
|
+
export interface MilkyReferrer {
|
|
13
|
+
/** Milly message scene of the message being answered. */
|
|
14
|
+
scene: MilkyScene;
|
|
15
|
+
/** Group number or user number. */
|
|
16
|
+
peerId: number;
|
|
17
|
+
/** `message_seq` inside that conversation. */
|
|
18
|
+
messageSeq: number;
|
|
19
|
+
/** Sender of the message. */
|
|
20
|
+
senderId?: number;
|
|
21
|
+
/** Unix timestamp (seconds) of the message. */
|
|
22
|
+
time?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Decode one event frame into a session.
|
|
26
|
+
*
|
|
27
|
+
* Only `message_receive`, `message_recall` and `group_message_reaction` have DSH consumers; every other event is left
|
|
28
|
+
* for the transport to log at debug level.
|
|
29
|
+
*
|
|
30
|
+
* @param bot - receiving bot (`selfId` decides `mentions.self`, the platform prefix names internal routes).
|
|
31
|
+
* @param event - one decoded protocol event.
|
|
32
|
+
* @returns the session, or `undefined` for an event this adapter does not surface.
|
|
33
|
+
*/
|
|
34
|
+
export declare function decodeFrame(bot: MilkyBot, event: Event): Session | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Decode one received message.
|
|
37
|
+
*
|
|
38
|
+
* @param bot - receiving bot.
|
|
39
|
+
* @param input - `IncomingMessage` of the event (or of a `get_message` answer).
|
|
40
|
+
* @returns the inbound message; its content is never empty.
|
|
41
|
+
*/
|
|
42
|
+
export declare function decodeMessage(bot: MilkyBot, input: IncomingMessage): InboundMessage;
|
|
43
|
+
//# sourceMappingURL=decode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../../src/decode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAKL,KAAK,cAAc,EAEnB,KAAK,OAAO,EAEb,MAAM,oCAAoC,CAAA;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAIL,KAAK,UAAU,EAGhB,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EACV,KAAK,EAEL,eAAe,EAGhB,MAAM,mBAAmB,CAAA;AAE1B,8GAA8G;AAC9G,MAAM,WAAW,aAAa;IAC5B,yDAAyD;IACzD,KAAK,EAAE,UAAU,CAAA;IACjB,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAA;IAClB,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,+CAA+C;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAKD;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,GAAG,SAAS,CAoD5E;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,eAAe,GACrB,cAAc,CA+BhB"}
|