@armadra/agent 0.5.1 → 0.6.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/CHANGELOG.md +203 -304
- package/CHANGELOG.zh-CN.md +462 -0
- package/README.md +408 -364
- package/README.zh-CN.md +705 -0
- package/dist/agent/session-plan.js +2 -2
- package/dist/agent/session-state.d.ts +3 -0
- package/dist/agent/session-state.js +20 -0
- package/dist/agent/session-subagent.d.ts +15 -1
- package/dist/agent/session-subagent.js +26 -3
- package/dist/agent/session-telemetry.d.ts +16 -2
- package/dist/agent/session-telemetry.js +29 -7
- package/dist/agent/session-tools.js +5 -2
- package/dist/agent/session-trace-writer.d.ts +27 -0
- package/dist/agent/session-trace-writer.js +253 -0
- package/dist/agent/session.d.ts +2 -0
- package/dist/agent/session.js +12 -0
- package/dist/agent/subagent-direct.d.ts +20 -0
- package/dist/agent/subagent-direct.js +76 -0
- package/dist/agent/subagent-registry.d.ts +8 -1
- package/dist/agent/subagent-registry.js +28 -1
- package/dist/agent/system-prompt.d.ts +3 -1
- package/dist/agent/system-prompt.js +3 -0
- package/dist/agent/tool-runner.d.ts +2 -1
- package/dist/agent/tool-runner.js +5 -4
- package/dist/agent/types-w6.d.ts +39 -0
- package/dist/agent/types-w6.js +4 -0
- package/dist/agent/types.d.ts +5 -2
- package/dist/agents/external.js +1 -1
- package/dist/agents/task-record.d.ts +74 -1
- package/dist/agents/task-record.js +100 -0
- package/dist/ai/apis/cache-params.js +2 -1
- package/dist/ai/apis/chatgpt-backend.d.ts +52 -0
- package/dist/ai/apis/chatgpt-backend.js +224 -0
- package/dist/ai/apis/chatgpt-rate-limits.d.ts +26 -0
- package/dist/ai/apis/chatgpt-rate-limits.js +91 -0
- package/dist/ai/apis/openai-responses-request.d.ts +2 -1
- package/dist/ai/apis/openai-responses-request.js +8 -2
- package/dist/ai/apis/openai-responses.d.ts +2 -0
- package/dist/ai/apis/openai-responses.js +51 -16
- package/dist/ai/overflow.d.ts +1 -1
- package/dist/ai/overflow.js +10 -7
- package/dist/ai/providers/auth.d.ts +15 -2
- package/dist/ai/providers/auth.js +69 -2
- package/dist/ai/providers/builtin.js +27 -0
- package/dist/ai/providers/catalog-data.js +1 -0
- package/dist/ai/providers/discovered-cache.d.ts +48 -0
- package/dist/ai/providers/discovered-cache.js +102 -0
- package/dist/ai/providers/enrich.js +2 -7
- package/dist/ai/providers/model-visibility.d.ts +33 -0
- package/dist/ai/providers/model-visibility.js +70 -0
- package/dist/ai/providers/models-dev-cache.js +15 -19
- package/dist/ai/providers/models-dev-snapshot.js +8 -7
- package/dist/ai/providers/models-dev.js +5 -15
- package/dist/ai/providers/registry.d.ts +2 -0
- package/dist/ai/providers/registry.js +6 -1
- package/dist/ai/providers/suggest.js +2 -16
- package/dist/ai/types.d.ts +27 -1
- package/dist/auth/chatgpt/backend-client.d.ts +26 -0
- package/dist/auth/chatgpt/backend-client.js +74 -0
- package/dist/auth/chatgpt/claims.d.ts +17 -0
- package/dist/auth/chatgpt/claims.js +46 -0
- package/dist/auth/chatgpt/cli.d.ts +35 -0
- package/dist/auth/chatgpt/cli.js +279 -0
- package/dist/auth/chatgpt/doctor.d.ts +17 -0
- package/dist/auth/chatgpt/doctor.js +36 -0
- package/dist/auth/chatgpt/host-id.d.ts +7 -0
- package/dist/auth/chatgpt/host-id.js +26 -0
- package/dist/auth/chatgpt/login.d.ts +30 -0
- package/dist/auth/chatgpt/login.js +130 -0
- package/dist/auth/chatgpt/presets.d.ts +66 -0
- package/dist/auth/chatgpt/presets.js +120 -0
- package/dist/auth/chatgpt/quota-text.d.ts +13 -0
- package/dist/auth/chatgpt/quota-text.js +36 -0
- package/dist/auth/oauth/browser.d.ts +12 -0
- package/dist/auth/oauth/browser.js +27 -0
- package/dist/auth/oauth/callback-server.d.ts +47 -0
- package/dist/auth/oauth/callback-server.js +147 -0
- package/dist/auth/oauth/flows.d.ts +62 -0
- package/dist/auth/oauth/flows.js +113 -0
- package/dist/auth/oauth/jwt.d.ts +24 -0
- package/dist/auth/oauth/jwt.js +81 -0
- package/dist/auth/oauth/live.d.ts +21 -0
- package/dist/auth/oauth/live.js +25 -0
- package/dist/auth/oauth/oidc.d.ts +26 -0
- package/dist/auth/oauth/oidc.js +72 -0
- package/dist/auth/oauth/pkce.d.ts +15 -0
- package/dist/auth/oauth/pkce.js +20 -0
- package/dist/auth/oauth/refresh.d.ts +35 -0
- package/dist/auth/oauth/refresh.js +129 -0
- package/dist/auth/oauth/token-client.d.ts +33 -0
- package/dist/auth/oauth/token-client.js +121 -0
- package/dist/auth/oauth/token-store.d.ts +23 -0
- package/dist/auth/oauth/token-store.js +125 -0
- package/dist/auth/testing/fake-oauth.d.ts +73 -0
- package/dist/auth/testing/fake-oauth.js +271 -0
- package/dist/auth/testing/refresh-child.d.ts +5 -0
- package/dist/auth/testing/refresh-child.js +16 -0
- package/dist/bundle/ama.cjs +26532 -11045
- package/dist/checkpoints/backend.js +6 -5
- package/dist/checkpoints/restore.js +3 -2
- package/dist/checkpoints/settings.js +2 -1
- package/dist/checkpoints/shadow-git.js +7 -6
- package/dist/checkpoints/shadow-restore.js +3 -2
- package/dist/checkpoints/tracker.js +4 -3
- package/dist/cli/args.d.ts +9 -2
- package/dist/cli/args.js +74 -27
- package/dist/cli/bootstrap.js +53 -31
- package/dist/cli/choice-prompt.js +8 -6
- package/dist/cli/codemode-notice.js +2 -2
- package/dist/cli/compose-agents.js +2 -1
- package/dist/cli/compose-extensions.js +2 -0
- package/dist/cli/compose-memory.d.ts +53 -0
- package/dist/cli/compose-memory.js +127 -0
- package/dist/cli/compose-providers.d.ts +6 -0
- package/dist/cli/compose-providers.js +38 -2
- package/dist/cli/compose-session.d.ts +5 -0
- package/dist/cli/compose-session.js +27 -13
- package/dist/cli/compose-store.d.ts +2 -0
- package/dist/cli/compose-store.js +9 -5
- package/dist/cli/compose.d.ts +2 -0
- package/dist/cli/compose.js +13 -5
- package/dist/cli/default-model.d.ts +0 -2
- package/dist/cli/default-model.js +5 -8
- package/dist/cli/deps.d.ts +5 -1
- package/dist/cli/exit-codes.d.ts +1 -1
- package/dist/cli/exit-codes.js +7 -16
- package/dist/cli/from-prompt.js +3 -2
- package/dist/cli/help-text.d.ts +2 -1
- package/dist/cli/help-text.js +5 -99
- package/dist/cli/main.d.ts +5 -0
- package/dist/cli/main.js +21 -2
- package/dist/cli/proxy.js +14 -9
- package/dist/cli/runtime.d.ts +5 -0
- package/dist/cli/startup-screen.js +20 -27
- package/dist/cli/startup-steps.js +6 -8
- package/dist/cli/subcommands/auth.d.ts +6 -3
- package/dist/cli/subcommands/auth.js +52 -22
- package/dist/cli/subcommands/config-set.d.ts +21 -0
- package/dist/cli/subcommands/config-set.js +145 -0
- package/dist/cli/subcommands/config.d.ts +2 -1
- package/dist/cli/subcommands/config.js +51 -37
- package/dist/cli/subcommands/doctor.d.ts +2 -1
- package/dist/cli/subcommands/doctor.js +97 -58
- package/dist/cli/subcommands/init.d.ts +1 -1
- package/dist/cli/subcommands/init.js +8 -7
- package/dist/cli/subcommands/memory.d.ts +18 -0
- package/dist/cli/subcommands/memory.js +189 -0
- package/dist/cli/subcommands/model-meta.js +11 -9
- package/dist/cli/subcommands/models-cache-probe.js +23 -20
- package/dist/cli/subcommands/models-discover.d.ts +4 -0
- package/dist/cli/subcommands/models-discover.js +60 -21
- package/dist/cli/subcommands/models-enable.d.ts +13 -0
- package/dist/cli/subcommands/models-enable.js +145 -0
- package/dist/cli/subcommands/models.d.ts +3 -1
- package/dist/cli/subcommands/models.js +39 -24
- package/dist/cli/subcommands/probe-runner.js +8 -7
- package/dist/cli/subcommands/providers-list.js +32 -21
- package/dist/cli/subcommands/providers-plan.js +24 -25
- package/dist/cli/subcommands/providers-probe.js +5 -6
- package/dist/cli/subcommands/providers.d.ts +1 -1
- package/dist/cli/subcommands/providers.js +45 -50
- package/dist/cli/subcommands/sessions-export.d.ts +1 -1
- package/dist/cli/subcommands/sessions-export.js +10 -9
- package/dist/cli/subcommands/sessions-search.d.ts +1 -1
- package/dist/cli/subcommands/sessions-search.js +11 -10
- package/dist/cli/subcommands/sessions-trace.d.ts +30 -0
- package/dist/cli/subcommands/sessions-trace.js +156 -0
- package/dist/cli/subcommands/sessions.d.ts +4 -3
- package/dist/cli/subcommands/sessions.js +40 -37
- package/dist/cli/subcommands/stats.d.ts +1 -1
- package/dist/cli/subcommands/stats.js +49 -30
- package/dist/cli/system-prompt-arg.js +3 -2
- package/dist/codemode/capability.js +3 -2
- package/dist/compaction/post-compact.d.ts +1 -0
- package/dist/compaction/post-compact.js +15 -1
- package/dist/compaction/prune-tier.d.ts +1 -1
- package/dist/compaction/prune-tier.js +3 -3
- package/dist/compaction/serialize.js +2 -1
- package/dist/config/auth-file.d.ts +12 -2
- package/dist/config/auth-file.js +32 -10
- package/dist/config/checker.js +12 -11
- package/dist/config/context-files.js +3 -2
- package/dist/config/edit.d.ts +106 -0
- package/dist/config/edit.js +350 -0
- package/dist/config/init.d.ts +4 -3
- package/dist/config/init.js +10 -18
- package/dist/config/json-schema.d.ts +2 -1
- package/dist/config/json-schema.js +102 -69
- package/dist/config/key-docs.d.ts +18 -7
- package/dist/config/key-docs.js +43 -128
- package/dist/config/load.js +7 -6
- package/dist/config/merge.d.ts +4 -1
- package/dist/config/merge.js +42 -22
- package/dist/config/paths.js +6 -5
- package/dist/config/profile.d.ts +5 -1
- package/dist/config/profile.js +7 -2
- package/dist/config/schema-w5.js +12 -4
- package/dist/config/schema-w6.d.ts +19 -0
- package/dist/config/schema-w6.js +115 -0
- package/dist/config/schema.js +34 -20
- package/dist/config/settings-registry.d.ts +81 -0
- package/dist/config/settings-registry.js +185 -0
- package/dist/config/types-w5.d.ts +7 -0
- package/dist/config/types-w5.js +2 -0
- package/dist/config/types-w6.d.ts +109 -0
- package/dist/config/types-w6.js +19 -0
- package/dist/config/types.d.ts +11 -8
- package/dist/config/types.js +1 -0
- package/dist/drivers/acp/client.js +1 -1
- package/dist/drivers/acp/driver.js +13 -8
- package/dist/drivers/agents.js +4 -3
- package/dist/drivers/base.js +3 -2
- package/dist/drivers/host-runners.js +2 -1
- package/dist/drivers/native/claude-stream.js +12 -11
- package/dist/drivers/native/codex-app-server.js +17 -12
- package/dist/drivers/native/oneshot.js +8 -7
- package/dist/drivers/pool.js +1 -1
- package/dist/drivers/runner.d.ts +3 -1
- package/dist/drivers/runner.js +68 -20
- package/dist/drivers/turn.js +1 -1
- package/dist/hooks/config.js +3 -2
- package/dist/hooks/protocol.js +18 -12
- package/dist/host/api-impl.js +11 -10
- package/dist/host/loader.js +9 -8
- package/dist/host/types.d.ts +3 -0
- package/dist/i18n/catalog.d.ts +2209 -0
- package/dist/i18n/catalog.js +72 -0
- package/dist/i18n/format.d.ts +21 -0
- package/dist/i18n/format.js +58 -0
- package/dist/i18n/index.d.ts +58 -0
- package/dist/i18n/index.js +72 -0
- package/dist/i18n/messages/agents.d.ts +84 -0
- package/dist/i18n/messages/agents.js +85 -0
- package/dist/i18n/messages/approval.d.ts +99 -0
- package/dist/i18n/messages/approval.js +100 -0
- package/dist/i18n/messages/auth.d.ts +189 -0
- package/dist/i18n/messages/auth.js +201 -0
- package/dist/i18n/messages/cli-args.d.ts +46 -0
- package/dist/i18n/messages/cli-args.js +46 -0
- package/dist/i18n/messages/cli-help.d.ts +12 -0
- package/dist/i18n/messages/cli-help.js +248 -0
- package/dist/i18n/messages/cli.d.ts +336 -0
- package/dist/i18n/messages/cli.js +311 -0
- package/dist/i18n/messages/config-keys.d.ts +293 -0
- package/dist/i18n/messages/config-keys.js +296 -0
- package/dist/i18n/messages/config.d.ts +508 -0
- package/dist/i18n/messages/config.js +241 -0
- package/dist/i18n/messages/drivers.d.ts +123 -0
- package/dist/i18n/messages/drivers.js +124 -0
- package/dist/i18n/messages/errors.d.ts +83 -0
- package/dist/i18n/messages/errors.js +171 -0
- package/dist/i18n/messages/interactive-line.d.ts +61 -0
- package/dist/i18n/messages/interactive-line.js +69 -0
- package/dist/i18n/messages/interactive-startup.d.ts +99 -0
- package/dist/i18n/messages/interactive-startup.js +100 -0
- package/dist/i18n/messages/interactive-view.d.ts +140 -0
- package/dist/i18n/messages/interactive-view.js +141 -0
- package/dist/i18n/messages/interactive.d.ts +489 -0
- package/dist/i18n/messages/interactive.js +248 -0
- package/dist/i18n/messages/memory.d.ts +123 -0
- package/dist/i18n/messages/memory.js +128 -0
- package/dist/i18n/messages/panels.d.ts +233 -0
- package/dist/i18n/messages/panels.js +232 -0
- package/dist/i18n/messages/permissions.d.ts +126 -0
- package/dist/i18n/messages/permissions.js +151 -0
- package/dist/i18n/messages/plan.d.ts +123 -0
- package/dist/i18n/messages/plan.js +124 -0
- package/dist/i18n/messages/print.d.ts +86 -0
- package/dist/i18n/messages/print.js +91 -0
- package/dist/i18n/messages/report.d.ts +391 -0
- package/dist/i18n/messages/report.js +490 -0
- package/dist/i18n/messages/rewind.d.ts +198 -0
- package/dist/i18n/messages/rewind.js +217 -0
- package/dist/i18n/messages/session.d.ts +230 -0
- package/dist/i18n/messages/session.js +258 -0
- package/dist/i18n/messages/settings.d.ts +355 -0
- package/dist/i18n/messages/settings.js +343 -0
- package/dist/i18n/messages/subcommands-config.d.ts +113 -0
- package/dist/i18n/messages/subcommands-config.js +129 -0
- package/dist/i18n/messages/subcommands-models.d.ts +34 -0
- package/dist/i18n/messages/subcommands-models.js +34 -0
- package/dist/i18n/messages/subcommands.d.ts +576 -0
- package/dist/i18n/messages/subcommands.js +477 -0
- package/dist/i18n/messages/trace.d.ts +243 -0
- package/dist/i18n/messages/trace.js +238 -0
- package/dist/i18n/types.d.ts +15 -0
- package/dist/i18n/types.js +7 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +2 -0
- package/dist/memory/edit.d.ts +24 -0
- package/dist/memory/edit.js +63 -0
- package/dist/memory/frontmatter.d.ts +37 -0
- package/dist/memory/frontmatter.js +79 -0
- package/dist/memory/index.d.ts +28 -0
- package/dist/memory/index.js +126 -0
- package/dist/memory/lock.d.ts +17 -0
- package/dist/memory/lock.js +62 -0
- package/dist/memory/paths.d.ts +57 -0
- package/dist/memory/paths.js +175 -0
- package/dist/memory/report.d.ts +36 -0
- package/dist/memory/report.js +86 -0
- package/dist/memory/runtime.d.ts +42 -0
- package/dist/memory/runtime.js +36 -0
- package/dist/memory/secrets.d.ts +8 -0
- package/dist/memory/secrets.js +27 -0
- package/dist/memory/section.d.ts +28 -0
- package/dist/memory/section.js +59 -0
- package/dist/memory/store.d.ts +70 -0
- package/dist/memory/store.js +284 -0
- package/dist/memory/tool.d.ts +31 -0
- package/dist/memory/tool.js +94 -0
- package/dist/modes/acp/acp-events.js +2 -1
- package/dist/modes/acp/acp-server.js +13 -12
- package/dist/modes/commands-core.d.ts +11 -0
- package/dist/modes/commands-core.js +93 -62
- package/dist/modes/image-input.js +20 -6
- package/dist/modes/interactive/agent-bar.d.ts +95 -0
- package/dist/modes/interactive/agent-bar.js +248 -0
- package/dist/modes/interactive/agent-panels.js +27 -26
- package/dist/modes/interactive/agent-transcript.d.ts +47 -0
- package/dist/modes/interactive/agent-transcript.js +191 -0
- package/dist/modes/interactive/agent-ui.d.ts +36 -1
- package/dist/modes/interactive/agent-ui.js +180 -14
- package/dist/modes/interactive/agent-view.d.ts +72 -0
- package/dist/modes/interactive/agent-view.js +281 -0
- package/dist/modes/interactive/approval-dialog.js +46 -34
- package/dist/modes/interactive/clipboard-paste.d.ts +2 -2
- package/dist/modes/interactive/clipboard-paste.js +9 -4
- package/dist/modes/interactive/commands.d.ts +22 -1
- package/dist/modes/interactive/commands.js +100 -49
- package/dist/modes/interactive/completion.js +2 -1
- package/dist/modes/interactive/config-panel.d.ts +70 -0
- package/dist/modes/interactive/config-panel.js +319 -0
- package/dist/modes/interactive/config-ui.d.ts +96 -0
- package/dist/modes/interactive/config-ui.js +397 -0
- package/dist/modes/interactive/confirm-dialog.js +6 -7
- package/dist/modes/interactive/event-notices.js +11 -9
- package/dist/modes/interactive/interactive-mode.d.ts +1 -1
- package/dist/modes/interactive/interactive-mode.js +21 -22
- package/dist/modes/interactive/key-dispatch.d.ts +12 -0
- package/dist/modes/interactive/key-dispatch.js +24 -9
- package/dist/modes/interactive/line/line-editor.js +2 -1
- package/dist/modes/interactive/line/line-mode.js +18 -7
- package/dist/modes/interactive/line/line-render.js +25 -24
- package/dist/modes/interactive/memory-panel.d.ts +64 -0
- package/dist/modes/interactive/memory-panel.js +221 -0
- package/dist/modes/interactive/message-view.d.ts +4 -2
- package/dist/modes/interactive/message-view.js +42 -33
- package/dist/modes/interactive/model-items.d.ts +45 -0
- package/dist/modes/interactive/model-items.js +134 -0
- package/dist/modes/interactive/model-picker.d.ts +57 -0
- package/dist/modes/interactive/model-picker.js +191 -0
- package/dist/modes/interactive/panels.js +39 -31
- package/dist/modes/interactive/pickers.d.ts +2 -1
- package/dist/modes/interactive/pickers.js +10 -6
- package/dist/modes/interactive/plan-command.d.ts +1 -1
- package/dist/modes/interactive/plan-command.js +24 -27
- package/dist/modes/interactive/plan-dialog.js +18 -17
- package/dist/modes/interactive/plan-flow.js +6 -5
- package/dist/modes/interactive/rewind-command.d.ts +1 -1
- package/dist/modes/interactive/rewind-command.js +18 -16
- package/dist/modes/interactive/rewind-flow.d.ts +0 -1
- package/dist/modes/interactive/rewind-flow.js +13 -14
- package/dist/modes/interactive/rewind-list.js +7 -6
- package/dist/modes/interactive/rewind-panel.js +40 -40
- package/dist/modes/interactive/rewind-text.d.ts +5 -3
- package/dist/modes/interactive/rewind-text.js +48 -38
- package/dist/modes/interactive/run-indicator.js +15 -12
- package/dist/modes/interactive/session-events.js +3 -2
- package/dist/modes/interactive/startup-header.js +22 -23
- package/dist/modes/interactive/startup-ui.d.ts +3 -9
- package/dist/modes/interactive/startup-ui.js +44 -88
- package/dist/modes/interactive/status-area.d.ts +2 -0
- package/dist/modes/interactive/status-area.js +8 -2
- package/dist/modes/interactive/status-bar.js +4 -3
- package/dist/modes/interactive/subagent-view.js +9 -7
- package/dist/modes/interactive/tasks-report.d.ts +6 -0
- package/dist/modes/interactive/tasks-report.js +28 -31
- package/dist/modes/interactive/terminal-setup.d.ts +9 -0
- package/dist/modes/interactive/terminal-setup.js +23 -0
- package/dist/modes/interactive/tool-summary.js +19 -17
- package/dist/modes/interactive/tool-view.js +7 -4
- package/dist/modes/interactive/trace-view.d.ts +89 -0
- package/dist/modes/interactive/trace-view.js +332 -0
- package/dist/modes/print/print-mode.js +14 -15
- package/dist/modes/rpc/commands.js +7 -3
- package/dist/modes/rpc/rpc-mode.js +9 -3
- package/dist/modes/session-report.d.ts +2 -0
- package/dist/modes/session-report.js +101 -105
- package/dist/modes/startup-ui-text.js +11 -6
- package/dist/permissions/bypass.d.ts +8 -10
- package/dist/permissions/bypass.js +19 -10
- package/dist/permissions/memory-class.d.ts +23 -0
- package/dist/permissions/memory-class.js +54 -0
- package/dist/permissions/modes.d.ts +3 -3
- package/dist/permissions/modes.js +21 -16
- package/dist/permissions/pipeline.d.ts +1 -1
- package/dist/permissions/pipeline.js +9 -2
- package/dist/permissions/preview.js +49 -42
- package/dist/permissions/rules.js +5 -2
- package/dist/permissions/types.d.ts +4 -0
- package/dist/plan/store.js +2 -1
- package/dist/rpc.d.ts +39 -1
- package/dist/rpc.js +3 -0
- package/dist/sandbox/bash.js +11 -8
- package/dist/sandbox/detect.js +14 -11
- package/dist/sdk.d.ts +17 -1
- package/dist/sdk.js +29 -7
- package/dist/session/export.js +31 -30
- package/dist/session/manager.d.ts +1 -1
- package/dist/session/manager.js +5 -3
- package/dist/session/reuse.js +5 -4
- package/dist/session/scan.js +3 -2
- package/dist/session/stats-aggregate.d.ts +3 -1
- package/dist/session/stats-aggregate.js +5 -1
- package/dist/session/stats-index.js +2 -1
- package/dist/session/stats-scan.d.ts +4 -1
- package/dist/session/stats-scan.js +6 -2
- package/dist/session/store.d.ts +11 -0
- package/dist/session/store.js +48 -1
- package/dist/session/types.d.ts +2 -0
- package/dist/skills/builtin.js +2 -1
- package/dist/tools/image-file.d.ts +26 -1
- package/dist/tools/image-file.js +55 -13
- package/dist/tools/presets.d.ts +14 -1
- package/dist/tools/presets.js +3 -3
- package/dist/tools/registry.js +1 -1
- package/dist/tools/truncate.d.ts +1 -1
- package/dist/tools/truncate.js +2 -2
- package/dist/tools/types.d.ts +17 -1
- package/dist/trace/build-index.d.ts +91 -0
- package/dist/trace/build-index.js +127 -0
- package/dist/trace/build-nodes.d.ts +24 -0
- package/dist/trace/build-nodes.js +279 -0
- package/dist/trace/build-util.d.ts +43 -0
- package/dist/trace/build-util.js +120 -0
- package/dist/trace/build.d.ts +82 -0
- package/dist/trace/build.js +382 -0
- package/dist/trace/detail.d.ts +35 -0
- package/dist/trace/detail.js +205 -0
- package/dist/trace/flatten.d.ts +69 -0
- package/dist/trace/flatten.js +173 -0
- package/dist/trace/format.d.ts +47 -0
- package/dist/trace/format.js +329 -0
- package/dist/trace/html-template.d.ts +19 -0
- package/dist/trace/html-template.js +150 -0
- package/dist/trace/html.d.ts +104 -0
- package/dist/trace/html.js +292 -0
- package/dist/trace/preview.d.ts +29 -0
- package/dist/trace/preview.js +59 -0
- package/dist/trace/query-session.d.ts +14 -0
- package/dist/trace/query-session.js +38 -0
- package/dist/trace/query.d.ts +55 -0
- package/dist/trace/query.js +188 -0
- package/dist/trace/session.d.ts +40 -0
- package/dist/trace/session.js +168 -0
- package/dist/trace/types.d.ts +243 -0
- package/dist/trace/types.js +13 -0
- package/dist/tui/components/editor-paste.d.ts +2 -0
- package/dist/tui/components/editor-paste.js +6 -3
- package/dist/tui/components/editor.js +2 -2
- package/dist/tui/components/loader.d.ts +3 -0
- package/dist/tui/components/loader.js +14 -0
- package/dist/tui/components/select-list.d.ts +2 -0
- package/dist/tui/components/select-list.js +7 -0
- package/dist/tui/components/settings-list.d.ts +61 -0
- package/dist/tui/components/settings-list.js +135 -0
- package/dist/tui/keybindings.d.ts +5 -0
- package/dist/tui/keybindings.js +17 -5
- package/dist/tui.d.ts +1 -0
- package/dist/tui.js +2 -0
- package/docs/en/host-api.md +167 -0
- package/docs/en/permissions.md +214 -0
- package/docs/en/providers.md +627 -0
- package/docs/en/rpc.md +361 -0
- package/docs/en/sessions.md +219 -0
- package/docs/en/tui.md +534 -0
- package/docs/host-api.md +18 -17
- package/docs/memory.md +172 -0
- package/docs/permissions.md +2 -2
- package/docs/providers.md +73 -1
- package/docs/rpc.md +31 -3
- package/docs/session-format.md +8 -2
- package/docs/sessions.md +29 -1
- package/docs/tui.md +140 -4
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -4,67 +4,74 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/@armadra/agent)
|
|
5
5
|
[](LICENSE)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
English · [简体中文](README.zh-CN.md)
|
|
8
|
+
|
|
9
|
+
A coding agent for the terminal that can also be embedded in the [Armadra](https://github.com/yovinchen/Armadra) canvas as a coordinator. Written in TypeScript with zero runtime dependencies, and also shipped as a single-file build.
|
|
8
10
|
|
|
9
11
|
```sh
|
|
10
12
|
npm i -g @armadra/agent
|
|
11
|
-
export ANTHROPIC_API_KEY=sk-... #
|
|
13
|
+
export ANTHROPIC_API_KEY=sk-... # a key from any supported provider works
|
|
12
14
|
ama
|
|
13
15
|
```
|
|
14
16
|
|
|
15
|
-
##
|
|
16
|
-
|
|
17
|
-
- [
|
|
18
|
-
- [
|
|
19
|
-
- [
|
|
20
|
-
- [
|
|
21
|
-
- [
|
|
22
|
-
- [
|
|
23
|
-
- [
|
|
24
|
-
- [
|
|
25
|
-
- [
|
|
26
|
-
- [
|
|
17
|
+
## Contents
|
|
18
|
+
|
|
19
|
+
- [Why ama](#why-ama)
|
|
20
|
+
- [Features](#features)
|
|
21
|
+
- [Install](#install)
|
|
22
|
+
- [Quick start](#quick-start)
|
|
23
|
+
- [Configuration](#configuration)
|
|
24
|
+
- [Relays and gateways](#relays-and-gateways)
|
|
25
|
+
- [ChatGPT login](#chatgpt-login)
|
|
26
|
+
- [Tools and presets](#tools-and-presets)
|
|
27
|
+
- [Caching](#caching)
|
|
28
|
+
- [Safety](#safety)
|
|
29
|
+
- [Sandbox](#sandbox)
|
|
27
30
|
- [Plan](#plan)
|
|
28
|
-
- [
|
|
29
|
-
- [
|
|
30
|
-
- [
|
|
31
|
-
- [
|
|
32
|
-
- [
|
|
33
|
-
- [
|
|
34
|
-
- [
|
|
35
|
-
- [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
|
|
|
52
|
-
|
|
|
53
|
-
|
|
|
54
|
-
|
|
|
55
|
-
|
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
|
|
|
59
|
-
|
|
|
60
|
-
|
|
|
61
|
-
|
|
|
62
|
-
|
|
|
63
|
-
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
31
|
+
- [Sub-agents](#sub-agents)
|
|
32
|
+
- [External agents](#external-agents)
|
|
33
|
+
- [Rewind](#rewind)
|
|
34
|
+
- [Memory](#memory)
|
|
35
|
+
- [Traces](#traces)
|
|
36
|
+
- [Interfaces and entry points](#interfaces-and-entry-points)
|
|
37
|
+
- [Embedding in Armadra](#embedding-in-armadra)
|
|
38
|
+
- [Documentation](#documentation)
|
|
39
|
+
- [Known limitations](#known-limitations)
|
|
40
|
+
- [Development](#development)
|
|
41
|
+
|
|
42
|
+
## Why ama
|
|
43
|
+
|
|
44
|
+
- **An agent built to be called**: ama is driven by other programs as often as by people. One-shot `-p` runs, `--mode rpc`, the SDK and host adapters are all first-class entry points; exit codes and JSON shapes are contracts.
|
|
45
|
+
- **Clean layering**: following Pi's layering, protocol implementations are separate from provider data. Four protocol lines (Anthropic Messages, OpenAI Chat Completions, OpenAI Responses, Google Generative AI) are written once; a provider is just "baseUrl + key + model table + compat switches".
|
|
46
|
+
- **Minimal configuration**: one environment variable is enough to start; the common settings are five keys and everything else has a default. API keys only (official or relay), Skills and built-in tools only, no MCP.
|
|
47
|
+
- **Cache first**: most of the usage in long tasks is cache reads. ama keeps the request prefix byte-stable, places cache breakpoints the way each provider expects, and shows whether the cache works and why it missed.
|
|
48
|
+
- **Two ways to use it**: standalone it is a terminal coding agent; embedded in Armadra it is the coordinator on the canvas, dispatching work to CLI agents such as Claude Code, Codex and OpenCode, collecting their reports and summarizing.
|
|
49
|
+
|
|
50
|
+
## Features
|
|
51
|
+
|
|
52
|
+
| Area | What you get |
|
|
53
|
+
| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
54
|
+
| Protocols and providers | 4 protocol lines, 18 built-in providers (Anthropic, OpenAI, Google, DeepSeek, Moonshot, Zhipu, Qwen, OpenRouter, Groq, xAI, Mistral, MiniMax, StepFun, Volcengine Ark, Tencent, ChatGPT plan login, Ollama, LM Studio), built-in channels (Messages / Responses preferred, Chat as fallback), custom providers, per-model protocols |
|
|
55
|
+
| Zero config and relays | With a key present, the first available provider is picked (relays pick a default model by price rules); `OPENAI_BASE_URL` / `ANTHROPIC_BASE_URL` are recognized; `ama providers add` connects a relay from just a baseUrl and key: lists models, probes channels and writes the config back |
|
|
56
|
+
| Model metadata | Context window, output limit, image input, reasoning and prices come from a bundled models.dev snapshot (no network at startup or runtime; `ama models refresh` updates explicitly); one provider can mount several channels (Chat / Responses / Messages), `provider/model@channel` |
|
|
57
|
+
| Image input | `-p --image`, `@image-path` in the interface, `Ctrl+V` / `/paste` for clipboard images; per-endpoint size tiers with automatic resizing; models without image input refuse up front and suggest switching |
|
|
58
|
+
| Tools and presets | read / edit / write / bash / grep / glob, plus ls, todo, task / task_ctl (sub-agents) and codemode; four presets `default` / `minimal` / `codemode-only` / `coordinator` |
|
|
59
|
+
| Plan and sub-agents | Plan mode researches read-only, proposes a plan and executes after approval; `task` delegates to sub-agents (built-in general / explore / plan, custom types, foreground / background / follow-up / worktree isolation); an agent bar and a live sub-agent view you can talk to directly |
|
|
60
|
+
| External agents | `task(agent="claude" \| "codex" \| "acp:<program>")` drives external coding agents with each CLI's own login, and approvals go to a human only; `ama --mode acp` exposes ama as an ACP agent |
|
|
61
|
+
| Rewind and sandbox | A checkpoint per turn; `/rewind` / double Esc returns to before any message (code, conversation or both); an OS sandbox on macOS / Linux isolates codemode and (optionally) bash |
|
|
62
|
+
| codemode | The model writes a piece of JS that orchestrates many tool calls in a child process constrained by the Node permission model; only the output goes back to the model |
|
|
63
|
+
| Skills | `SKILL.md` directories; the model reads them from an index, users invoke them with `/skill:<name>`; prompt templates too |
|
|
64
|
+
| Two hook layers | Command hooks (`hooks.json`, 11 events, user policy) and the in-process host adapter HostApi (for embedders) |
|
|
65
|
+
| Permissions | Four modes, allow / deny rules, dangerous-command detection (sees through `sh -c` / `eval` / `xargs` / `find -exec`), project trust, a pre-execution preview in approvals |
|
|
66
|
+
| Caching | A stable prefix, cache fields and compat switches, miss attribution, a three-state "reports / does not report cache" model, warming during long tool runs, compaction summaries that continue the session prefix |
|
|
67
|
+
| Sessions | A JSONL entry tree with forks and `/tree` navigation; two-tier compaction (prune large tool results → summarize) with a circuit breaker; budgets (`--max-turns` / `--max-cost`), repeated-call detection, model fallback |
|
|
68
|
+
| Memory and traces | Opt-in cross-session memory (Markdown files, an index in the system prompt); a trace of every turn, request and tool with TTFT / decode / tool timing, in the TUI (`/trace`), as a single-file HTML page or over RPC |
|
|
69
|
+
| Settings and language | `/config` settings panel and `ama config get / set`; Chinese and English interface (`--lang`, `ui.language`, `AMA_LANG`) |
|
|
70
|
+
| Entry points | A differential-rendering terminal UI, `--no-tui` line mode, `-p` (text / json / stream-json), `--mode rpc`, `--mode acp`, the SDK |
|
|
71
|
+
|
|
72
|
+
## Install
|
|
73
|
+
|
|
74
|
+
Requires **Node ≥ 22**.
|
|
68
75
|
|
|
69
76
|
### npm
|
|
70
77
|
|
|
@@ -73,88 +80,86 @@ npm i -g @armadra/agent
|
|
|
73
80
|
ama --version
|
|
74
81
|
```
|
|
75
82
|
|
|
76
|
-
###
|
|
83
|
+
### Single-file release
|
|
77
84
|
|
|
78
|
-
[Releases](https://github.com/Owlbay/armadra-agent/releases)
|
|
85
|
+
[Releases](https://github.com/Owlbay/armadra-agent/releases) ship `ama.cjs`, `ama-sandbox.cjs`, `package.tgz` and `SHA256SUMS`. `ama.cjs` is a fully inlined single file and `ama-sandbox.cjs` is the codemode sandbox child-process entry; keep both in the **same directory**:
|
|
79
86
|
|
|
80
87
|
```sh
|
|
81
|
-
sha256sum -c --ignore-missing SHA256SUMS # macOS
|
|
88
|
+
sha256sum -c --ignore-missing SHA256SUMS # macOS: shasum -a 256 -c --ignore-missing SHA256SUMS
|
|
82
89
|
node ama.cjs --version
|
|
83
90
|
alias ama="node /path/to/ama.cjs"
|
|
84
91
|
```
|
|
85
92
|
|
|
86
|
-
`package.tgz`
|
|
93
|
+
`package.tgz` has the same content as the npm package and can be installed offline: `npm i -g ./package.tgz`.
|
|
87
94
|
|
|
88
|
-
###
|
|
95
|
+
### Build from source
|
|
89
96
|
|
|
90
97
|
```sh
|
|
91
98
|
git clone https://github.com/Owlbay/armadra-agent.git && cd armadra-agent
|
|
92
99
|
corepack enable && pnpm install
|
|
93
|
-
pnpm build #
|
|
100
|
+
pnpm build # produces dist/ and dist/bundle/ama.cjs, dist/bundle/ama-sandbox.cjs
|
|
94
101
|
node dist/bundle/ama.cjs --version
|
|
95
102
|
```
|
|
96
103
|
|
|
97
|
-
### Node
|
|
104
|
+
### Node version, codemode and sandbox
|
|
98
105
|
|
|
99
|
-
| Node /
|
|
100
|
-
|
|
|
101
|
-
| ≥ 25
|
|
102
|
-
| 22 / 24 +
|
|
103
|
-
| 22 / 24
|
|
106
|
+
| Node / platform | codemode | bash sandbox (`sandbox.bash: "auto"`) |
|
|
107
|
+
| -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
|
|
108
|
+
| ≥ 25 | File system and network both isolated; `codemode` counts as a read-only tool and needs no approval in `default` permission mode; the `default` preset **enables** codemode by default | Depends on the platform (next two rows) |
|
|
109
|
+
| 22 / 24 + OS sandbox (macOS, most Linux) | The child process starts through `sandbox-exec` / bubblewrap and the kernel denies network; same as Node ≥ 25: read-only class, enabled by default in the `default` preset | Available with macOS `sandbox-exec` or Linux bubblewrap (`unshare` does not count) |
|
|
110
|
+
| 22 / 24 without an OS sandbox (e.g. Windows) | File system isolated, **network not isolated**; `codemode` counts as an execute-class tool and needs approval every time (red `net!` in the status bar); the `default` preset does **not** enable codemode, with a one-time notice per config directory | Not available; bash asks for approval as usual |
|
|
104
111
|
|
|
105
|
-
|
|
112
|
+
Everything else works the same from Node 22 on. `ama doctor` shows the OS sandbox capabilities of the machine ([docs/sandbox.md](docs/sandbox.md), Chinese); `sandbox.enabled: "off"` or `AMA_SANDBOX=off` turns it off. To use codemode without network isolation, enable it explicitly: `--codemode on` or `"codemode": { "mode": "on" }` in the config. `codemode.requireStrict: true` disables codemode outright when the network is not isolated.
|
|
106
113
|
|
|
107
|
-
##
|
|
114
|
+
## Quick start
|
|
108
115
|
|
|
109
|
-
|
|
116
|
+
**Zero config**: set the standard environment variable of any provider and go. ama picks the first provider with a key in built-in order, and that provider's default model (`ama config show` explains which and why). Without any key, startup tells you how to configure one instead of silently using the test `fake` provider.
|
|
110
117
|
|
|
111
118
|
```sh
|
|
112
|
-
export ANTHROPIC_API_KEY=sk-... #
|
|
119
|
+
export ANTHROPIC_API_KEY=sk-... # or OPENAI_API_KEY, GEMINI_API_KEY, DEEPSEEK_API_KEY, MOONSHOT_API_KEY …
|
|
113
120
|
cd your-project
|
|
114
|
-
ama #
|
|
121
|
+
ama # terminal UI
|
|
115
122
|
```
|
|
116
123
|
|
|
117
|
-
|
|
124
|
+
**Store a key**: if you prefer not to keep it in the environment, store it in `~/.config/ama/auth.json` (0600). The key is read from stdin, never from command-line arguments, so it stays out of shell history:
|
|
118
125
|
|
|
119
126
|
```sh
|
|
120
|
-
ama auth set deepseek #
|
|
121
|
-
ama auth list #
|
|
127
|
+
ama auth set deepseek # type it in the terminal (not echoed)
|
|
128
|
+
ama auth list # lists providers and key shapes only, never the key
|
|
122
129
|
ama auth remove deepseek
|
|
123
130
|
```
|
|
124
131
|
|
|
125
|
-
|
|
132
|
+
**One-shot runs**: `-p` exits when done, for scripts and pipes.
|
|
126
133
|
|
|
127
134
|
```sh
|
|
128
|
-
ama -p "
|
|
129
|
-
git diff | ama -p "
|
|
130
|
-
ama -p "
|
|
135
|
+
ama -p "explain src/index.ts"
|
|
136
|
+
git diff | ama -p "review this change" # the prompt can come from stdin too
|
|
137
|
+
ama -p "list the TODOs" --model deepseek/deepseek-v4-pro --output-format json
|
|
131
138
|
```
|
|
132
139
|
|
|
133
|
-
|
|
140
|
+
**Common flags**:
|
|
134
141
|
|
|
135
|
-
|
|
|
136
|
-
| ------------------------------------------------------- |
|
|
137
|
-
| `--model provider/id` |
|
|
138
|
-
| `--thinking off\|minimal\|low\|medium\|high\|xhigh` |
|
|
139
|
-
| `--permission-mode plan\|default\|auto-edit\|full-auto` |
|
|
140
|
-
| `-c` / `-r [id]` |
|
|
141
|
-
| `--tools-preset
|
|
142
|
-
| `--allow
|
|
143
|
-
| `--max-turns N` / `--max-cost USD` |
|
|
144
|
-
| `--agent-dir
|
|
145
|
-
| `--
|
|
142
|
+
| Flag | Effect |
|
|
143
|
+
| ------------------------------------------------------- | --------------------------------------------------------------------------- |
|
|
144
|
+
| `--model provider/id` | Pick a model (same syntax in config, command line, `/model` and the SDK) |
|
|
145
|
+
| `--thinking off\|minimal\|low\|medium\|high\|xhigh` | Thinking level (default `medium`) |
|
|
146
|
+
| `--permission-mode plan\|default\|auto-edit\|full-auto` | Permission mode (default `default`) |
|
|
147
|
+
| `-c` / `-r [id]` | Continue the latest session in this directory / pick a session to resume |
|
|
148
|
+
| `--tools-preset <name>` | Tool preset (see below) |
|
|
149
|
+
| `--allow <rule>` / `--deny <rule>` | Add permission rules; repeatable |
|
|
150
|
+
| `--max-turns N` / `--max-cost USD` | Turn / USD limit per run (`-p` exits with 8 when reached) |
|
|
151
|
+
| `--agent-dir <dir>` | Extra sub-agent definition directory; repeatable |
|
|
152
|
+
| `--lang zh\|en` | Interface language (also `AMA_LANG` and `ui.language`) |
|
|
153
|
+
| `--memory` / `--no-memory` | Turn memory on / off for this launch |
|
|
154
|
+
| `--mode rpc` / `--mode acp` | Speak RPC (JSONL) / ACP (JSON-RPC) on stdio, for hosts and editors to drive |
|
|
146
155
|
|
|
147
|
-
|
|
156
|
+
**Built-in providers** (18): Anthropic, OpenAI, Google, DeepSeek, Moonshot (Kimi), Zhipu, Qwen (DashScope), OpenRouter, Groq, xAI, Mistral, MiniMax, StepFun, Volcengine Ark, Tencent TokenHub, ChatGPT (sign in with your plan, see "ChatGPT login"), Ollama, LM Studio. Multi-protocol providers ship built-in channels with Messages / Responses preferred and Chat as fallback: OpenAI, xAI and Volcengine Ark use Responses; Qwen, MiniMax, StepFun and Tencent use Messages; DeepSeek, Zhipu and Kimi use Chat for now (`@messages` is optional). `provider/model@channel` picks a channel. The full table is in [docs/en/providers.md](docs/en/providers.md) "Built-in providers".
|
|
148
157
|
|
|
149
|
-
|
|
158
|
+
Local Ollama / LM Studio need no key: `ama --model ollama/<model>`. `ama --help` lists every flag and subcommand; for tests and troubleshooting use the free `--model fake/echo` (echoes the last user message; the model picker, `models list` and `doctor` hide this test provider unless `AMA_SHOW_FAKE=1`).
|
|
150
159
|
|
|
151
|
-
##
|
|
160
|
+
## Configuration
|
|
152
161
|
|
|
153
|
-
|
|
154
|
-
最小的 `config.json` 与给编辑器用的 `config.schema.json`;`config show`、`doctor`、`models list` 等只读命令不写配置目录。
|
|
155
|
-
也可以 `ama init` 手动建(已有文件不覆盖)。生成的 `config.json` 只有 `$schema`、`version` 与空 `providers`,不写死缺省值——以后
|
|
156
|
-
缺省值调整时老配置同样跟着变。`ama config path` 打印各文件位置,`ama config edit` 用 `$VISUAL` / `$EDITOR` 打开,
|
|
157
|
-
`config.schema.json` 给每个键带了说明与缺省值,编辑器悬停可见。常用的只有五个键:
|
|
162
|
+
One file: `~/.config/ama/config.json`. The first time you enter a conversation (interactive, `-p`, RPC) or run `ama providers add`, ama creates the directory (0700), a minimal `config.json` and a `config.schema.json` for editors; read-only commands such as `config show`, `doctor` and `models list` never write the config directory. You can also run `ama init` by hand (existing files are not overwritten). The generated `config.json` holds only `$schema`, `version` and empty `providers`, with no hard-coded defaults, so old configs follow when defaults change later. `ama config path` prints where each file lives, `ama config edit` opens it with `$VISUAL` / `$EDITOR`, and `config.schema.json` carries a description and default for every key, visible on hover in editors. The common settings are just five keys:
|
|
158
163
|
|
|
159
164
|
```json
|
|
160
165
|
{
|
|
@@ -168,54 +173,64 @@ ama -p "列出 TODO" --model deepseek/deepseek-v4-pro --output-format json
|
|
|
168
173
|
}
|
|
169
174
|
```
|
|
170
175
|
|
|
171
|
-
|
|
176
|
+
Everything else (`compaction`, `retry`, `codemode`, `hooks`, `ui`, `skills`, `cache`, `request`) has defaults. `ama config show` lists the effective value and source (default / user / profile / project / cli) of every key, and also accepts `--tools-preset` / `--codemode` to preview overrides.
|
|
177
|
+
|
|
178
|
+
**Request timeout**: model requests have an idle timeout, 300 s by default. Waiting longer than that for response headers, or between two chunks of the stream, counts as stuck and is retried with `retry` backoff as a retryable error (any byte received resets the timer, so long answers are unaffected). Adjust with `request.idleTimeoutMs` (user level only) or the `AMA_IDLE_TIMEOUT_MS` environment variable; 0 disables it.
|
|
179
|
+
|
|
180
|
+
**Interface language**: choose it with `ui.language` (`auto` / `zh` / `en`, default `auto`), `--lang zh|en` or the `AMA_LANG` environment variable. `auto` decides from `LC_ALL` / `LC_MESSAGES` / `LANG`: `zh*` is Chinese, anything else English (to keep Chinese regardless: `ama config set ui.language zh`). It affects the interface and config descriptions only (`config.schema.json` is written in the current language; run `ama init` again after switching to rewrite it); text sent to the model is always English. To have the model reply in a given language, set `ui.replyLanguage`. See [docs/i18n.md](docs/i18n.md) (Chinese).
|
|
172
181
|
|
|
173
|
-
|
|
174
|
-
走 `retry` 的退避重试(收到任何字节即重新计时,长回答不受影响)。用 `request.idleTimeoutMs`(只认用户级)或环境变量
|
|
175
|
-
`AMA_IDLE_TIMEOUT_MS` 调整,0 关闭。
|
|
182
|
+
**Proxy**: when `HTTPS_PROXY` / `HTTP_PROXY` is set (`NO_PROXY` excludes), ama enables Node's built-in environment proxy at startup (equivalent to `NODE_USE_ENV_PROXY=1`, zero dependencies). It works directly on Node 24+; on Node 22 only 22.21+ with `NODE_USE_ENV_PROXY=1` works, older versions print a one-time notice and connect directly. The "Proxy" section of `ama doctor` shows the current state (credentials in the proxy URL are masked).
|
|
176
183
|
|
|
177
|
-
|
|
178
|
-
`NODE_USE_ENV_PROXY=1`,零依赖)。Node 24+ 直接可用;Node 22 只有 22.21+ 设 `NODE_USE_ENV_PROXY=1` 才行,更早的版本会提示一次
|
|
179
|
-
并直连。`ama doctor` 的「代理」一节显示当前状态(代理地址里的账号密码打码)。
|
|
184
|
+
### File locations and layers
|
|
180
185
|
|
|
181
|
-
|
|
186
|
+
| Location | Contents |
|
|
187
|
+
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
188
|
+
| `~/.config/ama/` | User level: `config.json`, `config.schema.json` (generated by ama), `auth.json` (0600), `hooks.json`, `keybindings.json`, `trust.json`, `AGENTS.md`, `skills/` |
|
|
189
|
+
| `~/.local/share/ama/` | Data: `sessions/` (session JSONL), `plans/` (plan files), `file-history/` (checkpoint backups), `memory/` (memories, when enabled), `models-dev.json` (override from `ama models refresh`), input history |
|
|
190
|
+
| `<project>/.ama/` | Project level: `config.json` (can only tighten), `hooks.json` / `skills/` / `prompts/` (require trust) |
|
|
191
|
+
| `<project>/AGENTS.md` | Project conventions, looked up from cwd upwards and added to the system prompt automatically |
|
|
192
|
+
| `--profile <file>` | Host profile (for embedders, see "Embedding in Armadra") |
|
|
182
193
|
|
|
183
|
-
|
|
184
|
-
| --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
185
|
-
| `~/.config/ama/` | 用户级:`config.json`、`config.schema.json`(ama 生成)、`auth.json`(0600)、`hooks.json`、`keybindings.json`、`trust.json`、`AGENTS.md`、`skills/` |
|
|
186
|
-
| `~/.local/share/ama/` | 数据:`sessions/`(会话 JSONL)、`plans/`(计划文件)、`file-history/`(检查点备份)、`models-dev.json`(`ama models refresh` 的覆盖)、输入历史 |
|
|
187
|
-
| `<项目>/.ama/` | 项目级:`config.json`(只能收紧)、`hooks.json` / `skills/` / `prompts/`(需信任) |
|
|
188
|
-
| `<项目>/AGENTS.md` | 项目约定,从 cwd 向上查找,自动进系统提示 |
|
|
189
|
-
| `--profile <文件>` | 宿主 profile(嵌入方用,见「嵌入 Armadra」) |
|
|
194
|
+
`AMA_CONFIG_DIR` / `AMA_DATA_DIR` change the two directories; `XDG_CONFIG_HOME` / `XDG_DATA_HOME` are honored too, and on Windows they are `%APPDATA%\ama` and `%LOCALAPPDATA%\ama`.
|
|
190
195
|
|
|
191
|
-
`
|
|
196
|
+
Layers merge as **built-in defaults ← user ← profile ← project**, but the project level can only tighten: it can add deny rules, make the permission mode stricter, narrow the tool preset and turn codemode off. Loosening items such as `allow` rules, laxer modes, `cache` and `tools.default` are ignored with a warning. Cloning an unfamiliar repository therefore never widens permissions through its config.
|
|
192
197
|
|
|
193
|
-
|
|
198
|
+
### `/config` and `ama config`
|
|
194
199
|
|
|
195
|
-
|
|
200
|
+
`/config` in the terminal UI opens a settings panel: scalar settings by group with their effective value, source and when a change takes effect; ↑↓ Enter / Space change a value, `/` searches, Tab switches between user and project level (project level may only tighten). Changes are written at once (one key only, `.bak` kept); `/config key=value` sets one key without the panel. From the shell:
|
|
196
201
|
|
|
197
202
|
```sh
|
|
198
|
-
ama config
|
|
203
|
+
ama config get ui.language
|
|
204
|
+
ama config set ui.language en # --project writes .ama/config.json (tighten-only)
|
|
205
|
+
ama config set tools.disabled '["bash"]' --json-value
|
|
206
|
+
ama config unset ui.language
|
|
207
|
+
ama config list ui # value, source, when it applies
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Unknown keys, invalid values and loosening at project level exit with 3 and leave the file alone. See [docs/en/tui.md](docs/en/tui.md) "The `/config` settings panel and `ama config`".
|
|
211
|
+
|
|
212
|
+
### Checking
|
|
213
|
+
|
|
214
|
+
```sh
|
|
215
|
+
ama config show # effective value and source of every key, providers, the model to be used, tools
|
|
199
216
|
ama config show --json
|
|
200
|
-
ama doctor #
|
|
217
|
+
ama doctor # config layers, project trust, key sources, hooks, terminal capabilities
|
|
201
218
|
```
|
|
202
219
|
|
|
203
|
-
##
|
|
220
|
+
## Relays and gateways
|
|
204
221
|
|
|
205
|
-
|
|
222
|
+
**One-step setup**: give just a baseUrl and a key.
|
|
206
223
|
|
|
207
224
|
```sh
|
|
208
225
|
export PACKY_API_KEY=sk-...
|
|
209
226
|
ama providers add packy --base-url https://proxy.example/v1 --key-env PACKY_API_KEY --probe --limit 8 --yes
|
|
210
|
-
ama -p "hi" --model packy/kimi-k2.5 #
|
|
211
|
-
ama -p "hi" --model packy/kimi-k2.5@messages #
|
|
212
|
-
ama -p "
|
|
213
|
-
ama providers list #
|
|
227
|
+
ama -p "hi" --model packy/kimi-k2.5 # preferred channel
|
|
228
|
+
ama -p "hi" --model packy/kimi-k2.5@messages # a specific channel (Anthropic Messages)
|
|
229
|
+
ama -p "what colors are in this picture" --image shot.png --model packy/kimi-k2.5
|
|
230
|
+
ama providers list # provider → channels → model count, key source
|
|
214
231
|
```
|
|
215
232
|
|
|
216
|
-
`add`
|
|
217
|
-
请求,把能用的渠道写进每个模型的 `channels`;上下文、输出上限、图像、推理与价格不写进配置,运行时从内置的 models.dev
|
|
218
|
-
快照补(`ama models list` 标出每个字段的来源)。不给 `--key-env` 时 key 从 stdin 读(不回显)存进 `auth.json`。写入后的配置:
|
|
233
|
+
`add` lists the models from `GET {baseUrl}/models`, derives three candidate channels (chat / responses / messages) from the baseUrl, and with `--probe` sends a minimal request per channel and writes the working channels into each model's `channels`. Context window, output limit, images, reasoning and prices are not written to the config; at runtime they come from the bundled models.dev snapshot (`ama models list` marks where each field comes from). Without `--key-env` the key is read from stdin (not echoed) and stored in `auth.json`. The resulting config:
|
|
219
234
|
|
|
220
235
|
```json
|
|
221
236
|
{
|
|
@@ -237,14 +252,14 @@ ama providers list # 供应商 → 渠道 →
|
|
|
237
252
|
}
|
|
238
253
|
```
|
|
239
254
|
|
|
240
|
-
|
|
255
|
+
**Zero config**: the built-in `openai` / `anthropic` providers recognize `OPENAI_BASE_URL` / `ANTHROPIC_BASE_URL`. When the baseUrl is not an official host, model ids outside the catalog are accepted and cache-related fields use conservative defaults.
|
|
241
256
|
|
|
242
257
|
```sh
|
|
243
258
|
OPENAI_BASE_URL=https://proxy.example/v1 OPENAI_API_KEY=$PACKY_API_KEY \
|
|
244
259
|
ama -p "hi" --model openai/qwen3.8-flash
|
|
245
260
|
```
|
|
246
261
|
|
|
247
|
-
|
|
262
|
+
**One provider, per-model protocols**: under one relay, different models often support different protocols. Instead of a provider per protocol, put `api` on the model:
|
|
248
263
|
|
|
249
264
|
```json
|
|
250
265
|
{
|
|
@@ -263,258 +278,279 @@ OPENAI_BASE_URL=https://proxy.example/v1 OPENAI_API_KEY=$PACKY_API_KEY \
|
|
|
263
278
|
}
|
|
264
279
|
```
|
|
265
280
|
|
|
266
|
-
- `api`
|
|
267
|
-
- `apiKey`
|
|
268
|
-
-
|
|
269
|
-
|
|
281
|
+
- `api` defaults to `openai-completions`; also `openai-responses`, `anthropic-messages`, `google-generative-ai`.
|
|
282
|
+
- `apiKey` supports `$ENV` / `${ENV}` (read an environment variable) and `!command` (run a command for the value); never put a key in the config in plain text.
|
|
283
|
+
- Custom model metadata defaults to the bundled models.dev snapshot (no network at startup; `ama models refresh` refreshes explicitly into the data directory, `refresh-catalog` is the old name). Without a match `contextWindow` is not guessed and automatic compaction is off; add it to the model entry when needed, or point to an entry with `"modelsDev": "provider/model"`.
|
|
284
|
+
|
|
285
|
+
**Don't want to write the model table by hand**: let ama ask the relay.
|
|
286
|
+
|
|
287
|
+
```sh
|
|
288
|
+
ama models discover packy # list GET {baseUrl}/models
|
|
289
|
+
ama models discover packy --probe --write --limit 8 # probe each model's protocols and write back to the config
|
|
290
|
+
ama models check packy/grok-4.7 # one minimal request to confirm connectivity
|
|
291
|
+
ama models cache-probe packy/grok-4.7 # does this endpoint report cache usage
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
`--probe` tries a few protocols per model and records the first that works; `--write` merges into the user-level `config.json` (the original is backed up as `config.json.bak`, existing entries are not overwritten). Both `--probe` and `cache-probe` send real requests: they print an estimate first and stop on 401 / 403 / 429; `cache-probe` needs `--yes` when not interactive. Details in [docs/en/providers.md](docs/en/providers.md).
|
|
295
|
+
|
|
296
|
+
## ChatGPT login
|
|
270
297
|
|
|
271
|
-
|
|
298
|
+
Use your own ChatGPT Plus / Pro plan instead of an API key (built-in provider `chatgpt`; for your own personal use only):
|
|
272
299
|
|
|
273
300
|
```sh
|
|
274
|
-
ama
|
|
275
|
-
ama
|
|
276
|
-
ama models
|
|
277
|
-
ama
|
|
301
|
+
ama auth login chatgpt # official Sign in with ChatGPT in the browser; --paste over SSH
|
|
302
|
+
ama auth status # flavor, plan, masked email, token lifetime
|
|
303
|
+
ama models discover chatgpt # models available to the account
|
|
304
|
+
ama --model chatgpt/<model>
|
|
305
|
+
ama auth logout chatgpt
|
|
278
306
|
```
|
|
279
307
|
|
|
280
|
-
|
|
308
|
+
Credentials are an OAuth entry in `auth.json` (0600), refreshed automatically and serialized across processes; tokens never reach logs, sessions or events. Plan requests cost 0 and show as "subscription" in `/session` and `ama stats`; an exhausted quota reports `quota_exceeded`, an expired login `auth_expired`. `--flavor codex` is an opt-in fallback path. See [docs/en/providers.md](docs/en/providers.md) "ChatGPT login".
|
|
281
309
|
|
|
282
|
-
##
|
|
310
|
+
## Tools and presets
|
|
283
311
|
|
|
284
|
-
|
|
|
285
|
-
| --------------- |
|
|
286
|
-
| `default` | read
|
|
287
|
-
| `minimal` | read
|
|
288
|
-
| `codemode-only` |
|
|
289
|
-
| `coordinator` | read
|
|
312
|
+
| Preset | Tools the model sees directly | Good for |
|
|
313
|
+
| --------------- | --------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
314
|
+
| `default` | read, edit, write, bash, grep, glob; plus `codemode` with network isolation | The default (for todo, set `tools.default: ["+todo"]`) |
|
|
315
|
+
| `minimal` | read, edit, write, bash | Small models, small contexts; `full-auto` |
|
|
316
|
+
| `codemode-only` | only `codemode` | Long workflows heavy on tool calls |
|
|
317
|
+
| `coordinator` | read and the canvas tools registered by the host | The coordinator embedded in Armadra: writes no files, runs no bash; codemode is off by default, and when enabled explicitly scripts can call only these tools |
|
|
290
318
|
|
|
291
|
-
- `--tools-preset
|
|
292
|
-
- `tools.default`
|
|
293
|
-
-
|
|
319
|
+
- Pick a preset with `--tools-preset <name>` or `tools.preset`. `codemode` is the old name of `codemode-only` (0.3.0); config, command line, RPC and SDK still accept it, and `ama config show` shows the canonical name with a hint.
|
|
320
|
+
- `tools.default` tweaks the preset: `["+task", "+todo", "-glob"]`; bare names replace the whole set. `task` and `task_ctl` go together (`+task` adds both).
|
|
321
|
+
- There are also `--tools a,b,c` (enable only these), `--exclude-tools a,b` and `/tools` in interactive mode.
|
|
294
322
|
|
|
295
|
-
**codemode**
|
|
323
|
+
**codemode** lets the model write a piece of JavaScript that orchestrates many tool calls with `tools.<name>(args)` (concurrently with `Promise.all`); only the script's output goes back to the model. The script runs in a vm inside a `node --permission` child process: no `require` / `import` / `process` / `fetch`, and every inner call still goes through hooks, permissions and approval one by one.
|
|
296
324
|
|
|
297
|
-
|
|
325
|
+
**Default exposure**: when `codemode.mode` is unset it follows the preset: `default` → `on` (six tools + codemode, only inside a network-isolating sandbox: Node ≥ 25, or Node 22 / 24 + an OS sandbox; otherwise `off`), `codemode-only` → `only`, `minimal` / `coordinator` → `off`. An explicit `--codemode off|on|only` or `codemode.mode` wins; the project level can only write `off`. In `on` mode the codemode description lists, in one line, the direct tools callable from scripts (same parameters) and the script-only tool names, without re-declaring them, adding only about 400 tokens to the prefix (the [three-preset benchmark](https://github.com/Owlbay/armadra-agent/blob/main/docs/benchmarks/presets-2026-10-02.md) measured the codemode preset before deduplication: about 45% more input on small tasks, no fewer turns). Long workflows with many read-only lookups and many calls can use `codemode-only`.
|
|
298
326
|
|
|
299
|
-
##
|
|
327
|
+
## Caching
|
|
300
328
|
|
|
301
|
-
|
|
329
|
+
Most usage in long tasks is cache reads: once the prefix changes, every later request re-reads it at full price. ama handles this in three layers:
|
|
302
330
|
|
|
303
|
-
-
|
|
304
|
-
-
|
|
305
|
-
-
|
|
331
|
+
- **Protocol layer**: the system prompt sections have a fixed order and no timestamps, tools are sorted by name, and mid-session changes are only appended at the end; cache breakpoints follow each provider's style (Anthropic `cache_control`, OpenAI `prompt_cache_key`, …), and when an endpoint rejects a cache field with 400 it is dropped and the request resent.
|
|
332
|
+
- **Session layer**: every request records a prefix fingerprint to detect and attribute misses (idle timeout, sub-task, model switch, system prompt / tool table change, server eviction), decides whether the endpoint reports cache usage, and warms the cache during long tool runs.
|
|
333
|
+
- **Display layer**: the status bar, `/session`, `/cache`, RPC stats and `ama models cache-probe`.
|
|
306
334
|
|
|
307
|
-
###
|
|
335
|
+
### Reading the status bar
|
|
308
336
|
|
|
309
|
-
|
|
337
|
+
A standalone terminal shows two lines by default (`Ctrl+G` / `/statusline` switches to one; embedding hosts default to one):
|
|
310
338
|
|
|
311
339
|
```
|
|
312
340
|
tps: 100 tok/s • 546 tok / 5.5s (avg 100 · ttft 1.4s) ↑412k ↓8.1k · cache 83% ♨ · rebill $0.11 · [-]
|
|
313
341
|
Accept edits claude-opus-5-5 medium | Ctx 34.0% | proj ⎇ main 5ae9e54 (+12,-3) | $0.84 | 2h24m
|
|
314
342
|
```
|
|
315
343
|
|
|
316
|
-
|
|
344
|
+
The top line is throughput and usage; the bottom line is permission mode, model and thinking level, context, directory and git branch (with working-tree line changes), cost and session duration. The cache-related items:
|
|
317
345
|
|
|
318
|
-
|
|
|
319
|
-
|
|
|
320
|
-
| `cache 83%`
|
|
321
|
-
| `cache —`
|
|
322
|
-
| `cache
|
|
323
|
-
| `♨`
|
|
324
|
-
| `rebill $0.11`
|
|
325
|
-
| `Ctx 34.0%`
|
|
346
|
+
| Item | How to read it |
|
|
347
|
+
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
348
|
+
| `cache 83%` | Hit rate of the **latest** request; the session total is in `/session` |
|
|
349
|
+
| `cache —` | The endpoint has not reported cache usage yet (no long enough comparable request so far) |
|
|
350
|
+
| `cache` "not reported" | The endpoint does not report cache usage (reads and writes were 0 three times in a row); such requests are left out of the hit rate rather than shown as 0% |
|
|
351
|
+
| `♨` | Warming timer running |
|
|
352
|
+
| `rebill $0.11` | Extra spend in this session caused by cache misses (tokens for models without prices); hidden when 0 |
|
|
353
|
+
| `Ctx 34.0%` | Context usage; yellow at ≥ 70%, red at ≥ 90%, with an "about N turns left" note in the message area when crossed |
|
|
326
354
|
|
|
327
|
-
|
|
355
|
+
When one miss re-bills ≥ 20k tokens or ≥ $0.10, the message area gets one line with the reason. `/cache` shows cache stats and `/cache fingerprint` the prefix fingerprint (if the hash changed between two requests, the system prompt or tool table was modified).
|
|
328
356
|
|
|
329
|
-
###
|
|
357
|
+
### Three states, warming and summary continuation
|
|
330
358
|
|
|
331
|
-
-
|
|
332
|
-
-
|
|
333
|
-
-
|
|
359
|
+
- **Three states**: each endpoint (provider + host + model) is classified as `unknown` / `reported` / `silent`. Only `reported` shows a hit rate, detects misses and warms; relays that do not report cache usage are never misreported as 0%. For models known not to report on a relay, set `compat.cacheReporting: "silent"`.
|
|
360
|
+
- **Warming**: while a tool runs for a long time (long tests, `task` sub-tasks, codemode scripts), the previous request is replayed once before the cache TTL expires (`maxTokens: 1`), paying only the read price to keep the cache alive. `cache.warming` is `off` / `streaming` (default, only while running) / `idle` (also while idle, for expensive models); `/cache warm …` switches it for the session; nothing is sent when the expected saving is below `cache.minSavingsUsd` (default $0.05).
|
|
361
|
+
- **Summary continuation**: the compaction summary request follows a prefix byte-identical to the last real request, so the whole history is billed at the read price; on failure it falls back to a standalone summary request.
|
|
334
362
|
|
|
335
|
-
###
|
|
363
|
+
### Measurements
|
|
336
364
|
|
|
337
|
-
[
|
|
365
|
+
[Cache acceptance experiment](https://github.com/Owlbay/armadra-agent/blob/main/docs/benchmarks/cache-2026-10-02.md) (2026-10-02, through one test relay):
|
|
338
366
|
|
|
339
|
-
|
|
|
340
|
-
|
|
|
341
|
-
| Kimi
|
|
342
|
-
| DeepSeek
|
|
343
|
-
|
|
|
367
|
+
| Scenario | Result |
|
|
368
|
+
| -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
369
|
+
| Kimi summary continuation | The summary request read 20.2k / 20.5k from cache, **98.8% hit** (0% before the fix: sending `tool_choice` broke the prefix at the tools section) |
|
|
370
|
+
| DeepSeek reporting cache in 2048 units | False misses 3 → **0** (cache granularity inferred per endpoint) |
|
|
371
|
+
| Baseline hit rate (5-turn coding task) | Kimi 86% cumulative, MiniMax 75%, 0 misses each |
|
|
344
372
|
|
|
345
|
-
|
|
373
|
+
All cache settings and the fields for each protocol are in [docs/en/providers.md](docs/en/providers.md) "Caching".
|
|
346
374
|
|
|
347
|
-
##
|
|
375
|
+
## Safety
|
|
348
376
|
|
|
349
|
-
|
|
377
|
+
**Permission modes** (`--permission-mode`, config `permission.mode`, the `/permission` picker, and in interactive mode `Shift+Tab`, or `Tab` on an empty input, to cycle):
|
|
350
378
|
|
|
351
|
-
|
|
|
352
|
-
| ----------- | ------------------ |
|
|
353
|
-
| `default` | Manual | ✓
|
|
354
|
-
| `auto-edit` | Accept edits | ✓
|
|
355
|
-
| `plan` | Plan | ✓
|
|
356
|
-
| `auto` | Auto | ✓
|
|
357
|
-
| `full-auto` | Bypass permissions | ✓
|
|
358
|
-
| `allowlist` | Allowlist only | ✓
|
|
379
|
+
| Mode | Display name | Read | Write | Execute (bash etc.) |
|
|
380
|
+
| ----------- | ------------------ | ---- | --------------------------------------------------------------------------------------- | ----------------------------------- |
|
|
381
|
+
| `default` | Manual | ✓ | ask | ask |
|
|
382
|
+
| `auto-edit` | Accept edits | ✓ | ✓ | ask |
|
|
383
|
+
| `plan` | Plan | ✓ | deny | deny |
|
|
384
|
+
| `auto` | Auto | ✓ | ✓ ¹ | safe ones allowed, risky ones ask ² |
|
|
385
|
+
| `full-auto` | Bypass permissions | ✓ | ✓ | ✓ |
|
|
386
|
+
| `allowlist` | Allowlist only | ✓ | only calls matching allow rules pass, everything else is denied without asking (for CI) | same |
|
|
359
387
|
|
|
360
|
-
¹
|
|
361
|
-
²
|
|
388
|
+
¹ Secret files (`.env`, private keys, `.ssh/` …), `.git/` and `.ama/`, and writes outside the project directory still ask.
|
|
389
|
+
² Three tiers: the rule tier (dangerous commands, network, deletion, protected paths → ask) → static judgement (a safe list: `ls`, `cat`, `grep`, `git status/diff/log`, `npm test`, `tsc --noEmit`, `cargo test` … → allow) → when neither decides, one question to a model classifier (a separate request that leaves the main session cache untouched; `permission.autoModel` can name a cheap model). Details in [docs/en/permissions.md](docs/en/permissions.md).
|
|
362
390
|
|
|
363
|
-
|
|
391
|
+
**Decision order**: deny rules (including hook deny) → dangerous commands → (auto's rule tier) → mode / static judgement → allow rules turn "ask" into "allow" → (auto's classifier). A later step can never loosen an earlier decision. When unattended (`-p`, RPC without approvals) "ask" always means deny. Project config can only make the mode stricter and cannot set `auto` / `full-auto`.
|
|
364
392
|
|
|
365
|
-
-
|
|
366
|
-
-
|
|
367
|
-
- **bash
|
|
368
|
-
-
|
|
369
|
-
-
|
|
370
|
-
- **
|
|
371
|
-
-
|
|
393
|
+
- **Rules**: `bash(git push*)`, `write(src/**)`, `read(**)`, `canvas_*`; `--allow` / `--deny` are repeatable. Built-in deny: writes to `.git/**`, reads and writes to `.ssh/**`.
|
|
394
|
+
- **Dangerous commands**: `rm -rf /`, `sudo`, `git push --force`, `git reset --hard`, `git clean -f`, `curl … | sh`, `chmod -R 777`, `npm publish`, `shutdown` and so on ask even with an allow rule. Detection sees through `sh -c '…'`, `eval`, `xargs`, `find -exec` and git global options.
|
|
395
|
+
- **bash sandbox** (off by default): see "Sandbox" below.
|
|
396
|
+
- **Project trust**: `.ama/hooks.json`, `.ama/skills/` and `.ama/prompts/` execute or inject content from the project, so the directory must be trusted first (asked once in interactive mode, can be remembered; `--trust` / `--no-trust`; untrusted by default when non-interactive). `AGENTS.md` and `.ama/config.json` need no trust, since the latter can only tighten.
|
|
397
|
+
- **Pre-execution preview**: besides an input summary, the approval dialog lists what the step will touch: for `rm` / `mv` / `git clean` / `git reset --hard` / redirections in bash, whether the target paths exist, their size and how many files a directory holds; for write, the path and line count; for edit, a −/+ summary per change. `y` allows, `n` denies, `a` stops asking for the same kind this session, `v` shows the full input.
|
|
398
|
+
- **Hooks**: `hooks.json` runs shell commands on 11 events such as `PreToolUse`, `PostToolUse`, `UserPromptSubmit`, `Stop`, `PostCompact` and `PostRewind`; hooks can veto tool calls, rewrite input, add context or make the run go another round. See [docs/hooks.md](docs/hooks.md) (Chinese).
|
|
399
|
+
- **Approval origin**: approvals raised by sub-agents and external agents show their origin in the dialog title (`[task:explore]`, `[claude · session abc12345]`, "first run of an external agent"); see [docs/en/permissions.md](docs/en/permissions.md) "Origin labels in the approval dialog".
|
|
372
400
|
|
|
373
|
-
##
|
|
401
|
+
## Sandbox
|
|
374
402
|
|
|
375
|
-
macOS
|
|
403
|
+
macOS uses `sandbox-exec` and Linux uses bubblewrap (falling back to `unshare -r -n`, which isolates the network only). At startup a minimal probe runs with the target profile to confirm it really works (degrading for nested sandboxes or missing user namespaces), and `ama doctor` shows the result. Windows has no OS sandbox.
|
|
376
404
|
|
|
377
|
-
- **codemode
|
|
378
|
-
- **bash
|
|
379
|
-
- `sandbox.*`
|
|
405
|
+
- **codemode**: the child process starts inside the sandbox and the kernel denies network and all writes; with a sandbox, Node 22 / 24 behaves like Node ≥ 25: read-only class and enabled by default in the `default` preset (see "Node version, codemode and sandbox" above).
|
|
406
|
+
- **bash** (off by default): with `"sandbox": { "bash": "auto" }`, bash (including background bash) runs in the sandbox. It can only write the workspace, the system temp directory and directories added via `sandbox.writable`; the workspace's `.ama/`, `.git/hooks` and `.git/config` are read-only; credentials such as `~/.ssh` cannot be read; and there is no network by default (`sandbox.network: "allow"` opens it). In `default` / `auto-edit`, sandboxed commands need no approval (dangerous commands, deny rules and hook asks still apply); when the sandbox blocks something the model may ask to rerun with `sandbox: false` outside it, which is approved as usual and denied when unattended. The status bar shows an extra sandbox marker.
|
|
407
|
+
- `sandbox.*` is user level / profile only; the project level can only write the tightening `network: "deny"`. `sandbox.enabled: "off"` or `AMA_SANDBOX=off` turns it all off.
|
|
380
408
|
|
|
381
|
-
|
|
409
|
+
Details, per-platform policies and known bypasses are in [docs/sandbox.md](docs/sandbox.md) (Chinese).
|
|
382
410
|
|
|
383
411
|
## Plan
|
|
384
412
|
|
|
385
|
-
Plan
|
|
413
|
+
In Plan mode (`Shift+Tab`, `/permission plan`, `/plan <goal>`, `--permission-mode plan`) the model researches read-only: only read tools, read-only commands (`ls`, `rg`, `git log / diff` …) and read-only sub-agents are allowed. It ends with a `<proposed_plan>` block. ama extracts the steps, saves the plan under `<data dir>/plans/` and opens an approval dialog:
|
|
414
|
+
|
|
415
|
+
- **Approve and execute** / **Approve, execute in a fresh context** (a new session that opens with the full plan), then pick the execution mode (back to the previous mode / Accept edits / Auto); steps become todos and are worked through one by one (with `todo update` when the todo tool exists, otherwise the model writes a `[DONE:S1]` line per finished step);
|
|
416
|
+
- **Keep revising** (feedback goes to the model to rewrite the plan) / **Discard and leave Plan**; `e` edits the plan in an external editor, Esc discards but stays in Plan.
|
|
417
|
+
|
|
418
|
+
Line mode uses `/plan approve [mode|fresh]` / `/plan reject`; RPC clients approve after declaring the `plans` capability; the SDK uses `createAgentSession({ plan: { onProposed } })`. **ama never approves on a person's behalf**: `-p` stops at "plan awaiting approval" and exits with 9 by default; only the user-level config `"plan": { "unattended": "approve" }` approves and executes automatically when unattended. `plan.model` lets planning and execution use different models. See [docs/plan.md](docs/plan.md) (Chinese).
|
|
419
|
+
|
|
420
|
+
## Sub-agents
|
|
386
421
|
|
|
387
|
-
-
|
|
388
|
-
- **继续修改**(意见发给模型重写计划)/ **放弃并退出 Plan**;`e` 在外部编辑器里改计划,Esc 放弃但留在 Plan。
|
|
422
|
+
The `task` tool hands a sub-task to a sub-agent with a fresh context (same process, its own session file, depth 1); the result returns to the parent session as a tool result. Under the `default` preset `task` is only available inside codemode scripts; expose it directly with `--tools …,task` or `tools.default: ["+task"]`.
|
|
389
423
|
|
|
390
|
-
|
|
424
|
+
- Built-in types `general` (default), `explore` and `plan` (the last two are forced read-only and never prompt for approval); define your own types (tool allowlist, model, permissions, turns, worktree isolation) in `~/.config/ama/agents/*.md`, `.ama/agents/*.md` (requires trust) or `--agent-dir`.
|
|
425
|
+
- Several tasks in one reply run in parallel (`subagents.maxConcurrent`, default 4); `background: true` returns a `taskId` immediately and the parent session receives a `<task-notification>` when done; `task{taskId}` continues the conversation; `task_ctl` lists / waits / stops / reads output; `isolation: "worktree"` runs in a separate git worktree.
|
|
426
|
+
- The sub-session's tool table is byte-identical to the parent's, so its first request reuses the parent's cache prefix. In the interface the task tool line folds and shows progress; `/agents` lists the available types.
|
|
427
|
+
- **Agent bar and sub-agent view**: running tasks are listed above the status line; with an empty input press `Ctrl+B` (or `↓`, e.g. in tmux) to focus the bar, ↑↓ to pick and Enter to open a full-screen live view of that sub-agent, where your input goes straight to it (Esc goes back without interrupting). `/tasks` focuses the bar, `/tasks <id>` opens a view, `/tasks stop <id>` stops a task. See [docs/en/tui.md](docs/en/tui.md) "Agent bar".
|
|
391
428
|
|
|
392
|
-
|
|
429
|
+
See [docs/agents.md](docs/agents.md) (Chinese) "Sub-agents".
|
|
393
430
|
|
|
394
|
-
|
|
431
|
+
## External agents
|
|
395
432
|
|
|
396
|
-
|
|
397
|
-
- 同一回复里的多个 task 并行(`subagents.maxConcurrent`,缺省 4);`background: true` 立即返回 `taskId`,完成后父会话收到 `<task-notification>`;`task{taskId}` 续聊;`task_ctl` 列出 / 等待 / 停止 / 读输出;`isolation: "worktree"` 在独立 git worktree 里跑。
|
|
398
|
-
- 子会话工具表与父逐字节相同,首个请求复用父的缓存前缀。界面里 task 工具行折叠显示进度,`/tasks` 看输出或停止,`/agents` 列出可用类型。
|
|
433
|
+
`task(agent="claude")`, `"codex"` or `"acp:<program>"` (any ACP agent: Gemini CLI, OpenCode, Kimi, ama itself …) drives an external coding agent with your **existing login** in that CLI. Foreground / background / follow-up / `task_ctl` work as with ama's own sub-agents, and results are treated as reference material.
|
|
399
434
|
|
|
400
|
-
|
|
435
|
+
- **Approvals go to a human only**: operations the external agent wants confirmed go to the interface / host; neither the auto classifier nor the model takes part, and unattended runs always deny. The first run of a given external agent in each session is confirmed once (the allow rule `task(claude)` or `full-auto` lets it through).
|
|
436
|
+
- An external agent's mode is never wider than ama's current mode (read-only under plan / allowlist). By default the child process is stripped of provider keys, `*_BASE_URL` and `AMA_*`, so subscriptions are never switched to API billing; it only starts in trusted directories; there is a concurrency pool, a USD budget and a watchdog.
|
|
437
|
+
- When embedded in a host, ama does not start external CLIs itself; it only uses runners injected by the host through `HostApi.runners`.
|
|
438
|
+
- **ama as an ACP agent**: `ama --mode acp` can be driven by Zed, JetBrains and Armadra's ACP nodes; `@armadra/agent/acp` exports a client, a driver and a fake agent.
|
|
401
439
|
|
|
402
|
-
|
|
440
|
+
See [docs/agents.md](docs/agents.md) "External agents" and [docs/acp.md](docs/acp.md) (both Chinese).
|
|
403
441
|
|
|
404
|
-
|
|
442
|
+
## Rewind
|
|
405
443
|
|
|
406
|
-
|
|
407
|
-
- 外部 Agent 的模式不比 ama 当前模式宽(plan / allowlist 下只读);子进程缺省剥离供应商 key、`*_BASE_URL`、`AMA_*`,不把订阅切成 API 计费;只在已信任目录里启动;有并发池、美元预算与看门狗。
|
|
408
|
-
- 嵌入宿主时 ama 不自己启动外部 CLI,只用宿主经 `HostApi.runners` 注入的 runner。
|
|
409
|
-
- **ama 作为 ACP Agent**:`ama --mode acp` 供 Zed、JetBrains、Armadra 的 ACP 节点驱动;`@armadra/agent/acp` 导出客户端、驱动与假 Agent。
|
|
444
|
+
Every user message that starts a new turn is a rewind point: edit / write back up a file before writing it the first time, and each new turn re-snapshots tracked files (with `checkpoints.mode: "shadow-git"` the whole working directory goes into a shadow repository, so bash changes can be rolled back too).
|
|
410
445
|
|
|
411
|
-
|
|
446
|
+
- `/rewind`, or double Esc while idle, opens the list; the confirmation panel offers: restore code and conversation / restore conversation / restore code / summarize from here / summarize up to here, each with a preview. Files changed by hand outside the turn are listed as conflicts and skipped by default, with an option to overwrite; if git HEAD moved, ama only suggests commands and never touches git.
|
|
447
|
+
- When Esc interrupts a run before this turn produced any output, the message is withdrawn and put back into the input box (`ui.restoreOnCancel`).
|
|
448
|
+
- Line mode `/rewind <n> [both|conversation|code] [overwrite]`; RPC `get_rewind_points` / `rewind`; SDK `session.rewind()`; hook `PostRewind`.
|
|
412
449
|
|
|
413
|
-
|
|
450
|
+
See [docs/en/tui.md](docs/en/tui.md) "Rewind", [docs/rewind-plan.md](docs/rewind-plan.md) (Chinese) and [docs/en/sessions.md](docs/en/sessions.md).
|
|
414
451
|
|
|
415
|
-
|
|
452
|
+
## Memory
|
|
416
453
|
|
|
417
|
-
-
|
|
418
|
-
|
|
419
|
-
|
|
454
|
+
Cross-session personal notes, **off by default**. Turn it on with `ama memory enable` (or `--memory` / `AMA_MEMORY=1` for one launch); then saying "remember …" lets the model write a Markdown entry with the `memory` tool. Entries live under `<data dir>/memory/` in a user scope and a per-project scope (trusted projects only); an index goes into the system prompt at session start and bodies are read on demand. Writes ask in `default` mode, content that looks like a credential is refused, and sub-agents are read-only. Manage entries with `/memory` or `ama memory list | show | edit | rm | path | enable | disable`. When disabled, requests are byte-for-byte unchanged. See [docs/memory.md](docs/memory.md) (Chinese).
|
|
455
|
+
|
|
456
|
+
## Traces
|
|
457
|
+
|
|
458
|
+
Every model request records timing (time to first token, decode, tools, retries, compaction) in the session file, without content. `/trace` opens a tree of turns → requests → tools → sub-agents with timing bars, tokens and cache hits; `/trace <task id>` shows one task. To share or inspect outside the terminal:
|
|
459
|
+
|
|
460
|
+
```sh
|
|
461
|
+
ama sessions trace 3f9a1c2e --html trace.html # self-contained single file, redacted, no external loads
|
|
462
|
+
ama sessions trace 3f9a1c2e --json # same shape as RPC get_trace
|
|
463
|
+
```
|
|
420
464
|
|
|
421
|
-
|
|
465
|
+
RPC clients use `get_trace` (tail-first paging, increments after `entry_appended`) and the SDK `session.trace()`. See [docs/en/tui.md](docs/en/tui.md) "Traces", [docs/en/sessions.md](docs/en/sessions.md) and [docs/en/rpc.md](docs/en/rpc.md).
|
|
422
466
|
|
|
423
|
-
##
|
|
467
|
+
## Interfaces and entry points
|
|
424
468
|
|
|
425
|
-
###
|
|
469
|
+
### Terminal UI
|
|
426
470
|
|
|
427
|
-
|
|
471
|
+
Running `ama` (with stdin / stdout both TTYs) enters interactive mode. The interface uses the main screen only; the conversation history stays in the terminal scrollback, so tmux `capture-pane` can read the whole conversation.
|
|
428
472
|
|
|
429
|
-
|
|
|
430
|
-
|
|
|
431
|
-
| Enter
|
|
432
|
-
| Alt+Enter
|
|
433
|
-
| Shift+Enter / Ctrl+J
|
|
434
|
-
| Esc
|
|
435
|
-
| Esc Esc
|
|
436
|
-
| Shift+Tab / Tab
|
|
437
|
-
| Ctrl+O
|
|
438
|
-
| Ctrl+L / Ctrl+T
|
|
439
|
-
| Ctrl+G
|
|
440
|
-
| Ctrl+V
|
|
441
|
-
| Ctrl+
|
|
442
|
-
|
|
|
473
|
+
| Key | Effect |
|
|
474
|
+
| ------------------------ | --------------------------------------------------------------------------------------- |
|
|
475
|
+
| Enter | Send; while running, steer |
|
|
476
|
+
| Alt+Enter | While running, queue after this turn (followUp) |
|
|
477
|
+
| Shift+Enter / Ctrl+J | New line |
|
|
478
|
+
| Esc | Interrupt the current run |
|
|
479
|
+
| Esc Esc (idle) | Empty input: open the rewind list (same as `/rewind`); with text: clear it into history |
|
|
480
|
+
| Shift+Tab / Tab | Cycle permission modes (Tab only on an empty input; entering Bypass asks to confirm) |
|
|
481
|
+
| Ctrl+O | Expand / collapse tool output |
|
|
482
|
+
| Ctrl+L / Ctrl+T | Pick model / thinking level |
|
|
483
|
+
| Ctrl+G | Bottom info line, two lines ↔ one (same as `/statusline`) |
|
|
484
|
+
| Ctrl+V | Paste an image from the clipboard and insert `@<path>` (same as `/paste`) |
|
|
485
|
+
| Ctrl+B / ↓ (empty input) | Focus the agent bar when there are sub-agent tasks (↓ in tmux) |
|
|
486
|
+
| Ctrl+C | Clear the input; on an empty input, press again within 1.5 s to quit |
|
|
487
|
+
| Tab | Complete: `/` commands, templates and Skills, `@` file paths |
|
|
443
488
|
|
|
444
|
-
|
|
489
|
+
Common commands: `/model`, `/thinking`, `/permission`, `/tools`, `/compact`, `/tree` (branch again from before a message), `/fork`, `/resume`, `/new`, `/session`, `/cache`, `/hooks`, `/skill:<name>`, `/help`; wave 5 added `/plan` (plan panel and approval; `/plan <goal>` enters Plan), `/tasks` (sub-agent tasks), `/agents` (available types and external agents), `/paste` (clipboard image), `/rewind` and `/statusline [full|compact]`; wave 6 added `/config` (settings panel), `/trace` (trace), `/memory` (memories), and `/tasks` now focuses the agent bar (`/tasks <id>` opens the sub-agent view). An `@image-path` in the input (or a pasted / dropped image path) is sent to the model as an image attachment; `/model` groups models by "provider · channel" and marks context size and `img`. Key bindings can be overridden in `~/.config/ama/keybindings.json`. See [docs/en/tui.md](docs/en/tui.md).
|
|
445
490
|
|
|
446
|
-
`--no-tui
|
|
491
|
+
`--no-tui` (or when stdin / stdout is not a TTY, or `TERM=dumb`) enters line mode: readline with bracketed paste and the same commands.
|
|
447
492
|
|
|
448
|
-
### `-p`
|
|
493
|
+
### One-shot `-p`
|
|
449
494
|
|
|
450
|
-
| `--output-format` | stdout
|
|
451
|
-
| ----------------- |
|
|
452
|
-
| `text
|
|
453
|
-
| `json` |
|
|
454
|
-
| `stream-json` |
|
|
495
|
+
| `--output-format` | stdout |
|
|
496
|
+
| ----------------- | -------------------------------------------------------------------------------------- |
|
|
497
|
+
| `text` (default) | The text of the final answer |
|
|
498
|
+
| `json` | One `result` object: session id, model, `stopReason`, `text`, usage, cost, cache stats |
|
|
499
|
+
| `stream-json` | One event per line, same shapes as RPC events |
|
|
455
500
|
|
|
456
|
-
**stdin
|
|
457
|
-
首字节 2 秒(`AMA_STDIN_WAIT_MS` 可调,0 = 不等):一个字节都没收到就忽略 stdin、继续运行,并在 stderr 提示一行——父进程
|
|
458
|
-
留着不关的管道不会让 `-p` 挂起;收到首字节后读到 EOF。上游命令要先跑很久才输出时,在末尾加 `-` 一直等到 EOF
|
|
459
|
-
(`npm test 2>&1 | ama -p "找出失败原因" -`);`--no-stdin` 完全不读。`< 文件` 重定向总会读取。
|
|
501
|
+
**stdin**: piped content is appended after the prompt (`git diff | ama -p "review"`); without a prompt argument the piped content is the prompt. With a prompt argument ama waits only 2 seconds for the pipe's first byte (`AMA_STDIN_WAIT_MS` adjusts it, 0 = don't wait): if not a single byte arrives, stdin is ignored, the run continues and stderr gets one line, so a pipe a parent process leaves open never hangs `-p`; once the first byte arrives it reads to EOF. When the upstream command runs a long time before printing, add a trailing `-` to wait for EOF (`npm test 2>&1 | ama -p "find why it fails" -`); `--no-stdin` never reads. A `< file` redirect is always read.
|
|
460
502
|
|
|
461
|
-
`--image
|
|
462
|
-
模型不收图片时直接退出 2,不发请求。
|
|
503
|
+
`--image <file>` is repeatable and sends images with the prompt (PNG / JPEG / GIF / WebP; the per-image limit is tiered by endpoint and measured after base64: official Anthropic 10 MB, Gemini / OpenAI 20 MB, relays 5 MB; oversized images are resized with sips / ImageMagick when possible); `@image-path` in the prompt is attached too. When the current model does not accept images, ama exits with 2 without sending a request.
|
|
463
504
|
|
|
464
|
-
`--max-turns N`
|
|
465
|
-
`limits.maxTurns / maxCostUsd` 同义),到上限时提前结束(事件 `limit_reached`),**退出码 8**(0.4.x 的 `--max-turns` 是 1),
|
|
466
|
-
`json` 结果带 `limitReached{kind, value, limit}`(轮数到限另有 `maxTurnsReached: true`)。Plan 模式下计划待审批时退出 9(见上文「Plan」)。
|
|
505
|
+
`--max-turns N` caps a run at N turns (one model request plus its tool executions is one turn), and `--max-cost USD` caps a run's USD spend (config `limits.maxTurns / maxCostUsd` mean the same). When a limit is reached the run ends early (event `limit_reached`) with **exit code 8** (`--max-turns` exited with 1 in 0.4.x), and the `json` result carries `limitReached{kind, value, limit}` (plus `maxTurnsReached: true` for the turn limit). In Plan mode a plan awaiting approval exits with 9 (see "Plan" above).
|
|
467
506
|
|
|
468
|
-
`--system-prompt
|
|
469
|
-
缓存前缀不变;`--system-prompt-mode replace` 改为替换开头的角色说明,工具表、规则与 AGENTS.md 仍然保留。
|
|
507
|
+
`--system-prompt <text|@file>` adds to the system prompt (in every mode): by default it is appended as the last rule, keeping the preamble and tool table, the longest cache prefix, unchanged; `--system-prompt-mode replace` replaces the opening role description instead, while the tool table, rules and AGENTS.md stay.
|
|
470
508
|
|
|
471
|
-
`--no-session`
|
|
472
|
-
新会话同样不落盘。
|
|
509
|
+
`--no-session` keeps the session in memory only and writes no session file (for CI and one-off calls; `--resume` is impossible afterwards); new sessions started with `/new` in interactive mode are not saved either.
|
|
473
510
|
|
|
474
|
-
|
|
475
|
-
工具与原因,`json` 结果带 `deniedTools`,`stream-json` 的 `tool_execution_end` 带 `denied: true`,退出码 7。需要放行时用
|
|
476
|
-
`--permission-mode auto-edit`(放行写入)/ `auto`(ama 判断每一步),或 `--allow "bash(npm test*)"` 按规则放行。
|
|
511
|
+
**Unattended**: `-p` has nobody to approve, so calls that would ask under the default permission mode (writing files, running commands) are always denied. When something is denied, stderr summarizes the denied tools and reasons in one line, the `json` result carries `deniedTools`, `stream-json`'s `tool_execution_end` carries `denied: true`, and the exit code is 7. To allow them use `--permission-mode auto-edit` (allows writes) / `auto` (ama judges each step), or allow by rule with `--allow "bash(npm test*)"`.
|
|
477
512
|
|
|
478
|
-
|
|
|
479
|
-
|
|
|
480
|
-
| 0
|
|
481
|
-
| 1
|
|
482
|
-
| 2
|
|
483
|
-
| 3
|
|
484
|
-
| 4
|
|
485
|
-
| 5
|
|
486
|
-
| 6
|
|
487
|
-
| 7
|
|
488
|
-
| 8
|
|
489
|
-
| 9
|
|
490
|
-
| 78
|
|
491
|
-
| 130
|
|
513
|
+
| Exit code | Meaning |
|
|
514
|
+
| --------- | --------------------------------------------------------------------------------- |
|
|
515
|
+
| 0 | Success |
|
|
516
|
+
| 1 | Runtime error (the model ultimately failed, etc.) |
|
|
517
|
+
| 2 | Usage error; the current model does not accept images |
|
|
518
|
+
| 3 | Config / profile / path error; `ama config set` rejected a key or value |
|
|
519
|
+
| 4 | No usable model or key |
|
|
520
|
+
| 5 | Session missing / corrupted |
|
|
521
|
+
| 6 | Host / hook startup failure |
|
|
522
|
+
| 7 | `-p` had tool calls denied (no approver, deny rules, plan, …) |
|
|
523
|
+
| 8 | `-p` reached a budget limit (`--max-turns` / `--max-cost` / `limits`) |
|
|
524
|
+
| 9 | `-p` produced a plan that was saved and awaits approval (`plan.unattended: stop`) |
|
|
525
|
+
| 78 | Host API version mismatch |
|
|
526
|
+
| 130 | SIGINT; 143 = SIGTERM |
|
|
492
527
|
|
|
493
|
-
###
|
|
528
|
+
### Session stats, search and reuse
|
|
494
529
|
|
|
495
|
-
|
|
530
|
+
Sessions are JSONL files under `<data dir>/sessions`. These commands only read (by default they look at sessions of the current directory; `--all` looks at all):
|
|
496
531
|
|
|
497
532
|
```sh
|
|
498
|
-
ama stats --since 7d --by model #
|
|
499
|
-
ama sessions search "parser" --role user #
|
|
500
|
-
ama sessions show 3f9a1c2e #
|
|
501
|
-
ama -p --from 3f9a1c2e#2 --model packy/kimi-k2.5 #
|
|
502
|
-
ama sessions export 3f9a1c2e --format md --output s.md # md / json / jsonl
|
|
533
|
+
ama stats --since 7d --by model # requests, tokens, cache hit rate, cost, top N tool calls (--json available)
|
|
534
|
+
ama sessions search "parser" --role user # full-text search across sessions; /regex/ works too
|
|
535
|
+
ama sessions show 3f9a1c2e # lists user message numbers at the end
|
|
536
|
+
ama -p --from 3f9a1c2e#2 --model packy/kimi-k2.5 # ask that message (images included) again with another model
|
|
537
|
+
ama sessions export 3f9a1c2e --format md --output s.md # md / json / jsonl, redacted before export
|
|
538
|
+
ama sessions trace 3f9a1c2e --html t.html # trace as a single HTML file (see "Traces")
|
|
503
539
|
```
|
|
504
540
|
|
|
505
|
-
|
|
541
|
+
How the numbers are computed (hit rate only over endpoints that report cache usage, cost only over priced requests, …) and the export formats are in [docs/en/sessions.md](docs/en/sessions.md).
|
|
506
542
|
|
|
507
543
|
### RPC
|
|
508
544
|
|
|
509
|
-
`ama --mode rpc`
|
|
545
|
+
`ama --mode rpc` speaks JSONL on stdin / stdout: it first sends `hello` and `session_start`, then accepts commands such as `prompt`, `steer`, `abort`, `set_model`, `get_session_stats` and `fork`, and pushes stream events and approval requests.
|
|
510
546
|
|
|
511
547
|
```sh
|
|
512
548
|
printf '{"id":"1","type":"prompt","message":"hi"}\n' | ama --mode rpc --model fake/echo
|
|
513
549
|
```
|
|
514
550
|
|
|
515
|
-
`hello.capabilities`
|
|
551
|
+
`hello.capabilities` lists server capabilities (`approvals`, `images`, `hooks`, `plans`); clients declare with `set_client_capabilities` which approvals and plan approvals they take over. Wave 5 added plan (`plan_response` / `get_plan` / `get_todos`), task (`get_tasks` / `get_agents`) and rewind (`get_rewind_points` / `rewind` / `summarize_*`) commands, plus events such as `subagent_*`, `plan_*`, `limit_reached` and `telemetry_tick`; wave 6 added `get_trace` and the `quota_update` event. Decide by `code`, never by the human-readable `error` text, which follows the interface language. The protocol is in [docs/en/rpc.md](docs/en/rpc.md); import the types from `@armadra/agent/rpc`.
|
|
516
552
|
|
|
517
|
-
`ama --mode acp`
|
|
553
|
+
`ama --mode acp` speaks ACP (JSON-RPC over NDJSON); see [docs/acp.md](docs/acp.md) (Chinese).
|
|
518
554
|
|
|
519
555
|
### SDK
|
|
520
556
|
|
|
@@ -527,7 +563,7 @@ import { createAgentSession } from "@armadra/agent";
|
|
|
527
563
|
|
|
528
564
|
const session = await createAgentSession({
|
|
529
565
|
cwd: process.cwd(),
|
|
530
|
-
model: "anthropic/<model-id>", //
|
|
566
|
+
model: "anthropic/<model-id>", // "fake/echo" for a dry run
|
|
531
567
|
auth: { kind: "env" },
|
|
532
568
|
permission: {
|
|
533
569
|
mode: "default",
|
|
@@ -537,103 +573,111 @@ const session = await createAgentSession({
|
|
|
537
573
|
session.subscribe((event) => {
|
|
538
574
|
if (event.type === "tool_execution_start") console.error(`→ ${event.toolName}`);
|
|
539
575
|
});
|
|
540
|
-
await session.prompt("
|
|
576
|
+
await session.prompt("list the entry files under src");
|
|
541
577
|
console.log(session.getLastAssistantText());
|
|
542
578
|
console.log(session.getStats().cache?.hitRate);
|
|
543
579
|
await session.dispose();
|
|
544
580
|
```
|
|
545
581
|
|
|
546
|
-
- `createAgentSession`
|
|
547
|
-
-
|
|
548
|
-
-
|
|
549
|
-
- `createRuntime({ argv })`
|
|
550
|
-
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
##
|
|
555
|
-
|
|
556
|
-
Armadra
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
- ama
|
|
561
|
-
-
|
|
562
|
-
|
|
563
|
-
##
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
|
568
|
-
|
|
|
569
|
-
| [docs/
|
|
570
|
-
| [docs/
|
|
571
|
-
| [docs/
|
|
572
|
-
| [docs/
|
|
573
|
-
| [docs/
|
|
574
|
-
| [docs/
|
|
575
|
-
| [docs/
|
|
576
|
-
| [docs/
|
|
577
|
-
| [docs/
|
|
578
|
-
| [docs/
|
|
579
|
-
| [docs/
|
|
580
|
-
| [docs/
|
|
581
|
-
| [docs/
|
|
582
|
-
| [docs/
|
|
583
|
-
| [docs/
|
|
584
|
-
| [docs/
|
|
585
|
-
| [docs/
|
|
586
|
-
| [docs/
|
|
587
|
-
| [docs/
|
|
588
|
-
|
|
589
|
-
|
|
582
|
+
- `createAgentSession` does not read file-system config: an in-memory session, explicit tools and callback approvals, suited for embedding in other programs.
|
|
583
|
+
- Rewind: `session.rewindPoints()` lists the user messages on the active path that start new turns; `session.rewind({ entryId, mode: "both" | "conversation" | "code", dryRun?, onConflict? })` returns to before that message (returning the original message as a draft and the code restore result; in-memory sessions support conversation only); `session.summarizeFrom(entryId, instructions?)` / `session.summarizeUpTo(entryId, instructions?)` correspond to "summarize from here" / "summarize up to here". Design in [docs/rewind-plan.md](docs/rewind-plan.md) (Chinese).
|
|
584
|
+
- Plans: `createAgentSession({ plan: { onProposed } })` calls back for approval once a plan is proposed (return `{ decision: "approve" | "approve_fresh" | "revise" | "reject", mode?, feedback? }`), or use `session.plan.respond()` later; `session.plan.current()` / `todos()` read the current plan and todos. Types such as `SessionPlanOptions` and `PlanDecision` are exported from the package entry; see [docs/plan.md](docs/plan.md) (Chinese) "Interfaces".
|
|
585
|
+
- `createRuntime({ argv })` runs the same startup sequence as the `ama` command line (config, AGENTS.md, Skills, hooks.json, auth.json).
|
|
586
|
+
- Subpaths: `@armadra/agent/host` (host adapter types), `@armadra/agent/rpc` (RPC types), `@armadra/agent/tui` (terminal component library), `@armadra/agent/acp` (ACP types, client, driver and fake agent), `@armadra/agent/bundle` (the single-file `ama.cjs`; `require.resolve` gives its path to start with `node` or `ELECTRON_RUN_AS_NODE=1`).
|
|
587
|
+
|
|
588
|
+
A complete example is [examples/sdk-demo.ts](https://github.com/Owlbay/armadra-agent/blob/main/examples/sdk-demo.ts) (custom tools, streaming output, usage stats).
|
|
589
|
+
|
|
590
|
+
## Embedding in Armadra
|
|
591
|
+
|
|
592
|
+
Armadra starts ama with `ama --profile <path>`. The profile is a JSON file naming the host adapter (`host`), instructions (`instructions`), Skill and prompt template directories, the hook file, the key file (`authFile`; `authEnv: false` skips environment variables), the session directory and `trustProject`.
|
|
593
|
+
|
|
594
|
+
The host adapter is a local JS module exporting `hostApi` and `create(api)`; through `HostApi` it registers canvas tools (`canvas_*` / `context_*`), appends to the system prompt, takes over approvals, injects messages and shows status. When the same profile runs outside the canvas the adapter stays inactive and ama falls back to plain standalone mode. With the `coordinator` preset the coordinator only reads files and calls canvas tools, never changing code itself.
|
|
595
|
+
|
|
596
|
+
- ama's side of the interface: [docs/en/host-api.md](docs/en/host-api.md)
|
|
597
|
+
- Coordinator design and contract: [docs/design/coordinator-agent.md](https://github.com/yovinchen/Armadra/blob/main/docs/design/coordinator-agent.md) in the Armadra repository
|
|
598
|
+
|
|
599
|
+
## Documentation
|
|
600
|
+
|
|
601
|
+
English versions exist for six user docs; the rest are in Chinese.
|
|
602
|
+
|
|
603
|
+
| Document | Contents |
|
|
604
|
+
| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
605
|
+
| [docs/en/providers.md](docs/en/providers.md) ([中文](docs/providers.md)) | Built-in providers and channels, API keys, ChatGPT login, custom providers and relays, model metadata snapshot, image input, compat, caching |
|
|
606
|
+
| [docs/en/tui.md](docs/en/tui.md) ([中文](docs/tui.md)) | Terminal UI: layout, status bar, keys, commands, rewind, approvals, Plan approval, sub-agents and the agent bar, traces, memory, `/config`, component library |
|
|
607
|
+
| [docs/en/permissions.md](docs/en/permissions.md) ([中文](docs/permissions.md)) | Permission modes, read-only commands in plan, decision order, approval-free sandboxed commands, auto's three tiers, approval origin labels |
|
|
608
|
+
| [docs/en/host-api.md](docs/en/host-api.md) ([中文](docs/host-api.md)) | Host adapter API |
|
|
609
|
+
| [docs/en/rpc.md](docs/en/rpc.md) ([中文](docs/rpc.md)) | RPC protocol (stdio JSONL) |
|
|
610
|
+
| [docs/en/sessions.md](docs/en/sessions.md) ([中文](docs/sessions.md)) | Session stats, search, `--from` reuse, export, traces, checkpoints and shadow git |
|
|
611
|
+
| [docs/memory.md](docs/memory.md) | Memory: enabling, storage, the `memory` tool and permissions, system prompt and cache, commands (Chinese) |
|
|
612
|
+
| [docs/plan.md](docs/plan.md) | Plan mode: flow, plan format, approval, separate models, config and persistence (Chinese) |
|
|
613
|
+
| [docs/agents.md](docs/agents.md) | Sub-agents (types, definition files, background, follow-up, worktree) and external agents (drivers, permissions, environment, budget) (Chinese) |
|
|
614
|
+
| [docs/acp.md](docs/acp.md) | ACP: `ama --mode acp` and ama as an ACP client (Chinese) |
|
|
615
|
+
| [docs/sandbox.md](docs/sandbox.md) | OS sandbox: codemode and bash, per-platform implementation, config and known bypasses (Chinese) |
|
|
616
|
+
| [docs/codemode.md](docs/codemode.md) | codemode scripts, sandbox and permissions (Chinese) |
|
|
617
|
+
| [docs/hooks.md](docs/hooks.md) | Command hooks (hooks.json) (Chinese) |
|
|
618
|
+
| [docs/session-format.md](docs/session-format.md) | Session file format (Chinese) |
|
|
619
|
+
| [docs/rewind-plan.md](docs/rewind-plan.md) | Checkpoint and rewind design (Chinese) |
|
|
620
|
+
| [docs/tui-design.md](docs/tui-design.md) | Terminal UI visual spec and screen-by-screen mockups (Chinese) |
|
|
621
|
+
| [docs/design.md][design] | Overall design and decision log (Chinese) |
|
|
622
|
+
| [docs/extensions.md][extensions] | Local extensions (draft design, not implemented) (Chinese) |
|
|
623
|
+
| [docs/benchmarks/][benchmarks] | Preset benchmarks, the D20 todo retest and the cache acceptance experiment (reports and raw data) |
|
|
624
|
+
| [docs/wave6-plan.md][wave6] | Wave 6 design: agent bar and sub-agent view, traces, memory, ChatGPT login, bilingual UI, `/config` (Chinese) |
|
|
625
|
+
| [docs/i18n.md][i18n] | Bilingual development conventions: language selection, message catalogs and key naming, model-side isolation, check script (Chinese) |
|
|
626
|
+
| [docs/wave5-plan.md][wave5] | Wave 5 design (Chinese) |
|
|
627
|
+
| [docs/implementation-plan.md][impl], [wave3-plan][w3] | Early implementation plans (for history) (Chinese) |
|
|
628
|
+
| [docs/research/][research] | Wave 5 and wave 6 research reports (for history) (Chinese) |
|
|
629
|
+
|
|
630
|
+
The npm package includes the first sixteen user docs above (both languages where available); the rest are design and history material linked on GitHub.
|
|
590
631
|
|
|
591
632
|
[design]: https://github.com/Owlbay/armadra-agent/blob/main/docs/design.md
|
|
592
633
|
[extensions]: https://github.com/Owlbay/armadra-agent/blob/main/docs/extensions.md
|
|
593
634
|
[benchmarks]: https://github.com/Owlbay/armadra-agent/tree/main/docs/benchmarks
|
|
635
|
+
[wave6]: https://github.com/Owlbay/armadra-agent/blob/main/docs/wave6-plan.md
|
|
636
|
+
[i18n]: https://github.com/Owlbay/armadra-agent/blob/main/docs/i18n.md
|
|
594
637
|
[wave5]: https://github.com/Owlbay/armadra-agent/blob/main/docs/wave5-plan.md
|
|
595
638
|
[impl]: https://github.com/Owlbay/armadra-agent/blob/main/docs/implementation-plan.md
|
|
596
639
|
[w3]: https://github.com/Owlbay/armadra-agent/blob/main/docs/wave3-plan.md
|
|
597
640
|
[research]: https://github.com/Owlbay/armadra-agent/tree/main/docs/research
|
|
598
641
|
|
|
599
|
-
##
|
|
642
|
+
## Known limitations
|
|
600
643
|
|
|
601
|
-
- **Linux
|
|
602
|
-
-
|
|
603
|
-
- **DeepSeek
|
|
604
|
-
- **models.dev
|
|
605
|
-
-
|
|
644
|
+
- **The Linux sandbox is not verified on real machines**: the bubblewrap policies are only verified by unit tests and Ubuntu CI, never on a Linux desktop / server; without bwrap ama falls back to `unshare -r -n` (network isolation only, unusable for the bash sandbox), and with neither it behaves as if there were no sandbox (codemode back to the execute class, approval every time).
|
|
645
|
+
- **Real-CLI tests for external agents only run locally**: CI runs only recorded replays and ama driving ama; end-to-end tests against `claude` / `codex` need a logged-in machine and run with `AMA_E2E_AGENTS=1` (using your subscription quota); see [docs/agents.md](docs/agents.md) (Chinese).
|
|
646
|
+
- **DeepSeek, Zhipu and Kimi still default to Chat**: their Messages channels (`@messages`) have only been tested through relays; the default switches once direct official endpoints pass the measurement gate (`scripts/channel-probe.mjs`).
|
|
647
|
+
- **models.dev refresh PRs do not trigger CI automatically**: without the repository secret `MODELS_DEV_PR_TOKEN`, the weekly workflow opens the PR with the default token (after running `pnpm run ci` itself and putting the result in the description).
|
|
648
|
+
- **ChatGPT login is not yet verified with a real account**: both flavors are tested against a local mock only. Still to be confirmed with a real Plus / Pro account: the tool `namespace` shape on the official (siwc) path (`toolsInNamespace` stays off), whether the codex device code needs enabling in ChatGPT security settings, and the fields of the codex `wham/usage` quota response. Real-account checks run locally with `AMA_E2E_CHATGPT=1` (see [docs/en/providers.md](docs/en/providers.md)).
|
|
649
|
+
- Sub-agents have depth 1, do not read `.claude/agents` and have no fork mode that inherits the parent conversation; Windows has no OS sandbox.
|
|
606
650
|
|
|
607
|
-
##
|
|
651
|
+
## Development
|
|
608
652
|
|
|
609
|
-
|
|
653
|
+
Requires Node ≥ 22 and pnpm (version in `packageManager` of `package.json`; `corepack enable` is enough).
|
|
610
654
|
|
|
611
655
|
```sh
|
|
612
656
|
pnpm install
|
|
613
|
-
pnpm run ci # typecheck
|
|
614
|
-
AMA_E2E=1 pnpm test:e2e # bundle
|
|
657
|
+
pnpm run ci # typecheck, fmt:check, check:deps, check:i18n, release:check, test, build, then bundle --version
|
|
658
|
+
AMA_E2E=1 pnpm test:e2e # bundle-level end-to-end: print / rpc / acp / plan / sub-agents / rewind / codemode / cache / host / auth / config / memory / trace / i18n (fake provider, free)
|
|
615
659
|
```
|
|
616
660
|
|
|
617
|
-
pnpm 10
|
|
661
|
+
Since pnpm 10, `pnpm ci` is the built-in "clean install", so run the checks with `pnpm run ci`. Common single steps: `pnpm test`, `pnpm typecheck`, `pnpm fmt`, `pnpm build`. Tests always use the fake provider: `AMA_FAKE_SCRIPT=<script.json>` makes it produce text, tool calls, 429s, dropped streams and so on from a script; examples are in `test/fixtures/scripts/`.
|
|
618
662
|
|
|
619
|
-
|
|
663
|
+
**Real-model scripts** (run locally, not in CI; `pnpm build` first):
|
|
620
664
|
|
|
621
|
-
|
|
|
622
|
-
|
|
|
623
|
-
| `node scripts/bench-presets.mjs
|
|
624
|
-
| `node scripts/cache-experiment.mjs
|
|
625
|
-
| `node scripts/record-sse.mjs`
|
|
665
|
+
| Script | Purpose |
|
|
666
|
+
| -------------------------------------------------------- | ----------------------------------------------------------- |
|
|
667
|
+
| `node scripts/bench-presets.mjs` (`pnpm bench:presets`) | Preset benchmark (`--tasks long` for long multi-step tasks) |
|
|
668
|
+
| `node scripts/cache-experiment.mjs` (`pnpm bench:cache`) | Cache acceptance experiments E1–E5 |
|
|
669
|
+
| `node scripts/record-sse.mjs` | Record SSE samples of each protocol as test fixtures |
|
|
626
670
|
|
|
627
|
-
|
|
671
|
+
The first two share budget controls: `--config` / `AMA_REAL_CONFIG` (a config.json with key references), `--models` / `AMA_REAL_MODELS`, `--max-requests` / `AMA_REAL_MAX_REQUESTS` (default 60), `--budget-usd` / `AMA_REAL_BUDGET_USD` (default 3). They stop as soon as the request count or budget is exceeded and output the data collected so far; config and data directories point to temp directories, never your user config.
|
|
628
672
|
|
|
629
|
-
|
|
673
|
+
**Constraints**: runtime dependencies must be zero; `src/` may only use `node:` built-ins and relative paths (guarded by `pnpm check:deps`). `src/` is organized by layer (`ai` model access, `agent` loop, `session` session tree, `tools`, `codemode`, `permissions`, `hooks`, `host` host contract, `tui` component library, `modes` entry points, `cli` startup), and each directory's `types.ts` is the contract between modules.
|
|
630
674
|
|
|
631
|
-
|
|
675
|
+
**Releasing**: bump the version in `package.json`, update both changelogs (English [CHANGELOG.md](CHANGELOG.md) and Chinese [CHANGELOG.zh-CN.md](CHANGELOG.zh-CN.md), turning "Unreleased" into the version), merge into main and push a `v<version>` tag. Once CI is green the release job creates a GitHub Release (`ama.cjs`, `ama-sandbox.cjs`, `package.tgz`, `SHA256SUMS`) and publishes to npm with provenance. It prefers OIDC trusted publishing (npm ≥ 11.5.1, upgraded inside the job): add a GitHub Actions trusted publisher in the `@armadra/agent` package settings on npmjs.com (organization `Owlbay`, repository `armadra-agent`, workflow `ci.yml`, environment empty) and no long-lived token is needed; the repository secret `NPM_TOKEN` stays as a fallback, and the job fails with a hint when neither exists. `pnpm release:check` checks that the tag matches the version, requires a breaking version bump when protocol constants change, and checks that both READMEs / changelogs and `docs/en/` exist and link to each other and that both changelogs have a section for the current version (English from 0.6.0 on).
|
|
632
676
|
|
|
633
|
-
##
|
|
677
|
+
## Changelog
|
|
634
678
|
|
|
635
|
-
|
|
679
|
+
See [CHANGELOG.md](CHANGELOG.md) (English, from 0.6.0) and [CHANGELOG.zh-CN.md](CHANGELOG.zh-CN.md) (Chinese, complete history since 0.1).
|
|
636
680
|
|
|
637
|
-
##
|
|
681
|
+
## License
|
|
638
682
|
|
|
639
683
|
[MIT](LICENSE)
|