@yeaft/webchat-agent 1.0.236 → 1.0.237

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "1.0.236",
3
+ "version": "1.0.237",
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",
@@ -1734,12 +1734,13 @@ export class ConversationStore {
1734
1734
  *
1735
1735
  * @param {string} sessionId
1736
1736
  * @param {string} query
1737
- * @param {{ limit?: number, beforeSeq?: number|null }} [opts]
1737
+ * @param {{ limit?: number, beforeSeq?: number|null, senderKey?: string }} [opts]
1738
1738
  * @returns {{ results: object[], hasMore: boolean, nextBeforeSeq: number|null }}
1739
1739
  */
1740
1740
  searchVisibleBySession(sessionId, query, opts = {}) {
1741
1741
  const needle = typeof query === 'string' ? query.trim().toLocaleLowerCase() : '';
1742
- if (!sessionId || needle.length < 2) return { results: [], hasMore: false, nextBeforeSeq: null };
1742
+ const senderKey = typeof opts.senderKey === 'string' ? opts.senderKey : '';
1743
+ if (!sessionId || (needle.length < 2 && !senderKey)) return { results: [], hasMore: false, nextBeforeSeq: null };
1743
1744
 
1744
1745
  const limit = Math.min(50, Math.max(1, Number.isFinite(opts.limit) ? Math.floor(opts.limit) : 20));
1745
1746
  const beforeSeq = Number.isFinite(opts.beforeSeq) ? opts.beforeSeq : Infinity;
@@ -1747,8 +1748,14 @@ export class ConversationStore {
1747
1748
  let hasMore = false;
1748
1749
 
1749
1750
  for (const entry of this.#iterateVisibleResponseEntries(sessionId, { beforeSeq })) {
1751
+ const senderMatches = senderKey === 'user'
1752
+ ? entry.role === 'user'
1753
+ : (senderKey.startsWith('vp:')
1754
+ ? entry.role === 'assistant' && entry.speakerVpId === senderKey.slice(3)
1755
+ : true);
1756
+ if (!senderMatches) continue;
1750
1757
  const text = entry.textParts.join(' ');
1751
- const matchIndex = text.toLocaleLowerCase().indexOf(needle);
1758
+ const matchIndex = needle ? text.toLocaleLowerCase().indexOf(needle) : 0;
1752
1759
  if (matchIndex < 0) continue;
1753
1760
  if (results.length >= limit) {
1754
1761
  hasMore = true;
@@ -1756,7 +1763,9 @@ export class ConversationStore {
1756
1763
  }
1757
1764
  results.push({
1758
1765
  ...this.#projectVisibleResponseEntry(entry),
1759
- snippet: this.#searchSnippet(text, matchIndex, needle.length),
1766
+ snippet: needle
1767
+ ? this.#searchSnippet(text, matchIndex, needle.length)
1768
+ : this.#outlineSnippet(text),
1760
1769
  });
1761
1770
  }
1762
1771
 
@@ -6611,6 +6611,9 @@ export async function handleYeaftLoadHistoryOutline(msg) {
6611
6611
  export async function handleYeaftSearchHistory(msg) {
6612
6612
  const sessionId = typeof msg?.sessionId === 'string' ? msg.sessionId.trim() : '';
6613
6613
  const query = typeof msg?.query === 'string' ? msg.query.trim().slice(0, 500) : '';
6614
+ const senderKey = typeof msg?.senderKey === 'string' && (msg.senderKey === 'user' || msg.senderKey.startsWith('vp:'))
6615
+ ? msg.senderKey.slice(0, 103)
6616
+ : '';
6614
6617
  const requestId = typeof msg?.requestId === 'string' ? msg.requestId : null;
6615
6618
  const beforeSeq = Number.isFinite(msg?.beforeSeq) ? msg.beforeSeq : null;
6616
6619
  const limit = Math.min(50, Math.max(1, Number.isFinite(msg?.limit) ? Math.floor(msg.limit) : 20));
@@ -6619,13 +6622,14 @@ export async function handleYeaftSearchHistory(msg) {
6619
6622
  requestId,
6620
6623
  sessionId: sessionId || null,
6621
6624
  query,
6625
+ senderKey,
6622
6626
  results: [],
6623
6627
  hasMore: false,
6624
6628
  nextBeforeSeq: null,
6625
6629
  _requestClientId: msg?._requestClientId || null,
6626
6630
  };
6627
6631
 
6628
- if (!sessionId || query.length < 2) {
6632
+ if (!sessionId || (query.length < 2 && !senderKey)) {
6629
6633
  sendToServer(response);
6630
6634
  return;
6631
6635
  }
@@ -6634,7 +6638,7 @@ export async function handleYeaftSearchHistory(msg) {
6634
6638
  const defaultYeaftDir = ctx.CONFIG?.yeaftDir || DEFAULT_YEAFT_DIR;
6635
6639
  const storeDir = resolveSessionYeaftDir(defaultYeaftDir, sessionId);
6636
6640
  const store = new ConversationStore(storeDir);
6637
- const result = store.searchVisibleBySession(sessionId, query, { limit, beforeSeq });
6641
+ const result = store.searchVisibleBySession(sessionId, query, { limit, beforeSeq, senderKey });
6638
6642
  sendToServer({ ...response, ...result });
6639
6643
  } catch (err) {
6640
6644
  console.error('[Yeaft] Session history search failed:', err?.message || err);