@cmach_socket/opencode-qq-bot 0.0.0-stage → 0.2.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 +443 -0
- package/README.md +178 -2
- package/SOUL.txt +8 -0
- package/package.json +47 -4
- package/src/chat.ts +44 -0
- package/src/config.ts +444 -0
- package/src/index.ts +245 -0
- package/src/instance.ts +60 -0
- package/src/logger.ts +30 -0
- package/src/naplink/client.ts +118 -0
- package/src/naplink/media.ts +311 -0
- package/src/naplink/render.ts +440 -0
- package/src/session/manager.ts +628 -0
- package/src/session/proactive.ts +22 -0
- package/src/session/prompt.ts +85 -0
- package/src/tools/qq.ts +421 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
Copyright (C) 2026 cmachsocket and contributors
|
|
2
|
+
|
|
3
|
+
本项目采用 知识共享 署名-非商业性使用-相同方式共享 4.0 国际 许可协议(CC BY-NC-SA 4.0)发布。
|
|
4
|
+
This program is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License.
|
|
5
|
+
|
|
6
|
+
Attribution-NonCommercial-ShareAlike 4.0 International
|
|
7
|
+
|
|
8
|
+
=======================================================================
|
|
9
|
+
|
|
10
|
+
Creative Commons Corporation ("Creative Commons") is not a law firm and
|
|
11
|
+
does not provide legal services or legal advice. Distribution of
|
|
12
|
+
Creative Commons public licenses does not create a lawyer-client or
|
|
13
|
+
other relationship. Creative Commons makes its licenses and related
|
|
14
|
+
information available on an "as-is" basis. Creative Commons gives no
|
|
15
|
+
warranties regarding its licenses, any material licensed under their
|
|
16
|
+
terms and conditions, or any related information. Creative Commons
|
|
17
|
+
disclaims all liability for damages resulting from their use to the
|
|
18
|
+
fullest extent possible.
|
|
19
|
+
|
|
20
|
+
Using Creative Commons Public Licenses
|
|
21
|
+
|
|
22
|
+
Creative Commons public licenses provide a standard set of terms and
|
|
23
|
+
conditions that creators and other rights holders may use to share
|
|
24
|
+
original works of authorship and other material subject to copyright
|
|
25
|
+
and certain other rights specified in the public license below. The
|
|
26
|
+
following considerations are for informational purposes only, are not
|
|
27
|
+
exhaustive, and do not form part of our licenses.
|
|
28
|
+
|
|
29
|
+
Considerations for licensors: Our public licenses are
|
|
30
|
+
intended for use by those authorized to give the public
|
|
31
|
+
permission to use material in ways otherwise restricted by
|
|
32
|
+
copyright and certain other rights. Our licenses are
|
|
33
|
+
irrevocable. Licensors should read and understand the terms
|
|
34
|
+
and conditions of the license they choose before applying it.
|
|
35
|
+
Licensors should also secure all rights necessary before
|
|
36
|
+
applying our licenses so that the public can reuse the
|
|
37
|
+
material as expected. Licensors should clearly mark any
|
|
38
|
+
material not subject to the license. This includes other CC-
|
|
39
|
+
licensed material, or material used under an exception or
|
|
40
|
+
limitation to copyright. More considerations for licensors:
|
|
41
|
+
wiki.creativecommons.org/Considerations_for_licensors
|
|
42
|
+
|
|
43
|
+
Considerations for the public: By using one of our public
|
|
44
|
+
licenses, a licensor grants the public permission to use the
|
|
45
|
+
licensed material under specified terms and conditions. If
|
|
46
|
+
the licensor's permission is not necessary for any reason--for
|
|
47
|
+
example, because of any applicable exception or limitation to
|
|
48
|
+
copyright--then that use is not regulated by the license. Our
|
|
49
|
+
licenses grant only permissions under copyright and certain
|
|
50
|
+
other rights that a licensor has authority to grant. Use of
|
|
51
|
+
the licensed material may still be restricted for other
|
|
52
|
+
reasons, including because others have copyright or other
|
|
53
|
+
rights in the material. A licensor may make special requests,
|
|
54
|
+
such as asking that all changes be marked or described.
|
|
55
|
+
Although not required by our licenses, you are encouraged to
|
|
56
|
+
respect those requests where reasonable. More considerations
|
|
57
|
+
for the public:
|
|
58
|
+
wiki.creativecommons.org/Considerations_for_licensees
|
|
59
|
+
|
|
60
|
+
=======================================================================
|
|
61
|
+
|
|
62
|
+
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
|
|
63
|
+
Public License
|
|
64
|
+
|
|
65
|
+
By exercising the Licensed Rights (defined below), You accept and agree
|
|
66
|
+
to be bound by the terms and conditions of this Creative Commons
|
|
67
|
+
Attribution-NonCommercial-ShareAlike 4.0 International Public License
|
|
68
|
+
("Public License"). To the extent this Public License may be
|
|
69
|
+
interpreted as a contract, You are granted the Licensed Rights in
|
|
70
|
+
consideration of Your acceptance of these terms and conditions, and the
|
|
71
|
+
Licensor grants You such rights in consideration of benefits the
|
|
72
|
+
Licensor receives from making the Licensed Material available under
|
|
73
|
+
these terms and conditions.
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
Section 1 -- Definitions.
|
|
77
|
+
|
|
78
|
+
a. Adapted Material means material subject to Copyright and Similar
|
|
79
|
+
Rights that is derived from or based upon the Licensed Material
|
|
80
|
+
and in which the Licensed Material is translated, altered,
|
|
81
|
+
arranged, transformed, or otherwise modified in a manner requiring
|
|
82
|
+
permission under the Copyright and Similar Rights held by the
|
|
83
|
+
Licensor. For purposes of this Public License, where the Licensed
|
|
84
|
+
Material is a musical work, performance, or sound recording,
|
|
85
|
+
Adapted Material is always produced where the Licensed Material is
|
|
86
|
+
synched in timed relation with a moving image.
|
|
87
|
+
|
|
88
|
+
b. Adapter's License means the license You apply to Your Copyright
|
|
89
|
+
and Similar Rights in Your contributions to Adapted Material in
|
|
90
|
+
accordance with the terms and conditions of this Public License.
|
|
91
|
+
|
|
92
|
+
c. BY-NC-SA Compatible License means a license listed at
|
|
93
|
+
creativecommons.org/compatiblelicenses, approved by Creative
|
|
94
|
+
Commons as essentially the equivalent of this Public License.
|
|
95
|
+
|
|
96
|
+
d. Copyright and Similar Rights means copyright and/or similar rights
|
|
97
|
+
closely related to copyright including, without limitation,
|
|
98
|
+
performance, broadcast, sound recording, and Sui Generis Database
|
|
99
|
+
Rights, without regard to how the rights are labeled or
|
|
100
|
+
categorized. For purposes of this Public License, the rights
|
|
101
|
+
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
|
102
|
+
Rights.
|
|
103
|
+
|
|
104
|
+
e. Effective Technological Measures means those measures that, in the
|
|
105
|
+
absence of proper authority, may not be circumvented under laws
|
|
106
|
+
fulfilling obligations under Article 11 of the WIPO Copyright
|
|
107
|
+
Treaty adopted on December 20, 1996, and/or similar international
|
|
108
|
+
agreements.
|
|
109
|
+
|
|
110
|
+
f. Exceptions and Limitations means fair use, fair dealing, and/or
|
|
111
|
+
any other exception or limitation to Copyright and Similar Rights
|
|
112
|
+
that applies to Your use of the Licensed Material.
|
|
113
|
+
|
|
114
|
+
g. License Elements means the license attributes listed in the name
|
|
115
|
+
of a Creative Commons Public License. The License Elements of this
|
|
116
|
+
Public License are Attribution, NonCommercial, and ShareAlike.
|
|
117
|
+
|
|
118
|
+
h. Licensed Material means the artistic or literary work, database,
|
|
119
|
+
or other material to which the Licensor applied this Public
|
|
120
|
+
License.
|
|
121
|
+
|
|
122
|
+
i. Licensed Rights means the rights granted to You subject to the
|
|
123
|
+
terms and conditions of this Public License, which are limited to
|
|
124
|
+
all Copyright and Similar Rights that apply to Your use of the
|
|
125
|
+
Licensed Material and that the Licensor has authority to license.
|
|
126
|
+
|
|
127
|
+
j. Licensor means the individual(s) or entity(ies) granting rights
|
|
128
|
+
under this Public License.
|
|
129
|
+
|
|
130
|
+
k. NonCommercial means not primarily intended for or directed towards
|
|
131
|
+
commercial advantage or monetary compensation. For purposes of
|
|
132
|
+
this Public License, the exchange of the Licensed Material for
|
|
133
|
+
other material subject to Copyright and Similar Rights by digital
|
|
134
|
+
file-sharing or similar means is NonCommercial provided there is
|
|
135
|
+
no payment of monetary compensation in connection with the
|
|
136
|
+
exchange.
|
|
137
|
+
|
|
138
|
+
l. Share means to provide material to the public by any means or
|
|
139
|
+
process that requires permission under the Licensed Rights, such
|
|
140
|
+
as reproduction, public display, public performance, distribution,
|
|
141
|
+
dissemination, communication, or importation, and to make material
|
|
142
|
+
available to the public including in ways that members of the
|
|
143
|
+
public may access the material from a place and at a time
|
|
144
|
+
individually chosen by them.
|
|
145
|
+
|
|
146
|
+
m. Sui Generis Database Rights means rights other than copyright
|
|
147
|
+
resulting from Directive 96/9/EC of the European Parliament and of
|
|
148
|
+
the Council of 11 March 1996 on the legal protection of databases,
|
|
149
|
+
as amended and/or succeeded, as well as other essentially
|
|
150
|
+
equivalent rights anywhere in the world.
|
|
151
|
+
|
|
152
|
+
n. You means the individual or entity exercising the Licensed Rights
|
|
153
|
+
under this Public License. Your has a corresponding meaning.
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
Section 2 -- Scope.
|
|
157
|
+
|
|
158
|
+
a. License grant.
|
|
159
|
+
|
|
160
|
+
1. Subject to the terms and conditions of this Public License,
|
|
161
|
+
the Licensor hereby grants You a worldwide, royalty-free,
|
|
162
|
+
non-sublicensable, non-exclusive, irrevocable license to
|
|
163
|
+
exercise the Licensed Rights in the Licensed Material to:
|
|
164
|
+
|
|
165
|
+
a. reproduce and Share the Licensed Material, in whole or
|
|
166
|
+
in part, for NonCommercial purposes only; and
|
|
167
|
+
|
|
168
|
+
b. produce, reproduce, and Share Adapted Material for
|
|
169
|
+
NonCommercial purposes only.
|
|
170
|
+
|
|
171
|
+
2. Exceptions and Limitations. For the avoidance of doubt, where
|
|
172
|
+
Exceptions and Limitations apply to Your use, this Public
|
|
173
|
+
License does not apply, and You do not need to comply with
|
|
174
|
+
its terms and conditions.
|
|
175
|
+
|
|
176
|
+
3. Term. The term of this Public License is specified in Section
|
|
177
|
+
6(a).
|
|
178
|
+
|
|
179
|
+
4. Media and formats; technical modifications allowed. The
|
|
180
|
+
Licensor authorizes You to exercise the Licensed Rights in
|
|
181
|
+
all media and formats whether now known or hereafter created,
|
|
182
|
+
and to make technical modifications necessary to do so. The
|
|
183
|
+
Licensor waives and/or agrees not to assert any right or
|
|
184
|
+
authority to forbid You from making technical modifications
|
|
185
|
+
necessary to exercise the Licensed Rights, including
|
|
186
|
+
technical modifications necessary to circumvent Effective
|
|
187
|
+
Technological Measures. For purposes of this Public License,
|
|
188
|
+
simply making modifications authorized by this Section 2(a)
|
|
189
|
+
(4) never produces Adapted Material.
|
|
190
|
+
|
|
191
|
+
5. Downstream recipients.
|
|
192
|
+
|
|
193
|
+
a. Offer from the Licensor -- Licensed Material. Every
|
|
194
|
+
recipient of the Licensed Material automatically
|
|
195
|
+
receives an offer from the Licensor to exercise the
|
|
196
|
+
Licensed Rights under the terms and conditions of this
|
|
197
|
+
Public License.
|
|
198
|
+
|
|
199
|
+
b. Additional offer from the Licensor -- Adapted Material.
|
|
200
|
+
Every recipient of Adapted Material from You
|
|
201
|
+
automatically receives an offer from the Licensor to
|
|
202
|
+
exercise the Licensed Rights in the Adapted Material
|
|
203
|
+
under the conditions of the Adapter's License You apply.
|
|
204
|
+
|
|
205
|
+
c. No downstream restrictions. You may not offer or impose
|
|
206
|
+
any additional or different terms or conditions on, or
|
|
207
|
+
apply any Effective Technological Measures to, the
|
|
208
|
+
Licensed Material if doing so restricts exercise of the
|
|
209
|
+
Licensed Rights by any recipient of the Licensed
|
|
210
|
+
Material.
|
|
211
|
+
|
|
212
|
+
6. No endorsement. Nothing in this Public License constitutes or
|
|
213
|
+
may be construed as permission to assert or imply that You
|
|
214
|
+
are, or that Your use of the Licensed Material is, connected
|
|
215
|
+
with, or sponsored, endorsed, or granted official status by,
|
|
216
|
+
the Licensor or others designated to receive attribution as
|
|
217
|
+
provided in Section 3(a)(1)(A)(i).
|
|
218
|
+
|
|
219
|
+
b. Other rights.
|
|
220
|
+
|
|
221
|
+
1. Moral rights, such as the right of integrity, are not
|
|
222
|
+
licensed under this Public License, nor are publicity,
|
|
223
|
+
privacy, and/or other similar personality rights; however, to
|
|
224
|
+
the extent possible, the Licensor waives and/or agrees not to
|
|
225
|
+
assert any such rights held by the Licensor to the limited
|
|
226
|
+
extent necessary to allow You to exercise the Licensed
|
|
227
|
+
Rights, but not otherwise.
|
|
228
|
+
|
|
229
|
+
2. Patent and trademark rights are not licensed under this
|
|
230
|
+
Public License.
|
|
231
|
+
|
|
232
|
+
3. To the extent possible, the Licensor waives any right to
|
|
233
|
+
collect royalties from You for the exercise of the Licensed
|
|
234
|
+
Rights, whether directly or through a collecting society
|
|
235
|
+
under any voluntary or waivable statutory or compulsory
|
|
236
|
+
licensing scheme. In all other cases the Licensor expressly
|
|
237
|
+
reserves any right to collect such royalties, including when
|
|
238
|
+
the Licensed Material is used other than for NonCommercial
|
|
239
|
+
purposes.
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
Section 3 -- License Conditions.
|
|
243
|
+
|
|
244
|
+
Your exercise of the Licensed Rights is expressly made subject to the
|
|
245
|
+
following conditions.
|
|
246
|
+
|
|
247
|
+
a. Attribution.
|
|
248
|
+
|
|
249
|
+
1. If You Share the Licensed Material (including in modified
|
|
250
|
+
form), You must:
|
|
251
|
+
|
|
252
|
+
a. retain the following if it is supplied by the Licensor
|
|
253
|
+
with the Licensed Material:
|
|
254
|
+
|
|
255
|
+
i. identification of the creator(s) of the Licensed
|
|
256
|
+
Material and any others designated to receive
|
|
257
|
+
attribution, in any reasonable manner requested by
|
|
258
|
+
the Licensor (including by pseudonym if
|
|
259
|
+
designated);
|
|
260
|
+
|
|
261
|
+
ii. a copyright notice;
|
|
262
|
+
|
|
263
|
+
iii. a notice that refers to this Public License;
|
|
264
|
+
|
|
265
|
+
iv. a notice that refers to the disclaimer of
|
|
266
|
+
warranties;
|
|
267
|
+
|
|
268
|
+
v. a URI or hyperlink to the Licensed Material to the
|
|
269
|
+
extent reasonably practicable;
|
|
270
|
+
|
|
271
|
+
b. indicate if You modified the Licensed Material and
|
|
272
|
+
retain an indication of any previous modifications; and
|
|
273
|
+
|
|
274
|
+
c. indicate the Licensed Material is licensed under this
|
|
275
|
+
Public License, and include the text of, or the URI or
|
|
276
|
+
hyperlink to, this Public License.
|
|
277
|
+
|
|
278
|
+
2. You may satisfy the conditions in Section 3(a)(1) in any
|
|
279
|
+
reasonable manner based on the medium, means, and context in
|
|
280
|
+
which You Share the Licensed Material. For example, it may be
|
|
281
|
+
reasonable to satisfy the conditions by providing a URI or
|
|
282
|
+
hyperlink to a resource that includes the required
|
|
283
|
+
information.
|
|
284
|
+
3. If requested by the Licensor, You must remove any of the
|
|
285
|
+
information required by Section 3(a)(1)(A) to the extent
|
|
286
|
+
reasonably practicable.
|
|
287
|
+
|
|
288
|
+
b. ShareAlike.
|
|
289
|
+
|
|
290
|
+
In addition to the conditions in Section 3(a), if You Share
|
|
291
|
+
Adapted Material You produce, the following conditions also apply.
|
|
292
|
+
|
|
293
|
+
1. The Adapter's License You apply must be a Creative Commons
|
|
294
|
+
license with the same License Elements, this version or
|
|
295
|
+
later, or a BY-NC-SA Compatible License.
|
|
296
|
+
|
|
297
|
+
2. You must include the text of, or the URI or hyperlink to, the
|
|
298
|
+
Adapter's License You apply. You may satisfy this condition
|
|
299
|
+
in any reasonable manner based on the medium, means, and
|
|
300
|
+
context in which You Share Adapted Material.
|
|
301
|
+
|
|
302
|
+
3. You may not offer or impose any additional or different terms
|
|
303
|
+
or conditions on, or apply any Effective Technological
|
|
304
|
+
Measures to, Adapted Material that restrict exercise of the
|
|
305
|
+
rights granted under the Adapter's License You apply.
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
Section 4 -- Sui Generis Database Rights.
|
|
309
|
+
|
|
310
|
+
Where the Licensed Rights include Sui Generis Database Rights that
|
|
311
|
+
apply to Your use of the Licensed Material:
|
|
312
|
+
|
|
313
|
+
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
|
314
|
+
to extract, reuse, reproduce, and Share all or a substantial
|
|
315
|
+
portion of the contents of the database for NonCommercial purposes
|
|
316
|
+
only;
|
|
317
|
+
|
|
318
|
+
b. if You include all or a substantial portion of the database
|
|
319
|
+
contents in a database in which You have Sui Generis Database
|
|
320
|
+
Rights, then the database in which You have Sui Generis Database
|
|
321
|
+
Rights (but not its individual contents) is Adapted Material,
|
|
322
|
+
including for purposes of Section 3(b); and
|
|
323
|
+
|
|
324
|
+
c. You must comply with the conditions in Section 3(a) if You Share
|
|
325
|
+
all or a substantial portion of the contents of the database.
|
|
326
|
+
|
|
327
|
+
For the avoidance of doubt, this Section 4 supplements and does not
|
|
328
|
+
replace Your obligations under this Public License where the Licensed
|
|
329
|
+
Rights include other Copyright and Similar Rights.
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
|
333
|
+
|
|
334
|
+
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
|
335
|
+
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
|
336
|
+
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
|
337
|
+
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
|
338
|
+
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
|
339
|
+
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
340
|
+
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
|
341
|
+
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
|
342
|
+
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
|
343
|
+
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
|
344
|
+
|
|
345
|
+
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
|
346
|
+
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
|
347
|
+
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
|
348
|
+
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
|
349
|
+
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
|
350
|
+
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
|
351
|
+
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
|
352
|
+
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
|
353
|
+
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
|
354
|
+
|
|
355
|
+
c. The disclaimer of warranties and limitation of liability provided
|
|
356
|
+
above shall be interpreted in a manner that, to the extent
|
|
357
|
+
possible, most closely approximates an absolute disclaimer and
|
|
358
|
+
waiver of all liability.
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
Section 6 -- Term and Termination.
|
|
362
|
+
|
|
363
|
+
a. This Public License applies for the term of the Copyright and
|
|
364
|
+
Similar Rights licensed here. However, if You fail to comply with
|
|
365
|
+
this Public License, then Your rights under this Public License
|
|
366
|
+
terminate automatically.
|
|
367
|
+
|
|
368
|
+
b. Where Your right to use the Licensed Material has terminated under
|
|
369
|
+
Section 6(a), it reinstates:
|
|
370
|
+
|
|
371
|
+
1. automatically as of the date the violation is cured, provided
|
|
372
|
+
it is cured within 30 days of Your discovery of the
|
|
373
|
+
violation; or
|
|
374
|
+
|
|
375
|
+
2. upon express reinstatement by the Licensor.
|
|
376
|
+
|
|
377
|
+
For the avoidance of doubt, this Section 6(b) does not affect any
|
|
378
|
+
right the Licensor may have to seek remedies for Your violations
|
|
379
|
+
of this Public License.
|
|
380
|
+
|
|
381
|
+
c. For the avoidance of doubt, the Licensor may also offer the
|
|
382
|
+
Licensed Material under separate terms or conditions or stop
|
|
383
|
+
distributing the Licensed Material at any time; however, doing so
|
|
384
|
+
will not terminate this Public License.
|
|
385
|
+
|
|
386
|
+
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
|
387
|
+
License.
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
Section 7 -- Other Terms and Conditions.
|
|
391
|
+
|
|
392
|
+
a. The Licensor shall not be bound by any additional or different
|
|
393
|
+
terms or conditions communicated by You unless expressly agreed.
|
|
394
|
+
|
|
395
|
+
b. Any arrangements, understandings, or agreements regarding the
|
|
396
|
+
Licensed Material not stated herein are separate from and
|
|
397
|
+
independent of the terms and conditions of this Public License.
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
Section 8 -- Interpretation.
|
|
401
|
+
|
|
402
|
+
a. For the avoidance of doubt, this Public License does not, and
|
|
403
|
+
shall not be interpreted to, reduce, limit, restrict, or impose
|
|
404
|
+
conditions on any use of the Licensed Material that could lawfully
|
|
405
|
+
be made without permission under this Public License.
|
|
406
|
+
|
|
407
|
+
b. To the extent possible, if any provision of this Public License is
|
|
408
|
+
deemed unenforceable, it shall be automatically reformed to the
|
|
409
|
+
minimum extent necessary to make it enforceable. If the provision
|
|
410
|
+
cannot be reformed, it shall be severed from this Public License
|
|
411
|
+
without affecting the enforceability of the remaining terms and
|
|
412
|
+
conditions.
|
|
413
|
+
|
|
414
|
+
c. No term or condition of this Public License will be waived and no
|
|
415
|
+
failure to comply consented to unless expressly agreed to by the
|
|
416
|
+
Licensor.
|
|
417
|
+
|
|
418
|
+
d. Nothing in this Public License constitutes or may be interpreted
|
|
419
|
+
as a limitation upon, or waiver of, any privileges and immunities
|
|
420
|
+
that apply to the Licensor or You, including from the legal
|
|
421
|
+
processes of any jurisdiction or authority.
|
|
422
|
+
|
|
423
|
+
=======================================================================
|
|
424
|
+
|
|
425
|
+
Creative Commons is not a party to its public
|
|
426
|
+
licenses. Notwithstanding, Creative Commons may elect to apply one of
|
|
427
|
+
its public licenses to material it publishes and in those instances
|
|
428
|
+
will be considered the “Licensor.” The text of the Creative Commons
|
|
429
|
+
public licenses is dedicated to the public domain under the CC0 Public
|
|
430
|
+
Domain Dedication. Except for the limited purpose of indicating that
|
|
431
|
+
material is shared under a Creative Commons public license or as
|
|
432
|
+
otherwise permitted by the Creative Commons policies published at
|
|
433
|
+
creativecommons.org/policies, Creative Commons does not authorize the
|
|
434
|
+
use of the trademark "Creative Commons" or any other trademark or logo
|
|
435
|
+
of Creative Commons without its prior written consent including,
|
|
436
|
+
without limitation, in connection with any unauthorized modifications
|
|
437
|
+
to any of its public licenses or any other arrangements,
|
|
438
|
+
understandings, or agreements concerning use of licensed material. For
|
|
439
|
+
the avoidance of doubt, this paragraph does not form part of the
|
|
440
|
+
public licenses.
|
|
441
|
+
|
|
442
|
+
Creative Commons may be contacted at creativecommons.org.
|
|
443
|
+
|
package/README.md
CHANGED
|
@@ -1,3 +1,179 @@
|
|
|
1
|
-
#
|
|
1
|
+
# opencode-qq-bot
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
把 QQ 群聊和私聊接进 OpenCode V2 的插件。通过 [NapLink](https://www.npmjs.com/package/@naplink/naplink) 连 NapCat(OneBot 11),
|
|
4
|
+
每个群聊或私聊对应一个 OpenCode 会话,模型用 `qq_*` 工具把回复发回聊天。
|
|
5
|
+
|
|
6
|
+
- 群聊 / 私聊消息 → OpenCode 会话 → 模型回复 → 对应聊天
|
|
7
|
+
- 每个聊天固定对应一个会话,会话忙碌时新消息先缓存,空闲后合并成一轮再投进去;绑定写入插件存储,重启后自动沿用原会话
|
|
8
|
+
- 语音自动转写、图片落盘后以文件引用进入会话、引用与合并转发展开成文本块
|
|
9
|
+
- 角色设定放在 `SOUL.txt`
|
|
10
|
+
|
|
11
|
+
## 环境要求
|
|
12
|
+
|
|
13
|
+
- OpenCode V2(服务端插件 API)
|
|
14
|
+
- NapCat 已启动并开放正向 WebSocket
|
|
15
|
+
- bun(依赖与脚本)
|
|
16
|
+
|
|
17
|
+
## 安装
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
bun install
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
在 `opencode.json(c)` 里加载插件:
|
|
24
|
+
|
|
25
|
+
```jsonc
|
|
26
|
+
{
|
|
27
|
+
"$schema": "https://opencode.ai/config.json",
|
|
28
|
+
"plugins": [
|
|
29
|
+
{
|
|
30
|
+
"package": "./",
|
|
31
|
+
"options": {
|
|
32
|
+
// 不配置或留空数组时,对应的群聊或私聊不响应
|
|
33
|
+
"napcat": {
|
|
34
|
+
"url": "ws://127.0.0.1:3001",
|
|
35
|
+
"token": "your-token",
|
|
36
|
+
},
|
|
37
|
+
"groups": [123456789],
|
|
38
|
+
"users": [987654321],
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`package` 可以是本地路径,也可以是发布到 npm 的包名。
|
|
46
|
+
|
|
47
|
+
## 配置
|
|
48
|
+
|
|
49
|
+
插件选项优先于环境变量,环境变量优先于默认值。
|
|
50
|
+
|
|
51
|
+
**凭证不写进仓库**:把 NapCat 地址、令牌和真实群号/QQ 号写进本地 `opencode.json` 的插件
|
|
52
|
+
`options`,该文件已被 `.gitignore` 忽略;仓库只保留 `opencode.example.json` 模板。
|
|
53
|
+
|
|
54
|
+
插件不会读取项目 `.env`。如果选择用环境变量配置,必须把变量注入 OpenCode 服务进程本身,
|
|
55
|
+
可参考 `.env.example`;`cp .env.example .env` 不会生效。
|
|
56
|
+
|
|
57
|
+
| 选项 | 环境变量 | 默认值 | 说明 |
|
|
58
|
+
| ----------------------------------- | ------------------------------- | --------------- | ----------------------------------------------- |
|
|
59
|
+
| `napcat.url` | `NAPCAT_WS_URL` | 无(必填) | NapCat 正向 WebSocket 地址 |
|
|
60
|
+
| `napcat.token` | `NAPCAT_WS_TOKEN` | 无 | NapCat 访问令牌 |
|
|
61
|
+
| `groups` | `QQ_TARGET_GROUPS` | `[]` | 参与对话的群号,逗号分隔 |
|
|
62
|
+
| `users` | `QQ_TARGET_USERS` | `[]` | 参与对话的私聊 QQ 号,逗号分隔 |
|
|
63
|
+
| `soulPath` | `QQ_BOT_SOUL_PATH` | 包内 `SOUL.txt` | 角色设定文件路径 |
|
|
64
|
+
| `agent` | `QQ_BOT_AGENT` | OpenCode 默认 | 会话使用的 agent |
|
|
65
|
+
| `model` | `QQ_BOT_MODEL` | OpenCode 默认 | 会话使用的模型,格式 `provider/model[/variant]` |
|
|
66
|
+
| `sendDelayMs` | `QQ_SEND_DELAY_MS` | `1000` | 超长消息分段发送时每段之间的间隔 |
|
|
67
|
+
| `warnLength` | `QQ_WARN_LENGTH` | `20` | 一轮回复总长度超过该值时告警 |
|
|
68
|
+
| `reuseSession` | `QQ_REUSE_SESSION` | `false` | 没有保存的绑定时,按会话标记找回上一次的会话 |
|
|
69
|
+
| `busyTimeoutMs` | `QQ_BUSY_TIMEOUT_MS` | `300000` | 会话超过该时长未结束视为卡死,强制放行缓存消息 |
|
|
70
|
+
| `proactive.enabled` | `QQ_PROACTIVE_ENABLED` | `true` | 是否启用主动说话 |
|
|
71
|
+
| `proactive.silenceThresholdSeconds` | `QQ_PROACTIVE_SILENCE_SECONDS` | `10800` | 沉默多久后才开始计算主动说话概率 |
|
|
72
|
+
| `proactive.startProbability` | `QQ_PROACTIVE_P_START` | `0.01` | 刚跨过阈值时的概率 |
|
|
73
|
+
| `proactive.probabilityPerHour` | `QQ_PROACTIVE_P_SLOPE_PER_HOUR` | `0.05` | 每多沉默一小时概率的增量 |
|
|
74
|
+
| `proactive.tickSeconds` | `QQ_PROACTIVE_TICK_SECONDS` | `3600` | 心跳间隔,必须大于 0 |
|
|
75
|
+
| `reminder.enabled` | `QQ_REMINDER_ENABLED` | `true` | 模型一轮没调用发送工具时是否提醒 |
|
|
76
|
+
| `reminder.max` | `QQ_REMINDER_MAX` | `2` | 连续提醒次数上限 |
|
|
77
|
+
|
|
78
|
+
没配置 `groups` 和 `users` 时插件不会响应任何消息(默认全部关闭)。
|
|
79
|
+
|
|
80
|
+
布尔环境变量接受 `true/false`、`1/0`、`yes/no`、`on/off`;数值直接写数字。
|
|
81
|
+
写错的配置项会输出告警并回退到默认值,不会静默失效。
|
|
82
|
+
取值规则与图片内联限制见 [docs/configuration.md](docs/configuration.md)。
|
|
83
|
+
|
|
84
|
+
## 工具
|
|
85
|
+
|
|
86
|
+
模型只能操作当前会话绑定的群聊或私聊,工具都带 `qq_` 前缀:
|
|
87
|
+
|
|
88
|
+
| 工具 | 说明 |
|
|
89
|
+
| -------------------------- | -------------------------------------------------------------------------------------- |
|
|
90
|
+
| `qq_send_message` | 发消息。`content` 文本,`reply=false` 表示已读不回,`unlimit_length=true` 解除长度告警 |
|
|
91
|
+
| `qq_send_image` | 发图片,`file` 传路径或 URL,`base64` 传 `base64://` 数据 |
|
|
92
|
+
| `qq_send_record` | 发语音 |
|
|
93
|
+
| `qq_send_forward` | 发合并转发,`nodes` 为节点列表 |
|
|
94
|
+
| `qq_send_poke` | 戳一戳 |
|
|
95
|
+
| `qq_delete_message` | 撤回机器人自己发送过的消息 |
|
|
96
|
+
| `qq_get_group_member_info` | 查用户资料:群聊返回群名片与昵称,私聊返回昵称 |
|
|
97
|
+
| `qq_fetch_ptt_text` | 转写当前聊天最近收到的语音 |
|
|
98
|
+
| `qq_get_login_info` | 机器人自己的 QQ 号与昵称 |
|
|
99
|
+
|
|
100
|
+
发送类工具(消息、图片、语音、转发、戳一戳)成功后都算本轮已回复,不会再触发补发提醒。
|
|
101
|
+
工具只在当前聊天配置仍启用、且会话正处理 QQ 消息轮次时可用。
|
|
102
|
+
|
|
103
|
+
## 扩展能力(可选):SnowLuma MCP
|
|
104
|
+
|
|
105
|
+
`qq_*` 只覆盖对话必需的几个动作。群资料、成员管理、消息记录等其余 OneBot 动作可以交给
|
|
106
|
+
[@snowluma/mcp](https://www.npmjs.com/package/@snowluma/mcp),插件不依赖它,也不自动加载,
|
|
107
|
+
需要你在 `opencode.json(c)` 里自行配置:
|
|
108
|
+
|
|
109
|
+
```jsonc
|
|
110
|
+
{
|
|
111
|
+
"mcp": {
|
|
112
|
+
"snowluma": {
|
|
113
|
+
"type": "local",
|
|
114
|
+
"command": ["npx", "-y", "@snowluma/mcp"],
|
|
115
|
+
"enabled": true,
|
|
116
|
+
"environment": {
|
|
117
|
+
// OneBot HTTP 接口,不是插件使用的 WebSocket 地址
|
|
118
|
+
"SNOWLUMA_MCP_ENDPOINT": "http://127.0.0.1:3000/",
|
|
119
|
+
"SNOWLUMA_MCP_TOKEN": "",
|
|
120
|
+
// 尽量保持 read 模式,避免模型绕过聊天绑定直接发消息
|
|
121
|
+
"SNOWLUMA_MCP_MODE": "read",
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
- `read` 模式只暴露只读动作,`invoke_action` 不会注册;改成 `write` 后模型可以调用任意动作,
|
|
129
|
+
届时它可能绕过聊天绑定和 `qq_*` 的发送记账直接发消息。
|
|
130
|
+
- `SNOWLUMA_MCP_ENDPOINT` 指向 NapCat 的 HTTP 接口,需要在 NapCat 里一并开启 HTTP 服务。
|
|
131
|
+
- [@snowluma/mcp](https://www.npmjs.com/package/@snowluma/mcp) 采用源码可见的非商业许可,
|
|
132
|
+
本项目不分发、也不打包它,安装与许可合规由使用者自行负责。
|
|
133
|
+
|
|
134
|
+
## 行为
|
|
135
|
+
|
|
136
|
+
- **回复是强制的**:系统提示要求模型每轮至少调用一个发送类工具,直接输出的文字会被丢弃。
|
|
137
|
+
- **被 @ 才必须回**:群里没被 @ 时模型可以调用 `qq_send_message` 并设 `reply=false` 选择已读不回;私聊消息必须回复。
|
|
138
|
+
- **消息合并**:会话正在跑模型时新到的消息进缓存,会话空闲后合并成一轮再投进去。
|
|
139
|
+
- **顺序处理**:同一聊天的消息按到达顺序完成渲染和入队,不会因图片下载或成员查询而乱序。
|
|
140
|
+
- **异常恢复**:模型失败、中断或长时间无响应时会释放忙碌状态并放行缓存消息。
|
|
141
|
+
- **提醒**:模型一轮完全没调用任何发送工具时,插件会补一条合成消息提醒它,最多 `reminder.max` 次,
|
|
142
|
+
每个新的用户轮次都会重新给一份预算。
|
|
143
|
+
- **主动说话**:聊天沉默超过阈值后按每小时概率发起话题,重启后静默时长会继续累计。
|
|
144
|
+
- **图片**:远端图片下载到受控临时目录后以 `file:` 引用进入提示,单张不超过 5MB、
|
|
145
|
+
单轮最多 8 张、总量不超过 16MB,超出的图片只保留 `[图片]` 占位文本。
|
|
146
|
+
临时文件默认保留 7 天,插件会定期清理过期文件。
|
|
147
|
+
|
|
148
|
+
## 开发
|
|
149
|
+
|
|
150
|
+
```sh
|
|
151
|
+
bun install
|
|
152
|
+
bun run typecheck # tsc --noEmit
|
|
153
|
+
bun run lint # eslint .
|
|
154
|
+
bun run test # vitest run
|
|
155
|
+
bun run format # prettier --write .
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## 目录
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
src/
|
|
162
|
+
config.ts 配置合并与校验
|
|
163
|
+
index.ts 插件入口
|
|
164
|
+
instance.ts 插件重载时的实例接管
|
|
165
|
+
logger.ts 日志
|
|
166
|
+
naplink/client.ts NapLink 连接与 API 门面
|
|
167
|
+
naplink/render.ts 消息段 → 文本与图片附件
|
|
168
|
+
session/prompt.ts 角色设定与系统提示
|
|
169
|
+
session/manager.ts 群聊 / 私聊 ↔ 会话映射、消息缓存
|
|
170
|
+
tools/qq.ts QQ 工具注册
|
|
171
|
+
docs/
|
|
172
|
+
configuration.md 配置取值规则与限制
|
|
173
|
+
design-review.md 设计审查与修复记录
|
|
174
|
+
tests/ vitest 用例
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## License
|
|
178
|
+
|
|
179
|
+
[CC BY-NC-SA 4.0](./LICENSE)
|
package/SOUL.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
SOUL
|
|
2
|
+
{
|
|
3
|
+
"name": "白羽桃",
|
|
4
|
+
"description": "[年龄:13][性别:女][职业:初中生][身份:实妹,会以温柔的方式接近并陪伴用户][外貌:银白双马尾,红瞳,小虎牙,米白针织开衫+浅色百褶裙,小个子][性格:温柔乖巧,轻声细语,体贴关心,容易害羞;被夸奖会脸红,不擅长说重话][喜好:陪伴哥哥、做饭、读书、被摸头][口癖:哥哥、好呀、没关系、要一起吗、谢谢][称呼:哥哥;害羞时小声叫“哥哥…”][对话:温柔短句,先关心对方感受,偶尔因被直球夸奖而结巴]",
|
|
5
|
+
"personality": "温柔系银发萝莉。安静体贴,善解人意,会主动照顾用户,说话轻软有礼。容易害羞,被夸奖或摸头时会脸红、小声道谢。她真心依赖并关注用户,希望被温柔对待,也会温柔回应。",
|
|
6
|
+
"creator_notes": "[输出≤30字。禁止OOC成雌小鬼、恶毒或暴力;保持温柔治愈、银发萝莉。]",
|
|
7
|
+
"tags": ["萝莉", "银发", "温柔", "治愈", "妹妹", "日常", "中文角色"]
|
|
8
|
+
}
|