Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ Most `test:*` commands run files under `src/scripts/`, but **`test:stage30` is t
- **Multi-provider model config** lives in user/project `settings.json`:
- Anthropic provider names pass through directly
- Other providers use `protocol` + `baseURL` + `${ENV_VAR}` interpolation for API keys
- Relevant env vars: `ANTHROPIC_AUTH_TOKEN`, `ANTHROPIC_BASE_URL`, `OPENAI_API_KEY`, `GEMINI_API_KEY`, `WEB_SEARCH_API_KEY`
- Connection selection: `EASY_AGENT_PROFILE`, or explicit `EASY_AGENT_PROTOCOL` / `EASY_AGENT_MODEL` / `EASY_AGENT_BASE_URL` / `EASY_AGENT_API_KEY`. Provider variables work only through explicit profile references.
- **Notable CLI flags:** `--print` (headless JSON output), `--plan`, `--auto`, `--dump-system-prompt`, `--model <name-or-profile>`.
14 changes: 7 additions & 7 deletions CHANGELOG.md

Large diffs are not rendered by default.

36 changes: 23 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ The package installs two commands, `eagent` and the long alias `easy-agent`.
## Quick start

```bash
export ANTHROPIC_AUTH_TOKEN="your-token"
export EASY_AGENT_PROTOCOL="openai-chat"
export EASY_AGENT_MODEL="gpt-4.1"
export EASY_AGENT_API_KEY="your-api-key"
cd your-project
eagent
```
Expand Down Expand Up @@ -97,24 +99,26 @@ Settings are JSON files merged in this order, from lowest to highest priority:
1. User: `~/.easy-agent/settings.json`
2. Project: `<project>/.easy-agent/settings.json` (shared, applied once the folder is trusted)
3. Local: `<project>/.easy-agent/settings.local.json` (personal, applied once the folder is trusted)
4. Command line: `--settings <file>`, `--model`, `--permission-mode`, and similar flags
5. Managed policy: `/Library/Application Support/EasyAgent/managed-settings.json` on macOS, `/etc/easy-agent/managed-settings.json` on Linux, `%PROGRAMDATA%\EasyAgent\managed-settings.json` on Windows
4. Process environment
5. Explicit CLI / SDK / session overrides
6. Managed policy: `/Library/Application Support/EasyAgent/managed-settings.json` on macOS, `/etc/easy-agent/managed-settings.json` on Linux, `%PROGRAMDATA%\EasyAgent\managed-settings.json` on Windows

A project `.env` is applied after project and local settings, only for a trusted folder. Feature switches are described in [Configuration and feature controls](./docs/configuration.md).

For a raw Anthropic model name, environment variables are enough:
The selected Harness sits between user and project settings. A temporary connection requires both an explicit protocol and an upstream model:

```bash
export ANTHROPIC_AUTH_TOKEN="your-token"
export ANTHROPIC_MODEL="claude-sonnet-4-20250514" # optional
export EASY_AGENT_PROTOCOL="anthropic"
export EASY_AGENT_MODEL="claude-sonnet-4-20250514"
export EASY_AGENT_API_KEY="your-api-key"
eagent
```

Named Anthropic, OpenAI-compatible, Gemini, and local profiles go in `settings.json`:

