min-agent 0.6.2 → 0.6.4

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/docs/API.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # min-agent HTTP API
2
2
 
3
- `min-agent serve` 启动本地 HTTP 服务,以编程方式调用代理能力。未配置服务商时使用内置 OpenRouter 模型,不必先运行 `min-agent setup`。
3
+ `min-agent serve` 启动本地 HTTP 服务,以编程方式调用代理能力。未配置服务商时使用内置 OpenRouter 模型(`openrouter/free`,预设锁定、不可修改),不必先运行 `min-agent setup`。
4
4
 
5
5
  ## 启动
6
6
 
@@ -118,6 +118,8 @@ CLI 升级请使用 `min-agent update`(执行 `npm install -g min-agent`)。
118
118
  { "default_model": "gpt-4o", "models": ["gpt-4o", "gpt-4o-mini"] }
119
119
  ```
120
120
 
121
+ 当内置 OpenRouter 预设生效时,`models` 固定为 `["openrouter/free"]`(不发网络请求,也不允许其它模型)。
122
+
121
123
  ## `GET /v1/context`
122
124
 
123
125
  ```json
@@ -183,7 +185,7 @@ CLI 升级请使用 `min-agent update`(执行 `npm install -g min-agent`)。
183
185
  | `thinking` | string | 本轮思考强度:`off` / `low` / `medium` / `high` / `max`。不传则用配置,未配置时为 `medium` |
184
186
  | `memory` | string | 本轮是否使用记忆:`on` / `off`。不传则用配置,未配置时为 `off` |
185
187
 
186
- `auto_approve: false` 且未开流式时返回 `400 auto_approve_requires_stream`。确认/提问最多等待 5 分钟,超时视为拒绝或跳过。客户端断开连接时未完成的确认视为拒绝。
188
+ `auto_approve: false` 且未开流式时返回 `400 auto_approve_requires_stream`。确认/提问最多等待 5 分钟,超时视为拒绝或跳过。客户端断开连接时未完成的确认视为拒绝。`auto_approve: false` 时所有需要确认的操作都会回调,包括文件写入/编辑(不再受服务端 `permission` 的 `accept-edits` 影响);同一步的多个操作会各自发出一条 `confirm` 事件,分别用 `POST /v1/approvals` 回复。
187
189
 
188
190
  `max_steps_reached` 为 `true` 表示本轮已用尽自动续跑次数(上下文压缩/空回复等),或显式设置了 `agent.maxSteps` 且已到达该上限。默认不按固定步数切断一轮生成。`incomplete` 为 `true` 表示模型在调用工具后没有给出完整回复,或连续多次空回复。`stopped` 为 `true` 表示因同一操作反复执行而主动结束本轮。`empty_response` 为 `true` 表示 provider 连续返回空流(HTTP 200 但没有任何内容,多为上游超时/限流),`empty_attempts` 为已尝试次数;这类空回复会以原请求重发重试(首次立即,之后指数退避),可用 `agent.maxEmptyAttempts`(默认 4)与 `agent.emptyRetryDelayMs`(默认 1000)调整。发送下一条消息即可继续。`continues` 为本轮实际自动续跑次数。`task_state` 为当前任务目标与待办列表,会写入会话并在压缩后保留;纯问候不会记为任务目标。网页检索连续过久、或检索后尚未写出用户要求的结果时,代理会改为基于已有资料产出结果;本轮内再调用搜索/抓取会收到停止检索并直接产出的提示,而不是新的检索结果(即使 `autoContinue` 为 `false`)。
189
191
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "min-agent",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "type": "module",
5
5
  "description": "Minimal AI coding agent with tool use, MCP, and skills support",
6
6
  "license": "MIT",
@@ -80,16 +80,16 @@ Instructions...
80
80
 
81
81
  - Rules: edit the files in the table above. `/reload` reloads rules only, not MCP.
