Make English the repository working language (#5)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Yaowei Zheng
2026-07-20 17:45:02 +08:00
committed by GitHub
parent e80cde0ea6
commit 0eaaa54e25
136 changed files with 1515 additions and 1352 deletions
+18 -12
View File
@@ -140,7 +140,7 @@ export class Agent {
// credentials, pricing, and the context window would all be unavailable.
if (opts.modelId === undefined && opts.provider !== undefined) {
throw new Error(
"指定了 provider 却未指定 modelId:模型引用须成对给出(provider 不能单独使用)。",
"provider was specified without modelId: a model reference must be given as a pair (provider cannot be used alone).",
);
}
let ref: ModelRef;
@@ -151,13 +151,13 @@ export class Agent {
ref = this.projectConfig.default_model;
} else {
throw new Error(
"未指定 modelId,且 Project 配置中没有 default_model。请用 `penguin config model add/default` 设置默认模型。",
"No modelId was specified and the Project config has no default_model. Use `penguin config model add/default` to set the default model.",
);
}
const modelEntry = getModel(this.projectConfig, ref);
if (!modelEntry) {
throw new Error(
`Model 不在 Project 配置中:${formatModelRef(ref)}。请用 \`penguin config model list\` 查看已配置的模型,或用 \`penguin config model add\` 添加。`,
`Model is not in the Project config: ${formatModelRef(ref)}. Use \`penguin config model list\` to see the configured models, or \`penguin config model add\` to add one.`,
);
}
// Credentials are inlined on the model entry (single config file); an
@@ -177,11 +177,11 @@ export class Agent {
stat = await fs.stat(workspaceDir);
} catch {
throw new Error(
`Workspace 不存在:${workspaceDir}。请指定一个已存在的目录,或不指定 Workspace 以使用临时目录。`,
`Workspace does not exist: ${workspaceDir}. Specify an existing directory, or omit the Workspace to use a temporary directory.`,
);
}
if (!stat.isDirectory()) {
throw new Error(`Workspace 不是目录:${workspaceDir}。`);
throw new Error(`Workspace is not a directory: ${workspaceDir}.`);
}
} else {
workspaceDir = await createTempWorkspace(
@@ -284,17 +284,19 @@ export class Agent {
const dir = tracesDir(this.state.root, this.state.projectId, this.state.agentId);
const located = await findLatestTraceFile(dir, sessionId);
if (!located) {
throw new Error(`Session 不存在:${sessionId}(在 ${dir} 下未找到对应 Trace 文件)。`);
throw new Error(
`Session does not exist: ${sessionId} (no matching Trace file found under ${dir}).`,
);
}
const resumed = resumeTrace(await readTraceTolerant(located.path));
if (!resumed.meta) {
throw new Error(`Trace 缺少 session_meta,无法恢复:${located.path}`);
throw new Error(`Trace is missing session_meta and cannot be resumed: ${located.path}`);
}
const meta = resumed.meta.payload;
// Model reference is stored as a pair in session_meta; a missing provider means legacy data (no migration since the product hasn't shipped yet).
if (typeof meta.provider !== "string") {
throw new Error(
`Trace 来自旧版本数据(session_meta 缺少 provider,模型引用未分列):${located.path}。请删除数据目录后重建会话。`,
`Trace is from legacy data (session_meta is missing provider; the model reference is not split into separate fields): ${located.path}. Delete the data directory and recreate the Session.`,
);
}
@@ -304,10 +306,14 @@ export class Agent {
try {
stat = await fs.stat(workspaceDir);
} catch {
throw new Error(`原 Session 的 Workspace 已不存在:${workspaceDir},无法恢复。`);
throw new Error(
`The original Session's Workspace no longer exists: ${workspaceDir}; cannot resume.`,
);
}
if (!stat.isDirectory()) {
throw new Error(`原 Session 的 Workspace 不是目录:${workspaceDir},无法恢复。`);
throw new Error(
`The original Session's Workspace is not a directory: ${workspaceDir}; cannot resume.`,
);
}
// The Model carries over from the original Session (paired reference) and must still be present in the Project config.
@@ -315,7 +321,7 @@ export class Agent {
const modelEntry = getModel(this.projectConfig, ref);
if (!modelEntry) {
throw new Error(
`原 Session 的 Model 不在 Project 配置中:${formatModelRef(ref)}。请用 \`penguin config model add\` 重新配置后再恢复。`,
`The original Session's Model is not in the Project config: ${formatModelRef(ref)}. Use \`penguin config model add\` to configure it again before resuming.`,
);
}
const apiKey = opts.apiKey ?? modelEntry.api_key;
@@ -349,7 +355,7 @@ export class Agent {
} catch (err) {
const detail = err instanceof Error ? err.message : String(err);
throw new Error(
`恢复失败:Trace 历史无法注入(记录可能损坏,如非法的工具参数 JSON):${detail}`,
`Resume failed: the Trace history could not be injected (records may be corrupted, e.g. invalid tool-argument JSON): ${detail}`,
);
}
}
+3 -1
View File
@@ -130,7 +130,9 @@ export async function loadOrInitAgentState(opts?: {
typeof parsed !== "object" ||
typeof (parsed as SystemConfig).system_prompt !== "string"
) {
throw new Error(`Agent State 配置非法:${configPath} 为空、损坏或缺少 system_prompt 字段。`);
throw new Error(
`Invalid Agent State config: ${configPath} is empty, corrupted, or missing the system_prompt field.`,
);
}
systemConfig = parsed as SystemConfig;
agentsMd = (await fileExists(mdPath)) ? await fs.readFile(mdPath, "utf8") : defaultAgentsMd();
+12 -10
View File
@@ -126,7 +126,7 @@ export function defaultProjectConfig(): ProjectConfig {
/** The old format (concatenated storage id / string reference) is never migrated: reading it reports a clear error immediately (the product hasn't shipped yet). */
const OLD_FORMAT_HINT =
"产品未发布不做迁移:请删除该配置文件后用 `penguin config model add/default` 重建。";
"No migration since the product hasn't shipped yet: delete this config file and rebuild it with `penguin config model add/default`.";
/** Validates the default_model / vision_model fields: must be a { provider, model_id } paired reference. */
function parseRefField(file: string, name: string, value: unknown): ModelRef | undefined {
@@ -139,7 +139,7 @@ function parseRefField(file: string, name: string, value: unknown): ModelRef | u
typeof ref.model_id !== "string"
) {
throw new Error(
`.project_config.toml 的 ${name} 是旧版本/非法格式(须为 { provider = "...", model_id = "..." } 成对引用):${file}。${OLD_FORMAT_HINT}`,
`${name} in .project_config.toml is in a legacy/invalid format (must be a { provider = "...", model_id = "..." } paired reference): ${file}. ${OLD_FORMAT_HINT}`,
);
}
return { provider: ref.provider, model_id: ref.model_id };
@@ -155,7 +155,7 @@ function assertModelEntry(file: string, entry: unknown): ModelEntry {
typeof m.model_id !== "string"
) {
throw new Error(
`.project_config.toml 的 models 条目是旧版本/非法格式(provider 与 model_id 须为两个独立字段):${file}。${OLD_FORMAT_HINT}`,
`A models entry in .project_config.toml is in a legacy/invalid format (provider and model_id must be two separate fields): ${file}. ${OLD_FORMAT_HINT}`,
);
}
return entry as ModelEntry;
@@ -359,7 +359,7 @@ export async function setDefaultModel(
const cfg = await loadProjectConfig(root, projectId);
if (!getModel(cfg, ref)) {
throw new Error(
`default_model 必须指向已配置的模型:${formatModelRef(ref)} 不在 models 中。用 \`penguin config model list\` 查看已配置的模型。`,
`default_model must point to a configured model: ${formatModelRef(ref)} is not in models. Use \`penguin config model list\` to see the configured models.`,
);
}
cfg.default_model = { provider: ref.provider, model_id: ref.model_id };
@@ -381,11 +381,13 @@ export async function setVisionModel(
const entry = getModel(cfg, ref);
if (!entry) {
throw new Error(
`vision_model 必须指向已配置的模型:${formatModelRef(ref)} 不在 models 中。用 \`penguin config model list\` 查看已配置的模型。`,
`vision_model must point to a configured model: ${formatModelRef(ref)} is not in models. Use \`penguin config model list\` to see the configured models.`,
);
}
if (entry.vision === false) {
throw new Error(`vision_model 不能指向标注为不支持图片的模型:${formatModelRef(ref)}。`);
throw new Error(
`vision_model cannot point to a model tagged as not supporting images: ${formatModelRef(ref)}.`,
);
}
cfg.vision_model = { provider: ref.provider, model_id: ref.model_id };
await saveProjectConfig(root, projectId, cfg);
@@ -410,7 +412,7 @@ export function resolveModelRef(cfg: ProjectConfig, modelId: string, provider?:
const ref: ModelRef = { provider, model_id: modelId };
if (!getModel(cfg, ref)) {
throw new Error(
`Model 不在 Project 配置中:${formatModelRef(ref)}。请用 \`penguin config model list\` 查看已配置的模型,或用 \`penguin config model add\` 添加。`,
`Model is not in the Project config: ${formatModelRef(ref)}. Use \`penguin config model list\` to see the configured models, or \`penguin config model add\` to add one.`,
);
}
return ref;
@@ -421,12 +423,12 @@ export function resolveModelRef(cfg: ProjectConfig, modelId: string, provider?:
}
if (candidates.length === 0) {
throw new Error(
`Model 不在 Project 配置中:没有 model_id 为 ${modelId} 的条目。请用 \`penguin config model list\` 查看已配置的模型,或用 \`penguin config model add\` 添加。`,
`Model is not in the Project config: no entry has model_id ${modelId}. Use \`penguin config model list\` to see the configured models, or \`penguin config model add\` to add one.`,
);
}
throw new Error(
`模型引用有歧义:model_id ${modelId} 命中多个条目——${candidates
`Ambiguous model reference: model_id ${modelId} matches multiple entries: ${candidates
.map((m) => formatModelRef({ provider: m.provider, model_id: m.model_id }))
.join("、")}。请补充 provider 以给出成对引用。`,
.join(", ")}. Specify provider to give a paired reference.`,
);
}