@nekro-nxt/contracts 0.4.0 → 0.5.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/README.md +2 -0
- package/dist/index.mjs +2041 -58
- package/dist/index.mjs.map +1 -1
- package/lib/types/commands.d.ts +408 -0
- package/lib/types/commands.d.ts.map +1 -0
- package/lib/types/community-feedback-host.d.ts +442 -0
- package/lib/types/community-feedback-host.d.ts.map +1 -0
- package/lib/types/community-feedback.d.ts +1072 -0
- package/lib/types/community-feedback.d.ts.map +1 -0
- package/lib/types/community-personas.d.ts +4 -0
- package/lib/types/community-personas.d.ts.map +1 -1
- package/lib/types/community.d.ts +251 -13
- package/lib/types/community.d.ts.map +1 -1
- package/lib/types/domain.d.ts +33 -0
- package/lib/types/domain.d.ts.map +1 -1
- package/lib/types/extension-capabilities.d.ts +5 -2
- package/lib/types/extension-capabilities.d.ts.map +1 -1
- package/lib/types/extension-ui.d.ts +4 -4
- package/lib/types/host-api.d.ts +10163 -4331
- package/lib/types/host-api.d.ts.map +1 -1
- package/lib/types/index.d.ts +4 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/logs.d.ts +355 -0
- package/lib/types/logs.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/commands.ts +366 -0
- package/src/community-feedback-host.ts +121 -0
- package/src/community-feedback.ts +289 -0
- package/src/community.ts +56 -1
- package/src/domain.ts +59 -6
- package/src/extension-capabilities.ts +9 -2
- package/src/host-api.ts +1170 -56
- package/src/index.ts +5 -0
- package/src/logs.ts +138 -0
- package/src/management-api.ts +1 -1
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type AgentId, type ChannelId, type ChannelMemberId, type MessagePart } from './domain.js';
|
|
3
|
+
export declare const COMMAND_DEFAULT_TIMEOUT_SECONDS = 60;
|
|
4
|
+
export declare const COMMAND_MAX_TIMEOUT_SECONDS = 600;
|
|
5
|
+
/**
|
|
6
|
+
* Who may run a command. `channel-admin` is granted per channel; `admin` is an instance administrator (the signed-in
|
|
7
|
+
* console or a platform account listed in Settings → Administrators) and also holds every channel's `channel-admin`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const CommandPermissionSchema: z.ZodEnum<{
|
|
10
|
+
public: "public";
|
|
11
|
+
"channel-admin": "channel-admin";
|
|
12
|
+
admin: "admin";
|
|
13
|
+
}>;
|
|
14
|
+
export type CommandPermission = z.output<typeof CommandPermissionSchema>;
|
|
15
|
+
export declare const CommandParameterSchema: z.ZodObject<{
|
|
16
|
+
name: z.ZodString;
|
|
17
|
+
description: z.ZodOptional<z.ZodString>;
|
|
18
|
+
kind: z.ZodEnum<{
|
|
19
|
+
positional: "positional";
|
|
20
|
+
option: "option";
|
|
21
|
+
}>;
|
|
22
|
+
type: z.ZodEnum<{
|
|
23
|
+
string: "string";
|
|
24
|
+
number: "number";
|
|
25
|
+
boolean: "boolean";
|
|
26
|
+
integer: "integer";
|
|
27
|
+
}>;
|
|
28
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
29
|
+
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
30
|
+
choices: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
31
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
32
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
33
|
+
}, z.core.$strict>;
|
|
34
|
+
export declare const CommandDefinitionSchema: z.ZodObject<{
|
|
35
|
+
name: z.ZodString;
|
|
36
|
+
aliases: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
37
|
+
description: z.ZodString;
|
|
38
|
+
parameters: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
39
|
+
name: z.ZodString;
|
|
40
|
+
description: z.ZodOptional<z.ZodString>;
|
|
41
|
+
kind: z.ZodEnum<{
|
|
42
|
+
positional: "positional";
|
|
43
|
+
option: "option";
|
|
44
|
+
}>;
|
|
45
|
+
type: z.ZodEnum<{
|
|
46
|
+
string: "string";
|
|
47
|
+
number: "number";
|
|
48
|
+
boolean: "boolean";
|
|
49
|
+
integer: "integer";
|
|
50
|
+
}>;
|
|
51
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
52
|
+
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
53
|
+
choices: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
54
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
55
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
56
|
+
}, z.core.$strict>>>;
|
|
57
|
+
examples: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
58
|
+
minimumPermission: z.ZodDefault<z.ZodEnum<{
|
|
59
|
+
public: "public";
|
|
60
|
+
"channel-admin": "channel-admin";
|
|
61
|
+
admin: "admin";
|
|
62
|
+
}>>;
|
|
63
|
+
enabledByDefault: z.ZodDefault<z.ZodBoolean>;
|
|
64
|
+
consoleReply: z.ZodDefault<z.ZodEnum<{
|
|
65
|
+
channel: "channel";
|
|
66
|
+
local: "local";
|
|
67
|
+
}>>;
|
|
68
|
+
timeoutSeconds: z.ZodDefault<z.ZodNumber>;
|
|
69
|
+
}, z.core.$strict>;
|
|
70
|
+
export type CommandDefinition = z.output<typeof CommandDefinitionSchema>;
|
|
71
|
+
/** What an extension author writes: defaults are optional. */
|
|
72
|
+
export type CommandDefinitionInput = z.input<typeof CommandDefinitionSchema>;
|
|
73
|
+
export declare const CommandPolicySchema: z.ZodObject<{
|
|
74
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
75
|
+
permission: z.ZodOptional<z.ZodEnum<{
|
|
76
|
+
public: "public";
|
|
77
|
+
"channel-admin": "channel-admin";
|
|
78
|
+
admin: "admin";
|
|
79
|
+
}>>;
|
|
80
|
+
}, z.core.$strict>;
|
|
81
|
+
export type CommandPolicy = z.output<typeof CommandPolicySchema>;
|
|
82
|
+
export declare const CommandExecutionIdentitySchema: z.ZodObject<{
|
|
83
|
+
source: z.ZodEnum<{
|
|
84
|
+
web: "web";
|
|
85
|
+
platform: "platform";
|
|
86
|
+
}>;
|
|
87
|
+
connectionId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "ConnectionId", "out">>;
|
|
88
|
+
platformUserId: z.ZodOptional<z.ZodString>;
|
|
89
|
+
displayName: z.ZodString;
|
|
90
|
+
viewerId: z.ZodOptional<z.ZodString>;
|
|
91
|
+
}, z.core.$strict>;
|
|
92
|
+
export type CommandExecutionIdentity = z.output<typeof CommandExecutionIdentitySchema>;
|
|
93
|
+
export declare const CommandResultSchema: z.ZodObject<{
|
|
94
|
+
parts: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
95
|
+
type: z.ZodLiteral<"text">;
|
|
96
|
+
text: z.ZodString;
|
|
97
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
98
|
+
type: z.ZodLiteral<"mention">;
|
|
99
|
+
memberId: z.core.$ZodBranded<z.ZodString, "ChannelMemberId", "out">;
|
|
100
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
101
|
+
type: z.ZodLiteral<"image">;
|
|
102
|
+
assetId: z.core.$ZodBranded<z.ZodString, "AssetId", "out">;
|
|
103
|
+
alt: z.ZodOptional<z.ZodString>;
|
|
104
|
+
sticker: z.ZodOptional<z.ZodLiteral<true>>;
|
|
105
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
106
|
+
type: z.ZodLiteral<"file">;
|
|
107
|
+
assetId: z.core.$ZodBranded<z.ZodString, "AssetId", "out">;
|
|
108
|
+
name: z.ZodOptional<z.ZodString>;
|
|
109
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
110
|
+
type: z.ZodLiteral<"audio">;
|
|
111
|
+
assetId: z.core.$ZodBranded<z.ZodString, "AssetId", "out">;
|
|
112
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
113
|
+
type: z.ZodLiteral<"quote">;
|
|
114
|
+
messageId: z.core.$ZodBranded<z.ZodString, "LogicalMessageId", "out">;
|
|
115
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
116
|
+
type: z.ZodLiteral<"rich">;
|
|
117
|
+
adapterKey: z.ZodString;
|
|
118
|
+
kind: z.ZodString;
|
|
119
|
+
summary: z.ZodString;
|
|
120
|
+
title: z.ZodOptional<z.ZodString>;
|
|
121
|
+
source: z.ZodOptional<z.ZodString>;
|
|
122
|
+
targetUrl: z.ZodOptional<z.ZodURL>;
|
|
123
|
+
previewAssetId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "AssetId", "out">>;
|
|
124
|
+
extension: z.ZodOptional<z.ZodJSONSchema>;
|
|
125
|
+
}, z.core.$strict>], "type">>;
|
|
126
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
127
|
+
}, z.core.$strict>;
|
|
128
|
+
export type CommandResult = z.output<typeof CommandResultSchema>;
|
|
129
|
+
/** An execution may send a few progress replies before its final result. */
|
|
130
|
+
export declare const COMMAND_MAX_PROGRESS_REPLIES = 5;
|
|
131
|
+
export declare const CommandReplySchema: z.ZodObject<{
|
|
132
|
+
ordinal: z.ZodNumber;
|
|
133
|
+
kind: z.ZodEnum<{
|
|
134
|
+
progress: "progress";
|
|
135
|
+
final: "final";
|
|
136
|
+
}>;
|
|
137
|
+
parts: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
138
|
+
type: z.ZodLiteral<"text">;
|
|
139
|
+
text: z.ZodString;
|
|
140
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
141
|
+
type: z.ZodLiteral<"mention">;
|
|
142
|
+
memberId: z.core.$ZodBranded<z.ZodString, "ChannelMemberId", "out">;
|
|
143
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
144
|
+
type: z.ZodLiteral<"image">;
|
|
145
|
+
assetId: z.core.$ZodBranded<z.ZodString, "AssetId", "out">;
|
|
146
|
+
alt: z.ZodOptional<z.ZodString>;
|
|
147
|
+
sticker: z.ZodOptional<z.ZodLiteral<true>>;
|
|
148
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
149
|
+
type: z.ZodLiteral<"file">;
|
|
150
|
+
assetId: z.core.$ZodBranded<z.ZodString, "AssetId", "out">;
|
|
151
|
+
name: z.ZodOptional<z.ZodString>;
|
|
152
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
153
|
+
type: z.ZodLiteral<"audio">;
|
|
154
|
+
assetId: z.core.$ZodBranded<z.ZodString, "AssetId", "out">;
|
|
155
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
156
|
+
type: z.ZodLiteral<"quote">;
|
|
157
|
+
messageId: z.core.$ZodBranded<z.ZodString, "LogicalMessageId", "out">;
|
|
158
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
159
|
+
type: z.ZodLiteral<"rich">;
|
|
160
|
+
adapterKey: z.ZodString;
|
|
161
|
+
kind: z.ZodString;
|
|
162
|
+
summary: z.ZodString;
|
|
163
|
+
title: z.ZodOptional<z.ZodString>;
|
|
164
|
+
source: z.ZodOptional<z.ZodString>;
|
|
165
|
+
targetUrl: z.ZodOptional<z.ZodURL>;
|
|
166
|
+
previewAssetId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "AssetId", "out">>;
|
|
167
|
+
extension: z.ZodOptional<z.ZodJSONSchema>;
|
|
168
|
+
}, z.core.$strict>], "type">>;
|
|
169
|
+
intentId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "OutboundIntentId", "out">>;
|
|
170
|
+
error: z.ZodOptional<z.ZodString>;
|
|
171
|
+
}, z.core.$strict>;
|
|
172
|
+
export type CommandReply = z.output<typeof CommandReplySchema>;
|
|
173
|
+
export declare const CommandExecutionRecordSchema: z.ZodObject<{
|
|
174
|
+
id: z.ZodString;
|
|
175
|
+
channelId: z.core.$ZodBranded<z.ZodString, "ChannelId", "out">;
|
|
176
|
+
source: z.ZodEnum<{
|
|
177
|
+
web: "web";
|
|
178
|
+
platform: "platform";
|
|
179
|
+
}>;
|
|
180
|
+
requestId: z.ZodString;
|
|
181
|
+
eventId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "ChannelEventId", "out">>;
|
|
182
|
+
rawText: z.ZodString;
|
|
183
|
+
identity: z.ZodObject<{
|
|
184
|
+
source: z.ZodEnum<{
|
|
185
|
+
web: "web";
|
|
186
|
+
platform: "platform";
|
|
187
|
+
}>;
|
|
188
|
+
connectionId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "ConnectionId", "out">>;
|
|
189
|
+
platformUserId: z.ZodOptional<z.ZodString>;
|
|
190
|
+
displayName: z.ZodString;
|
|
191
|
+
viewerId: z.ZodOptional<z.ZodString>;
|
|
192
|
+
}, z.core.$strict>;
|
|
193
|
+
commandName: z.ZodOptional<z.ZodString>;
|
|
194
|
+
commandVersion: z.ZodOptional<z.ZodString>;
|
|
195
|
+
extensionRevisionId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "ExtensionRevisionId", "out">>;
|
|
196
|
+
agentId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "AgentId", "out">>;
|
|
197
|
+
agentRevisionId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "AgentRevisionId", "out">>;
|
|
198
|
+
status: z.ZodEnum<{
|
|
199
|
+
failed: "failed";
|
|
200
|
+
pending: "pending";
|
|
201
|
+
running: "running";
|
|
202
|
+
succeeded: "succeeded";
|
|
203
|
+
uncertain: "uncertain";
|
|
204
|
+
}>;
|
|
205
|
+
result: z.ZodOptional<z.ZodObject<{
|
|
206
|
+
parts: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
207
|
+
type: z.ZodLiteral<"text">;
|
|
208
|
+
text: z.ZodString;
|
|
209
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
210
|
+
type: z.ZodLiteral<"mention">;
|
|
211
|
+
memberId: z.core.$ZodBranded<z.ZodString, "ChannelMemberId", "out">;
|
|
212
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
213
|
+
type: z.ZodLiteral<"image">;
|
|
214
|
+
assetId: z.core.$ZodBranded<z.ZodString, "AssetId", "out">;
|
|
215
|
+
alt: z.ZodOptional<z.ZodString>;
|
|
216
|
+
sticker: z.ZodOptional<z.ZodLiteral<true>>;
|
|
217
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
218
|
+
type: z.ZodLiteral<"file">;
|
|
219
|
+
assetId: z.core.$ZodBranded<z.ZodString, "AssetId", "out">;
|
|
220
|
+
name: z.ZodOptional<z.ZodString>;
|
|
221
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
222
|
+
type: z.ZodLiteral<"audio">;
|
|
223
|
+
assetId: z.core.$ZodBranded<z.ZodString, "AssetId", "out">;
|
|
224
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
225
|
+
type: z.ZodLiteral<"quote">;
|
|
226
|
+
messageId: z.core.$ZodBranded<z.ZodString, "LogicalMessageId", "out">;
|
|
227
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
228
|
+
type: z.ZodLiteral<"rich">;
|
|
229
|
+
adapterKey: z.ZodString;
|
|
230
|
+
kind: z.ZodString;
|
|
231
|
+
summary: z.ZodString;
|
|
232
|
+
title: z.ZodOptional<z.ZodString>;
|
|
233
|
+
source: z.ZodOptional<z.ZodString>;
|
|
234
|
+
targetUrl: z.ZodOptional<z.ZodURL>;
|
|
235
|
+
previewAssetId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "AssetId", "out">>;
|
|
236
|
+
extension: z.ZodOptional<z.ZodJSONSchema>;
|
|
237
|
+
}, z.core.$strict>], "type">>;
|
|
238
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
239
|
+
}, z.core.$strict>>;
|
|
240
|
+
error: z.ZodOptional<z.ZodString>;
|
|
241
|
+
replies: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
242
|
+
ordinal: z.ZodNumber;
|
|
243
|
+
kind: z.ZodEnum<{
|
|
244
|
+
progress: "progress";
|
|
245
|
+
final: "final";
|
|
246
|
+
}>;
|
|
247
|
+
parts: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
248
|
+
type: z.ZodLiteral<"text">;
|
|
249
|
+
text: z.ZodString;
|
|
250
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
251
|
+
type: z.ZodLiteral<"mention">;
|
|
252
|
+
memberId: z.core.$ZodBranded<z.ZodString, "ChannelMemberId", "out">;
|
|
253
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
254
|
+
type: z.ZodLiteral<"image">;
|
|
255
|
+
assetId: z.core.$ZodBranded<z.ZodString, "AssetId", "out">;
|
|
256
|
+
alt: z.ZodOptional<z.ZodString>;
|
|
257
|
+
sticker: z.ZodOptional<z.ZodLiteral<true>>;
|
|
258
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
259
|
+
type: z.ZodLiteral<"file">;
|
|
260
|
+
assetId: z.core.$ZodBranded<z.ZodString, "AssetId", "out">;
|
|
261
|
+
name: z.ZodOptional<z.ZodString>;
|
|
262
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
263
|
+
type: z.ZodLiteral<"audio">;
|
|
264
|
+
assetId: z.core.$ZodBranded<z.ZodString, "AssetId", "out">;
|
|
265
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
266
|
+
type: z.ZodLiteral<"quote">;
|
|
267
|
+
messageId: z.core.$ZodBranded<z.ZodString, "LogicalMessageId", "out">;
|
|
268
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
269
|
+
type: z.ZodLiteral<"rich">;
|
|
270
|
+
adapterKey: z.ZodString;
|
|
271
|
+
kind: z.ZodString;
|
|
272
|
+
summary: z.ZodString;
|
|
273
|
+
title: z.ZodOptional<z.ZodString>;
|
|
274
|
+
source: z.ZodOptional<z.ZodString>;
|
|
275
|
+
targetUrl: z.ZodOptional<z.ZodURL>;
|
|
276
|
+
previewAssetId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "AssetId", "out">>;
|
|
277
|
+
extension: z.ZodOptional<z.ZodJSONSchema>;
|
|
278
|
+
}, z.core.$strict>], "type">>;
|
|
279
|
+
intentId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "OutboundIntentId", "out">>;
|
|
280
|
+
error: z.ZodOptional<z.ZodString>;
|
|
281
|
+
}, z.core.$strict>>>;
|
|
282
|
+
replySuppressed: z.ZodOptional<z.ZodBoolean>;
|
|
283
|
+
replyLocal: z.ZodOptional<z.ZodBoolean>;
|
|
284
|
+
createdAt: z.ZodNumber;
|
|
285
|
+
completedAt: z.ZodOptional<z.ZodNumber>;
|
|
286
|
+
}, z.core.$strict>;
|
|
287
|
+
export type CommandExecutionRecord = z.output<typeof CommandExecutionRecordSchema>;
|
|
288
|
+
/** Replies that still need an Outbound or a recorded failure. */
|
|
289
|
+
export declare const undeliveredCommandReplies: (record: CommandExecutionRecord) => readonly CommandReply[];
|
|
290
|
+
export interface CommandExecutionContext {
|
|
291
|
+
readonly channelId: ChannelId;
|
|
292
|
+
readonly agentId?: AgentId;
|
|
293
|
+
readonly identity: CommandExecutionIdentity;
|
|
294
|
+
readonly arguments: Readonly<Record<string, string | number | boolean>>;
|
|
295
|
+
readonly signal: AbortSignal;
|
|
296
|
+
/**
|
|
297
|
+
* Sends a progress reply now; the handler's return value is the final result. At most
|
|
298
|
+
* COMMAND_MAX_PROGRESS_REPLIES per execution, delivered in order without making the handler wait for receipts.
|
|
299
|
+
*/
|
|
300
|
+
readonly reply: (result: CommandResult) => void;
|
|
301
|
+
readonly host: {
|
|
302
|
+
status(): {
|
|
303
|
+
readonly bound: boolean;
|
|
304
|
+
readonly responseMode?: string;
|
|
305
|
+
readonly paused?: boolean;
|
|
306
|
+
readonly running: boolean;
|
|
307
|
+
};
|
|
308
|
+
/** Resolves with `stopped: false` when nothing was running. */
|
|
309
|
+
stop(): Promise<{
|
|
310
|
+
readonly stopped: boolean;
|
|
311
|
+
}>;
|
|
312
|
+
reset(mode: 'clear' | 'compact'): Promise<void>;
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
export type CommandHandler = (context: CommandExecutionContext) => CommandResult | Promise<CommandResult>;
|
|
316
|
+
export declare const CommandCatalogEntrySchema: z.ZodObject<{
|
|
317
|
+
definition: z.ZodObject<{
|
|
318
|
+
name: z.ZodString;
|
|
319
|
+
aliases: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
320
|
+
description: z.ZodString;
|
|
321
|
+
parameters: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
322
|
+
name: z.ZodString;
|
|
323
|
+
description: z.ZodOptional<z.ZodString>;
|
|
324
|
+
kind: z.ZodEnum<{
|
|
325
|
+
positional: "positional";
|
|
326
|
+
option: "option";
|
|
327
|
+
}>;
|
|
328
|
+
type: z.ZodEnum<{
|
|
329
|
+
string: "string";
|
|
330
|
+
number: "number";
|
|
331
|
+
boolean: "boolean";
|
|
332
|
+
integer: "integer";
|
|
333
|
+
}>;
|
|
334
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
335
|
+
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
336
|
+
choices: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
337
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
338
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
339
|
+
}, z.core.$strict>>>;
|
|
340
|
+
examples: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
341
|
+
minimumPermission: z.ZodDefault<z.ZodEnum<{
|
|
342
|
+
public: "public";
|
|
343
|
+
"channel-admin": "channel-admin";
|
|
344
|
+
admin: "admin";
|
|
345
|
+
}>>;
|
|
346
|
+
enabledByDefault: z.ZodDefault<z.ZodBoolean>;
|
|
347
|
+
consoleReply: z.ZodDefault<z.ZodEnum<{
|
|
348
|
+
channel: "channel";
|
|
349
|
+
local: "local";
|
|
350
|
+
}>>;
|
|
351
|
+
timeoutSeconds: z.ZodDefault<z.ZodNumber>;
|
|
352
|
+
}, z.core.$strict>;
|
|
353
|
+
fullName: z.ZodString;
|
|
354
|
+
source: z.ZodString;
|
|
355
|
+
extensionRevisionId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "ExtensionRevisionId", "out">>;
|
|
356
|
+
enabled: z.ZodBoolean;
|
|
357
|
+
permission: z.ZodEnum<{
|
|
358
|
+
public: "public";
|
|
359
|
+
"channel-admin": "channel-admin";
|
|
360
|
+
admin: "admin";
|
|
361
|
+
}>;
|
|
362
|
+
usage: z.ZodString;
|
|
363
|
+
available: z.ZodBoolean;
|
|
364
|
+
unavailableReason: z.ZodOptional<z.ZodString>;
|
|
365
|
+
globalPolicy: z.ZodOptional<z.ZodObject<{
|
|
366
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
367
|
+
permission: z.ZodOptional<z.ZodEnum<{
|
|
368
|
+
public: "public";
|
|
369
|
+
"channel-admin": "channel-admin";
|
|
370
|
+
admin: "admin";
|
|
371
|
+
}>>;
|
|
372
|
+
}, z.core.$strict>>;
|
|
373
|
+
channelPolicy: z.ZodOptional<z.ZodObject<{
|
|
374
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
375
|
+
permission: z.ZodOptional<z.ZodEnum<{
|
|
376
|
+
public: "public";
|
|
377
|
+
"channel-admin": "channel-admin";
|
|
378
|
+
admin: "admin";
|
|
379
|
+
}>>;
|
|
380
|
+
}, z.core.$strict>>;
|
|
381
|
+
}, z.core.$strict>;
|
|
382
|
+
export type CommandCatalogEntry = z.output<typeof CommandCatalogEntrySchema>;
|
|
383
|
+
/** Shell-like quoting without evaluation or interpolation. */
|
|
384
|
+
export declare function tokenizeCommand(text: string): string[];
|
|
385
|
+
export declare function parseCommandArguments(definition: CommandDefinition, tokens: readonly string[]): Readonly<Record<string, string | number | boolean>>;
|
|
386
|
+
export declare function commandUsage(definition: CommandDefinition, name?: string): string;
|
|
387
|
+
export type CommandRecognition = {
|
|
388
|
+
readonly kind: 'command';
|
|
389
|
+
readonly text: string;
|
|
390
|
+
} | {
|
|
391
|
+
readonly kind: 'escaped';
|
|
392
|
+
readonly parts: readonly MessagePart[];
|
|
393
|
+
} | {
|
|
394
|
+
readonly kind: 'chat';
|
|
395
|
+
};
|
|
396
|
+
export interface CommandRecognitionOptions {
|
|
397
|
+
/** External groups: only text addressed to this account is a command. */
|
|
398
|
+
readonly requireMention?: boolean;
|
|
399
|
+
/**
|
|
400
|
+
* The platform itself says this message mentions the account (QQ's @ events, WeCom group callbacks), even when the
|
|
401
|
+
* mention is not a leading mention part. Such adapters may also leave a leading `@name` as plain text.
|
|
402
|
+
*/
|
|
403
|
+
readonly addressed?: boolean;
|
|
404
|
+
}
|
|
405
|
+
export declare function recognizeCommand(parts: readonly MessagePart[], botMemberId?: ChannelMemberId, options?: CommandRecognitionOptions): CommandRecognition;
|
|
406
|
+
/** The command name a recognized text invokes (`/name args` → `name`). */
|
|
407
|
+
export declare const commandNameOf: (text: string) => string;
|
|
408
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EASL,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,WAAW,EACjB,MAAM,aAAa,CAAA;AAEpB,eAAO,MAAM,+BAA+B,KAAK,CAAA;AACjD,eAAO,MAAM,2BAA2B,MAAM,CAAA;AAC9C;;;GAGG;AACH,eAAO,MAAM,uBAAuB;;;;EAA+C,CAAA;AACnF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAOxE,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;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