refactor(agent): runAgent uses Agent upstreams only; deprecate legacy settings.pi fields
pi.provider / baseUrl / model / thinkingLevel / apiKeySecretRef are now DEPRECATED_SETTINGS_FIELDS: kept in the schema for stored JSON, dropped from PATCH /settings and from the settings sections, never read by the server. runAgent fails with a clear message when no upstream is set. The agent demo gate checks the default upstream provider; e2e seeds a fake upstream as default. OpenAPI summaries say Agent upstream. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
fb7727cf66
commit
3e37ac8ae7
15 files changed
+122
-115
No files matched your search
@@ -24,12 +24,12 @@ import { MOCK_RUNS, mockCreateRun, mockDetail, mockEventsAfter } from "~/compone
|
||||
import { TTL_SECOND } from "~/lib/api.ts";
|
||||
import { useSession } from "./auth.ts";
|
||||
import { apiMutate, apiParsed, cleanParams } from "./parse.ts";
|
||||
import { useSettings } from "./settings.ts";
|
||||
import { usePiUpstreams } from "./pi.ts";
|
||||
|
||||
// Agent 会话(W2-D:GET/POST /agent/runs、GET /agent/runs/{id}?afterSeq=、/messages、/abort),
|
||||
// 形状一律取 contracts(AgentRun / AgentRunDetail / AgentGoalReport)。
|
||||
// ?mock=1(或 VITE_AGENT_MOCK=1)只作演示开关:不连后端,用本地假数据预览交互;
|
||||
// 仅开发构建或后端 pi.provider = "fake" 时生效,生产构建连真实模型时忽略(见 agentMockAllowed)。
|
||||
// 仅开发构建或后端默认上游是 fake 时生效,生产构建连真实模型时忽略(见 agentMockAllowed)。
|
||||
|
||||
export const AGENT_BASE = "/api/v1/agent/runs";
|
||||
|
||||
@@ -48,7 +48,7 @@ export type RunSnapshot = Omit<RunDetail, "events" | "nextAfterSeq">;
|
||||
const RunPage = cursorPage(AgentRun);
|
||||
|
||||
/**
|
||||
* 演示开关是否可用:只在开发构建(import.meta.env.DEV)或后端 pi.provider = "fake"(脚本化假模型)时生效。
|
||||
* 演示开关是否可用:只在开发构建(import.meta.env.DEV)或后端默认上游 provider = "fake"(脚本化假模型)时生效。
|
||||
* 生产构建连着真实模型时一律忽略 ?mock=1 / VITE_AGENT_MOCK,并清掉 sessionStorage 里记住的开关,
|
||||
* 避免把演示数据当成真实运行展示(验收 S7 / AT78)。
|
||||
*/
|
||||
@@ -91,7 +91,7 @@ export function resolveAgentMock(o: {
|
||||
}
|
||||
}
|
||||
|
||||
/** 最近一次读到的后端 pi.provider 是否为 fake(由 useAgentMockGate 从 /settings 缓存同步) */
|
||||
/** 最近一次读到的后端默认上游是否为 fake(由 useAgentMockGate 从 /pi/upstreams 缓存同步) */
|
||||
let fakeProvider = false;
|
||||
|
||||
export function agentMockEnabled(): boolean {
|
||||
@@ -112,8 +112,8 @@ export function agentMockEnabled(): boolean {
|
||||
|
||||
/** Agent 页的列表/详情 hook 里调用:同步后端 provider,再判断演示开关 */
|
||||
function useAgentMockGate(): boolean {
|
||||
const settings = useSettings();
|
||||
fakeProvider = settings.data?.pi?.provider === "fake";
|
||||
const upstreams = usePiUpstreams();
|
||||
fakeProvider = upstreams.data?.items.find((u) => u.isDefault)?.provider === "fake";
|
||||
return agentMockEnabled();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user