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
@@ -58,13 +58,19 @@ describe("OAuth 请求", () => {
|
||||
});
|
||||
|
||||
describe("settings.pi 兼容", () => {
|
||||
it("缺省 defaultUpstreamId = null;旧字段仍可读写;PATCH 不能直接改 defaultUpstreamId", () => {
|
||||
it("缺省 defaultUpstreamId = null;PATCH 不能直接改 defaultUpstreamId,旧字段被丢弃", () => {
|
||||
expect(C.DEFAULT_SETTINGS.pi.defaultUpstreamId).toBeNull();
|
||||
expect(C.GlobalSettings.safeParse(C.DEFAULT_SETTINGS).success).toBe(true);
|
||||
const patch = C.GlobalSettingsUpdate.parse({
|
||||
pi: { defaultUpstreamId: "7d3f7f5e-8a8c-4b8e-9f0a-1b2c3d4e5f60", provider: "fake", contextBudget: 64_000 },
|
||||
pi: {
|
||||
defaultUpstreamId: "7d3f7f5e-8a8c-4b8e-9f0a-1b2c3d4e5f60",
|
||||
provider: "fake",
|
||||
apiKey: "sk-x",
|
||||
model: "m",
|
||||
contextBudget: 64_000,
|
||||
},
|
||||
});
|
||||
expect(patch.pi).toEqual({ provider: "fake", contextBudget: 64_000 });
|
||||
expect(patch.pi).toEqual({ contextBudget: 64_000 });
|
||||
const current = { ...C.DEFAULT_SETTINGS, pi: { ...C.DEFAULT_SETTINGS.pi, defaultUpstreamId: "keep-me" } };
|
||||
expect(C.mergeSettings(current as never, patch).pi.defaultUpstreamId).toBe("keep-me");
|
||||
});
|
||||
|
||||
@@ -157,11 +157,11 @@ describe("关键合同行为", () => {
|
||||
});
|
||||
|
||||
it("GlobalSettingsUpdate 部分更新不会注入默认值,mergeSettings 保留现值", () => {
|
||||
const patch = C.GlobalSettingsUpdate.parse({ automation: { enabled: false }, pi: { apiKey: "sk-x" } });
|
||||
expect(patch).toEqual({ automation: { enabled: false }, pi: { apiKey: "sk-x" } });
|
||||
const patch = C.GlobalSettingsUpdate.parse({ automation: { enabled: false }, pi: { contextBudget: 64_000 } });
|
||||
expect(patch).toEqual({ automation: { enabled: false }, pi: { contextBudget: 64_000 } });
|
||||
const merged = C.mergeSettings(C.DEFAULT_SETTINGS, patch);
|
||||
expect(merged.automation).toEqual({ enabled: false, readOnlyReconcile: false });
|
||||
expect(merged.pi).toEqual(C.DEFAULT_SETTINGS.pi);
|
||||
expect(merged.pi).toEqual({ ...C.DEFAULT_SETTINGS.pi, contextBudget: 64_000 });
|
||||
expect(C.GlobalSettings.safeParse(merged).success).toBe(true);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
DEFAULT_SETTINGS,
|
||||
DEPRECATED_SETTINGS_FIELDS,
|
||||
SETTINGS_SECTIONS,
|
||||
SettingsSectionId,
|
||||
settingsSectionForLegacyTab,
|
||||
@@ -11,8 +12,11 @@ describe("SETTINGS_SECTIONS", () => {
|
||||
expect(SETTINGS_SECTIONS.map((s) => s.id)).toEqual(SettingsSectionId.options);
|
||||
});
|
||||
|
||||
it("8 个存储 key 的每个字段恰好归属一个分区", () => {
|
||||
const all = Object.entries(DEFAULT_SETTINGS).flatMap(([key, v]) => Object.keys(v).map((f) => `${key}.${f}`));
|
||||
it("8 个存储 key 的每个字段(弃用字段除外)恰好归属一个分区", () => {
|
||||
const deprecated = new Set<string>(DEPRECATED_SETTINGS_FIELDS);
|
||||
const all = Object.entries(DEFAULT_SETTINGS)
|
||||
.flatMap(([key, v]) => Object.keys(v).map((f) => `${key}.${f}`))
|
||||
.filter((f) => !deprecated.has(f));
|
||||
const owned = SETTINGS_SECTIONS.flatMap((s) => s.fields);
|
||||
expect(new Set(owned).size).toBe(owned.length);
|
||||
expect([...owned].sort()).toEqual([...all].sort());
|
||||
|
||||
Reference in new issue
Block a user