Initialize repository with harness code and assets
Initial import of all source code, config, and README assets: the packages workspace (cli, core, server, web, docs, landing, skills), build scripts, tooling config, and CI workflows. Includes the data-layout revision made on this branch: the local data root defaults to ~/.penguin/data (PENGUIN_HOME still overrides; the installer keeps its binaries in ~/.penguin), and every Agent lives under <project>/agents/<agent>/ — path helpers, the three agent-enumeration scans, the system prompt, built-in Skills, tests and docs all follow the new layout. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018ihk8iQuo3kv2aPjAYEPuR
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* API error → display text: the server's message is hardcoded in Chinese
|
||||
* (`{error:{code,message}}`), but the UI language may be English — so for any
|
||||
* error the user might actually hit, we derive localized text from **code**;
|
||||
* the server message is only a fallback for unknown codes.
|
||||
*/
|
||||
import { ApiError } from "../api/client";
|
||||
import { S } from "./strings";
|
||||
|
||||
/**
|
||||
* ctx supplies context needed for localized text (e.g. the model id for a
|
||||
* missing key — the error body only has the code; the model id is filled in
|
||||
* by the caller: the model used by the current session/draft when sending).
|
||||
*/
|
||||
export function apiErrorText(err: unknown, ctx?: { modelId?: string }): string {
|
||||
if (!(err instanceof ApiError)) return S.common.unknownError;
|
||||
switch (err.code) {
|
||||
case "model_credential_missing":
|
||||
return ctx?.modelId ? S.errors.modelCredentialMissing(ctx.modelId) : err.message;
|
||||
case "no_default_model":
|
||||
return S.errors.noDefaultModel;
|
||||
default:
|
||||
return err.message;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user