```json
{
"defaultModel": "gpt",
"model": "gpt",
"models": {
"gpt": {
"protocol": "openai-chat",
Expand All @@ -130,25 +134,31 @@ Named Anthropic, OpenAI-compatible, Gemini, and local profiles go in `settings.j
"ollama": {
"protocol": "openai-chat",
"model": "qwen2.5-coder",
"baseURL": "http://localhost:11434/v1"
"baseURL": "http://localhost:11434/v1",
"authentication": { "type": "none" }
}
}
}
```

Select a profile with `eagent --model gpt` or `/model gpt` inside the REPL.
Select a saved profile with `EASY_AGENT_PROFILE=gpt`, `eagent --model gpt`, or `/model gpt`. A profile ID is distinct from its upstream model name. Unknown IDs are errors; no model or protocol is guessed. With multiple profiles, select a default. `eagent --login` creates a profile for any supported protocol using one API Key.

| Environment variable | Purpose |
|---|---|
| `ANTHROPIC_AUTH_TOKEN` | Anthropic API token or compatible gateway token |
| `ANTHROPIC_BASE_URL` | Optional Anthropic-compatible endpoint |
| `ANTHROPIC_MODEL` | Default raw Anthropic model name |
| `EASY_AGENT_API_KEY` | Single API Key for a temporary connection or an explicit profile reference |
| `EASY_AGENT_PROTOCOL` | Explicit temporary connection protocol |
| `EASY_AGENT_MODEL` | Upstream model for the temporary connection |
| `EASY_AGENT_BASE_URL` | Optional address for that connection |
| `EASY_AGENT_PROFILE` | Select a saved profile without overriding its connection |
| `OPENAI_API_KEY` | Referenced by OpenAI-compatible profiles |
| `GEMINI_API_KEY` | Referenced by Gemini profiles |
| `WEB_SEARCH_API_KEY` | Optional WebSearch provider key |

Run `/config list`, `/model list`, or `/doctor` to inspect the effective setup. Credential values are always redacted.

Profiles support a single API Key source, explicit custom or no-auth policies, capability overrides and protocol options. General reasoning uses `reasoning.mode` (`auto`, `on`, `off`), `budgetTokens` and `effort`. Unknown models use a labelled 32000-token context estimate, unknown prices and conservative automatic reasoning. See [Model profiles](./docs/model-profiles.md) and the [environment inventory](./docs/configuration-inventory.md).

Configuration accepts only the documented schema. Unknown fields report validation errors; unrelated environment variables are ignored unless explicitly referenced by a profile. Create a connection with `eagent --login` or the model settings page.

## Where data is stored

| Location | Contents |
Expand Down
36 changes: 23 additions & 13 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ curl -fsSL https://raw.githubusercontent.com/ConardLi/easy-agent/main/install.sh
## 快速上手

```bash
export ANTHROPIC_AUTH_TOKEN="your-token"
export EASY_AGENT_PROTOCOL="openai-chat"
export EASY_AGENT_MODEL="gpt-4.1"
export EASY_AGENT_API_KEY="your-api-key"
cd your-project
eagent
```
Expand Down Expand Up @@ -97,24 +99,26 @@ Easy Agent 不上报任何统计或遥测数据。它只会向这些地方发请
1. 用户级:`~/.easy-agent/settings.json`
2. 项目级:`<project>/.easy-agent/settings.json`(可提交共享,目录受信任后才生效)
3. 本地级:`<project>/.easy-agent/settings.local.json`(个人配置,目录受信任后才生效)
4. 命令行:`--settings <file>`、`--model`、`--permission-mode` 等参数
5. 托管策略:macOS 为 `/Library/Application Support/EasyAgent/managed-settings.json`,Linux 为 `/etc/easy-agent/managed-settings.json`,Windows 为 `%PROGRAMDATA%\EasyAgent\managed-settings.json`
4. 进程环境
5. 显式 CLI、SDK、会话覆盖
6. 托管策略:macOS 为 `/Library/Application Support/EasyAgent/managed-settings.json`,Linux 为 `/etc/easy-agent/managed-settings.json`,Windows 为 `%PROGRAMDATA%\EasyAgent\managed-settings.json`

项目里的 `.env` 在项目级和本地级配置之后应用,同样只在目录受信任时生效。各项功能开关见[配置与功能开关](./docs/configuration.md)。

使用原始 Anthropic 模型名时,配好环境变量就够了:
所选 Harness 位于用户设置与项目设置之间。临时连接必须明确提供协议和上游模型:

```bash
export ANTHROPIC_AUTH_TOKEN="your-token"
export ANTHROPIC_MODEL="claude-sonnet-4-20250514" # 可选
export EASY_AGENT_PROTOCOL="anthropic"
export EASY_AGENT_MODEL="claude-sonnet-4-20250514"
export EASY_AGENT_API_KEY="your-api-key"
eagent
```

具名的 Anthropic、OpenAI 兼容、Gemini 和本地模型 Profile 写在 `settings.json` 里:

```json
{
"defaultModel": "gpt",
"model": "gpt",
"models": {
"gpt": {
"protocol": "openai-chat",
Expand All @@ -130,25 +134,31 @@ eagent
"ollama": {
"protocol": "openai-chat",
"model": "qwen2.5-coder",
"baseURL": "http://localhost:11434/v1"
"baseURL": "http://localhost:11434/v1",
"authentication": { "type": "none" }
}
}
}
```

用 `eagent --model gpt` 启动,或在 REPL 里执行 `/model gpt` 切换 Profile。
用 `EASY_AGENT_PROFILE=gpt`、`eagent --model gpt` 或 `/model gpt` 选择已保存的 Profile。Profile ID 与上游模型名分开;未知 ID 会报错,不猜测协议。多个 Profile 时需要选定默认值。`eagent --login` 可为四种协议创建 Profile,只输入一个 API Key。

| 环境变量 | 用途 |
|---|---|
| `ANTHROPIC_AUTH_TOKEN` | Anthropic API Token 或兼容网关 Token |
| `ANTHROPIC_BASE_URL` | 可选的 Anthropic 兼容端点 |
| `ANTHROPIC_MODEL` | 默认的原始 Anthropic 模型名 |
| `EASY_AGENT_API_KEY` | 临时连接的唯一 API Key,或 Profile 明确引用的来源 |
| `EASY_AGENT_PROTOCOL` | 临时连接的明确协议 |
| `EASY_AGENT_MODEL` | 临时连接的上游模型 |
| `EASY_AGENT_BASE_URL` | 该连接的可选地址 |
| `EASY_AGENT_PROFILE` | 选择已保存的 Profile,不覆盖其连接 |
| `OPENAI_API_KEY` | OpenAI 兼容 Profile 引用的 Key |
| `GEMINI_API_KEY` | Gemini Profile 引用的 Key |
| `WEB_SEARCH_API_KEY` | 可选的 WebSearch 服务 Key |

运行 `/config list`、`/model list` 或 `/doctor` 可以查看最终生效的配置,凭据值一律脱敏显示。

Profile 支持单一 API Key 来源、明确的自定义认证或无认证策略、能力覆盖和协议选项。通用推理配置是 `reasoning.mode`(`auto`、`on`、`off`)、`budgetTokens` 和 `effort`。未知模型使用标注为估算的 32000-token 窗口、未知价格和保守的自动推理。详见[模型 Profile](./docs/model-profiles.md)和[环境变量目录](./docs/configuration-inventory.md)。

配置只接受文档定义的 schema。未知字段返回校验错误;无关环境变量被忽略,Profile 显式引用的变量除外。可通过 `eagent --login` 或模型设置页创建连接。

## 数据存放位置

| 位置 | 内容 |
Expand Down
10 changes: 7 additions & 3 deletions apps/desktop/src/renderer/features/agents/HarnessView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,13 @@ export function HarnessView({ summary, data, onDialog }: { summary: HarnessSumma
{numberRow("features.toolSearchAutoThreshold", "自动启用的阈值", "工具定义超过上下文窗口的这个比例时启用", "%")}
</Group>
<Group title="推理">
{boolRow("features.thinking", "扩展思考", "回答前先思考")}
{numberRow("features.thinkingBudget", "思考预算", "固定的思考 token 数;没设时由模型决定", "tokens")}
{choiceRow("features.effort", "推理强度", "模型支持时生效", [
{choiceRow("reasoning.mode", "推理模式", "自动依据已知能力;未知模型不发送可选推理参数", [
{ value: "auto", label: "自动" },
{ value: "on", label: "开启" },
{ value: "off", label: "关闭" },
])}
{numberRow("reasoning.budgetTokens", "推理预算", "正整数,需小于最大输出;由协议校验支持情况", "tokens")}
{choiceRow("reasoning.effort", "推理强度", "模型支持时生效", [
{ value: "low", label: "低" },
{ value: "medium", label: "中" },
{ value: "high", label: "高" },
Expand Down
29 changes: 7 additions & 22 deletions apps/desktop/src/renderer/features/composer/Pickers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export function ModelPicker({
}}
>
<Popover.Trigger asChild>
<button type="button" className={pill}>
<button type="button" className={pill} aria-label="选择模型">
<Cpu />
{model ?? "默认模型"}
<ChevronDown className="!size-3 text-fg-3" />
Expand All @@ -131,7 +131,7 @@ export function ModelPicker({
className="flex h-10 items-center gap-2 border-b border-line px-3"
onSubmit={(e) => {
e.preventDefault();
if (typed) choose(typed);
if (models.some((m) => m.id === typed)) choose(typed);
}}
>
<Search className="size-3.5 text-fg-3" />
Expand All @@ -140,7 +140,7 @@ export function ModelPicker({
autoFocus
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder="输入模型名称或配置里的模型句柄"
placeholder="搜索已配置的模型"
className="h-full flex-1 bg-transparent text-[13px] text-fg outline-none placeholder:text-fg-3"
/>
</form>
Expand All @@ -164,27 +164,12 @@ export function ModelPicker({
</button>
))}
{model && !models.some((m) => m.id === model) && (
<button
type="button"
onClick={() => setOpen(false)}
className="flex h-9 w-full items-center gap-2.5 rounded-lg bg-surface-2 px-2 text-left text-[13px] text-fg"
>
<Cpu className="size-4 text-fg-3" />
<span className="min-w-0 flex-1 truncate">{model}</span>
<Check className="size-3.5 text-accent" />
</button>
<p className="px-2 py-2 text-[12px] leading-relaxed text-warning">当前 profile「{model}」未配置,请选择列表中的模型或打开模型设置。</p>
)}
{typed && typed !== model && !models.some((m) => m.id === typed) && (
<button
type="button"
onClick={() => choose(typed)}
className="flex h-9 w-full items-center gap-2.5 rounded-lg px-2 text-left text-[13px] text-fg hover:bg-surface-2"
>
<Cpu className="size-4 text-fg-3" />
<span className="min-w-0 flex-1 truncate">
使用 <span className="font-mono">{typed}</span>
</span>
</button>
<p role="alert" className="px-2 py-2 text-[12px] leading-relaxed text-fg-3">
没有这个 profile,请先到模型设置添加完整连接。
</p>
)}
</div>
<button
Expand Down
12 changes: 6 additions & 6 deletions apps/desktop/src/renderer/features/customize/RulesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,20 @@ export function RulesPage({ query }: { query: string }) {
await sendMessage("/init");
};

/** Exclude a file by adding its path to `claudeMdExcludes`, or stop excluding it. */
/** Exclude a file by adding its path to `agentMdExcludes`, or stop excluding it. */
const setExcluded = async (rule: RuleInventoryItem, excluded: boolean) => {
if (!rule.path) return;
const current = (sourceValues(config, writeScope).claudeMdExcludes ?? []) as string[];
const current = (sourceValues(config, writeScope).agentMdExcludes ?? []) as string[];
const next = excluded ? [...new Set([...current, rule.path])] : current.filter((p) => p !== rule.path);
if (next.length === current.length && !excluded) {
toast(`${SCOPE_FILE[writeScope]} 里没有排除它,排除规则写在别的配置里`);
return;
}
await writeSetting(
writeScope,
"claudeMdExcludes",
"agentMdExcludes",
next.length > 0 ? next : null,
excluded ? `已在 ${SCOPE_FILE[writeScope]} 的 claudeMdExcludes 中加入 ${label(rule)}` : `已不再排除 ${label(rule)}`,
excluded ? `已在 ${SCOPE_FILE[writeScope]} 的 agentMdExcludes 中加入 ${label(rule)}` : `已不再排除 ${label(rule)}`,
);
};

Expand Down Expand Up @@ -198,7 +198,7 @@ export function RulesPage({ query }: { query: string }) {
<div className="mb-5 grid grid-cols-3 gap-2.5">
<Stat label="每轮占用" value={`${tokens(loaded.reduce((n, r) => n + r.tokens.value, 0))} tokens`} sub="全文加载,无法按需" />
<Stat label="已加载" value={`${loaded.length} 个文件`} sub={`${rules.length - loaded.length} 个被排除`} />
<Stat label="排除规则" value="claudeMdExcludes" sub="glob 匹配,所有配置合并生效" />
<Stat label="排除规则" value="agentMdExcludes" sub="glob 匹配,所有配置合并生效" />
</div>

<h3 className="mb-2 px-1 text-[12.5px] font-semibold text-fg">加载顺序</h3>
Expand Down Expand Up @@ -261,7 +261,7 @@ export function RulesPage({ query }: { query: string }) {
label="排除这个文件"
hint={
<>
关闭后会写入 claudeMdExcludes,比如 <code className="font-mono">"{selected.path}"</code>。排除只会少加载,任何一层配置里写了都生效。
关闭后会写入 agentMdExcludes,比如 <code className="font-mono">"{selected.path}"</code>。排除只会少加载,任何一层配置里写了都生效。
</>
}
>
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/renderer/features/customize/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const REASONS: [RegExp, (m: RegExpMatchArray) => string][] = [
[/^Listed to the model once a matching file/, () => "改到匹配的文件后才列给模型"],
[/^Not approved yet\.$/, () => "还没有批准"],
[/^Rejected in disabledMcpjsonServers\.$/, () => "已在 disabledMcpjsonServers 里拒绝"],
[/^Matched by claudeMdExcludes\.$/, () => "被 claudeMdExcludes 排除"],
[/^Matched by agentMdExcludes\.$/, () => "被 agentMdExcludes 排除"],
[/^Left out by (\S+) \(Agent "([^"]+)"\)\.$/, (m) => `Agent「${m[2]}」的 ${m[1]} 去掉了它`],
[/^Not in (\S+) \(Agent "([^"]+)"\)\.$/, (m) => `不在 Agent「${m[2]}」的 ${m[1]} 里`],
[/^Turned off by (\S+) \(Agent "([^"]+)"\)\.$/, (m) => `Agent「${m[2]}」的 ${m[1]} 关掉了它`],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { primaryAgentOf, useRuntime, useWorkspaces } from "../../state/workspace
import { lockedBy, setKey, sourceText } from "../agents/model";

/**
* A settings row for a value that belongs to the Agent (`features.*`): it
* A settings row for a value that belongs to the Agent: it
* shows and writes the setting of the Agent the workspace runs
* (`harnesses.<name>.<path>`), not a settings file.
*/
Expand All @@ -15,11 +15,13 @@ export function AgentSettingRow<T>({
hint,
path,
render,
stack = false,
}: {
title: string;
hint?: ReactNode;
path: string;
render: (value: T | undefined, set: (value: T) => void) => ReactNode;
stack?: boolean;
}) {
const workspaceId = useWorkspaces((s) => s.activeId);
const runtime = useRuntime(workspaceId ?? undefined);
Expand All @@ -34,7 +36,10 @@ export function AgentSettingRow<T>({
const locked = lockedBy(value);
const set = (next: T) => void changeWorkspaceAgent((spec) => setKey(spec, path, next), { message: (name) => `已写入 harnesses.${name}.${path}` });
return (
<div data-row={path} className="group/row flex items-center justify-between gap-6 border-b border-line py-3.5 last:border-b-0">
<div
data-row={path}
className={cn("group/row flex justify-between border-b border-line py-3.5 last:border-b-0", stack ? "flex-col items-start gap-3" : "items-center gap-6")}
>
<div className="min-w-0">
<div className="flex items-center gap-2">
<span className="text-[13.5px] font-medium text-fg">{title}</span>
Expand Down
Loading
Loading