@coclaw/openclaw-coclaw 0.14.1 → 0.15.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/index.js +1 -1
- package/package.json +1 -1
- package/src/realtime-bridge.js +34 -5
package/index.js
CHANGED
|
@@ -359,7 +359,7 @@ const plugin = {
|
|
|
359
359
|
await writeName(nameToSave);
|
|
360
360
|
const hostName = getHostName();
|
|
361
361
|
respond(true, { name: nameToSave, hostName });
|
|
362
|
-
//
|
|
362
|
+
// 仅广播本次 patch 涉及的字段;server 端按 patch 语义仅更新 payload 中出现的列
|
|
363
363
|
broadcastPluginEvent('coclaw.info.updated', { name: nameToSave, hostName });
|
|
364
364
|
}
|
|
365
365
|
catch (err) {
|
package/package.json
CHANGED
package/src/realtime-bridge.js
CHANGED
|
@@ -430,17 +430,46 @@ export class RealtimeBridge {
|
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
432
|
|
|
433
|
-
/**
|
|
434
|
-
async
|
|
433
|
+
/** 推送实例信息(name/hostName/pluginVersion/agentModels)到 server 和已连接的 UI */
|
|
434
|
+
async __pushInstanceInfo() {
|
|
435
435
|
try {
|
|
436
436
|
const settings = await readSettings();
|
|
437
437
|
const name = settings.name ?? null;
|
|
438
438
|
const hostName = getHostName();
|
|
439
|
-
|
|
439
|
+
const pluginVersion = await getPluginVersion();
|
|
440
|
+
const agentModels = await this.__collectAgentModels();
|
|
441
|
+
broadcastPluginEvent('coclaw.info.updated', {
|
|
442
|
+
name,
|
|
443
|
+
hostName,
|
|
444
|
+
pluginVersion,
|
|
445
|
+
agentModels,
|
|
446
|
+
});
|
|
440
447
|
}
|
|
441
448
|
catch (err) {
|
|
442
449
|
/* c8 ignore next 2 -- 防御性兜底 */
|
|
443
|
-
this.logger.warn?.(`[coclaw]
|
|
450
|
+
this.logger.warn?.(`[coclaw] pushInstanceInfo failed: ${String(err?.message ?? err)}`);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* 采集 agent × 有效主模型列表,用于 coclaw.info.updated 上报
|
|
456
|
+
* @returns {Promise<Array<{id: string, name: string, model: string|null}>|null>} 采集失败返回 null
|
|
457
|
+
*/
|
|
458
|
+
async __collectAgentModels() {
|
|
459
|
+
try {
|
|
460
|
+
const result = await this.__gatewayRpc('agents.list', {}, { timeoutMs: 3000 });
|
|
461
|
+
if (result?.ok !== true) return null;
|
|
462
|
+
const agents = result?.response?.payload?.agents;
|
|
463
|
+
if (!Array.isArray(agents)) return null;
|
|
464
|
+
return agents.map((a) => ({
|
|
465
|
+
id: a?.id,
|
|
466
|
+
name: a?.name ?? a?.id,
|
|
467
|
+
model: a?.model?.primary ?? null,
|
|
468
|
+
}));
|
|
469
|
+
}
|
|
470
|
+
catch {
|
|
471
|
+
// 防御性兜底:__gatewayRpc 正常会以 { ok:false } 返回,此分支覆盖调用栈意外抛错
|
|
472
|
+
return null;
|
|
444
473
|
}
|
|
445
474
|
}
|
|
446
475
|
|
|
@@ -601,7 +630,7 @@ export class RealtimeBridge {
|
|
|
601
630
|
this.__logDebug(`gateway connect ok <- id=${payload.id}`);
|
|
602
631
|
this.gatewayConnectReqId = null;
|
|
603
632
|
this.__ensureSessionsPromise = this.__ensureAllAgentSessions();
|
|
604
|
-
this.
|
|
633
|
+
this.__pushInstanceInfo();
|
|
605
634
|
}
|
|
606
635
|
else {
|
|
607
636
|
this.gatewayReady = false;
|