82
82
  - Memory: **off** by default. Config `memory` is `on` | `off` (`true`/`enable` → on, `false`/`disable` → off). Project overlays global; writing `memory` globally also removes a project `memory` overlay. When off, memories are not injected and `memory_save` / `memory_search` / `memory_delete` are not registered (takes effect next turn after you change the file). CLI `min-agent memory on|off` / `--memory` follow the same write-vs-this-run rule as permission. `/memory on|off` writes **global** by default (and clears a project overlay); `/memory --project` writes only the project file. `/memory` lists the switch plus stored entries; `/memory <text>` still writes `memory.json` even when off. Default save scope is project when `.min-agent/` exists. Shape: `{ "content": string, "tags": string[], "created": ISO string }` array. When on, memories are injected each turn as background reference, not as work to resume. Do not store secrets or API keys. HTTP: `GET/POST /v1/memory/mode`, chat body `memory`, and `GET /v1/memory` include `memory` / `source` / `label`.
83
- - Permission: `accept-edits` (default) | `ask` | `allow-all` in config `permission`. CLI `min-agent permission …` / `--permission` without a message writes config and exits; with a message it is this session only. `--yes` is this session only and does not write config.
83
+ - Permission: `accept-edits` (default) | `ask` | `allow-all` in config `permission`. CLI `min-agent permission …` / `--permission` without a message writes config and exits; with a message it is this session only. `--yes` is this session only and does not write config. `min-agent exec` (one-shot) uses a permissive default when neither `--permission` nor `--yes` is given: file edits and ordinary commands run without asking, and only genuinely destructive commands (deleting files/dirs, `drop`/`truncate`/`delete from`, `mkfs`/`dd`/raw-device writes, `shred`/`wipefs`, `git reset --hard`/`git clean -f`, `docker rm`/`prune`, `find … -delete`/`-exec rm`) still prompt. An explicit `--permission` (or `--yes`) overrides this and behaves exactly as in interactive sessions (`allow-all` runs even destructive commands silently). Confirmation prompts are coalesced: when several actions in one step need approval, a single overlay lists them all and one allow/deny decision applies to the whole batch instead of stacking separate prompts.
84
84
  - Thinking intensity: `off` | `low` | `medium` | `high` | `max` in config `thinking`. Omit the field to use **medium**, then clamp to levels the current model actually exposes (from the model catalog). `/think` opens an interactive picker of those English levels and writes **global** config; that also clears a project `thinking` overlay so a leftover project `off` cannot hide the new value after restart. `/think --project` writes only the project file. Typed `/think off|low|medium|high|max` still works when the model supports that value. `min-agent think …` / `--think` follow the same write-vs-this-run rule as permission. `xhigh` / `extra-high` / `none` are accepted as aliases (`xhigh` → `max`, `none` → `off`). Each request maps that intensity onto the current model and gateway (MiniMax uses `adaptive`/`disabled`; official OpenAI omits `thinking` and maps `max` to `xhigh`; an `ollama` provider uses native chat with `think` plus the configured window). Learned mappings are cached in `~/.min-agent/thinking-wire-cache.json` for 7 days. Per-model context window and supported effort values are loaded from the model catalog (`https://models.lonae.com`, override with `MIN_AGENT_MODELS_API_URL`) and cached in `~/.min-agent/model-catalog-cache.json` for 7 days after a successful lookup. When the provider host is unknown, effort levels are the majority across offerings that actually list efforts (toggle-only rows do not vote), so a single gateway cannot invent `medium`. An `ollama` provider skips that catalog and uses native `POST /api/show` instead (whether the model advertises thinking, plus the loaded window: Modelfile `num_ctx` if set, otherwise the architecture length capped at 32768). Chat completions are sent to native `POST /api/chat` so `options.num_ctx` and `think` actually apply — the OpenAI-compatible `/v1` endpoint ignores both. `/ctx` opens a picker of `2k` / `4k` / `8k` / `12k` / `16k` / `32k` / `64k` / `128k` / `256k` / `auto` and writes the active provider's `contextWindow` (global only; providers are not in project config). Typed `/ctx 8k` and CLI `min-agent ctx 8k` do the same; `auto` clears the override. The menu item is hidden unless the active provider is ollama. Results are cached in `~/.min-agent/ollama-model-cache.json` for 7 days.
