Browse Source

merge: 合并最新代码

master
Senor-Liu 1 month ago
parent
commit
05f6055a84
  1. 9
      web/client/src/app.jsx
  2. 2
      web/client/src/layout/components/header.jsx
  3. 2
      web/client/src/layout/index.jsx
  4. 2
      web/client/src/sections/aichat/router.js
  5. 2
      web/client/src/sections/articleSelect/actions/request.jsx
  6. 2
      web/client/src/sections/articleSelect/container/index.jsx
  7. 2
      web/client/src/sections/financeInvoice/components/FinanceInvoiceWorkspace.jsx
  8. 2
      web/client/src/sections/newAiChat/router.js
  9. 14
      web/client/src/sections/pepAuth/container/pepAuth.jsx
  10. 2
      web/client/src/sections/schemeList/container/schemeList.jsx
  11. 46
      web/client/src/sections/superAgent/container/index.jsx
  12. 6
      web/client/src/sections/superAgent/hooks/useSuperAgentChat.js
  13. 21
      web/client/src/sections/superAgent/hooks/useSuperAgentStream.js
  14. 2
      web/client/src/sections/superAgent/router.js
  15. 2
      web/client/src/sections/tender/container/tender.jsx
  16. 6
      web/client/src/utils/index.js

9
web/client/src/app.jsx

