@umx-bot/plugin-sdk 0.0.0-stage → 0.7.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/LICENSE +21 -0
- package/README.md +32 -2
- package/dist/collection.d.ts +29 -0
- package/dist/collection.d.ts.map +1 -0
- package/dist/collection.js +80 -0
- package/dist/collection.js.map +1 -0
- package/dist/command-args.d.ts +69 -0
- package/dist/command-args.d.ts.map +1 -0
- package/dist/command-args.js +113 -0
- package/dist/command-args.js.map +1 -0
- package/dist/index.d.ts +725 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +71 -0
- package/dist/index.js.map +1 -0
- package/package.json +39 -3
- package/src/collection.ts +136 -0
- package/src/command-args.ts +197 -0
- package/src/index.ts +955 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,955 @@
|
|
|
1
|
+
import type { CommandArgsSchema } from "./command-args.js";
|
|
2
|
+
|
|
3
|
+
export {
|
|
4
|
+
type Collection,
|
|
5
|
+
type CollectionEntry,
|
|
6
|
+
type CollectionFindOptions,
|
|
7
|
+
createCollection
|
|
8
|
+
} from "./collection.js";
|
|
9
|
+
export {
|
|
10
|
+
type ArgDefinition,
|
|
11
|
+
type ArgSpec,
|
|
12
|
+
type CommandArgsInput,
|
|
13
|
+
type CommandArgsSchema,
|
|
14
|
+
CommandArgumentError,
|
|
15
|
+
defineArgs,
|
|
16
|
+
type ParsedArgs
|
|
17
|
+
} from "./command-args.js";
|
|
18
|
+
|
|
19
|
+
export type Awaitable<T> = T | Promise<T>;
|
|
20
|
+
export type Dispose = () => Awaitable<void>;
|
|
21
|
+
export const LEGACY_PLUGIN_API_VERSION = 1 as const;
|
|
22
|
+
/**
|
|
23
|
+
* Contract version new plugins should declare.
|
|
24
|
+
*
|
|
25
|
+
* Evolution policy: within a version the contract only grows (new optional
|
|
26
|
+
* fields and methods). A change that could break an existing plugin bumps the
|
|
27
|
+
* version, and the runtime keeps accepting older versions listed in
|
|
28
|
+
* `SUPPORTED_PLUGIN_API_VERSIONS` for at least one major release. v2 added
|
|
29
|
+
* permissions, `requires`, plugin-emitted events, outbound hooks, interaction
|
|
30
|
+
* routing, metrics, cron scheduling, store TTL and command v2 (subcommands,
|
|
31
|
+
* argument schemas, scopes).
|
|
32
|
+
*/
|
|
33
|
+
export const PLUGIN_API_VERSION = 2 as const;
|
|
34
|
+
export const SUPPORTED_PLUGIN_API_VERSIONS = [
|
|
35
|
+
LEGACY_PLUGIN_API_VERSION,
|
|
36
|
+
PLUGIN_API_VERSION
|
|
37
|
+
] as const;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Powers a plugin must be granted when it declares `permissions` (or when the
|
|
41
|
+
* manifest restricts it). A plugin that declares nothing and has no manifest
|
|
42
|
+
* restriction keeps the legacy unrestricted behaviour.
|
|
43
|
+
*/
|
|
44
|
+
export const PLUGIN_PERMISSIONS = [
|
|
45
|
+
/** Active or platform-specific delivery and message streams. */
|
|
46
|
+
"messages.active",
|
|
47
|
+
/** Emitting `<plugin>.*` events for other plugins. */
|
|
48
|
+
"events.emit",
|
|
49
|
+
/** Registering interval, cron and one-shot tasks. */
|
|
50
|
+
"scheduler",
|
|
51
|
+
/** Seeing and short-circuiting every incoming message. */
|
|
52
|
+
"middleware",
|
|
53
|
+
/** Seeing and rewriting every outgoing message. */
|
|
54
|
+
"outbound"
|
|
55
|
+
] as const;
|
|
56
|
+
export type PluginPermission = (typeof PLUGIN_PERMISSIONS)[number];
|
|
57
|
+
|
|
58
|
+
/** Thrown when a restricted plugin uses a power it was not granted. */
|
|
59
|
+
export class PermissionError extends Error {
|
|
60
|
+
public constructor(
|
|
61
|
+
public readonly plugin: string,
|
|
62
|
+
public readonly permission: PluginPermission
|
|
63
|
+
) {
|
|
64
|
+
super(`plugin "${plugin}" needs the "${permission}" permission`);
|
|
65
|
+
this.name = "PermissionError";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type ChatScope = "group" | "direct" | "guild";
|
|
70
|
+
export type MemberRole = "member" | "admin" | "owner";
|
|
71
|
+
|
|
72
|
+
export interface MessageAuthor {
|
|
73
|
+
id: string;
|
|
74
|
+
name?: string;
|
|
75
|
+
role: MemberRole;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface MessageAttachment {
|
|
79
|
+
url: string;
|
|
80
|
+
filename?: string;
|
|
81
|
+
contentType?: string;
|
|
82
|
+
size?: number;
|
|
83
|
+
width?: number;
|
|
84
|
+
height?: number;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface MessageMention {
|
|
88
|
+
id: string;
|
|
89
|
+
name?: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** A message quoted by the incoming message. Presence indicates a quote/reply. */
|
|
93
|
+
export interface MessageQuote {
|
|
94
|
+
/** Original quoted text, or an empty string when the platform omitted it. */
|
|
95
|
+
content: string;
|
|
96
|
+
/** Opaque platform reference for the quoted message, when available. */
|
|
97
|
+
referenceId?: string;
|
|
98
|
+
attachments: MessageAttachment[];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface IncomingMessage {
|
|
102
|
+
id: string;
|
|
103
|
+
platform: string;
|
|
104
|
+
scope: ChatScope;
|
|
105
|
+
conversationId: string;
|
|
106
|
+
author: MessageAuthor;
|
|
107
|
+
content: string;
|
|
108
|
+
attachments: MessageAttachment[];
|
|
109
|
+
mentions: MessageMention[];
|
|
110
|
+
quote?: MessageQuote;
|
|
111
|
+
botMentioned?: boolean;
|
|
112
|
+
timestamp: Date;
|
|
113
|
+
raw?: unknown;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface SentMessage {
|
|
117
|
+
platform: string;
|
|
118
|
+
scope: ChatScope;
|
|
119
|
+
conversationId: string;
|
|
120
|
+
id: string;
|
|
121
|
+
timestamp: Date;
|
|
122
|
+
raw?: unknown;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export type OutgoingMediaKind = "image" | "video" | "audio" | "file";
|
|
126
|
+
|
|
127
|
+
export type OutgoingMediaSource =
|
|
128
|
+
| { type: "url"; url: string }
|
|
129
|
+
| { type: "data"; data: Uint8Array }
|
|
130
|
+
| {
|
|
131
|
+
type: "stream";
|
|
132
|
+
stream: AsyncIterable<Uint8Array>;
|
|
133
|
+
size: number;
|
|
134
|
+
checksums: readonly MediaChecksum[];
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export interface MediaChecksum {
|
|
138
|
+
algorithm: string;
|
|
139
|
+
digest: string;
|
|
140
|
+
/** When present, the digest covers only the first N bytes. */
|
|
141
|
+
bytes?: number;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface OutgoingMedia {
|
|
145
|
+
type: OutgoingMediaKind;
|
|
146
|
+
source: OutgoingMediaSource;
|
|
147
|
+
filename?: string;
|
|
148
|
+
contentType?: string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export interface RichMessageContent {
|
|
152
|
+
text?: string;
|
|
153
|
+
markdown?: string;
|
|
154
|
+
media?: readonly [OutgoingMedia, ...OutgoingMedia[]];
|
|
155
|
+
keyboard?: MessageKeyboard;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export type MessageContent = string | RichMessageContent;
|
|
159
|
+
|
|
160
|
+
export interface MessageKeyboardButtonBase {
|
|
161
|
+
id?: string;
|
|
162
|
+
label: string;
|
|
163
|
+
style?: "default" | "primary" | "success" | "danger";
|
|
164
|
+
visibleTo?: {
|
|
165
|
+
userIds?: string[];
|
|
166
|
+
/** Display hint only; command permission must still enforce authorization. */
|
|
167
|
+
minimumRole?: MemberRole;
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export type MessageKeyboardButton = MessageKeyboardButtonBase &
|
|
172
|
+
(
|
|
173
|
+
| {
|
|
174
|
+
action: "command";
|
|
175
|
+
data: string;
|
|
176
|
+
enter?: boolean;
|
|
177
|
+
reply?: boolean;
|
|
178
|
+
}
|
|
179
|
+
| {
|
|
180
|
+
action: "callback";
|
|
181
|
+
data: string;
|
|
182
|
+
}
|
|
183
|
+
| {
|
|
184
|
+
action: "link";
|
|
185
|
+
url: string;
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
export interface CustomMessageKeyboard {
|
|
190
|
+
rows: readonly (readonly MessageKeyboardButton[])[];
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export interface PlatformMessageKeyboard {
|
|
194
|
+
platform: string;
|
|
195
|
+
kind: string;
|
|
196
|
+
id: string;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export type MessageKeyboard = CustomMessageKeyboard | PlatformMessageKeyboard;
|
|
200
|
+
|
|
201
|
+
export type ReplyTarget =
|
|
202
|
+
| { type: "message"; messageId: string }
|
|
203
|
+
| { type: "event"; eventId: string };
|
|
204
|
+
|
|
205
|
+
export type MessageDelivery =
|
|
206
|
+
| { type: "passive"; target: ReplyTarget }
|
|
207
|
+
| { type: "active"; idempotencyKey: string }
|
|
208
|
+
| {
|
|
209
|
+
type: "platform";
|
|
210
|
+
platform: string;
|
|
211
|
+
mode: string;
|
|
212
|
+
idempotencyKey: string;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export interface MessageReference {
|
|
216
|
+
messageId: string;
|
|
217
|
+
ignoreGetMessageError?: boolean;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export interface OutgoingMessage {
|
|
221
|
+
conversationId: string;
|
|
222
|
+
scope: ChatScope;
|
|
223
|
+
content: MessageContent;
|
|
224
|
+
delivery: MessageDelivery;
|
|
225
|
+
reference?: MessageReference;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export interface ContactEvent {
|
|
229
|
+
platform: string;
|
|
230
|
+
userId: string;
|
|
231
|
+
eventId?: string;
|
|
232
|
+
timestamp: Date;
|
|
233
|
+
raw?: unknown;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export interface BotConversationEvent {
|
|
237
|
+
platform: string;
|
|
238
|
+
scope: Exclude<ChatScope, "guild">;
|
|
239
|
+
conversationId: string;
|
|
240
|
+
eventId?: string;
|
|
241
|
+
timestamp: Date;
|
|
242
|
+
raw?: unknown;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export interface DeliveryPreferenceEvent extends BotConversationEvent {
|
|
246
|
+
enabled: boolean;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export interface InteractionEvent extends BotConversationEvent {
|
|
250
|
+
interactionId?: string;
|
|
251
|
+
userId?: string;
|
|
252
|
+
/** Payload of the pressed `callback` button, when the platform sent one. */
|
|
253
|
+
data?: string;
|
|
254
|
+
buttonId?: string;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export type CommandOutcome = "completed" | "failed" | "denied" | "rejected";
|
|
258
|
+
|
|
259
|
+
export interface CommandExecutedEvent {
|
|
260
|
+
command: string;
|
|
261
|
+
subcommand?: string;
|
|
262
|
+
plugin: string;
|
|
263
|
+
outcome: CommandOutcome;
|
|
264
|
+
/** Why a command was `rejected`: scope, access, cooldown or arguments. */
|
|
265
|
+
reason?: "access" | "cooldown" | "arguments";
|
|
266
|
+
durationMs: number;
|
|
267
|
+
message: IncomingMessage;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface PlatformEvent {
|
|
271
|
+
platform: string;
|
|
272
|
+
type: string;
|
|
273
|
+
eventId?: string;
|
|
274
|
+
sequence?: number;
|
|
275
|
+
timestamp: Date;
|
|
276
|
+
raw: Readonly<unknown>;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export interface BotEvents {
|
|
280
|
+
"bot.ready": { adapter: string };
|
|
281
|
+
"bot.stopping": { adapter: string };
|
|
282
|
+
"bot.stopped": { adapter: string };
|
|
283
|
+
"message.created": IncomingMessage;
|
|
284
|
+
"contact.added": ContactEvent;
|
|
285
|
+
"contact.removed": ContactEvent;
|
|
286
|
+
"bot.conversation.joined": BotConversationEvent;
|
|
287
|
+
"bot.conversation.left": BotConversationEvent;
|
|
288
|
+
"message.delivery.enabled": DeliveryPreferenceEvent;
|
|
289
|
+
"message.delivery.disabled": DeliveryPreferenceEvent;
|
|
290
|
+
"interaction.created": InteractionEvent;
|
|
291
|
+
"platform.event": PlatformEvent;
|
|
292
|
+
"command.executed": CommandExecutedEvent;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export interface Logger {
|
|
296
|
+
debug(data: unknown, message?: string): void;
|
|
297
|
+
info(data: unknown, message?: string): void;
|
|
298
|
+
warn(data: unknown, message?: string): void;
|
|
299
|
+
error(data: unknown, message?: string): void;
|
|
300
|
+
child(bindings: Record<string, unknown>): Logger;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export interface EventSubscriptionOptions {
|
|
304
|
+
priority?: number;
|
|
305
|
+
once?: boolean;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export interface EventSubscriber {
|
|
309
|
+
on<K extends keyof BotEvents>(
|
|
310
|
+
event: K,
|
|
311
|
+
handler: (payload: BotEvents[K]) => Awaitable<void>,
|
|
312
|
+
options?: EventSubscriptionOptions
|
|
313
|
+
): Dispose;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export interface EventPublisher {
|
|
317
|
+
/**
|
|
318
|
+
* Publishes an event to other plugins. Only names under the plugin's own
|
|
319
|
+
* namespace (`<plugin>.…`) are accepted, so a plugin cannot forge built-in
|
|
320
|
+
* events. Declare payload types by augmenting `BotEvents`.
|
|
321
|
+
*/
|
|
322
|
+
emit<K extends keyof BotEvents>(
|
|
323
|
+
event: K,
|
|
324
|
+
payload: BotEvents[K]
|
|
325
|
+
): Promise<void>;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export interface MessageSender {
|
|
329
|
+
send(message: OutgoingMessage): Promise<SentMessage>;
|
|
330
|
+
reply(
|
|
331
|
+
message: IncomingMessage,
|
|
332
|
+
content: MessageContent
|
|
333
|
+
): Promise<SentMessage>;
|
|
334
|
+
recall(message: SentMessage): Promise<void>;
|
|
335
|
+
setTyping(
|
|
336
|
+
conversation: ConversationRef,
|
|
337
|
+
seconds: number,
|
|
338
|
+
target: ReplyTarget
|
|
339
|
+
): Promise<void>;
|
|
340
|
+
openStream(options: MessageStreamOptions): Promise<MessageStream>;
|
|
341
|
+
supports(capability: MessagingCapability): boolean;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export type MessagingCapability = "send" | "recall" | "typing" | "stream";
|
|
345
|
+
|
|
346
|
+
export interface MessageStreamOptions {
|
|
347
|
+
conversation: ConversationRef & { scope: "direct" };
|
|
348
|
+
delivery: MessageDelivery;
|
|
349
|
+
contentType: "text" | "markdown";
|
|
350
|
+
initialContent: string;
|
|
351
|
+
inputMode?: "append" | "replace";
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export type MessageStreamState =
|
|
355
|
+
| "open"
|
|
356
|
+
| "completed"
|
|
357
|
+
| "failed"
|
|
358
|
+
| "uncertain"
|
|
359
|
+
| "aborted";
|
|
360
|
+
|
|
361
|
+
export interface MessageStream {
|
|
362
|
+
readonly id: string;
|
|
363
|
+
readonly index: number;
|
|
364
|
+
readonly state: MessageStreamState;
|
|
365
|
+
append(content: string): Promise<SentMessage>;
|
|
366
|
+
replace(content: string): Promise<SentMessage>;
|
|
367
|
+
complete(content?: string): Promise<SentMessage>;
|
|
368
|
+
retry(): Promise<SentMessage>;
|
|
369
|
+
abort(content?: string): Promise<SentMessage>;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export interface CommandContext<TArgs = unknown> {
|
|
373
|
+
message: IncomingMessage;
|
|
374
|
+
command: string;
|
|
375
|
+
/** Set when a subcommand was selected. `args` then excludes its name. */
|
|
376
|
+
subcommand?: string;
|
|
377
|
+
args: string[];
|
|
378
|
+
rawArgs: string;
|
|
379
|
+
/** Result of the command's `args` schema; `undefined` without a schema. */
|
|
380
|
+
parsed: TArgs;
|
|
381
|
+
/** Logger bound to the plugin, command and message id. */
|
|
382
|
+
logger: Logger;
|
|
383
|
+
reply(content: MessageContent): Promise<SentMessage>;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
interface CommandBase<TArgs> {
|
|
387
|
+
description: string;
|
|
388
|
+
aliases?: string[];
|
|
389
|
+
permission?: MemberRole;
|
|
390
|
+
/** Argument syntax only. The framework adds the configured prefix and name. */
|
|
391
|
+
usage?: string;
|
|
392
|
+
examples?: readonly CommandExampleDefinition[];
|
|
393
|
+
hidden?: boolean;
|
|
394
|
+
cooldownMs?: number;
|
|
395
|
+
/** Chats the command works in. Elsewhere it behaves as if unregistered. */
|
|
396
|
+
scopes?: readonly ChatScope[];
|
|
397
|
+
/** Validates and types the arguments before `execute` runs. */
|
|
398
|
+
args?: CommandArgsSchema<TArgs>;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
export interface SubcommandDefinition<TArgs = unknown>
|
|
402
|
+
extends CommandBase<TArgs> {
|
|
403
|
+
name: string;
|
|
404
|
+
execute(context: CommandContext<TArgs>): Awaitable<void | SentMessage>;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
export interface CommandDefinition<TArgs = unknown> extends CommandBase<TArgs> {
|
|
408
|
+
name: string;
|
|
409
|
+
/**
|
|
410
|
+
* `/name <sub> …` runs the matching subcommand. Subcommands inherit the
|
|
411
|
+
* parent's permission, scopes and cooldown unless they set their own.
|
|
412
|
+
*/
|
|
413
|
+
// biome-ignore lint/suspicious/noExplicitAny: each subcommand has its own argument type
|
|
414
|
+
subcommands?: readonly SubcommandDefinition<any>[];
|
|
415
|
+
/**
|
|
416
|
+
* Runs when no subcommand matches. Optional only when `subcommands` is
|
|
417
|
+
* set, in which case the framework replies with the subcommand list.
|
|
418
|
+
*/
|
|
419
|
+
execute?(context: CommandContext<TArgs>): Awaitable<void | SentMessage>;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/** Typing helper that infers a subcommand's `TArgs` from its `args` schema. */
|
|
423
|
+
export function defineSubcommand<TArgs>(
|
|
424
|
+
subcommand: SubcommandDefinition<TArgs>
|
|
425
|
+
): SubcommandDefinition<TArgs> {
|
|
426
|
+
return subcommand;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/** Typing helper that infers `TArgs` from the `args` schema. */
|
|
430
|
+
export function defineCommand<TArgs>(
|
|
431
|
+
command: CommandDefinition<TArgs>
|
|
432
|
+
): CommandDefinition<TArgs> {
|
|
433
|
+
return command;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
export interface CommandExampleDefinition {
|
|
437
|
+
/** Example arguments only. Omit for the bare command. */
|
|
438
|
+
args?: string;
|
|
439
|
+
description?: string;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
export interface CommandExampleSummary {
|
|
443
|
+
command: string;
|
|
444
|
+
description?: string;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
export interface PluginHelpDefinition {
|
|
448
|
+
title?: string;
|
|
449
|
+
description?: string;
|
|
450
|
+
order?: number;
|
|
451
|
+
listed?: boolean;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export interface PluginHelpSummary {
|
|
455
|
+
name: string;
|
|
456
|
+
title: string;
|
|
457
|
+
description?: string;
|
|
458
|
+
order: number;
|
|
459
|
+
listed: boolean;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
export interface SubcommandSummary {
|
|
463
|
+
name: string;
|
|
464
|
+
invocation: string;
|
|
465
|
+
description: string;
|
|
466
|
+
aliases: string[];
|
|
467
|
+
permission: MemberRole;
|
|
468
|
+
usage: string;
|
|
469
|
+
examples: CommandExampleSummary[];
|
|
470
|
+
hidden: boolean;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
export interface CommandSummary {
|
|
474
|
+
name: string;
|
|
475
|
+
invocation: string;
|
|
476
|
+
description: string;
|
|
477
|
+
aliases: string[];
|
|
478
|
+
aliasInvocations: string[];
|
|
479
|
+
permission: MemberRole;
|
|
480
|
+
plugin: PluginHelpSummary;
|
|
481
|
+
usage: string;
|
|
482
|
+
examples: CommandExampleSummary[];
|
|
483
|
+
hidden: boolean;
|
|
484
|
+
/** Present only when the command is restricted to some chats. */
|
|
485
|
+
scopes?: ChatScope[];
|
|
486
|
+
/** Present only when the command has subcommands. */
|
|
487
|
+
subcommands?: SubcommandSummary[];
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
export interface CommandRegistry {
|
|
491
|
+
register<TArgs = unknown>(command: CommandDefinition<TArgs>): Dispose;
|
|
492
|
+
list(): CommandSummary[];
|
|
493
|
+
format(name: string, args?: string): string;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
export type NavigationSurface = "message" | "menu" | "panel";
|
|
497
|
+
|
|
498
|
+
export interface NavigationItemDefinition {
|
|
499
|
+
id?: string;
|
|
500
|
+
label: string;
|
|
501
|
+
/** Registered command name without a prefix. */
|
|
502
|
+
command: string;
|
|
503
|
+
/** Static arguments appended to the command. */
|
|
504
|
+
args?: string;
|
|
505
|
+
description?: string;
|
|
506
|
+
featured?: boolean;
|
|
507
|
+
order?: number;
|
|
508
|
+
permission?: MemberRole;
|
|
509
|
+
scopes?: ChatScope[];
|
|
510
|
+
/** Places where adapters may expose this entry. Defaults to message only. */
|
|
511
|
+
surfaces?: NavigationSurface[];
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
export interface NavigationPageDefinition {
|
|
515
|
+
id?: string;
|
|
516
|
+
/** Overrides the plugin help title for this page. */
|
|
517
|
+
title?: string;
|
|
518
|
+
description?: string;
|
|
519
|
+
order?: number;
|
|
520
|
+
items: readonly [NavigationItemDefinition, ...NavigationItemDefinition[]];
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
export interface NavigationItemSummary
|
|
524
|
+
extends Omit<
|
|
525
|
+
NavigationItemDefinition,
|
|
526
|
+
"id" | "scopes" | "surfaces" | "command" | "args"
|
|
527
|
+
> {
|
|
528
|
+
id: string;
|
|
529
|
+
commandName: string;
|
|
530
|
+
command: string;
|
|
531
|
+
args?: string;
|
|
532
|
+
scopes: ChatScope[];
|
|
533
|
+
surfaces: NavigationSurface[];
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
export interface NavigationPageSummary
|
|
537
|
+
extends Omit<NavigationPageDefinition, "id" | "items" | "title"> {
|
|
538
|
+
id: string;
|
|
539
|
+
plugin: PluginHelpSummary;
|
|
540
|
+
title: string;
|
|
541
|
+
items: NavigationItemSummary[];
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
export interface NavigationRegistry {
|
|
545
|
+
register(page: NavigationPageDefinition): Dispose;
|
|
546
|
+
list(): NavigationPageSummary[];
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
export interface MessageMiddlewareContext {
|
|
550
|
+
readonly message: IncomingMessage;
|
|
551
|
+
readonly state: Map<string, unknown>;
|
|
552
|
+
handled: boolean;
|
|
553
|
+
reply(content: MessageContent): Promise<SentMessage>;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
export type MessageMiddleware = (
|
|
557
|
+
context: MessageMiddlewareContext,
|
|
558
|
+
next: () => Promise<void>
|
|
559
|
+
) => Awaitable<void | SentMessage>;
|
|
560
|
+
|
|
561
|
+
export interface MiddlewareOptions {
|
|
562
|
+
priority?: number;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
export interface MiddlewareRegistry {
|
|
566
|
+
use(middleware: MessageMiddleware, options?: MiddlewareOptions): Dispose;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
export type OutboundHook = (
|
|
570
|
+
message: OutgoingMessage,
|
|
571
|
+
/**
|
|
572
|
+
* Continues to the next hook and finally the adapter. Pass a replacement
|
|
573
|
+
* message to rewrite it, call it more than once to split it, or do not call
|
|
574
|
+
* it to block the message (throw, or return a `SentMessage` you built).
|
|
575
|
+
*/
|
|
576
|
+
next: (message?: OutgoingMessage) => Promise<SentMessage>
|
|
577
|
+
) => Awaitable<SentMessage>;
|
|
578
|
+
|
|
579
|
+
export interface OutboundRegistry {
|
|
580
|
+
/**
|
|
581
|
+
* Higher priority runs first. Covers `messages.send` and `reply`; adapter
|
|
582
|
+
* internals such as message streams and recalls bypass it.
|
|
583
|
+
*/
|
|
584
|
+
use(hook: OutboundHook, options?: { priority?: number }): Dispose;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
export interface InteractionContext {
|
|
588
|
+
event: InteractionEvent;
|
|
589
|
+
/** The registered action name. */
|
|
590
|
+
action: string;
|
|
591
|
+
/** Everything after `<plugin>:<action>:` in the button data. */
|
|
592
|
+
payload: string;
|
|
593
|
+
reply(content: MessageContent): Promise<SentMessage>;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
export interface InteractionRegistry {
|
|
597
|
+
/**
|
|
598
|
+
* Handles presses of `callback` buttons whose data was built with
|
|
599
|
+
* `encode(action, payload)`. Routing is by plugin name, so two plugins can
|
|
600
|
+
* both use an action called `refresh`.
|
|
601
|
+
*/
|
|
602
|
+
handle(
|
|
603
|
+
action: string,
|
|
604
|
+
handler: (context: InteractionContext) => Awaitable<void>
|
|
605
|
+
): Dispose;
|
|
606
|
+
/** Builds button `data` that routes back to this plugin's handler. */
|
|
607
|
+
encode(action: string, payload?: string): string;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
export type MetricLabels = Readonly<Record<string, string | number | boolean>>;
|
|
611
|
+
|
|
612
|
+
export interface Counter {
|
|
613
|
+
inc(labels?: MetricLabels, value?: number): void;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
export interface Gauge {
|
|
617
|
+
set(value: number, labels?: MetricLabels): void;
|
|
618
|
+
add(value: number, labels?: MetricLabels): void;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
export interface Histogram {
|
|
622
|
+
observe(value: number, labels?: MetricLabels): void;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
export interface MetricOptions {
|
|
626
|
+
/** Label names. Every update must pass exactly these. */
|
|
627
|
+
labels?: readonly string[];
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
export interface MetricsRegistry {
|
|
631
|
+
/**
|
|
632
|
+
* Metrics are exported as `qq_bot_plugin_<plugin>_<name>`. Keep label values
|
|
633
|
+
* low-cardinality (a few dozen at most): never a user or message id.
|
|
634
|
+
*/
|
|
635
|
+
counter(name: string, help: string, options?: MetricOptions): Counter;
|
|
636
|
+
gauge(name: string, help: string, options?: MetricOptions): Gauge;
|
|
637
|
+
histogram(
|
|
638
|
+
name: string,
|
|
639
|
+
help: string,
|
|
640
|
+
options?: MetricOptions & { buckets?: readonly number[] }
|
|
641
|
+
): Histogram;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
export interface ScheduleOptions {
|
|
645
|
+
runImmediately?: boolean;
|
|
646
|
+
overlap?: "skip" | "allow";
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
export interface CronOptions {
|
|
650
|
+
/** Defaults to the process local time. */
|
|
651
|
+
timezone?: "local" | "utc";
|
|
652
|
+
overlap?: "skip" | "allow";
|
|
653
|
+
/**
|
|
654
|
+
* Run once at startup when at least one fire time was missed while the bot
|
|
655
|
+
* was down. The last run is persisted per task.
|
|
656
|
+
*/
|
|
657
|
+
catchUp?: boolean;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
export interface Scheduler {
|
|
661
|
+
every(
|
|
662
|
+
name: string,
|
|
663
|
+
intervalMs: number,
|
|
664
|
+
task: (signal: AbortSignal) => Awaitable<void>,
|
|
665
|
+
options?: ScheduleOptions
|
|
666
|
+
): Dispose;
|
|
667
|
+
/**
|
|
668
|
+
* Five-field cron (`minute hour day-of-month month day-of-week`) with `*`,
|
|
669
|
+
* lists, ranges and `/step`. When both day fields are restricted a day
|
|
670
|
+
* matches if either does, as in classic cron.
|
|
671
|
+
*/
|
|
672
|
+
cron(
|
|
673
|
+
name: string,
|
|
674
|
+
expression: string,
|
|
675
|
+
task: (signal: AbortSignal) => Awaitable<void>,
|
|
676
|
+
options?: CronOptions
|
|
677
|
+
): Dispose;
|
|
678
|
+
/** Runs once at `when` (immediately when it is already past). */
|
|
679
|
+
at(
|
|
680
|
+
name: string,
|
|
681
|
+
when: Date,
|
|
682
|
+
task: (signal: AbortSignal) => Awaitable<void>
|
|
683
|
+
): Dispose;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
export interface KeyValueEntry<T> {
|
|
687
|
+
key: string;
|
|
688
|
+
value: T;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
export interface KeyValueListOptions {
|
|
692
|
+
// `| undefined` is explicit because the workspace compiles with
|
|
693
|
+
// `exactOptionalPropertyTypes`: callers naturally hold `string | undefined`
|
|
694
|
+
// (e.g. `entries.at(-1)?.key`) and should not have to narrow it first.
|
|
695
|
+
/** Maximum number of entries to return. Implementations may cap this. */
|
|
696
|
+
limit?: number | undefined;
|
|
697
|
+
/** Exclusive lower bound, for paging through a large prefix. */
|
|
698
|
+
after?: string | undefined;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
export interface KeyValueSetOptions {
|
|
702
|
+
/**
|
|
703
|
+
* Expire the entry after this many milliseconds. Expired entries read as
|
|
704
|
+
* missing and are skipped by `list`. Stores that cannot expire entries
|
|
705
|
+
* ignore it, so treat it as a space optimisation, not as a guarantee.
|
|
706
|
+
* `update` keeps the entry's existing expiry.
|
|
707
|
+
*/
|
|
708
|
+
ttlMs?: number | undefined;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
export interface KeyValueStore {
|
|
712
|
+
get<T>(key: string): Promise<T | undefined>;
|
|
713
|
+
set<T>(key: string, value: T, options?: KeyValueSetOptions): Promise<void>;
|
|
714
|
+
delete(key: string): Promise<boolean>;
|
|
715
|
+
update<T>(
|
|
716
|
+
key: string,
|
|
717
|
+
updater: (current: T | undefined) => T | undefined
|
|
718
|
+
): Promise<T | undefined>;
|
|
719
|
+
/**
|
|
720
|
+
* Lists the entries whose key starts with `prefix`, in ascending key order.
|
|
721
|
+
*
|
|
722
|
+
* Optional, because not every backing store can scan keys. Callers must
|
|
723
|
+
* treat a missing implementation as "enumeration is unavailable" and never
|
|
724
|
+
* as "there are no entries" — see `supportsListing()`.
|
|
725
|
+
*/
|
|
726
|
+
list?<T>(
|
|
727
|
+
prefix: string,
|
|
728
|
+
options?: KeyValueListOptions
|
|
729
|
+
): Promise<KeyValueEntry<T>[]>;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
export interface ListableKeyValueStore extends KeyValueStore {
|
|
733
|
+
list<T>(
|
|
734
|
+
prefix: string,
|
|
735
|
+
options?: KeyValueListOptions
|
|
736
|
+
): Promise<KeyValueEntry<T>[]>;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
export function supportsListing(
|
|
740
|
+
store: KeyValueStore
|
|
741
|
+
): store is ListableKeyValueStore {
|
|
742
|
+
return typeof store.list === "function";
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
export interface ConversationRef {
|
|
746
|
+
platform: string;
|
|
747
|
+
scope: ChatScope;
|
|
748
|
+
conversationId: string;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
export type SettingsScope =
|
|
752
|
+
| { level: "global" }
|
|
753
|
+
| { level: "platform"; platform: string }
|
|
754
|
+
| { level: "chat"; platform: string; scope: ChatScope }
|
|
755
|
+
| {
|
|
756
|
+
level: "conversation";
|
|
757
|
+
platform: string;
|
|
758
|
+
scope: ChatScope;
|
|
759
|
+
conversationId: string;
|
|
760
|
+
};
|
|
761
|
+
|
|
762
|
+
export type DeepPartial<T> = T extends readonly unknown[]
|
|
763
|
+
? T
|
|
764
|
+
: T extends object
|
|
765
|
+
? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
766
|
+
: T;
|
|
767
|
+
|
|
768
|
+
export type DeepReadonly<T> = T extends (...args: never[]) => unknown
|
|
769
|
+
? T
|
|
770
|
+
: T extends readonly (infer TItem)[]
|
|
771
|
+
? readonly DeepReadonly<TItem>[]
|
|
772
|
+
: T extends object
|
|
773
|
+
? { readonly [K in keyof T]: DeepReadonly<T[K]> }
|
|
774
|
+
: T;
|
|
775
|
+
|
|
776
|
+
export interface SettingsSchema<T> {
|
|
777
|
+
parse(value: unknown): T;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
export interface SettingsDefinition<T extends object> {
|
|
781
|
+
key?: string;
|
|
782
|
+
defaults: T;
|
|
783
|
+
schema?: SettingsSchema<T>;
|
|
784
|
+
version?: number;
|
|
785
|
+
migrate?: (stored: unknown, fromVersion: number) => unknown;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
export interface SettingsInspection<T extends object> {
|
|
789
|
+
value: T;
|
|
790
|
+
layers: {
|
|
791
|
+
defaults: T;
|
|
792
|
+
global?: DeepPartial<T>;
|
|
793
|
+
platform?: DeepPartial<T>;
|
|
794
|
+
chat?: DeepPartial<T>;
|
|
795
|
+
conversation?: DeepPartial<T>;
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
export interface ScopedSettings<T extends object> {
|
|
800
|
+
get(target: ConversationRef): Promise<T>;
|
|
801
|
+
inspect(target: ConversationRef): Promise<SettingsInspection<T>>;
|
|
802
|
+
getOverrides(scope: SettingsScope): Promise<DeepPartial<T> | undefined>;
|
|
803
|
+
set(scope: SettingsScope, overrides: DeepPartial<T>): Promise<T>;
|
|
804
|
+
update(
|
|
805
|
+
scope: SettingsScope,
|
|
806
|
+
updater: (current: DeepPartial<T>) => DeepPartial<T>
|
|
807
|
+
): Promise<T>;
|
|
808
|
+
reset(scope: SettingsScope): Promise<boolean>;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
export interface SettingsRegistry {
|
|
812
|
+
define<T extends object>(
|
|
813
|
+
definition: SettingsDefinition<T>
|
|
814
|
+
): ScopedSettings<T>;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
export interface ScopedStateRegistry {
|
|
818
|
+
forConversation(target: ConversationRef): KeyValueStore;
|
|
819
|
+
forScope(scope: SettingsScope): KeyValueStore;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
export interface ServiceToken<T> {
|
|
823
|
+
readonly id: symbol;
|
|
824
|
+
readonly name: string;
|
|
825
|
+
readonly _type?: (value: T) => T;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
export function createServiceToken<T>(name: string): ServiceToken<T> {
|
|
829
|
+
if (name.trim().length === 0) {
|
|
830
|
+
throw new Error("service token name cannot be empty");
|
|
831
|
+
}
|
|
832
|
+
return Object.freeze({
|
|
833
|
+
id: Symbol(name),
|
|
834
|
+
name
|
|
835
|
+
}) as ServiceToken<T>;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
export interface ServiceRegistry {
|
|
839
|
+
provide<T>(token: ServiceToken<T>, service: T): Dispose;
|
|
840
|
+
get<T>(token: ServiceToken<T>): T;
|
|
841
|
+
has<T>(token: ServiceToken<T>): boolean;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* Capabilities a host adds with a context extension. Augment it to type them:
|
|
846
|
+
*
|
|
847
|
+
* ```ts
|
|
848
|
+
* declare module "@umx-bot/plugin-sdk" {
|
|
849
|
+
* interface PluginContextExtensions { readonly db: MyDatabase }
|
|
850
|
+
* }
|
|
851
|
+
* ```
|
|
852
|
+
* and declare `requires: ["db"]` so the plugin fails to load, with a clear
|
|
853
|
+
* message, on a host that does not provide it.
|
|
854
|
+
*/
|
|
855
|
+
// biome-ignore lint/suspicious/noEmptyInterface: augmentation point
|
|
856
|
+
export interface PluginContextExtensions {}
|
|
857
|
+
|
|
858
|
+
export interface PluginContext<TConfig extends object = Record<string, unknown>>
|
|
859
|
+
extends PluginContextExtensions {
|
|
860
|
+
readonly pluginName: string;
|
|
861
|
+
/**
|
|
862
|
+
* Host-provided, validated startup configuration. Conversation-adjustable
|
|
863
|
+
* settings belong in `settings` instead.
|
|
864
|
+
*/
|
|
865
|
+
readonly config: DeepReadonly<TConfig>;
|
|
866
|
+
readonly signal: AbortSignal;
|
|
867
|
+
readonly events: EventSubscriber & EventPublisher;
|
|
868
|
+
readonly commands: CommandRegistry;
|
|
869
|
+
readonly navigation: NavigationRegistry;
|
|
870
|
+
readonly middleware: MiddlewareRegistry;
|
|
871
|
+
readonly outbound: OutboundRegistry;
|
|
872
|
+
readonly interactions: InteractionRegistry;
|
|
873
|
+
readonly metrics: MetricsRegistry;
|
|
874
|
+
readonly messages: MessageSender;
|
|
875
|
+
readonly scheduler: Scheduler;
|
|
876
|
+
readonly store: KeyValueStore;
|
|
877
|
+
readonly settings: SettingsRegistry;
|
|
878
|
+
readonly state: ScopedStateRegistry;
|
|
879
|
+
readonly services: ServiceRegistry;
|
|
880
|
+
readonly logger: Logger;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
export interface PluginConfigurationDefinition<TConfig extends object> {
|
|
884
|
+
parse(value: unknown): TConfig;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
export interface BotPlugin<TConfig extends object = object> {
|
|
888
|
+
name: string;
|
|
889
|
+
version: string;
|
|
890
|
+
/** Plugin contract version. Omitted values are always treated as legacy API v1. */
|
|
891
|
+
apiVersion?: number;
|
|
892
|
+
description?: string;
|
|
893
|
+
help?: PluginHelpDefinition;
|
|
894
|
+
dependencies?: PluginDependency[];
|
|
895
|
+
/**
|
|
896
|
+
* Powers this plugin needs. Declaring any switches the plugin to the
|
|
897
|
+
* restricted model: powers not listed (or not granted by the manifest) throw
|
|
898
|
+
* `PermissionError` when used. Omit for the legacy unrestricted behaviour.
|
|
899
|
+
*/
|
|
900
|
+
permissions?: readonly PluginPermission[];
|
|
901
|
+
/**
|
|
902
|
+
* Host capabilities the plugin cannot work without: `messages.recall`,
|
|
903
|
+
* `messages.typing`, `messages.stream`, or the name of a context extension.
|
|
904
|
+
* Checked at load time.
|
|
905
|
+
*/
|
|
906
|
+
requires?: readonly string[];
|
|
907
|
+
configuration?: PluginConfigurationDefinition<TConfig>;
|
|
908
|
+
setup(context: PluginContext<TConfig>): Awaitable<void | Dispose>;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
export type PluginDependency =
|
|
912
|
+
| string
|
|
913
|
+
| {
|
|
914
|
+
name: string;
|
|
915
|
+
/** Supported SemVer range, for example ^1.2.0 or >=1.2.0 <2.0.0. */
|
|
916
|
+
version?: string;
|
|
917
|
+
optional?: boolean;
|
|
918
|
+
};
|
|
919
|
+
|
|
920
|
+
export function definePlugin<TConfig extends object>(
|
|
921
|
+
plugin: BotPlugin<TConfig> & {
|
|
922
|
+
configuration: PluginConfigurationDefinition<TConfig>;
|
|
923
|
+
}
|
|
924
|
+
): BotPlugin<TConfig>;
|
|
925
|
+
export function definePlugin(
|
|
926
|
+
plugin: BotPlugin<Record<string, unknown>>
|
|
927
|
+
): BotPlugin<Record<string, unknown>>;
|
|
928
|
+
export function definePlugin<TConfig extends object>(
|
|
929
|
+
plugin: BotPlugin<TConfig>
|
|
930
|
+
): BotPlugin<TConfig> {
|
|
931
|
+
return plugin;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
export interface BotAdapter {
|
|
935
|
+
readonly name: string;
|
|
936
|
+
start(
|
|
937
|
+
onMessage: (message: IncomingMessage) => Awaitable<void>,
|
|
938
|
+
onEvent?: <K extends Exclude<keyof BotEvents, "message.created">>(
|
|
939
|
+
event: K,
|
|
940
|
+
payload: BotEvents[K]
|
|
941
|
+
) => Awaitable<void>
|
|
942
|
+
): Promise<void>;
|
|
943
|
+
stop(): Promise<void>;
|
|
944
|
+
send(message: OutgoingMessage): Promise<SentMessage>;
|
|
945
|
+
recall?(message: SentMessage): Promise<void>;
|
|
946
|
+
setTyping?(
|
|
947
|
+
conversation: ConversationRef,
|
|
948
|
+
seconds: number,
|
|
949
|
+
target: ReplyTarget
|
|
950
|
+
): Promise<void>;
|
|
951
|
+
openMessageStream?(options: MessageStreamOptions): Promise<MessageStream>;
|
|
952
|
+
checkHealth?(): Promise<void>;
|
|
953
|
+
syncNavigation?(pages: readonly NavigationPageSummary[]): Promise<void>;
|
|
954
|
+
getDiagnostics?(): Readonly<Record<string, unknown>>;
|
|
955
|
+
}
|