@yeaft/webchat-agent 1.0.67 → 1.0.69

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.
@@ -38,7 +38,7 @@ import { loadMcpServers, updateMcpConfig } from '../mcp.js';
38
38
  import { getLlmConfig, updateLlmConfig, getYeaftSettings, updateYeaftSettings, getSearchSettings, updateSearchSettings, fetchTavilyUsage } from '../yeaft/config-api.js';
39
39
  import { discoverLlmModels } from '../llm-model-discovery.js';
40
40
  import { fetchModelsDev } from '../yeaft/llm/models-dev.js';
41
- import { handleYeaftSessionSend, handleYeaftSubAgentPrompt, handleYeaftTaskCancel, handleYeaftModeSwitch, handleYeaftModelSwitch, resetYeaftSession, handleYeaftLoadHistory, handleYeaftLoadMoreHistory, handleYeaftAbortThread, handleYeaftAbortAll, handleYeaftAbortTurn, handleYeaftVpSubscribe, handleYeaftVpCreate, handleYeaftVpUpdate, handleYeaftVpDelete, handleYeaftVpRead, handleYeaftListSessions, handleYeaftCreateSession, handleYeaftRenameSession, handleYeaftUpdateSession, handleYeaftUpdateSessionConfig, handleYeaftArchiveSession, handleYeaftDeleteSession, handleYeaftSessionAddMember, handleYeaftSessionRemoveMember, handleYeaftSessionSetDefaultVp, handleYeaftScanWorkdirSessions, handleYeaftRestoreSession, handleYeaftDreamTrigger, handleYeaftFetchToolStats, handleYeaftFetchDebugHistory, handleYeaftMcpList, handleYeaftMcpAdd, handleYeaftMcpRemove, handleYeaftMcpReload, broadcastLanguageChange, broadcastYeaftSessionSnapshotEager } from '../yeaft/web-bridge.js';
41
+ import { handleYeaftSessionSend, handleYeaftSubAgentPrompt, handleYeaftTaskCancel, handleYeaftModeSwitch, handleYeaftModelSwitch, resetYeaftSession, handleYeaftLoadHistory, handleYeaftLoadMoreHistory, handleYeaftAbortThread, handleYeaftAbortAll, handleYeaftAbortTurn, handleYeaftVpSubscribe, handleYeaftVpCreate, handleYeaftVpUpdate, handleYeaftVpDelete, handleYeaftVpRead, handleYeaftListSessions, handleYeaftCreateSession, handleYeaftRenameSession, handleYeaftUpdateSession, handleYeaftUpdateSessionConfig, handleYeaftArchiveSession, handleYeaftDeleteSession, handleYeaftSessionAddMember, handleYeaftSessionRemoveMember, handleYeaftSessionSetDefaultVp, handleYeaftScanWorkdirSessions, handleYeaftRestoreSession, handleYeaftDreamTrigger, handleYeaftFetchToolStats, handleYeaftFetchDebugHistory, handleYeaftMcpList, handleYeaftMcpAdd, handleYeaftMcpRemove, handleYeaftMcpReload, broadcastLanguageChange, broadcastYeaftSessionSnapshotEager, preloadYeaftSkillSlashCommands } from '../yeaft/web-bridge.js';
42
42
  import { startYeaftStatusRefresh, refreshYeaftStatus } from '../yeaft/status-cache.js';
43
43
 
44
44
  export async function handleMessage(msg) {
@@ -68,6 +68,8 @@ export async function handleMessage(msg) {
68
68
  reconnectInterval: ctx.CONFIG.reconnectInterval
69
69
  // 不保存 agentSecret 到配置文件(安全考虑)
70
70
  });
71
+ ctx.AGENT_ID = msg.agentId;
72
+ ctx.agentId = msg.agentId;
71
73
  console.log(`Registered as agent: ${msg.agentId} (name: ${ctx.CONFIG.agentName})`);
72
74
 
73
75
  // Check server-pushed upgrade notification
@@ -100,8 +102,12 @@ export async function handleMessage(msg) {
100
102
  sendToServer({ type: 'mcp_servers_list', servers: ctx.mcpServers });
101
103
  }
102
104
 
103
- // ★ Preload slash commands for immediate skill availability in new sessions
104
- preloadSlashCommands().catch(() => {});
105
+ // ★ Preload slash commands for immediate skill availability in new sessions.
106
+ // Load Claude/CLI commands first; Yeaft skill preload merges into that
107
+ // cache instead of making Claude Chat think the Yeaft-only list is final.
108
+ preloadSlashCommands()
109
+ .catch(() => {})
110
+ .finally(() => { preloadYeaftSkillSlashCommands(); });
105
111
  break;
106
112
 
107
113
  case 'create_conversation':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "1.0.67",
3
+ "version": "1.0.69",
4
4
  "description": "Remote worker agent for Yeaft Web Code Agent — connects the native Yeaft engine, CLI providers, and workbench tools",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -724,6 +724,11 @@ const ESCALATE_AFTER_ABORT_MS = 15_000;
724
724
  /** Virtual conversationId for the Yeaft session */
725
725
  let yeaftConversationId = null;
726
726
 
