@zero-library/chat-copilot 3.1.20 → 3.1.21

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/dist/index.cjs.js CHANGED
@@ -1213,17 +1213,6 @@ function createChatStore() {
1213
1213
  agent.loading = false;
1214
1214
  }
1215
1215
  };
1216
- const setAgent = (agentInfo) => {
1217
- agent.agentInfo = agentInfo;
1218
- if (agentInfo.agentType === 2 /* AUTONOMOUS */) {
1219
- setAgentModel({
1220
- modelName: agent.agentInfo.spec?.model?.modelName || "",
1221
- providerName: agent.agentInfo.spec?.model?.providerName || ""
1222
- });
1223
- } else if (config.layout.userInput) {
1224
- getUserInput(agent.agentInfo.id);
1225
- }
1226
- };
1227
1216
  const setUserInput = (userInput) => {
1228
1217
  if (agent.agentInfo.agentType === 1 /* FLOW */) {
1229
1218
  agent.agentInfo.userInput = userInput;
@@ -1231,15 +1220,28 @@ function createChatStore() {
1231
1220
  };
1232
1221
  const getAgentInfo = async (id) => {
1233
1222
  config.loading = true;
1234
- if (agent.agentInfo.id === id) return;
1235
1223
  try {
1236
1224
  const { data } = await config.services.request.fetchAgentInfo(id || "");
1237
- setAgent(data);
1238
- config.hooks?.onAfterSwitchAgent?.(data);
1225
+ agent.agentInfo = data;
1226
+ config.hooks?.onAfterSwitchAgent?.(agent.agentInfo);
1239
1227
  } finally {
1240
1228
  config.loading = false;
1241
1229
  }
1242
1230
  };
1231
+ const setAgent = async (agentInfo) => {
1232
+ if (!agent.agentInfo.id || agent.agentInfo.id !== agentInfo.id) {
1233
+ await getAgentInfo(agentInfo.id);
1234
+ }
1235
+ agent.agentInfo = { ...agent.agentInfo, ...agentInfo };
1236
+ if (agentInfo.agentType === 2 /* AUTONOMOUS */) {
1237
+ setAgentModel({
1238
+ modelName: agent.agentInfo.spec?.model?.modelName || "",
1239
+ providerName: agent.agentInfo.spec?.model?.providerName || ""
1240
+ });
1241
+ } else if (config.layout.userInput) {
1242
+ await getUserInput(agent.agentInfo.id);
1243
+ }
1244
+ };
1243
1245
  const conversations = valtio.proxy({
1244
1246
  /** 会话列表数据 */
1245
1247
  list: {
@@ -2292,7 +2294,7 @@ var ConversationShareBtn_default = ({ icon, ...rest }) => {
2292
2294
  const handleShareConversation = async () => {
2293
2295
  const { data } = await configState.services.request.shareConversation(conversationState.active.id);
2294
2296
  if (data) {
2295
- common.copyText(data.url);
2297
+ common.copyText(data.url, "\u94FE\u63A5\u5DF2\u590D\u5236\uFF0C\u53EF\u76F4\u63A5\u7C98\u8D34\u5206\u4EAB");
2296
2298
  }
2297
2299
  };
2298
2300
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -6635,25 +6637,10 @@ var layouts_default = React10.forwardRef(({ theme: theme5, params, hooks, layout
6635
6637
  chatStore.setServices(services);
6636
6638
  }, [services]);
6637
6639
  common.useDeepEffect(() => {
6638
- if (agentState.agentInfo.id && common.isObject(config.agent?.spec)) {
6639
- chatStore.setAgent({ ...agentState.agentInfo, spec: config.agent.spec || {} });
6640
- }
6641
- }, [agentState.agentInfo.id, config.agent?.spec]);
6642
- common.useDeepEffect(() => {
6643
- if (agentState.agentInfo.id && common.isObject(config.agent?.config)) {
6644
- chatStore.setAgent({ ...agentState.agentInfo, config: config.agent.config || {} });
6645
- }
6646
- }, [agentState.agentInfo.id, config.agent?.config]);
6647
- common.useDeepEffect(() => {
6648
- if (agentState.agentInfo.id) {
6649
- chatStore.setUserInput(config.agent.userInput);
6650
- }
6651
- }, [agentState.agentInfo.id, config.agent?.userInput]);
6652
- common.useDeepEffect(() => {
6653
- if (config?.agent?.id) {
6654
- chatStore.getAgentInfo(config.agent.id);
6640
+ if (config.agent) {
6641
+ chatStore.setAgent(config.agent);
6655
6642
  }
6656
- }, [config.agent?.id]);
6643
+ }, [config.agent]);
6657
6644
  common.useDeepEffect(() => {
6658
6645
  if (agentState.agentInfo.id) {
6659
6646
  chatStore.initConversation(config);