@coclaw/openclaw-coclaw 0.4.0 → 0.4.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/index.js +30 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -205,6 +205,36 @@ const plugin = {
|
|
|
205
205
|
}
|
|
206
206
|
});
|
|
207
207
|
|
|
208
|
+
api.registerGatewayMethod('coclaw.topics.update', async ({ params, respond }) => {
|
|
209
|
+
try {
|
|
210
|
+
const topicId = params?.topicId?.trim?.();
|
|
211
|
+
if (!topicId) {
|
|
212
|
+
respond(false, { error: 'topicId required' });
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const changes = params?.changes;
|
|
216
|
+
if (!changes || typeof changes !== 'object') {
|
|
217
|
+
respond(false, { error: 'changes required' });
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
// 当前版本仅处理 title
|
|
221
|
+
if (typeof changes.title !== 'string') {
|
|
222
|
+
respond(false, { error: 'No valid change field provided (supported: title)' });
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
await topicManager.updateTitle({ topicId, title: changes.title });
|
|
226
|
+
const { topic } = topicManager.get({ topicId });
|
|
227
|
+
if (!topic) {
|
|
228
|
+
respond(false, { error: `Topic not found: ${topicId}` });
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
respond(true, { topic });
|
|
232
|
+
}
|
|
233
|
+
catch (err) {
|
|
234
|
+
respondError(respond, err);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
|
|
208
238
|
api.registerGatewayMethod('coclaw.topics.generateTitle', async ({ params, respond }) => {
|
|
209
239
|
try {
|
|
210
240
|
const topicId = params?.topicId?.trim?.();
|