@yeaft/webchat-agent 0.1.901 → 0.1.903
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.
|
@@ -37,7 +37,7 @@ import { handleRestartAgent, handleUpgradeAgent } from './upgrade.js';
|
|
|
37
37
|
import { loadMcpServers, updateMcpConfig } from '../mcp.js';
|
|
38
38
|
import { getLlmConfig, updateLlmConfig, getYeaftSettings, updateYeaftSettings, getSearchSettings, updateSearchSettings, fetchTavilyUsage } from '../yeaft/config-api.js';
|
|
39
39
|
import { fetchModelsDev } from '../yeaft/llm/models-dev.js';
|
|
40
|
-
import { handleYeaftSessionSend, handleYeaftModeSwitch, handleYeaftModelSwitch, resetYeaftSession, handleYeaftLoadHistory, handleYeaftLoadMoreHistory, handleYeaftAbortThread, handleYeaftAbortAll, handleYeaftAbortTurn, handleYeaftVpSubscribe, handleYeaftVpCreate, handleYeaftVpUpdate, handleYeaftVpDelete, handleYeaftVpRead, handleYeaftListSessions, handleYeaftCreateSession, handleYeaftRenameSession, handleYeaftUpdateSession, handleYeaftUpdateSessionConfig, handleYeaftArchiveSession, handleYeaftDeleteSession, handleYeaftSessionAddMember, handleYeaftSessionRemoveMember, handleYeaftSessionSetDefaultVp, handleYeaftDreamTrigger, handleYeaftFetchToolStats, handleYeaftFetchDebugHistory, broadcastLanguageChange } from '../yeaft/web-bridge.js';
|
|
40
|
+
import { handleYeaftSessionSend, handleYeaftModeSwitch, handleYeaftModelSwitch, resetYeaftSession, handleYeaftLoadHistory, handleYeaftLoadMoreHistory, handleYeaftAbortThread, handleYeaftAbortAll, handleYeaftAbortTurn, handleYeaftVpSubscribe, handleYeaftVpCreate, handleYeaftVpUpdate, handleYeaftVpDelete, handleYeaftVpRead, handleYeaftListSessions, handleYeaftCreateSession, handleYeaftRenameSession, handleYeaftUpdateSession, handleYeaftUpdateSessionConfig, handleYeaftArchiveSession, handleYeaftDeleteSession, handleYeaftSessionAddMember, handleYeaftSessionRemoveMember, handleYeaftSessionSetDefaultVp, handleYeaftDreamTrigger, handleYeaftFetchToolStats, handleYeaftFetchDebugHistory, broadcastLanguageChange, broadcastYeaftSessionSnapshotEager } from '../yeaft/web-bridge.js';
|
|
41
41
|
|
|
42
42
|
export async function handleMessage(msg) {
|
|
43
43
|
// Wire-compat: old web bundles send `groupId` on Yeaft messages;
|
|
@@ -72,6 +72,16 @@ export async function handleMessage(msg) {
|
|
|
72
72
|
|
|
73
73
|
sendConversationList();
|
|
74
74
|
|
|
75
|
+
// fix-yeaft-session-per-agent: eagerly broadcast this agent's
|
|
76
|
+
// yeaft session snapshot on register so the unified sidebar can
|
|
77
|
+
// populate ALL online agents' rows without waiting for the user
|
|
78
|
+
// to send a first yeaft message (which is what historically
|
|
79
|
+
// triggered ensureSessionLoaded → snapshot emit). This fixes the
|
|
80
|
+
// "switch to Agent B and B's sessions are invisible" symptom.
|
|
81
|
+
// The callee already wraps its FS scan + emit in try/catch and
|
|
82
|
+
// logs via console.warn — no second guard needed here.
|
|
83
|
+
broadcastYeaftSessionSnapshotEager();
|
|
84
|
+
|
|
75
85
|
// ★ Flush 断连期间缓冲的消息
|
|
76
86
|
await flushMessageBuffer();
|
|
77
87
|
|
package/package.json
CHANGED
|
@@ -78,9 +78,10 @@ export class AmsRegistry {
|
|
|
78
78
|
/**
|
|
79
79
|
* Resolve the on-disk path for a group's ams.json.
|
|
80
80
|
*
|
|
81
|
-
* `sessionId` is trusted: `nextSessionId()` (
|
|
82
|
-
* `grp_[a-z0-9_-]
|
|
83
|
-
* `DEFAULT_GROUP_KEY`. No defensive
|
|
81
|
+
* `sessionId` is trusted: `nextSessionId()` (sessions/ids.js) emits ids matching
|
|
82
|
+
* `grp_[a-z0-9_-]+_[0-9A-HJKMNP-TV-Z]{8}` (slug + 8-char crockford suffix),
|
|
83
|
+
* and the single-VP path uses the literal `DEFAULT_GROUP_KEY`. No defensive
|
|
84
|
+
* escaping is needed.
|
|
84
85
|
*
|
|
85
86
|
* @param {string} sessionId
|
|
86
87
|
* @returns {string}
|
package/yeaft/sessions/ids.js
CHANGED
|
@@ -38,9 +38,15 @@ export function nextMsgId() {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export function nextSessionId(slug = 'default') {
|
|
41
|
-
// Slug-tolerant: lowercase a-z0-9_- only
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
// Slug-tolerant: lowercase a-z0-9_- only, capped at 24 chars so the
|
|
42
|
+
// total id stays compact after the suffix is appended.
|
|
43
|
+
const safe = String(slug).toLowerCase().replace(/[^a-z0-9_-]+/g, '-').slice(0, 24) || 'group';
|
|
44
|
+
// Append 8 crockford-base32 chars (~40 bits) so re-creating a session
|
|
45
|
+
// with the same display name yields a fresh id instead of throwing
|
|
46
|
+
// `duplicate` on the existsSync check in session-crud.js. The
|
|
47
|
+
// `duplicate` branch is now a true defensive guard rather than the
|
|
48
|
+
// first-collision footgun it used to be.
|
|
49
|
+
return `grp_${safe}_${randEncoded(8)}`;
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
/**
|
package/yeaft/web-bridge.js
CHANGED
|
@@ -1441,6 +1441,23 @@ function sendGroupSnapshotBroadcast() {
|
|
|
1441
1441
|
}
|
|
1442
1442
|
}
|
|
1443
1443
|
|
|
1444
|
+
/**
|
|
1445
|
+
* Eager-broadcast this agent's session snapshot to the server (which
|
|
1446
|
+
* relays it to all owner clients with `agentId` stamped). Called on
|
|
1447
|
+
* `registered` so the unified sidebar can render this agent's sessions
|
|
1448
|
+
* the moment the agent connects — without waiting for the user to
|
|
1449
|
+
* first enter Yeaft view and trigger `ensureSessionLoaded`. Cheap:
|
|
1450
|
+
* pure FS scan of `~/.yeaft/sessions/`, no engine boot.
|
|
1451
|
+
*
|
|
1452
|
+
* fix-yeaft-session-per-agent: previously, Agent B's sessions were
|
|
1453
|
+
* invisible in the unified sidebar until the user clicked into B's
|
|
1454
|
+
* Yeaft view, because `sendGroupSnapshotBroadcast` only fired from
|
|
1455
|
+
* `ensureSessionLoaded`. That made the cross-agent list look broken
|
|
1456
|
+
* ("I see A but not B even though B is online") and was a major
|
|
1457
|
+
* contributor to the "session list disappears on switch" symptom.
|
|
1458
|
+
*/
|
|
1459
|
+
export { sendGroupSnapshotBroadcast as broadcastYeaftSessionSnapshotEager };
|
|
1460
|
+
|
|
1444
1461
|
function sendGroupRosterChanged(session) {
|
|
1445
1462
|
if (!session) return;
|
|
1446
1463
|
const payload = {
|