85
85
  - Sandbox default is **off**. `mode`: `off` | `workspace` | `strict`. Optional `network`, `extraWriteRoots`, `extraReadRoots`. Isolation is independent of permission. `--sandbox` / `--network` without a message write config and exit.
86
86
 
87
87
  ## Providers
88
88
 
89
- Only in global `config.json`: `providers[]` with `name`, `type` (`openai-compatible` | `openai` | `ollama`), `baseURL`, `apiKey`, optional `defaultModel`, `contextWindow`. `activeProvider` selects one. Project config may set `activeProvider` and `defaultModel` (no keys). If `providers` is missing or empty, a built-in OpenRouter provider (`openrouter`, model `openrouter/free`) is used at runtime and is not written to disk. User-configured providers always win. `MIN_AGENT_NO_BUILTIN_PROVIDER=1` disables the fallback.
89
+ Only in global `config.json`: `providers[]` with `name`, `type` (`openai-compatible` | `openai` | `ollama`), `baseURL`, `apiKey`, optional `defaultModel`, `contextWindow`. `activeProvider` selects one. Project config may set `activeProvider` and `defaultModel` (no keys). If `providers` is missing or empty, a built-in OpenRouter provider (`openrouter`, model `openrouter/free`) is used at runtime and is not written to disk. The preset is **locked**: while it is the active provider, `min-agent setup` rejects adding, editing, switching, or removing providers, the model list is fixed to `openrouter/free` (never fetched), and only that model can be selected (`/model`, `--model`, chat `model`). `MIN_AGENT_NO_BUILTIN_PROVIDER=1` disables the fallback — with it set (or once any user provider exists) the lock no longer applies and setup works normally.
90
90
 
91
91
  `/provider` opens an interactive picker and writes **global** `activeProvider`; that also clears a project `activeProvider` overlay so the choice is what later turns use. Typed `/provider <name>` still works. Adding, editing, or removing providers is `min-agent setup` (not the TUI picker).
92
92
 
93
- CLI: `min-agent setup` (interactive wizard or flags). Flags: `--type openai-compatible|openai|ollama`, `--url`, `--api-key`, `--name`, `--default-model`, `--switch <name>`, `--remove <name>`. `--yes` skips overwrite/delete confirmation during setup; it does not change permission. Keys only in the global file.
93
+ CLI: `min-agent setup` (interactive wizard or flags). Flags: `--type openai-compatible|openai|ollama`, `--url`, `--api-key`, `--name`, `--default-model`, `--switch <name>`, `--remove <name>`. `--yes` skips overwrite/delete confirmation during setup; it does not change permission. Keys only in the global file. While the preset is active the wizard only shows the locked built-in provider (test connection / done).
94
94
 
95
95
  After changing keys or MCP connections, tell the user if a restart is required. Do not print full secrets back in chat.
@@ -72,7 +72,7 @@ Read this when you need exact keys. Files are strict JSON.
72
72
  - Old single-provider configs migrate on first run; write the `providers` array for new files.
73
73
  - Interactive and non-interactive provider setup both go through `min-agent setup`. API keys are written only to the global config.
74
74
  - Interactive `/provider` (and typed `/provider <name>`) writes global `activeProvider` and clears a project `activeProvider` overlay. It does not add, edit, or remove providers.
75
- - If `providers` is missing or empty, runtime uses a built-in OpenRouter provider (`name`: `openrouter`, `defaultModel`: `openrouter/free`) without writing it to disk. User entries always win. `MIN_AGENT_NO_BUILTIN_PROVIDER=1` disables that fallback.
75
+ - If `providers` is missing or empty, runtime uses a built-in OpenRouter provider (`name`: `openrouter`, `defaultModel`: `openrouter/free`) without writing it to disk. The preset is locked: while it is the active provider, `min-agent setup` refuses to add/edit/switch/remove providers, the model list is fixed to `openrouter/free` (no network fetch), and selecting any other model (interactive picker, `/model`, `--model`, HTTP chat `model`) is rejected. `MIN_AGENT_NO_BUILTIN_PROVIDER=1` disables the fallback; with the preset disabled or any user provider stored, the lock does not apply and setup works normally.
76
76
 
77
77
  ## Project `.min-agent/config.json`
78
78