paseo-plugin-zcode-provider 0.3.0 → 0.4.1
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/NOTICE.md +2 -2
- package/README.md +9 -9
- package/package.json +4 -4
- package/server/account.ts +10 -0
- package/server/build-info.ts +1 -1
- package/server/discovery/manifest.ts +2 -2
- package/server/mapping.ts +31 -0
- package/server/provider.ts +5 -18
- package/server/runtime/pins.ts +3 -3
- package/server/session.ts +7 -10
- package/server/unsupported-capabilities.ts +4 -1
- package/server/vendor/zcode/NOTICE.md +4 -1
- package/server/vendor/zcode/packages/rpc/src/channelClient.ts +1 -0
- package/server/vendor/zcode/packages/rpc/src/channelServer.ts +2 -0
- package/server/vendor/zcode/packages/rpc/src/channels.shared.ts +1 -0
- package/server/vendor/zcode/packages/rpc/src/protocol.ts +3 -2
- package/server/vendor/zcode/packages/shared/src/app-runtime-preferences.ts +18 -0
- package/server/vendor/zcode/packages/shared/src/attachment-source.ts +5 -0
- package/server/vendor/zcode/packages/shared/src/bots.ts +385 -2
- package/server/vendor/zcode/packages/shared/src/browser-use/commands.ts +3 -1
- package/server/vendor/zcode/packages/shared/src/channel-mention.ts +131 -0
- package/server/vendor/zcode/packages/shared/src/conversationSelection.ts +37 -0
- package/server/vendor/zcode/packages/shared/src/dynamic-workflow-feature.ts +137 -0
- package/server/vendor/zcode/packages/shared/src/env.ts +15 -11
- package/server/vendor/zcode/packages/shared/src/highspeed.ts +232 -0
- package/server/vendor/zcode/packages/shared/src/mcp-apps/appTools.ts +148 -0
- package/server/vendor/zcode/packages/shared/src/mcp-apps/contract.ts +262 -0
- package/server/vendor/zcode/packages/shared/src/mcp-apps/instance.ts +12 -0
- package/server/vendor/zcode/packages/shared/src/mcp-apps/resourceMime.ts +73 -0
- package/server/vendor/zcode/packages/shared/src/mcp-apps/sampling.ts +117 -0
- package/server/vendor/zcode/packages/shared/src/mcp-apps/schemas.ts +90 -0
- package/server/vendor/zcode/packages/shared/src/model-execution.ts +58 -1
- package/server/vendor/zcode/packages/shared/src/oauth.ts +3 -0
- package/server/vendor/zcode/packages/shared/src/off-peak-execution.ts +73 -0
- package/server/vendor/zcode/packages/shared/src/protocol.ts +78 -4
- package/server/vendor/zcode/packages/shared/src/remoteTarget.ts +65 -0
- package/server/vendor/zcode/packages/shared/src/request-security-edition/verification-policy.ts +46 -0
- package/server/vendor/zcode/packages/shared/src/server-remote.ts +93 -0
- package/server/vendor/zcode/packages/shared/src/source-server/compatibility.ts +115 -0
- package/server/vendor/zcode/packages/shared/src/source-server/contracts.ts +426 -0
- package/server/vendor/zcode/packages/shared/src/source-server/errorCodes.ts +74 -0
- package/server/vendor/zcode/packages/shared/src/sqlite-migrations/contract.ts +83 -0
- package/server/vendor/zcode/packages/shared/src/subagent-profile.ts +62 -0
- package/server/vendor/zcode/packages/shared/src/subagent-runtime-config.ts +51 -0
- package/server/vendor/zcode/packages/shared/src/subagents-types.ts +164 -0
- package/server/vendor/zcode/packages/shared/src/usage-stats.ts +14 -0
- package/server/vendor/zcode/packages/shared/src/validationAppSettings.ts +136 -3
- package/server/vendor/zcode/packages/shared/src/version.ts +13 -0
- package/server/vendor/zcode/packages/shared/src/zcode-agent-policy.ts +24 -1
- package/server/vendor/zcode/packages/shared/src/zcode-protocol/index.ts +697 -36
- package/server/vendor/zcode/packages/shared/src/zcode-protocol/trace.ts +11 -0
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-legacy-types.ts +14 -2
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/apply.ts +28 -9
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/attachment-ref.ts +3 -0
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/command.ts +73 -53
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/create-session-config.ts +15 -0
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/create-workflow-display.ts +47 -1
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/delta.ts +58 -2
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/input-intent.ts +31 -0
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/rows.ts +28 -13
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/sessions-index-workflow-activity.ts +37 -3
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/sessions-index.ts +36 -0
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/snapshot.ts +21 -0
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/submission.ts +1 -1
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/toolDisplay.ts +32 -4
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/transport.ts +31 -6
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/wire-assembler.ts +4 -1
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/wire-fault.ts +4 -1
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/workflow-artifacts.ts +62 -4
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/workflow-command-rejections.ts +30 -0
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/workflow-row-meta.ts +40 -3
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/workflow-run-settings-command.ts +2 -2
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/workflow-runs-delta.ts +6 -5
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/workflow-runs.ts +103 -26
- package/server/vendor/zcode/packages/shared/src/zcode-task-mode-schema.ts +13 -1
- package/server/vendor/zcode/packages/shared/src/zcode-task-types-core.ts +31 -2
- package/server/vendor/zcode/packages/shared/src/zcodeEndpoint.ts +188 -73
- package/server/vendor/zcode/provenance.json +189 -80
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import type { ZCodeProvider } from "./zcode-task-types-core.js";
|
|
2
|
+
import { modelSelectionSchema, type ModelSelection } from "./model-selection.js";
|
|
3
|
+
|
|
4
|
+
export type AgentScope = "built-in" | "workspace" | "user";
|
|
5
|
+
|
|
6
|
+
export type AgentSource = "built-in" | "user" | "plugin";
|
|
7
|
+
|
|
8
|
+
export type BuiltInSubagentName = "general-purpose" | "Explore";
|
|
9
|
+
|
|
10
|
+
export type BuiltInSubagentModelSelectionOverrides = Partial<
|
|
11
|
+
Record<BuiltInSubagentName, ModelSelection>
|
|
12
|
+
>;
|
|
13
|
+
|
|
14
|
+
export type PluginSubagentModelSelectionOverrides = Readonly<Record<string, ModelSelection>>;
|
|
15
|
+
|
|
16
|
+
/** 正式 reader 只接受结构化覆盖,不在读取时解释旧双 map 或重新匹配 Provider。 */
|
|
17
|
+
export function parsePluginSubagentModelSelectionOverrides(
|
|
18
|
+
value: unknown,
|
|
19
|
+
): PluginSubagentModelSelectionOverrides {
|
|
20
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
21
|
+
return Object.fromEntries(
|
|
22
|
+
Object.entries(value).flatMap(([id, candidate]) => {
|
|
23
|
+
const selection = modelSelectionSchema.safeParse(candidate);
|
|
24
|
+
return id.startsWith("plugin:") && selection.success ? [[id, selection.data]] : [];
|
|
25
|
+
}),
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type AgentPermissionMode =
|
|
30
|
+
| "acceptEdits"
|
|
31
|
+
| "auto"
|
|
32
|
+
| "bypassPermissions"
|
|
33
|
+
| "default"
|
|
34
|
+
| "dontAsk"
|
|
35
|
+
| "plan";
|
|
36
|
+
|
|
37
|
+
export type AgentColor =
|
|
38
|
+
| "red"
|
|
39
|
+
| "blue"
|
|
40
|
+
| "green"
|
|
41
|
+
| "yellow"
|
|
42
|
+
| "purple"
|
|
43
|
+
| "orange"
|
|
44
|
+
| "pink"
|
|
45
|
+
| "cyan";
|
|
46
|
+
|
|
47
|
+
export type SubagentsListMode = "allRuntimeScopes" | "settingsUserOnly";
|
|
48
|
+
|
|
49
|
+
export interface AgentSummary {
|
|
50
|
+
id: string;
|
|
51
|
+
name: string;
|
|
52
|
+
description: string;
|
|
53
|
+
systemPrompt: string;
|
|
54
|
+
color?: AgentColor;
|
|
55
|
+
modelSelection?: ModelSelection;
|
|
56
|
+
defaultModelSelection?: ModelSelection;
|
|
57
|
+
modelSelectionOverride?: ModelSelection;
|
|
58
|
+
tools?: string[];
|
|
59
|
+
disallowedTools?: string[];
|
|
60
|
+
injectAgentsMd?: boolean;
|
|
61
|
+
skills?: string[];
|
|
62
|
+
permissionMode?: AgentPermissionMode;
|
|
63
|
+
maxTurns?: number;
|
|
64
|
+
background?: boolean;
|
|
65
|
+
mcpServers?: unknown[];
|
|
66
|
+
path: string;
|
|
67
|
+
scope: AgentScope;
|
|
68
|
+
source: AgentSource;
|
|
69
|
+
enabled: boolean;
|
|
70
|
+
readOnly?: boolean;
|
|
71
|
+
projectPath?: string;
|
|
72
|
+
pluginId?: string;
|
|
73
|
+
pluginName?: string;
|
|
74
|
+
diagnostics?: AgentDiagnostic[];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface AgentDiagnostic {
|
|
78
|
+
code: string;
|
|
79
|
+
message: string;
|
|
80
|
+
path?: string;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface AgentsCapability {
|
|
84
|
+
userScopeAvailable: boolean;
|
|
85
|
+
userScopeReason?: "desktop_only";
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface AgentsListResult {
|
|
89
|
+
agents: AgentSummary[];
|
|
90
|
+
userAgents: AgentSummary[];
|
|
91
|
+
pluginAgents: AgentSummary[];
|
|
92
|
+
capability: AgentsCapability;
|
|
93
|
+
diagnostics?: AgentDiagnostic[];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Agent 配置,用于创建/更新 agent */
|
|
97
|
+
export interface SubAgentConfig {
|
|
98
|
+
name: string;
|
|
99
|
+
description: string;
|
|
100
|
+
systemPrompt: string;
|
|
101
|
+
color?: AgentColor;
|
|
102
|
+
modelSelection?: ModelSelection;
|
|
103
|
+
tools?: string[];
|
|
104
|
+
disallowedTools?: string[];
|
|
105
|
+
injectAgentsMd?: boolean;
|
|
106
|
+
skills?: string[];
|
|
107
|
+
permissionMode?: AgentPermissionMode;
|
|
108
|
+
maxTurns?: number;
|
|
109
|
+
background?: boolean;
|
|
110
|
+
mcpServers?: unknown[];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Agent 创建参数 */
|
|
114
|
+
export interface AgentCreateParams {
|
|
115
|
+
config: SubAgentConfig;
|
|
116
|
+
provider: ZCodeProvider;
|
|
117
|
+
scope?: "user" | "workspace";
|
|
118
|
+
workspacePath?: string;
|
|
119
|
+
workspaceIdentity?: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Agent 更新参数 */
|
|
123
|
+
export interface AgentUpdateParams {
|
|
124
|
+
agentId: string;
|
|
125
|
+
config: SubAgentConfig;
|
|
126
|
+
oldFilePath?: string;
|
|
127
|
+
provider: ZCodeProvider;
|
|
128
|
+
scope?: "user" | "workspace";
|
|
129
|
+
workspacePath?: string;
|
|
130
|
+
workspaceIdentity?: string;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Agent 删除参数 */
|
|
134
|
+
export interface AgentDeleteParams {
|
|
135
|
+
agentId: string;
|
|
136
|
+
filePath: string;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface BuiltInSubagentModelOverrideParams {
|
|
140
|
+
agentName: BuiltInSubagentName;
|
|
141
|
+
modelSelection?: ModelSelection;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface PluginSubagentModelOverrideParams {
|
|
145
|
+
agentId: string;
|
|
146
|
+
modelSelection?: ModelSelection;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* 插件 subagent 的稳定 id:`plugin:<pluginId>:<裸名小写>`。
|
|
151
|
+
* pluginId 为 `<name>@<marketplace>`,不含版本,插件升级后 id 不变,覆盖随之保留。
|
|
152
|
+
* services 与 CLI bootstrap 都用它做 agents-state.json 的键,必须共用一处实现。
|
|
153
|
+
*/
|
|
154
|
+
export function createPluginAgentStateId(pluginId: string, agentName: string): string {
|
|
155
|
+
return `plugin:${pluginId}:${agentName.trim().toLowerCase()}`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function createAgentStateId(input: {
|
|
159
|
+
name: string;
|
|
160
|
+
scope: AgentScope;
|
|
161
|
+
source: AgentSource;
|
|
162
|
+
}): string {
|
|
163
|
+
return `${input.source}:${input.scope}:${input.name.trim().toLowerCase()}`;
|
|
164
|
+
}
|
|
@@ -44,6 +44,20 @@ export interface CodingPlanUsageRequest {
|
|
|
44
44
|
timeZone?: string;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
/** Highspeed 只读取普通 Pro/Max decode TPS,不触发完整 Coding Plan 用量聚合。 */
|
|
48
|
+
export interface CodingPlanRegularTpsRequest {
|
|
49
|
+
preferredProviderId: string;
|
|
50
|
+
/**
|
|
51
|
+
* Registry 静态访问类别,或调用边界已解析的动态账号访问上下文。
|
|
52
|
+
*
|
|
53
|
+
* Bug 原因:此前该请求只带 organizationId/projectId,请求期鉴权靠 host 自行按 provider
|
|
54
|
+
* 猜测账号。Provider 重构后 Coding Plan 授权统一由 accountAccess 解析(Team scope 也内含
|
|
55
|
+
* 其中),缺失时 resolveAuthorization 必定返回 null,节省时间会静默不展示。
|
|
56
|
+
*/
|
|
57
|
+
accountAccess: ZCodeProviderAccountAccess | ZCodeAccountAccess;
|
|
58
|
+
timeZone?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
47
61
|
export interface UsageEntitlementRequest {
|
|
48
62
|
/** 购买或领取完成后,使对应 Start Plan balance 短期缓存失效。 */
|
|
49
63
|
invalidateBalanceCache?: boolean;
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
/* oxlint-disable eslint(max-lines) -- AppSettings schema 聚合历史迁移、默认值和 patch 校验,拆分会削弱设置迁移的单一入口。 */
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import { appToolSearchModeSchema } from "./app-runtime-preferences.js";
|
|
3
4
|
import type { AppSettings } from "./protocol.js";
|
|
4
5
|
import { REMOTE_ASSET_INSTALL_MODES } from "./remoteAssetInstallMode.js";
|
|
5
6
|
import { isKnownRemoteResourcePackageId } from "./remoteResourcePackages.js";
|
|
6
7
|
import { wslUserSchema } from "./wslUserValidation.js";
|
|
8
|
+
import { ZCODE_ENABLED_AGENT_PROVIDERS } from "./zcode-agent-policy.js";
|
|
9
|
+
import { DYNAMIC_WORKFLOW_MODES } from "./dynamic-workflow-feature.js";
|
|
7
10
|
import { normalizeZCodeEndpointOrigin } from "./zcodeEndpoint.js";
|
|
8
11
|
import {
|
|
9
12
|
DEFAULT_EMBEDDED_BROWSER_VIEWPORT_PREFERENCE,
|
|
10
13
|
embeddedBrowserViewportPreferenceSchema,
|
|
11
14
|
} from "./browser-use/command-metadata.js";
|
|
12
15
|
import { providerFamilyConnectionSelectionSettingsSchema } from "./provider-family-connection-selection.js";
|
|
16
|
+
import {
|
|
17
|
+
connectionProfileSchema,
|
|
18
|
+
sourceServerRecordSchema,
|
|
19
|
+
sourceServerWorkspaceHistoryEntrySchema,
|
|
20
|
+
} from "./source-server/contracts.js";
|
|
13
21
|
|
|
14
22
|
/** 引导职业枚举;单独导出供 onboarding 记录回填 settings 时做窄化校验。 */
|
|
15
23
|
const appSettingsOccupationSchema = z.enum([
|
|
@@ -33,8 +41,11 @@ export const appSettingsOccupationEnum = appSettingsOccupationSchema;
|
|
|
33
41
|
const nonEmptyStringSchema = z.string().trim().min(1);
|
|
34
42
|
|
|
35
43
|
export const localeSchema = z.enum(["zh-CN", "en-US"]);
|
|
36
|
-
const localePreferenceSchema = z.enum(["system", "zh-CN", "en-US"]);
|
|
44
|
+
export const localePreferenceSchema = z.enum(["system", "zh-CN", "en-US"]);
|
|
37
45
|
const zcodeInteractionBehaviorSchema = z.enum(["queue", "guide"]);
|
|
46
|
+
// launch.md「The user's choice」:读文件时未知取值(降级后读到新版本写的值)按「跟随」处理,
|
|
47
|
+
// 不能让一个偏好字段把整份设置读坏。
|
|
48
|
+
const dynamicWorkflowModeSettingSchema = z.enum(DYNAMIC_WORKFLOW_MODES).optional().catch(undefined);
|
|
38
49
|
const electronReleaseChannelSchema = z.enum(["stable", "preview"]);
|
|
39
50
|
const desktopZoomLevelSchema = z.number().int().min(-3).max(5);
|
|
40
51
|
const desktopWindowSizeSchema = z.object({
|
|
@@ -54,6 +65,10 @@ export const integratedTerminalShellSelectionSchema = z.discriminatedUnion("mode
|
|
|
54
65
|
path: nonEmptyStringSchema,
|
|
55
66
|
}),
|
|
56
67
|
]);
|
|
68
|
+
const enabledBuiltinAgentCliProvidersSchema = z
|
|
69
|
+
// 兼容旧 settings:历史列表可能残留三方 CLI provider,解析后统一归一为 ZCode Agent。
|
|
70
|
+
.array(z.enum(["claude", "opencode", "gemini", "codex", "glm"]))
|
|
71
|
+
.transform(() => [...ZCODE_ENABLED_AGENT_PROVIDERS]);
|
|
57
72
|
const providerFamilyDomainSchema = z.enum(["zai", "bigmodel"]);
|
|
58
73
|
|
|
59
74
|
export const postUpdateReleaseNotesPayloadSchema = z.object({
|
|
@@ -100,6 +115,14 @@ const remoteWorkspaceTargetSchema = z.discriminatedUnion("kind", [
|
|
|
100
115
|
kind: z.literal("docker"),
|
|
101
116
|
container: nonEmptyStringSchema,
|
|
102
117
|
}),
|
|
118
|
+
z.object({
|
|
119
|
+
kind: z.literal("server"),
|
|
120
|
+
url: z.string().url(),
|
|
121
|
+
name: nonEmptyStringSchema.optional(),
|
|
122
|
+
workspacePath: z.string().optional(),
|
|
123
|
+
serverId: nonEmptyStringSchema.optional(),
|
|
124
|
+
tokenCredentialKey: nonEmptyStringSchema.optional(),
|
|
125
|
+
}),
|
|
103
126
|
]);
|
|
104
127
|
|
|
105
128
|
const appWorkspaceSessionEntrySchema = z.discriminatedUnion("kind", [
|
|
@@ -111,6 +134,7 @@ const appWorkspaceSessionEntrySchema = z.discriminatedUnion("kind", [
|
|
|
111
134
|
z.object({
|
|
112
135
|
kind: z.literal("remote"),
|
|
113
136
|
workspacePath: nonEmptyStringSchema,
|
|
137
|
+
workspacePurpose: z.enum(["project", "conversation"]).default("project"),
|
|
114
138
|
localWorkspacePath: nonEmptyStringSchema.optional(),
|
|
115
139
|
workspaceIdentity: nonEmptyStringSchema.optional(),
|
|
116
140
|
target: remoteWorkspaceTargetSchema,
|
|
@@ -120,6 +144,26 @@ const appWorkspaceSessionEntrySchema = z.discriminatedUnion("kind", [
|
|
|
120
144
|
}),
|
|
121
145
|
]);
|
|
122
146
|
|
|
147
|
+
const webRemoteControlRelayV2DeviceSchema = z.object({
|
|
148
|
+
deviceSid: z.string().min(1),
|
|
149
|
+
userId: z.string().min(1),
|
|
150
|
+
endpointOrigin: z.url(),
|
|
151
|
+
});
|
|
152
|
+
const remoteConversationWorkspaceRecordSchema = z
|
|
153
|
+
.object({
|
|
154
|
+
workspacePath: nonEmptyStringSchema,
|
|
155
|
+
lastResolvedAt: z.number().int().nonnegative(),
|
|
156
|
+
})
|
|
157
|
+
.strict();
|
|
158
|
+
|
|
159
|
+
const webRemoteControlExternalRelayDeviceSchema = z.object({
|
|
160
|
+
deviceSid: nonEmptyStringSchema,
|
|
161
|
+
});
|
|
162
|
+
const webRemoteControlLastEnabledContextSchema = z.object({
|
|
163
|
+
workspacePath: nonEmptyStringSchema,
|
|
164
|
+
workspaceIdentity: nonEmptyStringSchema.optional(),
|
|
165
|
+
initialTaskId: nonEmptyStringSchema.optional(),
|
|
166
|
+
});
|
|
123
167
|
const zcodeEndpointOriginSchema = z.preprocess((value) => {
|
|
124
168
|
if (typeof value !== "string") {
|
|
125
169
|
return undefined;
|
|
@@ -190,6 +234,28 @@ function sanitizeEmbeddedBrowserViewportPreference(value: unknown): unknown {
|
|
|
190
234
|
return next;
|
|
191
235
|
}
|
|
192
236
|
|
|
237
|
+
function migrateRemoteBoundaryIntroAcknowledgement(value: unknown): unknown {
|
|
238
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return value;
|
|
239
|
+
const raw = value as Record<string, unknown>;
|
|
240
|
+
if (raw.remoteBoundaryOnboardingVersion !== 3) return value;
|
|
241
|
+
// 原因:旧客户端只接受 2,写 3 会让整份设置回退默认值。迁移已确认的 3 到新字段,
|
|
242
|
+
// 同时恢复旧字段合同;不能仅收窄 schema,否则修复版读取存量 3 也会丢设置。
|
|
243
|
+
return {
|
|
244
|
+
...raw,
|
|
245
|
+
remoteBoundaryOnboardingVersion: 2,
|
|
246
|
+
remoteBoundaryIntroAcknowledgedVersion: 1,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function migrateTaskAutoArchiveReset(value: unknown): unknown {
|
|
251
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return value;
|
|
252
|
+
const raw = value as Record<string, unknown>;
|
|
253
|
+
if (raw.taskAutoArchiveResetVersion === 1) return value;
|
|
254
|
+
// 旧版开关开启后可能未执行;修复后直接沿用会在启动时突然归档历史会话。
|
|
255
|
+
// 首次读取统一关闭并持久化标记,用户重新开启后不再重置。
|
|
256
|
+
return { ...raw, taskAutoArchiveEnabled: false, taskAutoArchiveResetVersion: 1 };
|
|
257
|
+
}
|
|
258
|
+
|
|
193
259
|
function migrateCloseToTrayOnWindowsDefault(value: unknown): unknown {
|
|
194
260
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
195
261
|
return value;
|
|
@@ -258,6 +324,24 @@ const legacyRemoteWorkspaceHistoryEntrySchema = z.object({
|
|
|
258
324
|
lastConnectionError: z.string().optional(),
|
|
259
325
|
});
|
|
260
326
|
|
|
327
|
+
function migrateLegacyBuiltinAgentCliProviders(value: unknown): unknown {
|
|
328
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
329
|
+
return value;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
const raw = value as {
|
|
333
|
+
enabledBuiltinAgentCliProviders?: unknown;
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
// Bugfix: 单 ZCode Agent 迁移后,旧 setting.json 可能还保存已移除的第三方 CLI provider
|
|
337
|
+
// 的启用状态。若这些值继续进入 UI / bot 的 provider 选项,会和 server 侧唯一 glm 状态打架。
|
|
338
|
+
// 这里在 schema 入口统一归一到 ZCode Agent,让核心 provider 状态只有一个事实源。
|
|
339
|
+
return {
|
|
340
|
+
...raw,
|
|
341
|
+
enabledBuiltinAgentCliProviders: [...ZCODE_ENABLED_AGENT_PROVIDERS],
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
|
|
261
345
|
function stripHistoricalRemoteResourcePackages(target: unknown): unknown {
|
|
262
346
|
if (!target || typeof target !== "object" || Array.isArray(target)) {
|
|
263
347
|
return target;
|
|
@@ -437,9 +521,12 @@ const appSettingsObjectSchema = z.object({
|
|
|
437
521
|
// default 只对缺省字段生效,显式存过 false 的用户仍保持展示。
|
|
438
522
|
computerUseComposerEntryHidden: z.boolean().default(true),
|
|
439
523
|
taskAutoArchiveEnabled: z.boolean().default(false),
|
|
440
|
-
|
|
524
|
+
taskAutoArchiveResetVersion: z.literal(1).default(1),
|
|
525
|
+
taskAutoArchiveOlderThanDays: z.number().int().positive().max(365).default(30),
|
|
441
526
|
closeToTrayOnWindows: z.boolean().default(true),
|
|
442
527
|
closeToTrayOnWindowsMigrationInitialized: z.boolean().default(true),
|
|
528
|
+
// default(false):新装与存量用户首次启动都视为未归位,由 main 进程按平台决定是否迁移。
|
|
529
|
+
closeToTrayLinuxMigrationInitialized: z.boolean().default(false),
|
|
443
530
|
keepAwakeWhileRunning: z.boolean().default(false),
|
|
444
531
|
desktopZoomLevel: desktopZoomLevelSchema.optional(),
|
|
445
532
|
desktopWindowSize: desktopWindowSizeSchema.optional(),
|
|
@@ -453,16 +540,34 @@ const appSettingsObjectSchema = z.object({
|
|
|
453
540
|
zcodeInteractionBehavior: zcodeInteractionBehaviorSchema.default("queue"),
|
|
454
541
|
askUserQuestionAutoResolutionEnabled: z.boolean().default(true),
|
|
455
542
|
modelIoFullRetentionEnabled: z.boolean().default(false),
|
|
543
|
+
dynamicWorkflowMode: dynamicWorkflowModeSettingSchema,
|
|
544
|
+
enabledBuiltinAgentCliProviders: enabledBuiltinAgentCliProvidersSchema.default([
|
|
545
|
+
...ZCODE_ENABLED_AGENT_PROVIDERS,
|
|
546
|
+
]),
|
|
456
547
|
startPlanRecommendationDismissed: z.boolean().default(false),
|
|
457
548
|
providerFamilyConnectionSelections: providerFamilyConnectionSelectionSettingsSchema.default({}),
|
|
458
549
|
providerFamilyDomain: providerFamilyDomainSchema.optional(),
|
|
459
550
|
providerFamilyDomainUpdatedAt: z.number().int().nonnegative().optional(),
|
|
460
551
|
providerFamilyDomainMigrated: z.boolean().default(false),
|
|
461
552
|
nativeSearchEnhancementsEnabled: z.boolean().default(true),
|
|
553
|
+
toolSearchMode: appToolSearchModeSchema.default("off"),
|
|
462
554
|
onboardingOccupation: appSettingsOccupationSchema.nullish(),
|
|
463
555
|
proactiveSuggestionsEnabled: z.boolean().optional(),
|
|
464
556
|
memoryEnabled: z.boolean().default(false),
|
|
465
557
|
lastWorkspaceSession: z.array(appWorkspaceSessionEntrySchema).default([]),
|
|
558
|
+
lastActiveWorkspace: appWorkspaceSessionEntrySchema.nullable().optional(),
|
|
559
|
+
remoteConversationWorkspaceBySourceServerId: z
|
|
560
|
+
.record(nonEmptyStringSchema, remoteConversationWorkspaceRecordSchema)
|
|
561
|
+
.optional(),
|
|
562
|
+
sourceServers: z.array(sourceServerRecordSchema).default([]),
|
|
563
|
+
connectionProfiles: z.array(connectionProfileSchema).default([]),
|
|
564
|
+
sourceServerWorkspaceHistory: z.array(sourceServerWorkspaceHistoryEntrySchema).default([]),
|
|
565
|
+
// Bug 原因:该开关过去只声明在 patch schema,SettingService 合并后再走完整 schema 时会把
|
|
566
|
+
// 显式 false 剥离,导致重启后恢复为默认开启。完整 schema 必须拥有这项持久化事实。
|
|
567
|
+
remoteStartupAutoReconnectEnabled: z.boolean().optional(),
|
|
568
|
+
sourceServerDirectoryMigrationVersion: z.literal(1).optional(),
|
|
569
|
+
remoteBoundaryOnboardingVersion: z.literal(2).optional(),
|
|
570
|
+
remoteBoundaryIntroAcknowledgedVersion: z.literal(1).optional(),
|
|
466
571
|
lastActiveTabIndex: z.number().int().nonnegative().default(0),
|
|
467
572
|
lastActiveTaskByWorkspace: z.record(z.string(), z.string()).optional(),
|
|
468
573
|
dataBaseDir: z.string().trim().min(1).optional(),
|
|
@@ -471,6 +576,9 @@ const appSettingsObjectSchema = z.object({
|
|
|
471
576
|
autoDownloadAndInstallUpdates: z.boolean().default(false),
|
|
472
577
|
skippedElectronUpdateVersions: skippedElectronUpdateVersionsSchema,
|
|
473
578
|
settingsSyncFirstRunPromptHandled: z.boolean().optional(),
|
|
579
|
+
webRemoteControlRelayV2Device: webRemoteControlRelayV2DeviceSchema.optional(),
|
|
580
|
+
webRemoteControlExternalRelayDevice: webRemoteControlExternalRelayDeviceSchema.optional(),
|
|
581
|
+
webRemoteControlLastEnabledContext: webRemoteControlLastEnabledContextSchema.optional(),
|
|
474
582
|
zcodeEndpointOrigin: zcodeEndpointOriginSchema.optional(),
|
|
475
583
|
});
|
|
476
584
|
|
|
@@ -481,7 +589,13 @@ export const appSettingsSchema = z.preprocess(
|
|
|
481
589
|
migrateMessageStreamShowReasoningDefault(
|
|
482
590
|
migrateCloseToTrayOnWindowsDefault(
|
|
483
591
|
migrateLegacyLocalePreference(
|
|
484
|
-
sanitizeZCodeEndpointOrigin(
|
|
592
|
+
sanitizeZCodeEndpointOrigin(
|
|
593
|
+
migrateLegacyWorkspaceSession(
|
|
594
|
+
migrateLegacyBuiltinAgentCliProviders(
|
|
595
|
+
migrateRemoteBoundaryIntroAcknowledgement(migrateTaskAutoArchiveReset(value)),
|
|
596
|
+
),
|
|
597
|
+
),
|
|
598
|
+
),
|
|
485
599
|
),
|
|
486
600
|
),
|
|
487
601
|
),
|
|
@@ -509,6 +623,7 @@ export const appSettingsPatchSchema = z.object({
|
|
|
509
623
|
closeToTrayOnWindows: z.boolean().optional(),
|
|
510
624
|
keepAwakeWhileRunning: z.boolean().optional(),
|
|
511
625
|
closeToTrayOnWindowsMigrationInitialized: z.boolean().optional(),
|
|
626
|
+
closeToTrayLinuxMigrationInitialized: z.boolean().optional(),
|
|
512
627
|
desktopZoomLevel: desktopZoomLevelSchema.optional(),
|
|
513
628
|
desktopWindowSize: desktopWindowSizeSchema.optional(),
|
|
514
629
|
desktopChromiumHardwareAccelerationEnabled: z.boolean().optional(),
|
|
@@ -521,12 +636,16 @@ export const appSettingsPatchSchema = z.object({
|
|
|
521
636
|
zcodeInteractionBehavior: zcodeInteractionBehaviorSchema.optional(),
|
|
522
637
|
askUserQuestionAutoResolutionEnabled: z.boolean().optional(),
|
|
523
638
|
modelIoFullRetentionEnabled: z.boolean().optional(),
|
|
639
|
+
// 空串是「删除选择、回到跟随」的哨兵:RPC 会吞掉 undefined,normalizeSettingsPatch 把它归一成删除。
|
|
640
|
+
dynamicWorkflowMode: z.union([z.enum(DYNAMIC_WORKFLOW_MODES), z.literal("")]).optional(),
|
|
641
|
+
enabledBuiltinAgentCliProviders: enabledBuiltinAgentCliProvidersSchema.optional(),
|
|
524
642
|
startPlanRecommendationDismissed: z.boolean().optional(),
|
|
525
643
|
providerFamilyConnectionSelections: providerFamilyConnectionSelectionSettingsSchema.optional(),
|
|
526
644
|
providerFamilyDomain: z.union([providerFamilyDomainSchema, z.literal("")]).optional(),
|
|
527
645
|
providerFamilyDomainUpdatedAt: z.number().int().nonnegative().optional(),
|
|
528
646
|
providerFamilyDomainMigrated: z.boolean().optional(),
|
|
529
647
|
nativeSearchEnhancementsEnabled: z.boolean().optional(),
|
|
648
|
+
toolSearchMode: appToolSearchModeSchema.optional(),
|
|
530
649
|
onboardingOccupation: z
|
|
531
650
|
.enum([
|
|
532
651
|
"office",
|
|
@@ -548,6 +667,17 @@ export const appSettingsPatchSchema = z.object({
|
|
|
548
667
|
proactiveSuggestionsEnabled: z.boolean().optional(),
|
|
549
668
|
memoryEnabled: z.boolean().optional(),
|
|
550
669
|
lastWorkspaceSession: z.array(appWorkspaceSessionEntrySchema).optional(),
|
|
670
|
+
lastActiveWorkspace: appWorkspaceSessionEntrySchema.nullable().optional(),
|
|
671
|
+
remoteConversationWorkspaceBySourceServerId: z
|
|
672
|
+
.record(nonEmptyStringSchema, remoteConversationWorkspaceRecordSchema)
|
|
673
|
+
.optional(),
|
|
674
|
+
sourceServers: z.array(sourceServerRecordSchema).optional(),
|
|
675
|
+
connectionProfiles: z.array(connectionProfileSchema).optional(),
|
|
676
|
+
sourceServerWorkspaceHistory: z.array(sourceServerWorkspaceHistoryEntrySchema).optional(),
|
|
677
|
+
remoteStartupAutoReconnectEnabled: z.boolean().optional(),
|
|
678
|
+
sourceServerDirectoryMigrationVersion: z.literal(1).optional(),
|
|
679
|
+
remoteBoundaryOnboardingVersion: z.literal(2).optional(),
|
|
680
|
+
remoteBoundaryIntroAcknowledgedVersion: z.literal(1).optional(),
|
|
551
681
|
lastActiveTabIndex: z.number().int().nonnegative().optional(),
|
|
552
682
|
lastActiveTaskByWorkspace: z.record(z.string(), z.string()).optional(),
|
|
553
683
|
dataBaseDir: z.string().trim().min(1).optional(),
|
|
@@ -558,5 +688,8 @@ export const appSettingsPatchSchema = z.object({
|
|
|
558
688
|
.partialRecord(electronReleaseChannelSchema, nonEmptyStringSchema)
|
|
559
689
|
.optional(),
|
|
560
690
|
settingsSyncFirstRunPromptHandled: z.boolean().optional(),
|
|
691
|
+
webRemoteControlRelayV2Device: webRemoteControlRelayV2DeviceSchema.optional(),
|
|
692
|
+
webRemoteControlExternalRelayDevice: webRemoteControlExternalRelayDeviceSchema.optional(),
|
|
693
|
+
webRemoteControlLastEnabledContext: webRemoteControlLastEnabledContextSchema.optional(),
|
|
561
694
|
zcodeEndpointOrigin: zcodeEndpointOriginSchema.optional(),
|
|
562
695
|
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// 由各 bundler 通过 define 注入,避免运行时 JSON import 的跨 bundler 兼容问题。
|
|
2
|
+
// 非构建环境(如 e2e 测试的 mocha)下 define 不存在,
|
|
3
|
+
// 用 typeof 检查 + fallback 避免 ReferenceError。
|
|
4
|
+
declare const __ZCODE_VERSION__: string;
|
|
5
|
+
declare const __ZCODE_COMMIT__: string;
|
|
6
|
+
declare const __ZCODE_BUILD_TIME__: string;
|
|
7
|
+
|
|
8
|
+
export const ZCODE_VERSION: string =
|
|
9
|
+
typeof __ZCODE_VERSION__ !== "undefined" ? __ZCODE_VERSION__ : "0.0.0-dev";
|
|
10
|
+
export const ZCODE_COMMIT: string =
|
|
11
|
+
typeof __ZCODE_COMMIT__ !== "undefined" ? __ZCODE_COMMIT__ : "unknown";
|
|
12
|
+
export const ZCODE_BUILD_TIME: string =
|
|
13
|
+
typeof __ZCODE_BUILD_TIME__ !== "undefined" ? __ZCODE_BUILD_TIME__ : "unknown";
|
|
@@ -6,7 +6,18 @@ export const ZCODE_AGENT_PROVIDER = "glm" satisfies ZCodeProvider;
|
|
|
6
6
|
export const ZCODE_AGENT_PROVIDER_LABEL = "ZCode Agent";
|
|
7
7
|
export const ZCODE_COMMAND_AGENT_SOURCE = "zcodeAgent" satisfies CommandAgentSource;
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* 解析持久化/relay 数据时的 provider 归一 schema:
|
|
11
|
+
* 已移除的第三方 provider 历史值仅作为归一化输入保留,统一收敛为 glm;
|
|
12
|
+
* 其它非法值保持拒绝,与收窄前的校验边界一致。
|
|
13
|
+
*/
|
|
14
|
+
export const legacyZCodeProviderSchema = z
|
|
15
|
+
.enum(["claude", "opencode", "gemini", "codex", "glm"])
|
|
16
|
+
.transform((): typeof ZCODE_AGENT_PROVIDER => ZCODE_AGENT_PROVIDER);
|
|
17
|
+
|
|
18
|
+
export const ZCODE_ENABLED_AGENT_PROVIDERS = [
|
|
19
|
+
ZCODE_AGENT_PROVIDER,
|
|
20
|
+
] as const satisfies readonly ZCodeProvider[];
|
|
10
21
|
|
|
11
22
|
export const ZCODE_COMMAND_AGENT_SOURCES = [
|
|
12
23
|
ZCODE_COMMAND_AGENT_SOURCE,
|
|
@@ -18,6 +29,18 @@ export function normalizeAgentProviderToZCodeAgent(
|
|
|
18
29
|
return ZCODE_AGENT_PROVIDER;
|
|
19
30
|
}
|
|
20
31
|
|
|
32
|
+
export function normalizeAgentProvidersToZCodeAgent(
|
|
33
|
+
_providers?: ReadonlyArray<ZCodeProvider> | null,
|
|
34
|
+
): ZCodeProvider[] {
|
|
35
|
+
return [...ZCODE_ENABLED_AGENT_PROVIDERS];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function normalizeCommandAgentSourceToZCodeAgent(
|
|
39
|
+
_agentSource?: CommandAgentSource | null,
|
|
40
|
+
): CommandAgentSource {
|
|
41
|
+
return ZCODE_COMMAND_AGENT_SOURCE;
|
|
42
|
+
}
|
|
43
|
+
|
|
21
44
|
export function isZCodeAgentProvider(
|
|
22
45
|
provider: ZCodeProvider | null | undefined,
|
|
23
46
|
): provider is typeof ZCODE_AGENT_PROVIDER {
|