@ -207,17 +207,12 @@ const App = () => {
const initAuth = async () => { const initAuth = async () => {
const { search, pathname } = window.location; const { search, pathname } = window.location;
const urlParams = new URLSearchParams(search); const urlParams = new URLSearchParams(search);
const clientId = urlParams.get("clientid") || "pep-feixiaoshang";
const authRoutes = ["/tender", "/schemeList", "/automatedReports"]; const authRoutes = ["/tender", "/schemeList", "/automatedReports"];
if ( if (authRoutes.includes(pathname)) {
authRoutes.includes(pathname) ||
(pathname === "/aichat" && clientId === "pep-feixiaoshang")
) {
if (import.meta.env.DEV) return; // 开发环境跳过认证 if (import.meta.env.DEV) return; // 开发环境跳过认证
if (urlParams.get("dev") === "true") return; // url参数dev为true时跳过认证 if (urlParams.get("dev") === "true") return; // url参数dev为true时跳过认证
const query = search ? `${search}&redirect=${encodeURIComponent(pathname)}` : `?redirect=${encodeURIComponent(pathname)}`; window.location.replace("/chat");
window.location.replace(`/pepAuth${query}`);
} }
}; };

2
web/client/src/layout/components/header.jsx

@ -30,7 +30,7 @@ export default function header () {
items: [{ items: [{
label: <div onClick={() => { label: <div onClick={() => {
clearCompatibleAuthInfo(); clearCompatibleAuthInfo();
navigate("/aichat"); navigate("/chat");
}}> }}>
退出登录 退出登录
</div>, </div>,

2
web/client/src/layout/index.jsx

@ -95,7 +95,7 @@ export default function index(props) {
<Routes> <Routes>
{outerRoutes} {outerRoutes}
<Route path="/" element={<Layout routerNav={routerNav} />}> <Route path="/" element={<Layout routerNav={routerNav} />}>
<Route index element={<Navigate to="/aichat" replace />} /> <Route index element={<Navigate to="/chat" replace />} />
{innerRoutes} {innerRoutes}
</Route> </Route>
</Routes> </Routes>

2
web/client/src/sections/aichat/router.js

@ -4,7 +4,7 @@ export default {
type: 'outer', type: 'outer',
route: { route: {
key: 'aichat', key: 'aichat',
path: "/aichatv1", path: "/chatv1",
component: AiChat component: AiChat
} }
}; };

2
web/client/src/sections/articleSelect/actions/request.jsx

@ -11,7 +11,7 @@ export const apiRequest = new request({
if (err) { if (err) {
if (err?.status === 401) { if (err?.status === 401) {
clearCompatibleAuthInfo() clearCompatibleAuthInfo()
window.location.replace('/aichat'); window.location.replace('/chat');
} }
return err return err
} }

2
web/client/src/sections/articleSelect/container/index.jsx

@ -15,7 +15,7 @@ export default function MatchContainer() {
interceptor: (res, err) => { // 拦截器,用于处理请求结果,两参数互斥出现 interceptor: (res, err) => { // 拦截器,用于处理请求结果,两参数互斥出现
if (err) { if (err) {
if (err?.status === 401) { if (err?.status === 401) {
window.location.replace('/aichat'); window.location.replace('/chat');
sessionStorage.clear() sessionStorage.clear()
} }
return err return err

2
web/client/src/sections/financeInvoice/components/FinanceInvoiceWorkspace.jsx

@ -87,7 +87,7 @@ const formatQueryHistoryTitle = (item) => {
const handleFinanceInvoiceAuthExpired = () => { const handleFinanceInvoiceAuthExpired = () => {
clearCompatibleAuthInfo(); clearCompatibleAuthInfo();
window.location.replace("/aichat"); window.location.replace("/chat");
}; };
/** /**

2
web/client/src/sections/newAiChat/router.js

@ -4,7 +4,7 @@ export default {
type: "outer", type: "outer",
route: { route: {
key: "chat", key: "chat",
path: "/chat", path: "/chatv2",
component: NewAiChat, component: NewAiChat,
nav: false, nav: false,
}, },

14
web/client/src/sections/pepAuth/container/pepAuth.jsx

@ -15,9 +15,9 @@ export default function PepAuth() {
const urlParams = new URLSearchParams(search); const urlParams = new URLSearchParams(search);
const token = urlParams.get('token'); const token = urlParams.get('token');
if (!token) { if (!token) {
message.warning('请登录项企后跳转飞小尚'); message.warning('登录状态无效,请返回聊天页面');
setTimeout(() => { setTimeout(() => {
window.location.href = 'https://pep.anxinyun.cn' window.location.replace('/chat');
}, 2000); }, 2000);
return; return;
} }
@ -27,18 +27,18 @@ export default function PepAuth() {
const pepUserId = userRes.payload.data?.pepUserId || userRes.payload.data?.pepId || userRes.payload.data?.id; const pepUserId = userRes.payload.data?.pepUserId || userRes.payload.data?.pepId || userRes.payload.data?.id;
localStorage.setItem('userId', String(pepUserId || '')); localStorage.setItem('userId', String(pepUserId || ''));
localStorage.setItem('userInfo', JSON.stringify(userRes.payload.data)); localStorage.setItem('userInfo', JSON.stringify(userRes.payload.data));
window.location.replace(urlParams.get('redirect') || '/aichat'); window.location.replace(urlParams.get('redirect') || '/chat');
} else { } else {
message.warning('鉴权失败!请重新登录项企后跳转飞小尚'); message.warning('鉴权失败,请返回聊天页面');
setTimeout(() => { setTimeout(() => {
window.location.href = 'https://pep.anxinyun.cn'; window.location.replace('/chat');
}, 2000); }, 2000);
} }
} catch (error) { } catch (error) {
console.error(error); console.error(error);
message.warning('鉴权失败!请重新登录项企后跳转飞小尚'); message.warning('鉴权失败,请返回聊天页面');
setTimeout(() => { setTimeout(() => {
window.location.href = 'https://pep.anxinyun.cn'; window.location.replace('/chat');
}, 2000); }, 2000);
} }
} }

2
web/client/src/sections/schemeList/container/schemeList.jsx

@ -120,7 +120,7 @@ export default function SchemeList() {
<Header className={styles.header} style={{ background: '#fff', display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}> <Header className={styles.header} style={{ background: '#fff', display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<div style={{ display: 'flex', alignItems: 'center' }}> <div style={{ display: 'flex', alignItems: 'center' }}>
<Button onClick={() => { <Button onClick={() => {
navigate('/aichat'); navigate('/chat');
}} style={{ marginRight: 16 }}><LeftOutlined /></Button> }} style={{ marginRight: 16 }}><LeftOutlined /></Button>
<h1>方案清单</h1> <h1>方案清单</h1>
</div> </div>

46
web/client/src/sections/superAgent/container/index.jsx

@ -864,27 +864,25 @@ const SuperAgent = () => {
runtimeTask.sessionStatus || runtimeTask.sessionStatus ||
"" ""
).toLowerCase(); ).toLowerCase();
const hasLocalRunSignal = stream.isLocalRunActive === true;
const runtimeTaskType = String( const runtimeTaskType = String(
runtimeTask?.task_type || runtimeTask?.taskType || "" runtimeTask?.task_type || runtimeTask?.taskType || ""
).toLowerCase(); ).toLowerCase();
const runtimeTaskTotal = Number(runtimeTask?.total || 0); const runtimeTaskTotal = Number(runtimeTask?.total || 0);
const hasPersistedActiveThread = const hasPersistedActiveThread =
streamReadyForActiveSession && stream.isPersistedThreadActive === true; streamReadyForActiveSession && stream.isPersistedThreadActive === true;
const hasRuntimeExecutionSignal =
!hasPendingInterruptSignal &&
(
stream.isBusinessRunning ||
stream.isLocalRunActive ||
["running", "resuming"].includes(String(stream.runPhase || "").toLowerCase())
);
const displayTaskStatus = const displayTaskStatus =
hasRuntimeExecutionSignal && taskStatus === "suspended" hasLocalRunSignal && ["failed", "error"].includes(taskStatus)
? "running" ? "running"
: taskStatus; : taskStatus;
const displayRuntimeSessionStatus = const displayRuntimeSessionStatus =
hasRuntimeExecutionSignal && runtimeSessionStatus === "suspended" hasLocalRunSignal && ["failed", "error"].includes(runtimeSessionStatus)
? "running" ? "running"
: runtimeSessionStatus; : runtimeSessionStatus;
const isFailedTask =
["failed", "error"].includes(displayTaskStatus) ||
["failed", "error"].includes(displayRuntimeSessionStatus) ||
(stream.runPhase === "failed" && !hasPendingInterruptSignal && !hasLocalRunSignal);
const hasSuspendedRuntimeStatus = const hasSuspendedRuntimeStatus =
displayTaskStatus === "suspended" || displayRuntimeSessionStatus === "suspended"; displayTaskStatus === "suspended" || displayRuntimeSessionStatus === "suspended";
const displayActiveStreamTask = activeStreamTask const displayActiveStreamTask = activeStreamTask
@ -902,7 +900,7 @@ const SuperAgent = () => {
hasPendingInterruptSignal && hasPendingInterruptSignal &&
(taskStatus === "suspended" || runtimeSessionStatus === "suspended"); (taskStatus === "suspended" || runtimeSessionStatus === "suspended");
const hasPersistedRunningThread = const hasPersistedRunningThread =
hasPersistedActiveThread && !hasSuspendedRuntimeStatus; hasPersistedActiveThread && !hasSuspendedRuntimeStatus && !isFailedTask;
const isTerminalRuntimeSession = [ const isTerminalRuntimeSession = [
"failed", "failed",
"completed", "completed",
@ -933,10 +931,6 @@ const SuperAgent = () => {
(displayRuntimeSessionStatus (displayRuntimeSessionStatus
? displayRuntimeSessionStatus === "running" ? displayRuntimeSessionStatus === "running"
: ["running", "resuming"].includes(stream.runPhase)); : ["running", "resuming"].includes(stream.runPhase));
const isFailedTask =
["failed", "error"].includes(displayTaskStatus) ||
["failed", "error"].includes(displayRuntimeSessionStatus) ||
(stream.runPhase === "failed" && !hasPendingInterruptSignal);
const hasTerminalTaskStatus = [ const hasTerminalTaskStatus = [
"completed", "completed",
"done", "done",
@ -949,6 +943,7 @@ const SuperAgent = () => {
"suspended", "suspended",
].includes(displayTaskStatus) && !isSuspendedByInterrupt; ].includes(displayTaskStatus) && !isSuspendedByInterrupt;
const isTerminalTask = const isTerminalTask =
isFailedTask ||
(hasSuspendedRuntimeStatus && !isSuspendedByInterrupt) || (hasSuspendedRuntimeStatus && !isSuspendedByInterrupt) ||
(!hasPersistedActiveThread && !isBodyGenerationRuntimeActive && hasTerminalTaskStatus) || (!hasPersistedActiveThread && !isBodyGenerationRuntimeActive && hasTerminalTaskStatus) ||
isTerminalRuntimeSession || isTerminalRuntimeSession ||
@ -994,11 +989,12 @@ const SuperAgent = () => {
["running", "awaiting_interrupt", "resuming"].includes(stream.runPhase) && ["running", "awaiting_interrupt", "resuming"].includes(stream.runPhase) &&
(!isTerminalTask || stream.isLocalRunActive); (!isTerminalTask || stream.isLocalRunActive);
const isStreamRunning = const isStreamRunning =
hasPersistedRunningThread || !isFailedTask &&
(hasPersistedRunningThread ||
isBodyGenerationRuntimeActive || isBodyGenerationRuntimeActive ||
hasActiveStreamRunPhase || hasActiveStreamRunPhase ||
(hasStreamExecutionSignal && (hasStreamExecutionSignal &&
(!isTerminalTask || hasRunningTaskStatus || hasActiveToolCallSignal)); (!isTerminalTask || hasRunningTaskStatus || hasActiveToolCallSignal)));
const projectedStreamMessages = stream.messages; const projectedStreamMessages = stream.messages;
const streamConversationMessages = streamReadyForActiveSession const streamConversationMessages = streamReadyForActiveSession
? buildStreamConversationMessages( ? buildStreamConversationMessages(
@ -1517,12 +1513,17 @@ const SuperAgent = () => {
} }
}; };
const respondCheckpointToAgent = ({ response, interruptId, namespace, respondBody = {} }) => { const respondCheckpointToAgent = async ({
response,
interruptId,
namespace,
respondBody = {},
}) => {
const matchingInterrupt = activeStreamInterrupts.find((item) => { const matchingInterrupt = activeStreamInterrupts.find((item) => {
const payload = item?.value || item?.payload || {}; const payload = item?.value || item?.payload || {};
return payload.checkpoint_id === respondBody.checkpoint_id; return payload.checkpoint_id === respondBody.checkpoint_id;
}); });
return stream.respondInterrupt(response || { const result = await stream.respondInterrupt(response || {
type: respondBody.action || "respond", type: respondBody.action || "respond",
edits: respondBody.edits, edits: respondBody.edits,
display_content: respondBody.display_content, display_content: respondBody.display_content,
@ -1530,6 +1531,15 @@ const SuperAgent = () => {
interruptId: interruptId || matchingInterrupt?.id, interruptId: interruptId || matchingInterrupt?.id,
namespace: namespace || matchingInterrupt?.namespace, namespace: namespace || matchingInterrupt?.namespace,
}); });
try {
await stream.refreshState();
} catch (error) {
superAgentError("container.interrupt", "state.refresh_failed", {
sessionId: activeSessionId,
error,
});
}
return result;
}; };
const handleStopAndCancel = async () => { const handleStopAndCancel = async () => {

6
web/client/src/sections/superAgent/hooks/useSuperAgentChat.js

@ -1470,11 +1470,17 @@ const useSuperAgentChat = ({
const openAgentSquare = () => { const openAgentSquare = () => {
setRouteType("agents"); setRouteType("agents");
setWorkspaceOpen(false); setWorkspaceOpen(false);
setActiveSessionId("");
setActiveTaskId("");
clearActiveSessionId();
}; };
const openResourceLibrary = () => { const openResourceLibrary = () => {
setRouteType("assets"); setRouteType("assets");
setWorkspaceOpen(false); setWorkspaceOpen(false);
setActiveSessionId("");
setActiveTaskId("");
clearActiveSessionId();
}; };
const handleTenderQuickStart = () => { const handleTenderQuickStart = () => {

21
web/client/src/sections/superAgent/hooks/useSuperAgentStream.js

@ -1162,25 +1162,18 @@ const useSuperAgentStream = ({
!hasPersistedInterrupts && !hasPersistedInterrupts &&
["waiting_interrupt", "awaiting_interrupt"].includes(runPhase); ["waiting_interrupt", "awaiting_interrupt"].includes(runPhase);
const isPersistedThreadActive = const isPersistedThreadActive =
isPersistedTaskActive || hasPersistedNextNodes || hasPersistedInterrupts; hasPersistedInterrupts ||
isPersistedTaskActive ||
hasPersistedNextNodes;
const isPersistedExecutionActive = const isPersistedExecutionActive =
isPersistedThreadActive && isPersistedThreadActive &&
![ !["suspended", "waiting_user", "awaiting_interrupt", "waiting_interrupt"].includes(
"suspended", persistedTaskStatus
"waiting_user", ) &&
"awaiting_interrupt",
"waiting_interrupt",
].includes(persistedTaskStatus) &&
!hasPersistedInterrupts; !hasPersistedInterrupts;
const hasRuntimeExecutionSignal =
localRunActiveRef.current ||
isLocalRunActive ||
isBusinessRunning ||
["running", "resuming"].includes(runPhase);
const isPersistedSuspended = const isPersistedSuspended =
persistedTaskStatus === "suspended" && persistedTaskStatus === "suspended" &&
!hasPersistedInterrupts && !hasPersistedInterrupts;
!hasRuntimeExecutionSignal;
const isTerminalRunPhase = [ const isTerminalRunPhase = [
"completed", "completed",
"aborted", "aborted",

2
web/client/src/sections/superAgent/router.js

@ -18,7 +18,7 @@ export default {
type: "outer", type: "outer",
route: { route: {
key: "superAgent", key: "superAgent",
path: "/aichat", path: "/chat",
component: SuperAgent, component: SuperAgent,
nav: false, nav: false,
}, },

2
web/client/src/sections/tender/container/tender.jsx

@ -136,7 +136,7 @@ export default function Tender() {
<Header className={styles.header} style={{ background: '#fff', display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}> <Header className={styles.header} style={{ background: '#fff', display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<div style={{ display: 'flex', alignItems: 'center' }}> <div style={{ display: 'flex', alignItems: 'center' }}>
<Button onClick={() => { <Button onClick={() => {
navigate('/aichat'); navigate('/chat');
}} style={{ marginRight: 16 }}><LeftOutlined /></Button> }} style={{ marginRight: 16 }}><LeftOutlined /></Button>
<h1>我的标书</h1> <h1>我的标书</h1>
</div> </div>

6
web/client/src/utils/index.js

@ -34,7 +34,7 @@ const apiRequest = new request({
if (err) { if (err) {
if (err?.status === 401) { if (err?.status === 401) {
clearCompatibleAuthInfo(); clearCompatibleAuthInfo();
window.location.replace("/aichat"); window.location.replace("/chat");
} }
return err; return err;
} }
@ -48,7 +48,7 @@ const fgptRequest = new request({
if (err) { if (err) {
if (err?.status === 401) { if (err?.status === 401) {
clearCompatibleAuthInfo(); clearCompatibleAuthInfo();
window.location.replace("/aichat"); window.location.replace("/chat");
} }
return err; return err;
} }
@ -75,7 +75,7 @@ const schemeListRequest = new request({
if (err) { if (err) {
if (err?.status === 401) { if (err?.status === 401) {
clearCompatibleAuthInfo(); clearCompatibleAuthInfo();
window.location.replace("/aichat"); window.location.replace("/chat");
} }
return err; return err;
} }

Loading…
Cancel
Save