@armadra/agent 0.5.1 → 0.6.0
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 +177 -304
- package/CHANGELOG.zh-CN.md +442 -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/enrich.js +2 -7
- 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/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 +33 -0
- package/dist/auth/chatgpt/cli.js +252 -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 +25928 -11144
- 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 +5 -0
- package/dist/cli/compose-providers.js +32 -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 +137 -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 +3 -0
- package/dist/cli/subcommands/models-discover.js +44 -21
- package/dist/cli/subcommands/models.d.ts +1 -1
- package/dist/cli/subcommands/models.js +29 -22
- 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 +101 -68
- 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 +3 -2
- 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 +78 -0
- package/dist/config/settings-registry.js +184 -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 +2169 -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 +187 -0
- package/dist/i18n/messages/auth.js +189 -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 +244 -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 +289 -0
- package/dist/i18n/messages/config-keys.js +292 -0
- package/dist/i18n/messages/config.d.ts +502 -0
- package/dist/i18n/messages/config.js +239 -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 +103 -0
- package/dist/i18n/messages/interactive-startup.js +104 -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 +493 -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 +190 -0
- package/dist/i18n/messages/panels.js +189 -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 +348 -0
- package/dist/i18n/messages/settings.js +336 -0
- package/dist/i18n/messages/subcommands-config.d.ts +111 -0
- package/dist/i18n/messages/subcommands-config.js +127 -0
- package/dist/i18n/messages/subcommands.d.ts +548 -0
- package/dist/i18n/messages/subcommands.js +474 -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 +19 -1
- package/dist/modes/interactive/commands.js +84 -40
- 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 +19 -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/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.js +38 -30
- 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/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 +625 -0
- package/docs/en/rpc.md +361 -0
- package/docs/en/sessions.md +219 -0
- package/docs/en/tui.md +527 -0
- package/docs/host-api.md +18 -17
- package/docs/memory.md +172 -0
- package/docs/permissions.md +2 -2
- package/docs/providers.md +67 -1
- package/docs/rpc.md +31 -3
- package/docs/session-format.md +8 -2
- package/docs/sessions.md +29 -1
- package/docs/tui.md +132 -3
- package/package.json +8 -3
|
@@ -23,6 +23,7 @@ import { type AmaConfig } from "../config/types.js";
|
|
|
23
23
|
import type { AgentEventBus } from "../host/api-impl.js";
|
|
24
24
|
import type { Skill } from "../skills/discover.js";
|
|
25
25
|
import { type PromptTemplate } from "../skills/templates.js";
|
|
26
|
+
import type { MemoryRuntime } from "../memory/runtime.js";
|
|
26
27
|
import type { SessionAssembly } from "./deps.js";
|
|
27
28
|
import type { Runtime } from "./runtime.js";
|
|
28
29
|
/** createRuntimeDeps 闭包里跨步骤共享的状态。 */
|
|
@@ -38,6 +39,8 @@ export interface ComposeState {
|
|
|
38
39
|
providers?: ProviderRegistryApi;
|
|
39
40
|
/** [S2] tools.create 算出的 bash 沙箱设定,permissions.create 用同一份。 */
|
|
40
41
|
bashSandbox?: BashSandbox;
|
|
42
|
+
/** [W6-M] tools.create 收到的记忆运行期(未开启为 undefined)。 */
|
|
43
|
+
memory?: MemoryRuntime | undefined;
|
|
41
44
|
}
|
|
42
45
|
export declare function emptyComposeState(): ComposeState;
|
|
43
46
|
export type LogFn = (level: "debug" | "info" | "warn" | "error", message: string) => void;
|
|
@@ -48,6 +51,8 @@ export interface SessionComposeOptions {
|
|
|
48
51
|
}
|
|
49
52
|
/** `AMA_LOG=debug|info|warn|error`(缺省 warn)过滤后写 stderr。 */
|
|
50
53
|
export declare function stderrLog(env?: NodeJS.ProcessEnv): LogFn;
|
|
54
|
+
/** [W6-S] D22:回复语言规则(发给模型,固定英文)。 */
|
|
55
|
+
export declare function replyLanguageRule(language: string): string;
|
|
51
56
|
/** config `cache` 段 + 环境变量 → 会话缓存设置;非法的环境变量值忽略并 warning。 */
|
|
52
57
|
export declare function cacheSettingsFrom(config: Pick<AmaConfig, "cache">, env?: NodeJS.ProcessEnv, warn?: (message: string) => void): Partial<CacheSettings>;
|
|
53
58
|
/**
|
|
@@ -34,7 +34,9 @@ import { expandPromptCommand } from "../skills/templates.js";
|
|
|
34
34
|
import { PresetToolRegistry } from "../tools/presets.js";
|
|
35
35
|
import { openSession } from "./compose-store.js";
|
|
36
36
|
import { composeExtensions } from "./compose-extensions.js";
|
|
37
|
+
import { attachMemory, withMemorySection } from "./compose-memory.js";
|
|
37
38
|
import { ExitCode } from "./exit-codes.js";
|
|
39
|
+
import { msg } from "../i18n/index.js";
|
|
38
40
|
export function emptyComposeState() {
|
|
39
41
|
return { skills: [], templates: [], warnings: [], session: undefined };
|
|
40
42
|
}
|
|
@@ -66,7 +68,7 @@ function sourceText(source, cache, log) {
|
|
|
66
68
|
text = readFileSync(source.path, "utf8");
|
|
67
69
|
}
|
|
68
70
|
catch (error) {
|
|
69
|
-
log("warn",
|
|
71
|
+
log("warn", msg().cli.composeSession.instructionsReadFailed(source.path, error.message));
|
|
70
72
|
}
|
|
71
73
|
cache.set(source.path, text);
|
|
72
74
|
return text;
|
|
@@ -85,6 +87,10 @@ function contextFiles(record) {
|
|
|
85
87
|
}));
|
|
86
88
|
return [...resources.contextFiles, ...extra.filter((f) => f.content.trim() !== "")];
|
|
87
89
|
}
|
|
90
|
+
/** [W6-S] D22:回复语言规则(发给模型,固定英文)。 */
|
|
91
|
+
export function replyLanguageRule(language) {
|
|
92
|
+
return `Reply to the user in ${language}.`;
|
|
93
|
+
}
|
|
88
94
|
function systemInput(record, active) {
|
|
89
95
|
const system = { contextFiles: contextFiles(record) };
|
|
90
96
|
const override = record.assembly.overrides?.systemPrompt;
|
|
@@ -92,6 +98,10 @@ function systemInput(record, active) {
|
|
|
92
98
|
system.preamble = override.text;
|
|
93
99
|
else if (override !== undefined)
|
|
94
100
|
system.extraRules = [override.text];
|
|
101
|
+
// [W6-S] D22 ui.replyLanguage:会话开始在 rules 节末尾追加一句英文规则;不设时零字节变化
|
|
102
|
+
const reply = record.assembly.config.ui?.replyLanguage?.trim();
|
|
103
|
+
if (reply)
|
|
104
|
+
system.extraRules = [...(system.extraRules ?? []), replyLanguageRule(reply)];
|
|
95
105
|
const index = formatSkillIndex(record.state.skills, {
|
|
96
106
|
hasSkillTool: false,
|
|
97
107
|
hasReadTool: active.includes("read"),
|
|
@@ -122,8 +132,7 @@ async function expandPrompt(record, session, text) {
|
|
|
122
132
|
refreshSystem(record, session);
|
|
123
133
|
const skill = await expandSkillCommand(text, record.state.skills);
|
|
124
134
|
if (skill?.kind === "unknown") {
|
|
125
|
-
|
|
126
|
-
throw new AmaError("skill_not_found", `未知 Skill:${skill.name}${hint}`);
|
|
135
|
+
throw new AmaError("skill_not_found", msg().cli.composeSession.unknownSkill(skill.name, skill.available));
|
|
127
136
|
}
|
|
128
137
|
if (skill?.kind === "expanded")
|
|
129
138
|
return { text: skill.text };
|
|
@@ -142,7 +151,7 @@ export function cacheSettingsFrom(config, env = process.env, warn = () => undefi
|
|
|
142
151
|
if (WARMING_MODES.includes(warming))
|
|
143
152
|
settings.warming = warming;
|
|
144
153
|
else
|
|
145
|
-
warn(
|
|
154
|
+
warn(msg().cli.composeSession.invalidCacheWarming(warming));
|
|
146
155
|
}
|
|
147
156
|
const retention = env["AMA_CACHE_RETENTION"];
|
|
148
157
|
if (retention !== undefined && retention !== "") {
|
|
@@ -150,7 +159,7 @@ export function cacheSettingsFrom(config, env = process.env, warn = () => undefi
|
|
|
150
159
|
if (CACHE_RETENTIONS.includes(value))
|
|
151
160
|
settings.retention = value;
|
|
152
161
|
else
|
|
153
|
-
warn(
|
|
162
|
+
warn(msg().cli.composeSession.invalidCacheRetention(retention));
|
|
154
163
|
}
|
|
155
164
|
return settings;
|
|
156
165
|
}
|
|
@@ -164,7 +173,7 @@ export function idleTimeoutFrom(config, env = process.env, warn = () => undefine
|
|
|
164
173
|
const value = Number(raw);
|
|
165
174
|
if (Number.isFinite(value) && value >= 0)
|
|
166
175
|
return value;
|
|
167
|
-
warn(
|
|
176
|
+
warn(msg().cli.composeSession.invalidIdleTimeout(raw));
|
|
168
177
|
}
|
|
169
178
|
return config.request?.idleTimeoutMs;
|
|
170
179
|
}
|
|
@@ -229,6 +238,11 @@ export function bridgeEvent(event, bus) {
|
|
|
229
238
|
void bus.emit("context_pressure", pressure);
|
|
230
239
|
return;
|
|
231
240
|
}
|
|
241
|
+
case "quota_update": {
|
|
242
|
+
const { type: _type, ...quota } = event;
|
|
243
|
+
void bus.emit("quota_update", quota);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
232
246
|
// [W5-C0] 子 Agent 与计划事件
|
|
233
247
|
case "subagent_start": {
|
|
234
248
|
const { type: _type, ...payload } = event;
|
|
@@ -276,7 +290,7 @@ function buildSession(record, manager, model, thinkingLevel) {
|
|
|
276
290
|
unattended: assembly.unattended,
|
|
277
291
|
approvalTimeoutMs: approvalTimeout(record.options),
|
|
278
292
|
hooks: assembly.hooks,
|
|
279
|
-
system: systemInput(record, active),
|
|
293
|
+
system: withMemorySection(systemInput(record, active), record.state.memory, manager),
|
|
280
294
|
compaction: { ...config.compaction },
|
|
281
295
|
retry: { ...config.retry },
|
|
282
296
|
expandPrompt: (text) => expandPrompt(record, session, text),
|
|
@@ -320,6 +334,7 @@ function buildSession(record, manager, model, thinkingLevel) {
|
|
|
320
334
|
sessionsRoot: assembly.paths.sessionDir,
|
|
321
335
|
});
|
|
322
336
|
session = new AgentSessionImpl(options);
|
|
337
|
+
attachMemory(session, record.state.memory);
|
|
323
338
|
session.subscribe((event) => bridgeEvent(event, assembly.events));
|
|
324
339
|
records.set(session, record);
|
|
325
340
|
record.state.session = session;
|
|
@@ -329,12 +344,11 @@ function buildSession(record, manager, model, thinkingLevel) {
|
|
|
329
344
|
export function composeSession(assembly, state = emptyComposeState(), options = {}) {
|
|
330
345
|
const manager = assembly.sessionManager;
|
|
331
346
|
if (!(manager instanceof SessionManager)) {
|
|
332
|
-
throw new AmaError("invalid_arguments",
|
|
347
|
+
throw new AmaError("invalid_arguments", msg().cli.composeSession.notSessionManager);
|
|
333
348
|
}
|
|
334
349
|
const { model } = assembly;
|
|
335
350
|
if (assembly.providers.getApi(model.api) === undefined) {
|
|
336
|
-
|
|
337
|
-
throw new StartupError("provider_not_found", `模型 ${model.provider}/${model.id} 的协议 ${model.api} 尚未实现${via}`, ExitCode.NoModel);
|
|
351
|
+
throw new StartupError("provider_not_found", msg().cli.composeSession.apiNotImplemented(`${model.provider}/${model.id}`, model.api, model.api === "google-generative-ai"), ExitCode.NoModel);
|
|
338
352
|
}
|
|
339
353
|
for (const warning of state.warnings.splice(0))
|
|
340
354
|
assembly.warn(warning);
|
|
@@ -366,7 +380,7 @@ export function composeSession(assembly, state = emptyComposeState(), options =
|
|
|
366
380
|
record.current.addTool(tool, active);
|
|
367
381
|
}
|
|
368
382
|
catch (error) {
|
|
369
|
-
record.log("warn",
|
|
383
|
+
record.log("warn", msg().cli.composeSession.appendToolFailed(tool.name, error.message));
|
|
370
384
|
}
|
|
371
385
|
});
|
|
372
386
|
}
|
|
@@ -390,10 +404,10 @@ export function currentSession(target) {
|
|
|
390
404
|
export async function switchSession(target, request) {
|
|
391
405
|
const record = recordOf(target);
|
|
392
406
|
if (record === undefined)
|
|
393
|
-
throw new AmaError("not_implemented",
|
|
407
|
+
throw new AmaError("not_implemented", msg().cli.composeSession.notComposed);
|
|
394
408
|
const old = record.current;
|
|
395
409
|
if (old.state.isStreaming)
|
|
396
|
-
throw new AmaError("busy",
|
|
410
|
+
throw new AmaError("busy", msg().cli.composeSession.switchWhileStreaming);
|
|
397
411
|
const { assembly } = record;
|
|
398
412
|
const sessionDir = assembly.paths.sessionDir;
|
|
399
413
|
let manager;
|
|
@@ -17,8 +17,10 @@ export declare function openSession(request: SessionRequest, context: {
|
|
|
17
17
|
sessionDir: string;
|
|
18
18
|
cwd: string;
|
|
19
19
|
}): SessionManager;
|
|
20
|
+
/** 列会话(最新在前);子 Agent 会话缺省跳过,`includeSubagents` 时保留(带 `subagent` 标记)。 */
|
|
20
21
|
export declare function listSessions(context: {
|
|
21
22
|
sessionDir: string;
|
|
22
23
|
cwd?: string;
|
|
24
|
+
includeSubagents?: boolean;
|
|
23
25
|
}): SessionListItem[];
|
|
24
26
|
export declare function createSessionStore(): RuntimeDeps["sessions"];
|
|
@@ -14,6 +14,7 @@ import { AmaError } from "../errors.js";
|
|
|
14
14
|
import { SessionManager } from "../session/manager.js";
|
|
15
15
|
import { migrateSessionLines } from "../session/migrate.js";
|
|
16
16
|
import { TRASH_DIR_NAME, listSessionFiles, purgeTrash, readSessionLines, sessionDirForCwd, sessionIdFromFileName, trashSession, } from "../session/store.js";
|
|
17
|
+
import { msg } from "../i18n/index.js";
|
|
17
18
|
/** 根目录下全部 cwd 子目录(不含 trash)。 */
|
|
18
19
|
function cwdDirs(root) {
|
|
19
20
|
if (!existsSync(root))
|
|
@@ -49,7 +50,7 @@ export function findSessionFile(root, id, cwd) {
|
|
|
49
50
|
}
|
|
50
51
|
if (prefix.length > 1) {
|
|
51
52
|
const ids = prefix.map((f) => sessionIdFromFileName(f) ?? f).slice(0, 10);
|
|
52
|
-
throw new AmaError("invalid_arguments",
|
|
53
|
+
throw new AmaError("invalid_arguments", msg().cli.composeStore.ambiguousId(id, ids), {
|
|
53
54
|
exitCode: 5,
|
|
54
55
|
});
|
|
55
56
|
}
|
|
@@ -58,7 +59,7 @@ export function findSessionFile(root, id, cwd) {
|
|
|
58
59
|
function requireFile(root, id, cwd) {
|
|
59
60
|
const file = findSessionFile(root, id, cwd);
|
|
60
61
|
if (file === undefined)
|
|
61
|
-
throw new AmaError("session_not_found",
|
|
62
|
+
throw new AmaError("session_not_found", msg().cli.composeStore.sessionNotFound(id));
|
|
62
63
|
return file;
|
|
63
64
|
}
|
|
64
65
|
export function openSession(request, context) {
|
|
@@ -84,7 +85,7 @@ export function openSession(request, context) {
|
|
|
84
85
|
try {
|
|
85
86
|
const leaf = source.leafId();
|
|
86
87
|
if (leaf === null)
|
|
87
|
-
throw new AmaError("session_corrupt",
|
|
88
|
+
throw new AmaError("session_corrupt", msg().cli.composeStore.noEntries(request.id));
|
|
88
89
|
return source.fork(leaf);
|
|
89
90
|
}
|
|
90
91
|
finally {
|
|
@@ -93,12 +94,14 @@ export function openSession(request, context) {
|
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
}
|
|
97
|
+
/** 列会话(最新在前);子 Agent 会话缺省跳过,`includeSubagents` 时保留(带 `subagent` 标记)。 */
|
|
96
98
|
export function listSessions(context) {
|
|
97
99
|
const dirs = context.cwd === undefined
|
|
98
100
|
? cwdDirs(context.sessionDir)
|
|
99
101
|
: [sessionDirForCwd(context.sessionDir, context.cwd)];
|
|
100
102
|
return dirs
|
|
101
103
|
.flatMap((dir) => SessionManager.list(dir))
|
|
104
|
+
.filter((item) => context.includeSubagents === true || item.subagent !== true)
|
|
102
105
|
.sort((a, b) => b.modifiedAt.localeCompare(a.modifiedAt));
|
|
103
106
|
}
|
|
104
107
|
export function createSessionStore() {
|
|
@@ -109,13 +112,14 @@ export function createSessionStore() {
|
|
|
109
112
|
const file = requireFile(context.sessionDir, id);
|
|
110
113
|
const item = SessionManager.list(join(file, "..")).find((i) => i.file === file);
|
|
111
114
|
if (item === undefined)
|
|
112
|
-
throw new AmaError("session_corrupt",
|
|
115
|
+
throw new AmaError("session_corrupt", msg().cli.composeStore.unreadable(file));
|
|
113
116
|
const { entries } = migrateSessionLines(readSessionLines(file).lines, file);
|
|
114
117
|
return { item, entries };
|
|
115
118
|
},
|
|
116
119
|
prune: async (context) => {
|
|
117
120
|
const cutoff = Date.now() - context.olderThanDays * 24 * 60 * 60 * 1000;
|
|
118
|
-
|
|
121
|
+
// 子 Agent 会话一样按时间清理
|
|
122
|
+
const old = listSessions({ ...context, includeSubagents: true }).filter((i) => Date.parse(i.modifiedAt) < cutoff);
|
|
119
123
|
if (context.dryRun)
|
|
120
124
|
return { moved: old.map((i) => i.file) };
|
|
121
125
|
for (const item of old)
|
package/dist/cli/compose.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ import type { Rule } from "../permissions/types.js";
|
|
|
30
30
|
import { type SandboxCapability } from "../codemode/capability.js";
|
|
31
31
|
import { type BashSandbox } from "../sandbox/bash.js";
|
|
32
32
|
import { PresetToolRegistry } from "../tools/presets.js";
|
|
33
|
+
import type { MemoryRuntime } from "../memory/runtime.js";
|
|
33
34
|
import type { ToolDefinition, ToolRegistryApi } from "../tools/types.js";
|
|
34
35
|
import { type ComposeState, type LogFn } from "./compose-session.js";
|
|
35
36
|
import type { CliIo, InteractiveUi, ModeRunner, RuntimeDeps } from "./deps.js";
|
|
@@ -94,6 +95,7 @@ export declare function createTools(input: {
|
|
|
94
95
|
configDir: string;
|
|
95
96
|
dataDir: string;
|
|
96
97
|
} | undefined;
|
|
98
|
+
memory?: MemoryRuntime | undefined;
|
|
97
99
|
}, options: ComposeOptions, state: ComposeState): PresetToolRegistry;
|
|
98
100
|
/** 当前模型是否收图片(read 工具用);查不到模型时按收(交给协议层过滤)。 */
|
|
99
101
|
export declare function modelAcceptsImages(state: ComposeState, model: ModelRef | undefined): boolean;
|
package/dist/cli/compose.js
CHANGED
|
@@ -37,12 +37,14 @@ import { join } from "node:path";
|
|
|
37
37
|
import { AUTH_FILE } from "../config/paths.js";
|
|
38
38
|
import { PresetToolRegistry, resolvePreset } from "../tools/presets.js";
|
|
39
39
|
import { builtinTools } from "../tools/registry.js";
|
|
40
|
+
import { MEMORY_TOOL, createMemoryTool } from "../memory/tool.js";
|
|
40
41
|
import { takeCodemodeNotice } from "./codemode-notice.js";
|
|
41
42
|
import { buildProviderRegistry } from "./compose-providers.js";
|
|
42
43
|
import { composeSession, emptyComposeState, } from "./compose-session.js";
|
|
43
44
|
import { createSessionStore } from "./compose-store.js";
|
|
44
45
|
import { defaultSendUser } from "./startup-steps.js";
|
|
45
46
|
import { imageFitOptionsFor } from "../modes/image-input.js";
|
|
47
|
+
import { msg } from "../i18n/index.js";
|
|
46
48
|
/** 缺省工具工厂:codemode(生效模式为 off 时不注册;缺省跟随预设,见 tools/presets.ts)。 */
|
|
47
49
|
export const DEFAULT_TOOL_FACTORIES = [codemodeToolFactory()];
|
|
48
50
|
export function lazyMode(load) {
|
|
@@ -105,9 +107,13 @@ export function createTools(input, options, state) {
|
|
|
105
107
|
produced.push(tool);
|
|
106
108
|
}
|
|
107
109
|
catch (error) {
|
|
108
|
-
state.warnings.push(
|
|
110
|
+
state.warnings.push(msg().cli.compose.toolFactoryFailed(error.message));
|
|
109
111
|
}
|
|
110
112
|
}
|
|
113
|
+
// [W6-M] 记忆开启时注册 memory 工具并放进活动集(关闭时什么都不加,工具表字节不变)
|
|
114
|
+
if (input.memory !== undefined)
|
|
115
|
+
produced.push(createMemoryTool(input.memory));
|
|
116
|
+
state.memory = input.memory;
|
|
111
117
|
const extra = options.extraTools ?? [];
|
|
112
118
|
const names = new Set([...builtins, ...produced, ...extra].map((tool) => tool.name));
|
|
113
119
|
const preset = resolvePreset({
|
|
@@ -120,13 +126,15 @@ export function createTools(input, options, state) {
|
|
|
120
126
|
registry.register(tool, "builtin");
|
|
121
127
|
}
|
|
122
128
|
catch (error) {
|
|
123
|
-
state.warnings.push(
|
|
129
|
+
state.warnings.push(msg().cli.compose.toolRegisterFailed(tool.name, error.message));
|
|
124
130
|
}
|
|
125
131
|
}
|
|
126
132
|
for (const tool of extra)
|
|
127
133
|
registry.register(tool, "sdk");
|
|
134
|
+
if (input.memory !== undefined && preset.codemode !== "only")
|
|
135
|
+
preset.builtin.push(MEMORY_TOOL);
|
|
128
136
|
applyCodemodeMode(registry, preset);
|
|
129
|
-
state.warnings.push(...preset.warnings);
|
|
137
|
+
state.warnings.push(...preset.warnings.map((w) => msg().session.codemode.presetWarning(w)));
|
|
130
138
|
// 一次性提示只给有人看的界面(交互 / 行式);-p 与 RPC 的 stderr 常被脚本解析,不打扰。
|
|
131
139
|
if (input.paths !== undefined && (input.mode === "interactive" || input.mode === "line")) {
|
|
132
140
|
const notice = takeCodemodeNotice({ config: input.config, capability, ...input.paths });
|
|
@@ -157,7 +165,7 @@ export function buildRules(specs, builtinDeny, warn) {
|
|
|
157
165
|
rules.push(parseRule(spec.raw, spec.effect, spec.source));
|
|
158
166
|
}
|
|
159
167
|
catch (error) {
|
|
160
|
-
warn(
|
|
168
|
+
warn(msg().cli.compose.permissionRuleIgnored(spec.source, error.message));
|
|
161
169
|
}
|
|
162
170
|
}
|
|
163
171
|
return rules;
|
|
@@ -238,7 +246,7 @@ export function createRuntimeDeps(options = {}) {
|
|
|
238
246
|
const skipped = [...new Set([...skills.skippedUntrusted, ...prompts.skippedUntrusted])];
|
|
239
247
|
const warnings = [...skills.warnings, ...prompts.warnings];
|
|
240
248
|
if (skipped.length > 0)
|
|
241
|
-
warnings.push(
|
|
249
|
+
warnings.push(msg().cli.compose.untrustedDirsSkipped(skipped.length));
|
|
242
250
|
return {
|
|
243
251
|
skills: skills.skills.map((s) => ({
|
|
244
252
|
name: s.name,
|
|
@@ -27,8 +27,6 @@ export interface PricePick {
|
|
|
27
27
|
/** 为什么选它(一句话)。 */
|
|
28
28
|
reason: string;
|
|
29
29
|
}
|
|
30
|
-
/** 规则说明(帮助与输出共用)。 */
|
|
31
|
-
export declare const PRICE_RULE = "\u652F\u6301\u5DE5\u5177\u8C03\u7528\u3001\u4E0A\u4E0B\u6587 \u2265 64k \u4E14\u6709\u4EF7\u683C\u7684\u6A21\u578B\u91CC\u8F93\u5165\u4EF7\u6700\u4F4E";
|
|
32
30
|
/** 按价格挑缺省模型;没有满足条件的返回 undefined(规则见文件头)。 */
|
|
33
31
|
export declare function pickByPrice(candidates: readonly PriceCandidate[]): PricePick | undefined;
|
|
34
32
|
export interface DefaultModelChoice {
|
|
@@ -12,10 +12,9 @@
|
|
|
12
12
|
* 无 key 时探测)。跳过 `fake`(测试供应商只能显式 `--model fake/…`)与协议尚未实现的供应商。
|
|
13
13
|
*/
|
|
14
14
|
import { compactTokens, metadataOf } from "./subcommands/model-meta.js";
|
|
15
|
+
import { msg } from "../i18n/index.js";
|
|
15
16
|
/** 缺省模型的最小上下文(token)。 */
|
|
16
17
|
export const MIN_DEFAULT_CONTEXT = 64_000;
|
|
17
|
-
/** 规则说明(帮助与输出共用)。 */
|
|
18
|
-
export const PRICE_RULE = "支持工具调用、上下文 ≥ 64k 且有价格的模型里输入价最低";
|
|
19
18
|
/** 按价格挑缺省模型;没有满足条件的返回 undefined(规则见文件头)。 */
|
|
20
19
|
export function pickByPrice(candidates) {
|
|
21
20
|
let best;
|
|
@@ -41,7 +40,7 @@ export function pickByPrice(candidates) {
|
|
|
41
40
|
const { c } = best;
|
|
42
41
|
return {
|
|
43
42
|
id: c.id,
|
|
44
|
-
reason:
|
|
43
|
+
reason: msg().cli.defaultModel.priceReason(c.inputCost, compactTokens(c.contextWindow)),
|
|
45
44
|
};
|
|
46
45
|
}
|
|
47
46
|
/** 供应商内挑模型:内置取目录首条;自定义按价格规则,挑不出再取首条。 */
|
|
@@ -51,7 +50,7 @@ export function pickProviderModel(registry, provider) {
|
|
|
51
50
|
if (first === undefined)
|
|
52
51
|
return undefined;
|
|
53
52
|
if (provider.builtin)
|
|
54
|
-
return { model: first, rule:
|
|
53
|
+
return { model: first, rule: msg().cli.defaultModel.builtinFirst };
|
|
55
54
|
const picked = pickByPrice(usable.map((m) => ({
|
|
56
55
|
id: m.id,
|
|
57
56
|
contextWindow: m.contextWindow,
|
|
@@ -63,7 +62,7 @@ export function pickProviderModel(registry, provider) {
|
|
|
63
62
|
return { model, rule: picked.reason };
|
|
64
63
|
return {
|
|
65
64
|
model: first,
|
|
66
|
-
rule:
|
|
65
|
+
rule: msg().cli.defaultModel.listFirst,
|
|
67
66
|
};
|
|
68
67
|
}
|
|
69
68
|
export async function pickDefaultModel(registry) {
|
|
@@ -105,7 +104,5 @@ export function noModelGuidance(registry) {
|
|
|
105
104
|
.map((p) => p.envKeys[0])
|
|
106
105
|
.filter((name) => name !== undefined);
|
|
107
106
|
const shown = envs.slice(0, 3).join(" / ");
|
|
108
|
-
|
|
109
|
-
return (`没有可用模型:设置 ${shown}${more}环境变量,或 \`ama auth set <provider>\` 保存 key,` +
|
|
110
|
-
"或 `ama providers add <id> --base-url <url>` 接入中转站(也可 --model 指定)");
|
|
107
|
+
return msg().cli.defaultModel.noModel(shown, envs.length > 3);
|
|
111
108
|
}
|
package/dist/cli/deps.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ import type { AmaConfig } from "../config/types.js";
|
|
|
15
15
|
import type { PermissionRuleSpec } from "../config/merge.js";
|
|
16
16
|
import type { TrustPromptAnswer } from "../config/trust.js";
|
|
17
17
|
import type { HookDispatcherApi } from "../hooks/types.js";
|
|
18
|
+
import type { MemoryRuntime } from "../memory/runtime.js";
|
|
18
19
|
import type { WarmingDecisionHandler } from "../ai/cache/types.js";
|
|
19
20
|
import type { AgentEventBus } from "../host/api-impl.js";
|
|
20
21
|
import type { ApprovalBroker, HostAdapterHandle, InstructionSource } from "../host/types.js";
|
|
@@ -162,10 +163,11 @@ export interface RuntimeDeps {
|
|
|
162
163
|
sessionDir: string;
|
|
163
164
|
cwd: string;
|
|
164
165
|
}): SessionManagerApi | Promise<SessionManagerApi>;
|
|
165
|
-
/** `--resume` 选择器与 `ama sessions`
|
|
166
|
+
/** `--resume` 选择器与 `ama sessions` 用;子 Agent 会话缺省不列,`includeSubagents` 时列出。 */
|
|
166
167
|
list?(context: {
|
|
167
168
|
sessionDir: string;
|
|
168
169
|
cwd?: string;
|
|
170
|
+
includeSubagents?: boolean;
|
|
169
171
|
}): Promise<SessionListItem[]>;
|
|
170
172
|
/** `ama sessions show`:id 可为前缀;找不到抛 AmaError{code:"session_not_found"}。 */
|
|
171
173
|
show?(id: string, context: {
|
|
@@ -195,6 +197,8 @@ export interface RuntimeDeps {
|
|
|
195
197
|
configDir: string;
|
|
196
198
|
dataDir: string;
|
|
197
199
|
};
|
|
200
|
+
/** [W6-M] 记忆运行期(开启时注册 memory 工具;组装会话时渲染 memory 节)。 */
|
|
201
|
+
memory?: MemoryRuntime | undefined;
|
|
198
202
|
}): ToolRegistryApi;
|
|
199
203
|
};
|
|
200
204
|
/** B3:权限管线。 */
|
package/dist/cli/exit-codes.d.ts
CHANGED
|
@@ -37,5 +37,5 @@ export declare const ExitCode: {
|
|
|
37
37
|
};
|
|
38
38
|
export type ExitCodeName = keyof typeof ExitCode;
|
|
39
39
|
export type ExitCode = (typeof ExitCode)[ExitCodeName];
|
|
40
|
-
|
|
40
|
+
/** [W6-I1] 退出码说明按界面语言取(`msg().cli.exitCodes`,键是 `ExitCode` 名字的 camelCase)。 */
|
|
41
41
|
export declare function describeExitCode(code: number): string;
|
package/dist/cli/exit-codes.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 进程退出码(设计 §11.3)。[B0] 契约文件。
|
|
3
3
|
*/
|
|
4
|
+
import { msg } from "../i18n/index.js";
|
|
4
5
|
export const ExitCode = {
|
|
5
6
|
/** 正常。 */
|
|
6
7
|
Ok: 0,
|
|
@@ -35,21 +36,11 @@ export const ExitCode = {
|
|
|
35
36
|
/** SIGTERM。 */
|
|
36
37
|
Sigterm: 143,
|
|
37
38
|
};
|
|
38
|
-
|
|
39
|
-
0: "正常",
|
|
40
|
-
1: "运行期错误(模型最终失败等)",
|
|
41
|
-
2: "参数用法错误",
|
|
42
|
-
3: "配置 / profile / 路径错误",
|
|
43
|
-
4: "无可用模型或密钥",
|
|
44
|
-
5: "会话不存在 / 损坏 / cwd 不匹配",
|
|
45
|
-
6: "宿主 / Hook 加载或启动失败",
|
|
46
|
-
7: "-p 运行中有工具调用被拒(没有人审批)",
|
|
47
|
-
8: "-p 到达预算上限(--max-turns / --max-cost / limits)",
|
|
48
|
-
9: "-p 产出的计划已落盘、待审批(未执行)",
|
|
49
|
-
78: "HOST_API_VERSION 不匹配",
|
|
50
|
-
130: "SIGINT 退出(两次 Ctrl+C)",
|
|
51
|
-
143: "SIGTERM",
|
|
52
|
-
};
|
|
39
|
+
/** [W6-I1] 退出码说明按界面语言取(`msg().cli.exitCodes`,键是 `ExitCode` 名字的 camelCase)。 */
|
|
53
40
|
export function describeExitCode(code) {
|
|
54
|
-
|
|
41
|
+
const texts = msg().cli.exitCodes;
|
|
42
|
+
const name = Object.keys(ExitCode).find((key) => ExitCode[key] === code);
|
|
43
|
+
if (name === undefined)
|
|
44
|
+
return texts.unknown;
|
|
45
|
+
return texts[`${name[0].toLowerCase()}${name.slice(1)}`];
|
|
55
46
|
}
|
package/dist/cli/from-prompt.js
CHANGED
|
@@ -13,6 +13,7 @@ import { tmpdir } from "node:os";
|
|
|
13
13
|
import { join } from "node:path";
|
|
14
14
|
import { resolveFromMessage } from "../session/reuse.js";
|
|
15
15
|
import { UsageError } from "./args.js";
|
|
16
|
+
import { msg } from "../i18n/index.js";
|
|
16
17
|
const EXT = {
|
|
17
18
|
"image/png": "png",
|
|
18
19
|
"image/jpeg": "jpg",
|
|
@@ -25,7 +26,7 @@ export function applyFromOption(args, runtime, io) {
|
|
|
25
26
|
if (spec === undefined)
|
|
26
27
|
return plain;
|
|
27
28
|
if (runtime.mode === "rpc")
|
|
28
|
-
throw new UsageError(
|
|
29
|
+
throw new UsageError(msg().cli.fromPrompt.notWithRpc);
|
|
29
30
|
const picked = resolveFromMessage(runtime.paths.sessionDir, spec, runtime.paths.cwd);
|
|
30
31
|
const parts = [picked.text, args.prompt ?? ""].filter((p) => p.trim() !== "");
|
|
31
32
|
const prompt = parts.length > 0 ? parts.join("\n\n") : undefined;
|
|
@@ -33,7 +34,7 @@ export function applyFromOption(args, runtime, io) {
|
|
|
33
34
|
return { context: { args, prompt, io }, cleanup: () => { } };
|
|
34
35
|
}
|
|
35
36
|
if (runtime.mode !== "print") {
|
|
36
|
-
io.stderr(
|
|
37
|
+
io.stderr(msg().cli.fromPrompt.imagesDropped(picked.images.length));
|
|
37
38
|
return { context: { args, prompt, io }, cleanup: () => { } };
|
|
38
39
|
}
|
|
39
40
|
const dir = mkdtempSync(join(tmpdir(), "ama-from-"));
|
package/dist/cli/help-text.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `ama --help` 的文本(从 args.ts 搬出,args.ts 再导出)。[W5-C0]
|
|
3
|
+
* [W6-I1] 文本进消息目录(`msg().cli.help`),按界面语言取;不能是模块级常量(会按 import 时的语言定死)。
|
|
3
4
|
*/
|
|
4
|
-
export declare const HELP_TEXT = "\u7528\u6CD5\uFF1Aama [\u9009\u9879] [\u63D0\u793A]\n ama <\u5B50\u547D\u4EE4> \u2026\n\n\u6A21\u5F0F\n \uFF08\u7F3A\u7701\uFF09 \u7EC8\u7AEF\u754C\u9762\uFF1Bstdin / stdout \u975E TTY \u6216 TERM=dumb \u65F6\u81EA\u52A8\u964D\u7EA7\u4E3A\u884C\u5F0F\n --no-tui \u884C\u5F0F\u754C\u9762\uFF08readline + \u62EC\u53F7\u7C98\u8D34\uFF09\n -p, --print \u975E\u4EA4\u4E92\uFF1A\u6267\u884C\u63D0\u793A\u540E\u9000\u51FA\u3002\u63D0\u793A = \u53C2\u6570 + stdin \u7BA1\u9053\u5185\u5BB9\uFF1B\u6709\u63D0\u793A\u53C2\u6570\u65F6\n \u53EA\u7B49\u7BA1\u9053\u9996\u5B57\u8282 2 s\uFF08AMA_STDIN_WAIT_MS\uFF09\uFF0C\u6CA1\u6536\u5230\u5C31\u5FFD\u7565\u5E76\u63D0\u793A\uFF1B\n \u672B\u5C3E\u52A0 - \u5219\u4E00\u76F4\u7B49\u5230 EOF\uFF08\u5982 npm test | ama -p \u627E\u539F\u56E0 -\uFF09\n --no-stdin -p \u4E0D\u8BFB stdin\uFF08\u7236\u8FDB\u7A0B\u7559\u7740\u7BA1\u9053\u3001\u53C8\u4E0D\u60F3\u7B49 2 s \u65F6\uFF09\n --output-format <\u683C\u5F0F> -p \u7684\u8F93\u51FA\uFF1Atext\uFF08\u7F3A\u7701\uFF09| json | stream-json\n --max-turns <N> -p \u6700\u591A\u8DD1 N \u8F6E\uFF08\u4E00\u6B21\u6A21\u578B\u8BF7\u6C42\u52A0\u5176\u5DE5\u5177\u6267\u884C\u7B97\u4E00\u8F6E\uFF09\uFF1B\u5230\u8FBE\u4E0A\u9650\u4ECD\u6709\n \u672A\u5B8C\u6210\u7684\u5DE5\u5177\u8C03\u7528\u65F6\u63D0\u524D\u7ED3\u675F\uFF0C\u9000\u51FA\u7801 8\n --image <\u6587\u4EF6> -p \u968F\u63D0\u793A\u53D1\u9001\u56FE\u7247\uFF08\u53EF\u91CD\u590D\uFF1Bpng / jpg / gif / webp\uFF0C\u5355\u5F20 \u2264 5 MB\uFF09\uFF1B\n \u4EA4\u4E92\u754C\u9762\u91CC\u5199 @\u56FE\u7247\u8DEF\u5F84 \u6216\u7C98\u8D34\u56FE\u7247\u8DEF\u5F84\n --mode rpc stdio JSONL \u534F\u8BAE\uFF08\u4F9B\u5D4C\u5165\uFF09\n --mode acp ACP \u670D\u52A1\u7AEF\uFF08\u4F9B Zed / JetBrains / Armadra \u9A71\u52A8\uFF09\n --max-cost <USD> \u4E00\u6B21\u8FD0\u884C\u7684\u7F8E\u5143\u4E0A\u9650\uFF08\u6309\u76EE\u5F55\u4EF7\u4F30\u7B97\uFF09\uFF1B\u5230\u9650\u7ED3\u675F\u8FD0\u884C\uFF0C-p \u9000\u51FA\u7801 8\n --tui-mode <\u6A21\u5F0F> \u663E\u793A\u6A21\u5F0F\uFF0C\u7B2C\u4E00\u671F\u53EA\u6709 regular\uFF08\u4E3B\u5C4F\uFF09\n --quiet-startup <\u6863> \u542F\u52A8\u753B\u9762\uFF1Anormal | header | silent\n\n\u6A21\u578B\n --model <provider/id> \u6A21\u578B\uFF08\u53EF\u914D\u5408 --provider \u53EA\u5199 id\uFF1B@\u6E20\u9053 \u6307\u5B9A\u6E20\u9053\uFF0C\u5982 packy/kimi-k2.5@messages\uFF09\n --provider <id> \u4F9B\u5E94\u5546\uFF08\u5FC5\u987B\u540C\u65F6\u7ED9 --model\uFF09\n --api-key <key> \u53EA\u7528\u4E8E\u672C\u6B21\u542F\u52A8\u7684 key\uFF08\u9700\u8981 --model\uFF1B\u4F18\u5148\u7528 ama auth set\uFF09\n --thinking <\u7EA7\u522B> off | minimal | low | medium | high | xhigh\n\n\u4F1A\u8BDD\n -c, --continue \u7EE7\u7EED\u672C\u76EE\u5F55\u6700\u8FD1\u7684\u4F1A\u8BDD\n -r, --resume [id] \u6062\u590D\u4F1A\u8BDD\uFF08\u4EA4\u4E92\u6A21\u5F0F\u65E0 id \u65F6\u5F39\u9009\u62E9\u5668\uFF09\n --session-id <id> \u4F7F\u7528\u6307\u5B9A id \u7684\u4F1A\u8BDD\uFF08\u4E0D\u5B58\u5728\u5219\u65B0\u5EFA\uFF09\n --fork <id> \u4ECE\u6307\u5B9A\u4F1A\u8BDD\u5206\u53C9\u51FA\u65B0\u4F1A\u8BDD\n --session-dir <\u76EE\u5F55> \u4F1A\u8BDD\u76EE\u5F55\uFF08\u7F3A\u7701 ~/.local/share/ama/sessions\uFF09\n --no-session \u4F1A\u8BDD\u53EA\u5728\u5185\u5B58\u91CC\uFF0C\u4E0D\u5199\u4F1A\u8BDD\u6587\u4EF6\uFF08\u4E4B\u540E\u65E0\u6CD5 --resume\uFF09\n --from <id>[#\u7F16\u53F7] \u7528\u65E7\u4F1A\u8BDD\u7684\u4E00\u6761\u7528\u6237\u6D88\u606F\u4F5C\u63D0\u793A\uFF08\u7F3A\u7701\u6700\u540E\u4E00\u6761\uFF1B-p \u65F6\u8FDE\u56FE\u7247\u4E00\u8D77\uFF1B\n \u7F16\u53F7\u89C1 ama sessions show\uFF09\n\n\u6743\u9650\u4E0E\u4FE1\u4EFB\n --permission-mode <\u6A21\u5F0F> default | auto-edit | plan | auto | full-auto | allowlist\n \uFF08auto \u7531 ama \u5224\u65AD\u6BCF\u4E00\u6B65\uFF1Ballowlist \u53EA\u653E\u884C allow \u89C4\u5219\u547D\u4E2D\u7684\uFF0C\u9002\u5408 CI\uFF09\n --allow <\u89C4\u5219> \u8FFD\u52A0\u5141\u8BB8\u89C4\u5219\uFF0C\u53EF\u91CD\u590D\uFF08\u5982 \"bash(git status*)\"\uFF09\n --deny <\u89C4\u5219> \u8FFD\u52A0\u62D2\u7EDD\u89C4\u5219\uFF0C\u53EF\u91CD\u590D\uFF08\u5982 \"write(**/.env*)\"\uFF09\n --trust / --no-trust \u4FE1\u4EFB / \u4E0D\u4FE1\u4EFB\u5F53\u524D\u9879\u76EE\uFF08\u9879\u76EE\u7EA7 Hook\u3001Skill\u3001\u63D0\u793A\u6A21\u677F\uFF09\n\n\u8D44\u6E90\n --system-prompt <\u6587\u672C|@\u6587\u4EF6> \u8FFD\u52A0\u7CFB\u7EDF\u63D0\u793A\uFF1A\u7F3A\u7701\u4F5C\u4E3A\u6700\u540E\u4E00\u6761\u89C4\u5219\u8FFD\u52A0\uFF08\u5DE5\u5177\u8868\u7B49\u524D\u7F00\u4E0D\u53D8\uFF0C\u5229\u4E8E\u7F13\u5B58\uFF09\n --system-prompt-mode <\u65B9\u5F0F> append\uFF08\u7F3A\u7701\uFF09| replace\uFF08\u66FF\u6362\u5F00\u5934\u7684\u89D2\u8272\u8BF4\u660E\uFF0C\u5DE5\u5177\u4E0E\u9879\u76EE\u4E0A\u4E0B\u6587\u4FDD\u7559\uFF09\n --profile <\u6587\u4EF6> \u5BBF\u4E3B profile.json\uFF08\u5B57\u6BB5\u7B49\u4EF7\u4E8E\u5BF9\u5E94\u53C2\u6570\uFF0C\u547D\u4EE4\u884C\u4F18\u5148\uFF09\n --host <\u6A21\u5757> \u5BBF\u4E3B\u9002\u914D\u5668\u6A21\u5757\uFF08CJS / ESM\uFF09\n --instructions <\u6587\u4EF6> \u8FFD\u52A0\u6307\u4EE4\u6587\u4EF6\uFF0C\u53EF\u91CD\u590D\n --skill-dir <\u76EE\u5F55> \u8FFD\u52A0 Skill \u76EE\u5F55\uFF0C\u53EF\u91CD\u590D\n --agent-dir <\u76EE\u5F55> \u8FFD\u52A0\u5B50 Agent \u5B9A\u4E49\u76EE\u5F55\uFF0C\u53EF\u91CD\u590D\n --auth-file <\u6587\u4EF6> auth.json \u4F4D\u7F6E\uFF08\u7F3A\u7701 ~/.config/ama/auth.json\uFF09\n --tools <a,b,\u2026> \u53EA\u542F\u7528\u8FD9\u4E9B\u5DE5\u5177\n --exclude-tools <a,b,\u2026> \u7981\u7528\u8FD9\u4E9B\u5DE5\u5177\n --tools-preset <\u540D> \u5DE5\u5177\u9884\u8BBE\uFF1Adefault\uFF08\u7F3A\u7701\uFF09| minimal | codemode-only | coordinator\n \uFF08codemode \u662F codemode-only \u7684\u65E7\u540D\uFF0C\u4ECD\u53EF\u7528\uFF09\n --codemode <\u6A21\u5F0F> codemode \u8C03\u7528\u65B9\u5F0F\uFF1Aoff | on | only\uFF08\u7F3A\u7701\u968F\u9884\u8BBE\uFF09\n\n\u5B50\u547D\u4EE4\n ama auth set <provider> \u4ECE stdin \u8BFB\u53D6 key \u5199\u5165 auth.json\uFF080600\uFF09\n ama auth list \u5217\u51FA\u5DF2\u4FDD\u5B58 key \u7684\u4F9B\u5E94\u5546\uFF08\u4E0D\u663E\u793A key\uFF09\n ama auth remove <provider> \u5220\u9664\u5DF2\u4FDD\u5B58\u7684 key\n ama sessions list|show|prune \u4F1A\u8BDD\u7BA1\u7406\n ama sessions search <\u5173\u952E\u8BCD|/\u6B63\u5219/> [--all] [--role user|assistant|tool] [--since 7d] [--limit N]\n \u8DE8\u4F1A\u8BDD\u5168\u6587\u68C0\u7D22\n ama sessions export <id> [--format md|json|jsonl] [--output <\u6587\u4EF6>] [--branch leaf|all]\n \u5BFC\u51FA\u4F1A\u8BDD\uFF08\u5DF2\u8131\u654F\uFF09\n ama models list [--provider <id>] \u5217\u51FA\u6A21\u578B\uFF08\u542B\u6765\u6E90\u4E0E key \u72B6\u6001\uFF09\n ama models check <provider/id> \u53D1\u4E00\u6B21\u6700\u5C0F\u8BF7\u6C42\u68C0\u67E5\u53EF\u7528\u6027\n ama models discover <provider> [--probe] [--write] [--limit N]\n \u4ECE\u4E2D\u8F6C /v1/models \u5217\u51FA\u6A21\u578B\uFF0C\u63A2\u6D4B\u534F\u8BAE\u5E76\u5199\u5165\u914D\u7F6E\n ama models refresh [--provider <id>] \u8054\u7F51\u5237\u65B0 models.dev \u5143\u6570\u636E\u5230\u6570\u636E\u76EE\u5F55\uFF08\u542F\u52A8\u4E0D\u8054\u7F51\uFF1B\n \u65E7\u540D refresh-catalog\uFF09\n ama providers add <id> --base-url <url> [--key-env VAR] [--probe] [--channel n=api@url] [--yes]\n \u4E00\u952E\u63A5\u5165\uFF1A\u5217\u6A21\u578B\u3001\u8865 models.dev \u5143\u6570\u636E\u3001\u63A2\u6D4B\u6E20\u9053\u3001\u5199\u5165\u914D\u7F6E\n ama providers list|channels <id>|remove <id>|refresh <id>\n \u4F9B\u5E94\u5546 \u2192 \u6E20\u9053 \u2192 \u6A21\u578B\uFF1B\u5220\u9664\uFF1B\u91CD\u62C9\u6A21\u578B\u5217\u8868\n ama models cache-probe <provider/id> [--tokens N] [--gap-ms MS] [--yes] [--json]\n \u5224\u65AD\u7AEF\u70B9\u662F\u5426\u62A5\u544A\u7F13\u5B58\u547D\u4E2D\n ama doctor \u914D\u7F6E\u5C42\u7EA7\u3001\u4FE1\u4EFB\u3001key \u6765\u6E90\u3001Hook\u3001\u7EC8\u7AEF\u80FD\u529B\n ama config show [--json] \u751F\u6548\u914D\u7F6E\u4E0E\u6BCF\u9879\u6765\u6E90\u3001\u5C06\u4F7F\u7528\u7684\u6A21\u578B\n ama config path \u914D\u7F6E\u76EE\u5F55\u3001\u6570\u636E\u76EE\u5F55\u4E0E\u5404\u6587\u4EF6\u8DEF\u5F84\n ama config edit \u7528 $VISUAL / $EDITOR \u6253\u5F00 config.json\n ama init [--force] \u5EFA\u914D\u7F6E\u76EE\u5F55\uFF080700\uFF09\u4E0E config.json\u3001config.schema.json\uFF1B\u5DF2\u6709\u7684\u4E0D\u8986\u76D6\n ama stats [--since 7d] [--by day|week|month|provider|channel|model|project] [--all] [--json]\n \u8DE8\u4F1A\u8BDD\u7EDF\u8BA1\uFF1A\u8BF7\u6C42\u3001token\u3001\u7F13\u5B58\u547D\u4E2D\u7387\u3001\u8D39\u7528\u3001\u5DE5\u5177\u8C03\u7528\n\n\u5176\u5B83\n -h, --help \u8F93\u51FA\u672C\u5E2E\u52A9\n -v, --version \u8F93\u51FA\u7248\u672C\n\n\u9000\u51FA\u7801\uFF1A0 \u6B63\u5E38 \u00B7 1 \u8FD0\u884C\u671F\u9519\u8BEF \u00B7 2 \u7528\u6CD5\u9519\u8BEF \u00B7 3 \u914D\u7F6E\u9519\u8BEF \u00B7 4 \u65E0\u53EF\u7528\u6A21\u578B\u6216 key \u00B7\n 5 \u4F1A\u8BDD\u9519\u8BEF \u00B7 6 \u5BBF\u4E3B / Hook \u542F\u52A8\u5931\u8D25 \u00B7 7 -p \u6709\u5DE5\u5177\u8C03\u7528\u88AB\u62D2\uFF08\u65E0\u4EBA\u5BA1\u6279\uFF1B\u7528\n --permission-mode auto-edit|auto \u6216 --allow \u653E\u884C\uFF09\u00B7 8 -p \u5230\u8FBE\u9884\u7B97\u4E0A\u9650 \u00B7\n 9 -p \u7684\u8BA1\u5212\u5DF2\u843D\u76D8\u5F85\u5BA1\u6279\uFF08plan.unattended: approve \u5219\u81EA\u52A8\u6279\u51C6\u6267\u884C\uFF09\u00B7\n 78 \u5BBF\u4E3B API \u7248\u672C\u4E0D\u5339\u914D \u00B7\n 130 SIGINT \u00B7 143 SIGTERM\n";
|
|
5
|
+
export declare function helpText(): string;
|
package/dist/cli/help-text.js
CHANGED
|
@@ -1,102 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `ama --help` 的文本(从 args.ts 搬出,args.ts 再导出)。[W5-C0]
|
|
3
|
+
* [W6-I1] 文本进消息目录(`msg().cli.help`),按界面语言取;不能是模块级常量(会按 import 时的语言定死)。
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
(缺省) 终端界面;stdin / stdout 非 TTY 或 TERM=dumb 时自动降级为行式
|
|
9
|
-
--no-tui 行式界面(readline + 括号粘贴)
|
|
10
|
-
-p, --print 非交互:执行提示后退出。提示 = 参数 + stdin 管道内容;有提示参数时
|
|
11
|
-
只等管道首字节 2 s(AMA_STDIN_WAIT_MS),没收到就忽略并提示;
|
|
12
|
-
末尾加 - 则一直等到 EOF(如 npm test | ama -p 找原因 -)
|
|
13
|
-
--no-stdin -p 不读 stdin(父进程留着管道、又不想等 2 s 时)
|
|
14
|
-
--output-format <格式> -p 的输出:text(缺省)| json | stream-json
|
|
15
|
-
--max-turns <N> -p 最多跑 N 轮(一次模型请求加其工具执行算一轮);到达上限仍有
|
|
16
|
-
未完成的工具调用时提前结束,退出码 8
|
|
17
|
-
--image <文件> -p 随提示发送图片(可重复;png / jpg / gif / webp,单张 ≤ 5 MB);
|
|
18
|
-
交互界面里写 @图片路径 或粘贴图片路径
|
|
19
|
-
--mode rpc stdio JSONL 协议(供嵌入)
|
|
20
|
-
--mode acp ACP 服务端(供 Zed / JetBrains / Armadra 驱动)
|
|
21
|
-
--max-cost <USD> 一次运行的美元上限(按目录价估算);到限结束运行,-p 退出码 8
|
|
22
|
-
--tui-mode <模式> 显示模式,第一期只有 regular(主屏)
|
|
23
|
-
--quiet-startup <档> 启动画面:normal | header | silent
|
|
24
|
-
|
|
25
|
-
模型
|
|
26
|
-
--model <provider/id> 模型(可配合 --provider 只写 id;@渠道 指定渠道,如 packy/kimi-k2.5@messages)
|
|
27
|
-
--provider <id> 供应商(必须同时给 --model)
|
|
28
|
-
--api-key <key> 只用于本次启动的 key(需要 --model;优先用 ama auth set)
|
|
29
|
-
--thinking <级别> off | minimal | low | medium | high | xhigh
|
|
30
|
-
|
|
31
|
-
会话
|
|
32
|
-
-c, --continue 继续本目录最近的会话
|
|
33
|
-
-r, --resume [id] 恢复会话(交互模式无 id 时弹选择器)
|
|
34
|
-
--session-id <id> 使用指定 id 的会话(不存在则新建)
|
|
35
|
-
--fork <id> 从指定会话分叉出新会话
|
|
36
|
-
--session-dir <目录> 会话目录(缺省 ~/.local/share/ama/sessions)
|
|
37
|
-
--no-session 会话只在内存里,不写会话文件(之后无法 --resume)
|
|
38
|
-
--from <id>[#编号] 用旧会话的一条用户消息作提示(缺省最后一条;-p 时连图片一起;
|
|
39
|
-
编号见 ama sessions show)
|
|
40
|
-
|
|
41
|
-
权限与信任
|
|
42
|
-
--permission-mode <模式> default | auto-edit | plan | auto | full-auto | allowlist
|
|
43
|
-
(auto 由 ama 判断每一步;allowlist 只放行 allow 规则命中的,适合 CI)
|
|
44
|
-
--allow <规则> 追加允许规则,可重复(如 "bash(git status*)")
|
|
45
|
-
--deny <规则> 追加拒绝规则,可重复(如 "write(**/.env*)")
|
|
46
|
-
--trust / --no-trust 信任 / 不信任当前项目(项目级 Hook、Skill、提示模板)
|
|
47
|
-
|
|
48
|
-
资源
|
|
49
|
-
--system-prompt <文本|@文件> 追加系统提示:缺省作为最后一条规则追加(工具表等前缀不变,利于缓存)
|
|
50
|
-
--system-prompt-mode <方式> append(缺省)| replace(替换开头的角色说明,工具与项目上下文保留)
|
|
51
|
-
--profile <文件> 宿主 profile.json(字段等价于对应参数,命令行优先)
|
|
52
|
-
--host <模块> 宿主适配器模块(CJS / ESM)
|
|
53
|
-
--instructions <文件> 追加指令文件,可重复
|
|
54
|
-
--skill-dir <目录> 追加 Skill 目录,可重复
|
|
55
|
-
--agent-dir <目录> 追加子 Agent 定义目录,可重复
|
|
56
|
-
--auth-file <文件> auth.json 位置(缺省 ~/.config/ama/auth.json)
|
|
57
|
-
--tools <a,b,…> 只启用这些工具
|
|
58
|
-
--exclude-tools <a,b,…> 禁用这些工具
|
|
59
|
-
--tools-preset <名> 工具预设:default(缺省)| minimal | codemode-only | coordinator
|
|
60
|
-
(codemode 是 codemode-only 的旧名,仍可用)
|
|
61
|
-
--codemode <模式> codemode 调用方式:off | on | only(缺省随预设)
|
|
62
|
-
|
|
63
|
-
子命令
|
|
64
|
-
ama auth set <provider> 从 stdin 读取 key 写入 auth.json(0600)
|
|
65
|
-
ama auth list 列出已保存 key 的供应商(不显示 key)
|
|
66
|
-
ama auth remove <provider> 删除已保存的 key
|
|
67
|
-
ama sessions list|show|prune 会话管理
|
|
68
|
-
ama sessions search <关键词|/正则/> [--all] [--role user|assistant|tool] [--since 7d] [--limit N]
|
|
69
|
-
跨会话全文检索
|
|
70
|
-
ama sessions export <id> [--format md|json|jsonl] [--output <文件>] [--branch leaf|all]
|
|
71
|
-
导出会话(已脱敏)
|
|
72
|
-
ama models list [--provider <id>] 列出模型(含来源与 key 状态)
|
|
73
|
-
ama models check <provider/id> 发一次最小请求检查可用性
|
|
74
|
-
ama models discover <provider> [--probe] [--write] [--limit N]
|
|
75
|
-
从中转 /v1/models 列出模型,探测协议并写入配置
|
|
76
|
-
ama models refresh [--provider <id>] 联网刷新 models.dev 元数据到数据目录(启动不联网;
|
|
77
|
-
旧名 refresh-catalog)
|
|
78
|
-
ama providers add <id> --base-url <url> [--key-env VAR] [--probe] [--channel n=api@url] [--yes]
|
|
79
|
-
一键接入:列模型、补 models.dev 元数据、探测渠道、写入配置
|
|
80
|
-
ama providers list|channels <id>|remove <id>|refresh <id>
|
|
81
|
-
供应商 → 渠道 → 模型;删除;重拉模型列表
|
|
82
|
-
ama models cache-probe <provider/id> [--tokens N] [--gap-ms MS] [--yes] [--json]
|
|
83
|
-
判断端点是否报告缓存命中
|
|
84
|
-
ama doctor 配置层级、信任、key 来源、Hook、终端能力
|
|
85
|
-
ama config show [--json] 生效配置与每项来源、将使用的模型
|
|
86
|
-
ama config path 配置目录、数据目录与各文件路径
|
|
87
|
-
ama config edit 用 $VISUAL / $EDITOR 打开 config.json
|
|
88
|
-
ama init [--force] 建配置目录(0700)与 config.json、config.schema.json;已有的不覆盖
|
|
89
|
-
ama stats [--since 7d] [--by day|week|month|provider|channel|model|project] [--all] [--json]
|
|
90
|
-
跨会话统计:请求、token、缓存命中率、费用、工具调用
|
|
91
|
-
|
|
92
|
-
其它
|
|
93
|
-
-h, --help 输出本帮助
|
|
94
|
-
-v, --version 输出版本
|
|
95
|
-
|
|
96
|
-
退出码:0 正常 · 1 运行期错误 · 2 用法错误 · 3 配置错误 · 4 无可用模型或 key ·
|
|
97
|
-
5 会话错误 · 6 宿主 / Hook 启动失败 · 7 -p 有工具调用被拒(无人审批;用
|
|
98
|
-
--permission-mode auto-edit|auto 或 --allow 放行)· 8 -p 到达预算上限 ·
|
|
99
|
-
9 -p 的计划已落盘待审批(plan.unattended: approve 则自动批准执行)·
|
|
100
|
-
78 宿主 API 版本不匹配 ·
|
|
101
|
-
130 SIGINT · 143 SIGTERM
|
|
102
|
-
`;
|
|
5
|
+
import { msg } from "../i18n/index.js";
|
|
6
|
+
export function helpText() {
|
|
7
|
+
return msg().cli.help;
|
|
8
|
+
}
|