727
+ /** Last agent-level Yeaft slash command payload. Replayed after the web side
728
+ * creates/replaces the virtual Yeaft conversation id so `/` autocomplete never
729
+ * falls back to built-ins while full Session metadata is still loading. */
730
+ let lastYeaftSlashCommandSnapshot = null;
731
+
727
732
  /** task-334-followup-batch-b: stored unsubscribe fn from VP subscribe,
728
733
  * called on session reset to prevent stale subscriber leaks. */
729
734
  let _vpUnsubscribe = null;
@@ -920,7 +925,10 @@ function loadVisibleGroupHistoryPage(store, sessionId, limit, beforeSeq = null)
920
925
  }
921
926
 
922
927
  function ensureYeaftConversationId() {
923
- if (!yeaftConversationId) yeaftConversationId = `yeaft-${Date.now()}`;
928
+ if (!yeaftConversationId) {
929
+ yeaftConversationId = `yeaft-${Date.now()}`;
930
+ replayCachedSkillSlashCommandsToYeaftConversation();
931
+ }
924
932
  return yeaftConversationId;
925
933
  }
926
934
 
@@ -1807,6 +1815,8 @@ export async function __testResetVpState() {
1807
1815
  sessionContexts.clear();
1808
1816
  vpCurrentTodos.clear();
1809
1817
  threadClassifier = defaultClassifyThread;
1818
+ yeaftConversationId = null;
1819
+ lastYeaftSlashCommandSnapshot = null;
1810
1820
  // Per-group compact in-flight + pending state lives on the session's
1811
1821
  // Compactor. Clear it so a follow-on test doesn't see ghost in-flight
1812
1822
  // promises from a prior run.
@@ -1880,6 +1890,39 @@ export function buildMergedSkillSlashCommands(skillManagers = []) {
1880
1890
  return { commands: [...new Set(commands)].sort((a, b) => a.localeCompare(b)), descriptions };
1881
1891
  }
1882
1892
 
1893
+ function sendSkillSlashCommandsUpdate({ conversationId, slashCommands, slashCommandDescriptions }) {
1894
+ sendToServer({
1895
+ type: 'slash_commands_update',
1896
+ agentId: ctx.AGENT_ID || ctx.agentId || null,
1897
+ conversationId,
1898
+ slashCommands,
1899
+ slashCommandDescriptions,
1900
+ });
1901
+ }
1902
+
1903
+ function replayCachedSkillSlashCommandsToYeaftConversation() {
1904
+ if (!yeaftConversationId || !lastYeaftSlashCommandSnapshot) return;
1905
+ sendSkillSlashCommandsUpdate({
1906
+ conversationId: yeaftConversationId,
1907
+ slashCommands: lastYeaftSlashCommandSnapshot.slashCommands,
1908
+ slashCommandDescriptions: lastYeaftSlashCommandSnapshot.slashCommandDescriptions,
1909
+ });
1910
+ }
1911
+
1912
+ export function preloadYeaftSkillSlashCommands() {
1913
+ const yeaftDir = ctx.CONFIG?.yeaftDir || DEFAULT_YEAFT_DIR;
1914
+ const roots = [process.cwd()];
1915
+ const configuredWorkDir = typeof ctx.CONFIG?.workDir === 'string' ? ctx.CONFIG.workDir.trim() : '';
1916
+ if (configuredWorkDir && configuredWorkDir !== process.cwd()) roots.push(configuredWorkDir);
1917
+ const skillManager = createSkillManager(yeaftDir, roots.join(delimiter));
1918
+ broadcastSkillSlashCommands({ skillManager });
1919
+ return {
1920
+ skills: skillManager.size,
1921
+ slashCommands: ctx.slashCommands,
1922
+ slashCommandDescriptions: ctx.slashCommandDescriptions,
1923
+ };
1924
+ }
1925
+
1883
1926
  function broadcastSkillSlashCommands(sessionLike, extraSkillManagers = []) {
1884
1927
  const managers = [sessionLike?.skillManager, ...extraSkillManagers].filter(Boolean);
1885
1928
  const { commands, descriptions } = buildMergedSkillSlashCommands(managers);
@@ -1894,9 +1937,8 @@ function broadcastSkillSlashCommands(sessionLike, extraSkillManagers = []) {
1894
1937
  Object.assign(slashCommandDescriptions, descriptions);
1895
1938
  ctx.slashCommands = slashCommands;
1896
1939
  ctx.slashCommandDescriptions = slashCommandDescriptions;
1897
- sendToServer({
1898
- type: 'slash_commands_update',
1899
- agentId: ctx.AGENT_ID || ctx.agentId || null,
1940
+ lastYeaftSlashCommandSnapshot = { slashCommands, slashCommandDescriptions };
1941
+ sendSkillSlashCommandsUpdate({
1900
1942
  conversationId: yeaftConversationId || '__preload__',
1901
1943
  slashCommands,
1902
1944
  slashCommandDescriptions,
@@ -5917,6 +5959,12 @@ export const __testHooks = {
5917
5959
  session = nextSession || null;
5918
5960
  sessionLoadPromise = null;
5919
5961
  },
5962
+ ensureYeaftConversationIdForTest() {
5963
+ return ensureYeaftConversationId();
5964
+ },
5965
+ preloadYeaftSkillSlashCommandsForTest() {
5966
+ return broadcastSkillSlashCommands(session);
5967
+ },
5920
5968
  resetAbortState() {
5921
5969
  turnAbortCtrls.clear();
5922
5970
  turnAbortMeta.clear();