@yushaw/sanqian-chat 0.2.9 → 0.2.11

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.
@@ -1,5 +1,6 @@
1
1
  import * as _yushaw_sanqian_sdk from '@yushaw/sanqian-sdk';
2
2
  import { SanqianSDK } from '@yushaw/sanqian-sdk';
3
+ export { AgentCapability, Capability, CapabilitySearchResult, CapabilityType, ContextCapability, ListCapabilitiesOptions, SearchCapabilitiesOptions, SkillCapability, ToolCapability } from '@yushaw/sanqian-sdk';
3
4
  import { BrowserWindow, WebContents } from 'electron';
4
5
 
5
6
  /**
@@ -1,5 +1,6 @@
1
1
  import * as _yushaw_sanqian_sdk from '@yushaw/sanqian-sdk';
2
2
  import { SanqianSDK } from '@yushaw/sanqian-sdk';
3
+ export { AgentCapability, Capability, CapabilitySearchResult, CapabilityType, ContextCapability, ListCapabilitiesOptions, SearchCapabilitiesOptions, SkillCapability, ToolCapability } from '@yushaw/sanqian-sdk';
3
4
  import { BrowserWindow, WebContents } from 'electron';
4
5
 
5
6
  /**
@@ -877,11 +877,10 @@ var import_electron2 = require("electron");
877
877
  var import_fs2 = __toESM(require("fs"));
878
878
  var import_os2 = __toESM(require("os"));
879
879
  var import_path2 = __toESM(require("path"));
880
- var BaseWindowClass;
881
880
  var WebContentsViewClass;
882
881
  try {
883
882
  const electron = require("electron");
884
- BaseWindowClass = electron.BaseWindow;
883
+ void electron.BaseWindow;
885
884
  WebContentsViewClass = electron.WebContentsView;
886
885
  } catch {
887
886
  }
@@ -852,11 +852,10 @@ import {
852
852
  import fs2 from "fs";
853
853
  import os2 from "os";
854
854
  import path2 from "path";
855
- var BaseWindowClass;
856
855
  var WebContentsViewClass;
857
856
  try {
858
857
  const electron = __require("electron");
859
- BaseWindowClass = electron.BaseWindow;
858
+ void electron.BaseWindow;
860
859
  WebContentsViewClass = electron.WebContentsView;
861
860
  } catch {
862
861
  }
@@ -6753,7 +6753,7 @@ function ToolCallItem({ toolCall, toolResult }) {
6753
6753
  const [expanded, setExpanded] = (0, import_react19.useState)(false);
6754
6754
  const hasArgs = toolCall.toolArgs && Object.keys(toolCall.toolArgs).length > 0;
6755
6755
  const rawName = cleanToolName(toolCall.toolName);
6756
- const displayName = rawName && !/^[{\[]/.test(rawName.trim()) ? rawName : toolCall.toolCallId || "tool";
6756
+ const displayName = rawName && !/^[{[]/.test(rawName.trim()) ? rawName : toolCall.toolCallId || "tool";
6757
6757
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
6758
6758
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
6759
6759
  "span",
@@ -6791,7 +6791,7 @@ function StreamingToolCallItem({
6791
6791
  const [expanded, setExpanded] = (0, import_react19.useState)(false);
6792
6792
  const hasArgs = toolCall.toolArgs && Object.keys(toolCall.toolArgs).length > 0;
6793
6793
  const rawName = cleanToolName(toolCall.toolName);
6794
- const displayName = rawName && !/^[{\[]/.test(rawName.trim()) ? rawName : toolCall.toolCallId || "tool";
6794
+ const displayName = rawName && !/^[{[]/.test(rawName.trim()) ? rawName : toolCall.toolCallId || "tool";
6795
6795
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
6796
6796
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
6797
6797
  "span",
@@ -7931,6 +7931,7 @@ var ResourcePicker = (0, import_react25.memo)(function ResourcePicker2({
7931
7931
  isOpen,
7932
7932
  onClose,
7933
7933
  providers,
7934
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- reserved for future use
7934
7935
  isLoadingProviders,
7935
7936
  selectedProviderId,
7936
7937
  onSelectProvider,
@@ -8635,7 +8636,9 @@ var SanqianChat = (0, import_react28.memo)(function SanqianChat2({
8635
8636
  const chatInputRef = (0, import_react28.useRef)(null);
8636
8637
  const messageListRef = (0, import_react28.useRef)(null);
8637
8638
  const onStateChangeRef = (0, import_react28.useRef)(onStateChange);
8638
- onStateChangeRef.current = onStateChange;
8639
+ (0, import_react28.useEffect)(() => {
8640
+ onStateChangeRef.current = onStateChange;
8641
+ }, [onStateChange]);
8639
8642
  const resolvedConfig = useResolvedUiConfig(config);
8640
8643
  const { themeClass, isDarkMode } = useResolvedTheme(resolvedConfig?.theme ?? "auto");
8641
8644
  const accentStyle = useAccentStyle(resolvedConfig?.accentColor);
@@ -9346,7 +9349,9 @@ var HistoryList = (0, import_react34.memo)(function HistoryList2({
9346
9349
  const [hoveredId, setHoveredId] = (0, import_react34.useState)(null);
9347
9350
  const loadMoreRef = (0, import_react34.useRef)(null);
9348
9351
  const isLoadingRef = (0, import_react34.useRef)(isLoading);
9349
- isLoadingRef.current = isLoading;
9352
+ (0, import_react34.useEffect)(() => {
9353
+ isLoadingRef.current = isLoading;
9354
+ }, [isLoading]);
9350
9355
  (0, import_react34.useEffect)(() => {
9351
9356
  if (!hasMore || loadError || !onLoadMore) return;
9352
9357
  const sentinel = loadMoreRef.current;
@@ -6674,7 +6674,7 @@ function ToolCallItem({ toolCall, toolResult }) {
6674
6674
  const [expanded, setExpanded] = useState12(false);
6675
6675
  const hasArgs = toolCall.toolArgs && Object.keys(toolCall.toolArgs).length > 0;
6676
6676
  const rawName = cleanToolName(toolCall.toolName);
6677
- const displayName = rawName && !/^[{\[]/.test(rawName.trim()) ? rawName : toolCall.toolCallId || "tool";
6677
+ const displayName = rawName && !/^[{[]/.test(rawName.trim()) ? rawName : toolCall.toolCallId || "tool";
6678
6678
  return /* @__PURE__ */ jsxs4("div", { children: [
6679
6679
  /* @__PURE__ */ jsxs4(
6680
6680
  "span",
@@ -6712,7 +6712,7 @@ function StreamingToolCallItem({
6712
6712
  const [expanded, setExpanded] = useState12(false);
6713
6713
  const hasArgs = toolCall.toolArgs && Object.keys(toolCall.toolArgs).length > 0;
6714
6714
  const rawName = cleanToolName(toolCall.toolName);
6715
- const displayName = rawName && !/^[{\[]/.test(rawName.trim()) ? rawName : toolCall.toolCallId || "tool";
6715
+ const displayName = rawName && !/^[{[]/.test(rawName.trim()) ? rawName : toolCall.toolCallId || "tool";
6716
6716
  return /* @__PURE__ */ jsxs4("div", { children: [
6717
6717
  /* @__PURE__ */ jsxs4(
6718
6718
  "span",
@@ -7860,6 +7860,7 @@ var ResourcePicker = memo10(function ResourcePicker2({
7860
7860
  isOpen,
7861
7861
  onClose,
7862
7862
  providers,
7863
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- reserved for future use
7863
7864
  isLoadingProviders,
7864
7865
  selectedProviderId,
7865
7866
  onSelectProvider,
@@ -8564,7 +8565,9 @@ var SanqianChat = memo13(function SanqianChat2({
8564
8565
  const chatInputRef = useRef13(null);
8565
8566
  const messageListRef = useRef13(null);
8566
8567
  const onStateChangeRef = useRef13(onStateChange);
8567
- onStateChangeRef.current = onStateChange;
8568
+ useEffect20(() => {
8569
+ onStateChangeRef.current = onStateChange;
8570
+ }, [onStateChange]);
8568
8571
  const resolvedConfig = useResolvedUiConfig(config);
8569
8572
  const { themeClass, isDarkMode } = useResolvedTheme(resolvedConfig?.theme ?? "auto");
8570
8573
  const accentStyle = useAccentStyle(resolvedConfig?.accentColor);
@@ -9275,7 +9278,9 @@ var HistoryList = memo15(function HistoryList2({
9275
9278
  const [hoveredId, setHoveredId] = useState20(null);
9276
9279
  const loadMoreRef = useRef16(null);
9277
9280
  const isLoadingRef = useRef16(isLoading);
9278
- isLoadingRef.current = isLoading;
9281
+ useEffect23(() => {
9282
+ isLoadingRef.current = isLoading;
9283
+ }, [isLoading]);
9279
9284
  useEffect23(() => {
9280
9285
  if (!hasMore || loadError || !onLoadMore) return;
9281
9286
  const sentinel = loadMoreRef.current;
@@ -9373,7 +9378,7 @@ var HistoryList = memo15(function HistoryList2({
9373
9378
  });
9374
9379
 
9375
9380
  // src/renderer/components/HistoryModal.tsx
9376
- import { memo as memo16, useEffect as useEffect24, useCallback as useCallback20, useRef as useRef17, useState as useState21 } from "react";
9381
+ import { memo as memo16, useEffect as useEffect24, useCallback as useCallback19, useRef as useRef17, useState as useState21 } from "react";
9377
9382
  import { jsx as jsx23, jsxs as jsxs18 } from "react/jsx-runtime";
9378
9383
  var ANIMATION_DURATION = 120;
9379
9384
  var HistoryModal = memo16(function HistoryModal2({
@@ -9399,7 +9404,7 @@ var HistoryModal = memo16(function HistoryModal2({
9399
9404
  }, ANIMATION_DURATION);
9400
9405
  }
9401
9406
  }, [isOpen, shouldRender, isClosing]);
9402
- const handleClose = useCallback20(() => {
9407
+ const handleClose = useCallback19(() => {
9403
9408
  setIsClosing(true);
9404
9409
  setTimeout(() => {
9405
9410
  setShouldRender(false);
@@ -9422,7 +9427,7 @@ var HistoryModal = memo16(function HistoryModal2({
9422
9427
  if (!isOpen || !modalRef.current) return;
9423
9428
  modalRef.current.focus();
9424
9429
  }, [isOpen]);
9425
- const handleBackdropClick = useCallback20(
9430
+ const handleBackdropClick = useCallback19(
9426
9431
  (e) => {
9427
9432
  if (e.target === e.currentTarget && !isClosing) {
9428
9433
  handleClose();
@@ -9561,7 +9566,7 @@ var HistoryModal = memo16(function HistoryModal2({
9561
9566
  });
9562
9567
 
9563
9568
  // src/renderer/components/CompactChat.tsx
9564
- import { memo as memo17, useRef as useRef18, useState as useState22, useEffect as useEffect25, useCallback as useCallback21, useMemo as useMemo12 } from "react";
9569
+ import { memo as memo17, useRef as useRef18, useState as useState22, useEffect as useEffect25, useCallback as useCallback20, useMemo as useMemo12 } from "react";
9565
9570
  import { createPortal } from "react-dom";
9566
9571
 
9567
9572
  // src/renderer/components/PanelControls.tsx
@@ -9703,14 +9708,14 @@ var CompactChat = memo17(function CompactChat2({
9703
9708
  () => resourcePicker.providers.filter((p) => p.hasGetList),
9704
9709
  [resourcePicker.providers]
9705
9710
  );
9706
- const handleHitlCancel = useCallback21(() => {
9711
+ const handleHitlCancel = useCallback20(() => {
9707
9712
  if (chat.pendingInterrupt?.type === "approval_request") {
9708
9713
  chat.rejectHitl();
9709
9714
  } else {
9710
9715
  chat.submitHitlInput({ cancelled: true });
9711
9716
  }
9712
9717
  }, [chat.pendingInterrupt?.type, chat.rejectHitl, chat.submitHitlInput]);
9713
- const handleSendWithResources = useCallback21((content) => {
9718
+ const handleSendWithResources = useCallback20((content) => {
9714
9719
  const resources = resourcePicker.attachedResources;
9715
9720
  chat.sendMessage(content, resources.length > 0 ? { attachedResources: resources } : void 0);
9716
9721
  resourcePicker.clearAttachedResources();
@@ -9761,14 +9766,14 @@ var CompactChat = memo17(function CompactChat2({
9761
9766
  conversations.loadConversations();
9762
9767
  }
9763
9768
  }, [showHistory, connection.isConnected]);
9764
- const handleSelectConversation = useCallback21(
9769
+ const handleSelectConversation = useCallback20(
9765
9770
  async (id) => {
9766
9771
  setShowHistory(false);
9767
9772
  await chat.loadConversation(id);
9768
9773
  },
9769
9774
  [chat]
9770
9775
  );
9771
- const handleDeleteConversation = useCallback21(
9776
+ const handleDeleteConversation = useCallback20(
9772
9777
  async (id) => {
9773
9778
  await conversations.deleteConversation(id);
9774
9779
  if (id === chat.conversationId) {
@@ -9777,7 +9782,7 @@ var CompactChat = memo17(function CompactChat2({
9777
9782
  },
9778
9783
  [conversations, chat]
9779
9784
  );
9780
- const handleNewChat = useCallback21(() => {
9785
+ const handleNewChat = useCallback20(() => {
9781
9786
  chat.newConversation();
9782
9787
  setShowHistory(false);
9783
9788
  setTimeout(() => {
@@ -9798,7 +9803,7 @@ var CompactChat = memo17(function CompactChat2({
9798
9803
  }, [handleNewChat]);
9799
9804
  const isMac = typeof navigator !== "undefined" && navigator.platform.includes("Mac");
9800
9805
  const shortcutKey = isMac ? "\u2318N" : "Ctrl+N";
9801
- const defaultRenderMessage = useCallback21((message) => {
9806
+ const defaultRenderMessage = useCallback20((message) => {
9802
9807
  if (message.role === "tool") return null;
9803
9808
  const isUser = message.role === "user";
9804
9809
  const hasToolCalls = message.toolCalls && message.toolCalls.length > 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yushaw/sanqian-chat",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
4
4
  "description": "Floating chat window SDK for Sanqian AI Assistant",
5
5
  "main": "./dist/main/index.js",
6
6
  "types": "./dist/main/index.d.ts",
@@ -44,7 +44,7 @@
44
44
  "test:watch": "vitest"
45
45
  },
46
46
  "dependencies": {
47
- "@yushaw/sanqian-sdk": "^0.3.4",
47
+ "@yushaw/sanqian-sdk": "^0.3.5",
48
48
  "react-virtuoso": "^4.15.0",
49
49
  "rehype-harden": "^1.1.6",
50
50
  "remark-gfm": "^4.0.1",