@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/dist/cli/bootstrap.js
CHANGED
|
@@ -19,13 +19,17 @@ import { loadHookConfigs } from "../hooks/config.js";
|
|
|
19
19
|
import { HookDispatcher } from "../hooks/dispatcher.js";
|
|
20
20
|
import { AgentEventBus, createHostApi } from "../host/api-impl.js";
|
|
21
21
|
import { activateHost, disposeHost } from "../host/loader.js";
|
|
22
|
-
import {
|
|
22
|
+
import { helpText, parseArgs, UsageError } from "./args.js";
|
|
23
23
|
import { applyFromOption } from "./from-prompt.js";
|
|
24
24
|
import { ExitCode } from "./exit-codes.js";
|
|
25
25
|
import { applyProfile, applyToolFilters, decideMode, defaultSendUser, instructionSources, resolveModel, sessionRequestOf, sourceOf, step, thinkingOf, toStartupError, } from "./startup-steps.js";
|
|
26
26
|
import { resolveSystemPromptArg } from "./system-prompt-arg.js";
|
|
27
|
+
import { memoryEnvOverride, resolveMemory } from "./compose-memory.js";
|
|
28
|
+
import { msg, resolveLocale, setLocale } from "../i18n/index.js";
|
|
27
29
|
/** §11.1 第 3–14 步。 */
|
|
28
30
|
export async function bootstrap(argsIn, deps, io) {
|
|
31
|
+
// 文案按调用时的语言取(第 9 步可能按 profile / 项目级 ui.language 补定语言)
|
|
32
|
+
const m = () => msg().cli.bootstrap;
|
|
29
33
|
const warnings = [];
|
|
30
34
|
const warn = (message) => {
|
|
31
35
|
warnings.push(message);
|
|
@@ -43,13 +47,13 @@ export async function bootstrap(argsIn, deps, io) {
|
|
|
43
47
|
const mode = decideMode(args, io);
|
|
44
48
|
const interactive = mode === "interactive" || mode === "line";
|
|
45
49
|
// 5. 目录
|
|
46
|
-
const paths = await step(ExitCode.Config,
|
|
50
|
+
const paths = await step(ExitCode.Config, m().steps.dirs, () => {
|
|
47
51
|
const resolved = resolvePaths({ env: io.env, cwd: io.cwd, sessionDirFlag: args.sessionDir });
|
|
48
52
|
ensurePaths(resolved);
|
|
49
53
|
return resolved;
|
|
50
54
|
});
|
|
51
55
|
// 6. 用户级 + profile.config
|
|
52
|
-
const base = await step(ExitCode.Config,
|
|
56
|
+
const base = await step(ExitCode.Config, m().steps.config, () => {
|
|
53
57
|
const user = loadConfigFile("config", userFile(paths, CONFIG_FILE));
|
|
54
58
|
if (user !== undefined)
|
|
55
59
|
warnings.push(...user.warnings);
|
|
@@ -63,27 +67,27 @@ export async function bootstrap(argsIn, deps, io) {
|
|
|
63
67
|
let request = sessionRequestOf(args);
|
|
64
68
|
if (request === "pick") {
|
|
65
69
|
if (!interactive || deps.ui?.pickSession === undefined || deps.sessions.list === undefined) {
|
|
66
|
-
throw new UsageError(
|
|
70
|
+
throw new UsageError(m().resumeNeedsId);
|
|
67
71
|
}
|
|
68
|
-
const items = await step(ExitCode.Session,
|
|
72
|
+
const items = await step(ExitCode.Session, m().steps.sessionList, () => deps.sessions.list?.({ sessionDir: paths.sessionDir, cwd: paths.cwd }) ?? []);
|
|
69
73
|
const id = await deps.ui.pickSession(items);
|
|
70
74
|
if (id === undefined)
|
|
71
|
-
throw new StartupError("session_not_found",
|
|
75
|
+
throw new StartupError("session_not_found", m().noSessionPicked, ExitCode.Session);
|
|
72
76
|
request = { kind: "resume", id };
|
|
73
77
|
}
|
|
74
78
|
const sessionRequest = request;
|
|
75
|
-
const sessionManager = await step(ExitCode.Session,
|
|
79
|
+
const sessionManager = await step(ExitCode.Session, m().steps.session, () => deps.sessions.open(sessionRequest, { sessionDir: paths.sessionDir, cwd: paths.cwd }));
|
|
76
80
|
let sessionCwd = sessionManager.cwd;
|
|
77
81
|
if (!existsSync(sessionCwd)) {
|
|
78
82
|
const replacement = interactive ? await deps.ui?.askCwd?.(sessionCwd) : undefined;
|
|
79
83
|
if (replacement === undefined) {
|
|
80
|
-
throw new StartupError("session_corrupt",
|
|
84
|
+
throw new StartupError("session_corrupt", m().sessionCwdMissing(sessionCwd), ExitCode.Session);
|
|
81
85
|
}
|
|
82
86
|
sessionCwd = resolve(replacement);
|
|
83
87
|
}
|
|
84
88
|
const runtimePaths = { ...paths, cwd: sessionCwd };
|
|
85
89
|
// 8. 信任(以会话 cwd 为准)
|
|
86
|
-
const trust = await step(ExitCode.Config,
|
|
90
|
+
const trust = await step(ExitCode.Config, m().steps.trust, () => decideTrust({
|
|
87
91
|
cwd: sessionCwd,
|
|
88
92
|
configDir: paths.configDir,
|
|
89
93
|
flag: args.trust,
|
|
@@ -92,7 +96,7 @@ export async function bootstrap(argsIn, deps, io) {
|
|
|
92
96
|
prompt: deps.ui?.promptTrust,
|
|
93
97
|
}));
|
|
94
98
|
// 9. 项目级配置(只能收紧)+ 命令行
|
|
95
|
-
const merged = await step(ExitCode.Config,
|
|
99
|
+
const merged = await step(ExitCode.Config, m().steps.projectConfig, () => {
|
|
96
100
|
const project = loadConfigFile("config", projectFile(sessionCwd, CONFIG_FILE));
|
|
97
101
|
if (project !== undefined)
|
|
98
102
|
warnings.push(...project.warnings);
|
|
@@ -105,16 +109,21 @@ export async function bootstrap(argsIn, deps, io) {
|
|
|
105
109
|
tuiMode: args.tuiMode,
|
|
106
110
|
toolsPreset: args.toolsPreset,
|
|
107
111
|
codemode: args.codemode,
|
|
112
|
+
memory: args.memory ?? memoryEnvOverride(io.env),
|
|
108
113
|
});
|
|
109
114
|
});
|
|
110
115
|
warnings.push(...merged.warnings);
|
|
111
116
|
const config = merged.config;
|
|
117
|
+
// [W6-C0] main.ts 只看了用户级;profile 的 language 与合并后的 ui.language 在这里补定(AMA_LANG / --lang 仍优先)
|
|
118
|
+
const language = profile?.language ?? config.ui?.language;
|
|
119
|
+
if (language === "zh" || language === "en")
|
|
120
|
+
setLocale(resolveLocale(io.env, { language }, args.lang));
|
|
112
121
|
// 10. 资源发现
|
|
113
122
|
const context = findContextFiles({ cwd: sessionCwd, configDir: paths.configDir });
|
|
114
123
|
warnings.push(...context.warnings);
|
|
115
124
|
const discovered = deps.resources === undefined
|
|
116
125
|
? { skills: [], prompts: [], warnings: [] }
|
|
117
|
-
: await step(ExitCode.Config,
|
|
126
|
+
: await step(ExitCode.Config, m().steps.skillDiscovery, () => deps.resources?.discover({
|
|
118
127
|
cwd: sessionCwd,
|
|
119
128
|
configDir: paths.configDir,
|
|
120
129
|
trusted: trust.trusted,
|
|
@@ -139,7 +148,7 @@ export async function bootstrap(argsIn, deps, io) {
|
|
|
139
148
|
instructions,
|
|
140
149
|
};
|
|
141
150
|
// 11. 供应商与模型
|
|
142
|
-
const providers = await step(ExitCode.Config,
|
|
151
|
+
const providers = await step(ExitCode.Config, m().steps.providers, () => deps.providers.create({
|
|
143
152
|
config,
|
|
144
153
|
cwd: sessionCwd,
|
|
145
154
|
authFile: args.authFile !== undefined
|
|
@@ -157,18 +166,25 @@ export async function bootstrap(argsIn, deps, io) {
|
|
|
157
166
|
}
|
|
158
167
|
: {}),
|
|
159
168
|
}));
|
|
160
|
-
const { model, provider } = await step(ExitCode.NoModel,
|
|
169
|
+
const { model, provider } = await step(ExitCode.NoModel, m().steps.model, () => resolveModel(args, providers, sessionManager, config.defaultModel, deps, interactive, io.env));
|
|
161
170
|
const thinkingLevel = thinkingOf(args, sessionManager, config.thinkingLevel);
|
|
162
171
|
// 12. 工具注册表
|
|
163
|
-
const tools = await step(ExitCode.RuntimeError,
|
|
172
|
+
const tools = await step(ExitCode.RuntimeError, m().steps.tools, () => deps.tools.create({
|
|
164
173
|
config,
|
|
165
174
|
cwd: sessionCwd,
|
|
166
175
|
mode,
|
|
167
176
|
paths: { configDir: paths.configDir, dataDir: paths.dataDir },
|
|
177
|
+
memory: resolveMemory({
|
|
178
|
+
config,
|
|
179
|
+
cwd: sessionCwd,
|
|
180
|
+
dataDir: paths.dataDir,
|
|
181
|
+
trusted: trust.trusted,
|
|
182
|
+
embedded: profile,
|
|
183
|
+
}),
|
|
168
184
|
}));
|
|
169
185
|
for (const name of config.tools?.disabled ?? []) {
|
|
170
186
|
if (tools.get(name) === undefined)
|
|
171
|
-
warn(
|
|
187
|
+
warn(m().unknownDisabledTool(name));
|
|
172
188
|
else
|
|
173
189
|
tools.disable(name);
|
|
174
190
|
}
|
|
@@ -176,7 +192,7 @@ export async function bootstrap(argsIn, deps, io) {
|
|
|
176
192
|
let session;
|
|
177
193
|
const events = new AgentEventBus((level, message, detail) => {
|
|
178
194
|
if (level === "warn" || level === "error")
|
|
179
|
-
warn(
|
|
195
|
+
warn(m().eventWarning(message, detail instanceof Error ? detail.message : undefined));
|
|
180
196
|
});
|
|
181
197
|
const binding = createHostApi({
|
|
182
198
|
mode,
|
|
@@ -191,7 +207,7 @@ export async function bootstrap(argsIn, deps, io) {
|
|
|
191
207
|
bus: events,
|
|
192
208
|
sendUser: (text, origin) => {
|
|
193
209
|
if (session === undefined)
|
|
194
|
-
return Promise.reject(new AmaError("busy",
|
|
210
|
+
return Promise.reject(new AmaError("busy", m().sessionNotReady));
|
|
195
211
|
return (deps.sendUser ?? defaultSendUser)(session, text, origin);
|
|
196
212
|
},
|
|
197
213
|
stderr: io.stderr,
|
|
@@ -200,7 +216,7 @@ export async function bootstrap(argsIn, deps, io) {
|
|
|
200
216
|
const hostSpec = args.host;
|
|
201
217
|
let host;
|
|
202
218
|
if (hostSpec !== undefined) {
|
|
203
|
-
host = await step(ExitCode.HostOrHook,
|
|
219
|
+
host = await step(ExitCode.HostOrHook, m().steps.host, () => activateHost({ module: hostSpec, binding, cwd: io.cwd }));
|
|
204
220
|
}
|
|
205
221
|
let shutdown;
|
|
206
222
|
try {
|
|
@@ -209,7 +225,7 @@ export async function bootstrap(argsIn, deps, io) {
|
|
|
209
225
|
const unattended = mode === "print";
|
|
210
226
|
const builtinDeny = config.permission?.builtinDeny;
|
|
211
227
|
const autoSafeCommands = config.permission?.autoSafeCommands;
|
|
212
|
-
const permission = await step(ExitCode.Config,
|
|
228
|
+
const permission = await step(ExitCode.Config, m().steps.permission, () => deps.permissions.create({
|
|
213
229
|
mode: config.permission?.mode ?? "default",
|
|
214
230
|
rules: merged.ruleSpecs,
|
|
215
231
|
unattended,
|
|
@@ -285,14 +301,14 @@ export async function bootstrap(argsIn, deps, io) {
|
|
|
285
301
|
overrides.systemPrompt = systemPrompt;
|
|
286
302
|
if (Object.keys(overrides).length > 0)
|
|
287
303
|
assembly.overrides = overrides;
|
|
288
|
-
session = await step(ExitCode.RuntimeError,
|
|
304
|
+
session = await step(ExitCode.RuntimeError, m().steps.assembly, () => deps.session.create(assembly));
|
|
289
305
|
const active = session;
|
|
290
306
|
let disposed;
|
|
291
307
|
shutdown = (reason) => {
|
|
292
308
|
disposed ??= (async () => {
|
|
293
309
|
await events.emit("session_shutdown", {});
|
|
294
310
|
await hooks.run("SessionEnd", { reason }).catch(() => undefined);
|
|
295
|
-
await disposeHost(host, (e) => warn(
|
|
311
|
+
await disposeHost(host, (e) => warn(m().hostDisposeFailed(String(e))));
|
|
296
312
|
// 会话被替换过时 dispose 当前那个(旧会话由替换方负责)
|
|
297
313
|
await (session ?? active).dispose();
|
|
298
314
|
})();
|
|
@@ -306,14 +322,18 @@ export async function bootstrap(argsIn, deps, io) {
|
|
|
306
322
|
});
|
|
307
323
|
const outcome = await hooks.run("SessionStart", { source });
|
|
308
324
|
if (outcome.decision === "block") {
|
|
309
|
-
throw new StartupError("hook_failed",
|
|
325
|
+
throw new StartupError("hook_failed", m().sessionStartBlocked(outcome.reason), ExitCode.HostOrHook);
|
|
310
326
|
}
|
|
311
327
|
sessionStartContext = outcome.additionalContext;
|
|
312
328
|
const finalShutdown = shutdown;
|
|
313
329
|
return {
|
|
314
330
|
mode,
|
|
315
331
|
paths: runtimePaths,
|
|
316
|
-
config
|
|
332
|
+
// [W6-S] /config 换配置:getter 跟随 assembly.config(/new 组装会话读它)
|
|
333
|
+
get config() {
|
|
334
|
+
return assembly.config;
|
|
335
|
+
},
|
|
336
|
+
replaceConfig: (next) => void (assembly.config = next),
|
|
317
337
|
trust,
|
|
318
338
|
resources,
|
|
319
339
|
providers,
|
|
@@ -340,7 +360,7 @@ export async function bootstrap(argsIn, deps, io) {
|
|
|
340
360
|
await shutdown("exit").catch(() => undefined);
|
|
341
361
|
else
|
|
342
362
|
await disposeHost(host);
|
|
343
|
-
throw toStartupError(error, ExitCode.RuntimeError,
|
|
363
|
+
throw toStartupError(error, ExitCode.RuntimeError, m().steps.startup);
|
|
344
364
|
}
|
|
345
365
|
}
|
|
346
366
|
/** 非交互模式接管 stdout:console.log / info / debug 改写到 stderr;返回还原函数。 */
|
|
@@ -362,14 +382,14 @@ export async function runCli(argv, deps, io) {
|
|
|
362
382
|
try {
|
|
363
383
|
const parsed = parseArgs(argv);
|
|
364
384
|
if (parsed.kind !== "run")
|
|
365
|
-
throw new UsageError(
|
|
385
|
+
throw new UsageError(msg().cli.bootstrap.subcommandNotDispatched);
|
|
366
386
|
args = parsed.args;
|
|
367
387
|
}
|
|
368
388
|
catch (error) {
|
|
369
389
|
return reportError(error, io);
|
|
370
390
|
}
|
|
371
391
|
if (args.help) {
|
|
372
|
-
io.stdout(
|
|
392
|
+
io.stdout(helpText());
|
|
373
393
|
return ExitCode.Ok;
|
|
374
394
|
}
|
|
375
395
|
// [W5-E] --mode acp:装配同 rpc(宿主看到的 mode 也是 rpc),分派到 ACP 服务端
|
|
@@ -377,7 +397,7 @@ export async function runCli(argv, deps, io) {
|
|
|
377
397
|
if (acp)
|
|
378
398
|
args = { ...args, mode: "rpc" };
|
|
379
399
|
if (deps === undefined) {
|
|
380
|
-
io.stderr(
|
|
400
|
+
io.stderr(msg().cli.bootstrap.runtimeNotAssembled);
|
|
381
401
|
return ExitCode.RuntimeError;
|
|
382
402
|
}
|
|
383
403
|
let runtime;
|
|
@@ -392,7 +412,7 @@ export async function runCli(argv, deps, io) {
|
|
|
392
412
|
try {
|
|
393
413
|
if (runtime.mode !== "interactive")
|
|
394
414
|
for (const w of runtime.warnings)
|
|
395
|
-
io.stderr(
|
|
415
|
+
io.stderr(msg().cli.bootstrap.warning(w));
|
|
396
416
|
// [W4-D] --from:旧会话的一条用户消息作提示(-p 时连图片,临时文件在 finally 删除)。
|
|
397
417
|
const from = applyFromOption(args, runtime, io);
|
|
398
418
|
cleanupFrom = from.cleanup;
|
|
@@ -401,7 +421,9 @@ export async function runCli(argv, deps, io) {
|
|
|
401
421
|
? (await import("../modes/acp/acp-mode.js")).runAcpMode
|
|
402
422
|
: deps.modes[runtime.mode];
|
|
403
423
|
if (runner === undefined)
|
|
404
|
-
throw new AmaError("not_implemented",
|
|
424
|
+
throw new AmaError("not_implemented", msg().cli.bootstrap.modeNotAssembled(runtime.mode), {
|
|
425
|
+
exitCode: 1,
|
|
426
|
+
});
|
|
405
427
|
try {
|
|
406
428
|
return await runner(runtime, context);
|
|
407
429
|
}
|
|
@@ -409,7 +431,7 @@ export async function runCli(argv, deps, io) {
|
|
|
409
431
|
const line = deps.modes.line;
|
|
410
432
|
if (runtime.mode !== "interactive" || !isTerminalInitError(error) || line === undefined)
|
|
411
433
|
throw error;
|
|
412
|
-
io.stderr(
|
|
434
|
+
io.stderr(msg().cli.bootstrap.terminalFallback(error.message));
|
|
413
435
|
return await line(runtime, context);
|
|
414
436
|
}
|
|
415
437
|
}
|
|
@@ -424,7 +446,7 @@ export async function runCli(argv, deps, io) {
|
|
|
424
446
|
}
|
|
425
447
|
export function reportError(error, io, fallback = ExitCode.RuntimeError) {
|
|
426
448
|
if (error instanceof UsageError) {
|
|
427
|
-
io.stderr(
|
|
449
|
+
io.stderr(msg().cli.bootstrap.usageError(error.message));
|
|
428
450
|
return ExitCode.Usage;
|
|
429
451
|
}
|
|
430
452
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { createInterface } from "node:readline/promises";
|
|
12
12
|
import { createTheme, defaultKeybindings, detectCapabilities, padToWidth, resolveAscii, visibleWidth, } from "../tui.js";
|
|
13
|
+
import { msg } from "../i18n/index.js";
|
|
13
14
|
const HIDE_CURSOR = "\x1b[?25l";
|
|
14
15
|
const SHOW_CURSOR = "\x1b[?25h";
|
|
15
16
|
/** 能否用方向键选择:输入是 TTY 且能开 raw。 */
|
|
@@ -45,7 +46,7 @@ export function promptChoice(options) {
|
|
|
45
46
|
const keys = item.keys === undefined ? "" : ` ${theme.fg("dim", item.keys.padEnd(keyWidth))}`;
|
|
46
47
|
return (on ? theme.fg("accent", theme.bold(left)) : left) + keys;
|
|
47
48
|
}),
|
|
48
|
-
theme.fg("dim", `${g.arrowUp}${g.arrowDown}
|
|
49
|
+
theme.fg("dim", msg().cli.choicePrompt.hint(`${g.arrowUp}${g.arrowDown}`, n)),
|
|
49
50
|
];
|
|
50
51
|
const draw = (lines) => {
|
|
51
52
|
const up = drawn > 0 ? `\x1b[${drawn}A` : "";
|
|
@@ -66,7 +67,7 @@ export function promptChoice(options) {
|
|
|
66
67
|
input.off("data", onData);
|
|
67
68
|
input.off("end", onEnd);
|
|
68
69
|
process.off("exit", restore);
|
|
69
|
-
const answer = index === undefined ?
|
|
70
|
+
const answer = index === undefined ? msg().cli.choicePrompt.cancelled : items[index].label;
|
|
70
71
|
draw([`${question} ${theme.fg("dim", answer)}`]);
|
|
71
72
|
restore();
|
|
72
73
|
input.pause?.();
|
|
@@ -113,14 +114,15 @@ export function promptChoice(options) {
|
|
|
113
114
|
* 否则回落为文本 `继续?[y/N]`(只有 y / yes 算同意)。
|
|
114
115
|
*/
|
|
115
116
|
export async function confirmContinue(options = {}) {
|
|
116
|
-
const
|
|
117
|
+
const m = msg().cli.choicePrompt;
|
|
118
|
+
const question = options.question ?? m.continueQuestion;
|
|
117
119
|
const input = options.input ?? process.stdin;
|
|
118
120
|
if (canPromptChoice(input)) {
|
|
119
121
|
const index = await promptChoice({
|
|
120
122
|
question,
|
|
121
123
|
options: [
|
|
122
|
-
{ label:
|
|
123
|
-
{ label:
|
|
124
|
+
{ label: m.continue, keys: "y" },
|
|
125
|
+
{ label: m.cancel, keys: "n Esc" },
|
|
124
126
|
],
|
|
125
127
|
selected: 1,
|
|
126
128
|
input,
|
|
@@ -132,7 +134,7 @@ export async function confirmContinue(options = {}) {
|
|
|
132
134
|
}
|
|
133
135
|
const rl = createInterface({ input, output: options.output ?? process.stderr });
|
|
134
136
|
try {
|
|
135
|
-
return /^y(es)?$/i.test((await rl.question(
|
|
137
|
+
return /^y(es)?$/i.test((await rl.question(m.textQuestion(question))).trim());
|
|
136
138
|
}
|
|
137
139
|
finally {
|
|
138
140
|
rl.close();
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
12
12
|
import { join } from "node:path";
|
|
13
13
|
import { resolveCodemodeMode } from "../tools/presets.js";
|
|
14
|
+
import { msg } from "../i18n/index.js";
|
|
14
15
|
export const NOTICES_FILE = "notices.json";
|
|
15
16
|
const KEY = "codemodeNonStrictDefault";
|
|
16
17
|
function readNotices(path) {
|
|
@@ -30,8 +31,7 @@ function readNotices(path) {
|
|
|
30
31
|
return { version: 1 };
|
|
31
32
|
}
|
|
32
33
|
export function codemodeNoticeText(capability) {
|
|
33
|
-
return (
|
|
34
|
-
"用 `--codemode on` 或 config 的 codemode.mode 开启(每个配置目录只提示一次)");
|
|
34
|
+
return msg().cli.codemodeNotice(capability.nodeMajor);
|
|
35
35
|
}
|
|
36
36
|
/** 需要提示时返回文案并记下(之后同一配置目录不再提示);不需要时 undefined。 */
|
|
37
37
|
export function takeCodemodeNotice(input) {
|
|
@@ -18,6 +18,7 @@ import { agentSources, discoverAgents } from "../agents/discover.js";
|
|
|
18
18
|
import { NO_AGENT_PROBE_ENV, SessionExternalAgents, registerExternalAgents, } from "../agents/external.js";
|
|
19
19
|
import { hostRunnersOf } from "../host/api-impl.js";
|
|
20
20
|
import { bindTaskAgents } from "../tools/task.js";
|
|
21
|
+
import { msg } from "../i18n/index.js";
|
|
21
22
|
/** 同一装配材料只提示一次(`/new` 等会重新装配会话)。 */
|
|
22
23
|
const warned = new WeakSet();
|
|
23
24
|
export function loadAgentCatalog(deps) {
|
|
@@ -33,7 +34,7 @@ export function loadAgentCatalog(deps) {
|
|
|
33
34
|
for (const warning of found.warnings)
|
|
34
35
|
assembly.warn(warning);
|
|
35
36
|
for (const dir of found.skippedUntrusted)
|
|
36
|
-
assembly.warn(
|
|
37
|
+
assembly.warn(msg().cli.composeAgents.untrustedAgentDir(dir));
|
|
37
38
|
}
|
|
38
39
|
return new AgentCatalog(found.agents);
|
|
39
40
|
}
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* 配置从 `deps.assembly.config` 读(键与校验已在 config/schema-w5.ts,C0 统一加好)。
|
|
20
20
|
*/
|
|
21
21
|
import { telemetryFactory } from "../agent/session-telemetry.js";
|
|
22
|
+
import { traceWriterFactory } from "../agent/session-trace-writer.js";
|
|
22
23
|
import { createImageBudgetExtension } from "../agent/session-images.js";
|
|
23
24
|
import { createLimitsExtension } from "../agent/limits.js";
|
|
24
25
|
import { createRemindersExtension, remindersSettings } from "../agent/reminders.js";
|
|
@@ -37,6 +38,7 @@ export function composeExtensions(deps) {
|
|
|
37
38
|
({ core }) => createImageBudgetExtension(core),
|
|
38
39
|
// [W5-A] createTelemetryExtension(...)
|
|
39
40
|
telemetryFactory(deps.assembly.config.ui),
|
|
41
|
+
traceWriterFactory(), // [W6-C0] ama.trace(主会话与子会话都写)
|
|
40
42
|
// [W5-E] 外部 Agent 记账 → SessionStats.external(只主会话)
|
|
41
43
|
({ core }) => core.depth > 0 ? undefined : createExternalStatsExtension(() => core.manager.branch()),
|
|
42
44
|
createSubagentsFactory(deps), // [W5-G] 子 Agent 任务注册表
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 记忆的组装(docs/wave6-plan.md §3、D8、D9、D11、D12)。[W6-M]
|
|
3
|
+
*
|
|
4
|
+
* - 开关:独立终端看合并后的 `memory.enabled`(用户级 / profile.config;项目级只能设 false;`--memory` /
|
|
5
|
+
* `--no-memory`;`AMA_MEMORY=0|1` 经 bootstrap 并入命令行覆盖,命令行优先)。缺省关闭:不建运行期、不读盘、
|
|
6
|
+
* 不注册工具、不渲染节。
|
|
7
|
+
* - 嵌入宿主(有 profile;SDK `createAgentSession`):只看 `profile.memory = { enabled, dir }`,作用域只有
|
|
8
|
+
* `workspace`(= dir),不读用户级;合并配置里显式 `memory.enabled: false`(项目级、`--no-memory`、
|
|
9
|
+
* `AMA_MEMORY=0`)仍可关掉。
|
|
10
|
+
* - 项目作用域要求项目已受信任,否则跳过(`/memory` 提示)。
|
|
11
|
+
* - 系统节:会话开始(新会话)渲染一次;resume / fork 沿用会话里已有的 `memory` 节;压缩结束后重渲染
|
|
12
|
+
* (`compaction_end` 时 `updateSystem`,压缩本就是前缀重置点);`/memory reload` 显式重渲染。
|
|
13
|
+
*/
|
|
14
|
+
import type { AgentSessionImpl } from "../agent/session.js";
|
|
15
|
+
import type { AgentSession } from "../agent/types.js";
|
|
16
|
+
import type { AmaConfig, ProfileMemoryOptions } from "../config/types.js";
|
|
17
|
+
import { MemoryRuntime } from "../memory/runtime.js";
|
|
18
|
+
import type { SessionManager } from "../session/manager.js";
|
|
19
|
+
/** `AMA_MEMORY=0|1`(也认 true / false / on / off);其它值或未设 → undefined。 */
|
|
20
|
+
export declare function memoryEnvOverride(env: Readonly<Record<string, string | undefined>>): boolean | undefined;
|
|
21
|
+
export interface MemorySetupInput {
|
|
22
|
+
config: Pick<AmaConfig, "memory">;
|
|
23
|
+
cwd: string;
|
|
24
|
+
dataDir: string;
|
|
25
|
+
trusted: boolean;
|
|
26
|
+
/** 嵌入宿主:profile 存在(或 SDK 会话)时给出(`memory` 可缺省 = 禁用)。 */
|
|
27
|
+
embedded?: {
|
|
28
|
+
memory?: ProfileMemoryOptions | undefined;
|
|
29
|
+
} | undefined;
|
|
30
|
+
today?(): string;
|
|
31
|
+
}
|
|
32
|
+
/** 按配置建运行期;关闭时返回 undefined(什么都不做)。 */
|
|
33
|
+
export declare function resolveMemory(input: MemorySetupInput): MemoryRuntime | undefined;
|
|
34
|
+
/** 会话的记忆运行期(未开启 → undefined)。 */
|
|
35
|
+
export declare function memoryOf(session: AgentSession): MemoryRuntime | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* 新会话渲染当前索引;会话里已有 system 状态(resume / fork)时沿用其中的 `memory` 节(可能没有)。
|
|
38
|
+
* 未开启 → undefined。
|
|
39
|
+
*/
|
|
40
|
+
export declare function initialMemorySection(runtime: MemoryRuntime | undefined, manager: Pick<SessionManager, "branch">): string | undefined;
|
|
41
|
+
/** 把 `memory` 节并进静态系统输入(未开启时原样返回同一对象,字节不变)。 */
|
|
42
|
+
export declare function withMemorySection<T extends {
|
|
43
|
+
memory?: string;
|
|
44
|
+
}>(system: T, runtime: MemoryRuntime | undefined, manager: Pick<SessionManager, "branch">): T;
|
|
45
|
+
/** 会话建好后:登记运行期,压缩结束后重渲染 `memory` 节。 */
|
|
46
|
+
export declare function attachMemory(session: AgentSessionImpl, runtime: MemoryRuntime | undefined): void;
|
|
47
|
+
/**
|
|
48
|
+
* `/memory reload`:按磁盘重渲染 `memory` 节。返回 undefined = 会话未开启记忆;`changed` = 节有变化
|
|
49
|
+
* (下次请求产生一条 system 补丁,缓存前缀断一次)。
|
|
50
|
+
*/
|
|
51
|
+
export declare function reloadMemorySection(session: AgentSession): {
|
|
52
|
+
changed: boolean;
|
|
53
|
+
} | undefined;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 记忆的组装(docs/wave6-plan.md §3、D8、D9、D11、D12)。[W6-M]
|
|
3
|
+
*
|
|
4
|
+
* - 开关:独立终端看合并后的 `memory.enabled`(用户级 / profile.config;项目级只能设 false;`--memory` /
|
|
5
|
+
* `--no-memory`;`AMA_MEMORY=0|1` 经 bootstrap 并入命令行覆盖,命令行优先)。缺省关闭:不建运行期、不读盘、
|
|
6
|
+
* 不注册工具、不渲染节。
|
|
7
|
+
* - 嵌入宿主(有 profile;SDK `createAgentSession`):只看 `profile.memory = { enabled, dir }`,作用域只有
|
|
8
|
+
* `workspace`(= dir),不读用户级;合并配置里显式 `memory.enabled: false`(项目级、`--no-memory`、
|
|
9
|
+
* `AMA_MEMORY=0`)仍可关掉。
|
|
10
|
+
* - 项目作用域要求项目已受信任,否则跳过(`/memory` 提示)。
|
|
11
|
+
* - 系统节:会话开始(新会话)渲染一次;resume / fork 沿用会话里已有的 `memory` 节;压缩结束后重渲染
|
|
12
|
+
* (`compaction_end` 时 `updateSystem`,压缩本就是前缀重置点);`/memory reload` 显式重渲染。
|
|
13
|
+
*/
|
|
14
|
+
import { AmaError } from "../errors.js";
|
|
15
|
+
import { projectRootOf, standaloneRoots } from "../memory/paths.js";
|
|
16
|
+
import { MemoryRuntime } from "../memory/runtime.js";
|
|
17
|
+
import { DEFAULT_MEMORY_LIMITS, MemoryStore } from "../memory/store.js";
|
|
18
|
+
import { replaySystem } from "../session/projection.js";
|
|
19
|
+
/** `AMA_MEMORY=0|1`(也认 true / false / on / off);其它值或未设 → undefined。 */
|
|
20
|
+
export function memoryEnvOverride(env) {
|
|
21
|
+
const raw = env["AMA_MEMORY"]?.trim().toLowerCase();
|
|
22
|
+
if (raw === "1" || raw === "true" || raw === "on")
|
|
23
|
+
return true;
|
|
24
|
+
if (raw === "0" || raw === "false" || raw === "off")
|
|
25
|
+
return false;
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
/** 按配置建运行期;关闭时返回 undefined(什么都不做)。 */
|
|
29
|
+
export function resolveMemory(input) {
|
|
30
|
+
const config = input.config.memory ?? {};
|
|
31
|
+
const limits = {
|
|
32
|
+
indexMaxBytes: config.indexMaxBytes ?? DEFAULT_MEMORY_LIMITS.indexMaxBytes,
|
|
33
|
+
fileMaxBytes: config.fileMaxBytes ?? DEFAULT_MEMORY_LIMITS.fileMaxBytes,
|
|
34
|
+
maxFiles: config.maxFiles ?? DEFAULT_MEMORY_LIMITS.maxFiles,
|
|
35
|
+
};
|
|
36
|
+
const subagents = config.subagents ?? "read";
|
|
37
|
+
const storeOptions = input.today === undefined ? {} : { today: input.today };
|
|
38
|
+
if (input.embedded !== undefined) {
|
|
39
|
+
const profile = input.embedded.memory;
|
|
40
|
+
if (profile?.enabled !== true || config.enabled === false)
|
|
41
|
+
return undefined;
|
|
42
|
+
if (profile.dir === undefined || profile.dir === "")
|
|
43
|
+
throw new AmaError("invalid_arguments", "memory.enabled is true but memory.dir is missing (embedded hosts must give a per-workspace directory)");
|
|
44
|
+
const roots = { workspace: profile.dir };
|
|
45
|
+
return new MemoryRuntime(new MemoryStore(roots, limits, storeOptions), {
|
|
46
|
+
subagents,
|
|
47
|
+
embedded: true,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (config.enabled !== true)
|
|
51
|
+
return undefined;
|
|
52
|
+
const scopes = config.scopes ?? ["user", "project"];
|
|
53
|
+
const skipped = [];
|
|
54
|
+
let projectRoot;
|
|
55
|
+
if (scopes.includes("project")) {
|
|
56
|
+
if (input.trusted)
|
|
57
|
+
projectRoot = projectRootOf(input.cwd);
|
|
58
|
+
else
|
|
59
|
+
skipped.push({ scope: "project", reason: "untrusted" });
|
|
60
|
+
}
|
|
61
|
+
const roots = standaloneRoots({
|
|
62
|
+
dataDir: input.dataDir,
|
|
63
|
+
projectRoot,
|
|
64
|
+
user: scopes.includes("user"),
|
|
65
|
+
});
|
|
66
|
+
const store = new MemoryStore(roots, limits, {
|
|
67
|
+
...storeOptions,
|
|
68
|
+
...(projectRoot === undefined ? {} : { projectRoot }),
|
|
69
|
+
});
|
|
70
|
+
return new MemoryRuntime(store, {
|
|
71
|
+
subagents,
|
|
72
|
+
embedded: false,
|
|
73
|
+
skipped,
|
|
74
|
+
...(projectRoot === undefined ? {} : { projectRoot }),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
const attached = new WeakMap();
|
|
78
|
+
/** 会话的记忆运行期(未开启 → undefined)。 */
|
|
79
|
+
export function memoryOf(session) {
|
|
80
|
+
return attached.get(session);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* 新会话渲染当前索引;会话里已有 system 状态(resume / fork)时沿用其中的 `memory` 节(可能没有)。
|
|
84
|
+
* 未开启 → undefined。
|
|
85
|
+
*/
|
|
86
|
+
export function initialMemorySection(runtime, manager) {
|
|
87
|
+
if (runtime === undefined)
|
|
88
|
+
return undefined;
|
|
89
|
+
const messages = manager
|
|
90
|
+
.branch()
|
|
91
|
+
.flatMap((entry) => (entry.type === "message" ? [entry.message] : []));
|
|
92
|
+
const existing = replaySystem(messages);
|
|
93
|
+
if (existing !== undefined)
|
|
94
|
+
return existing.sections["memory"];
|
|
95
|
+
return runtime.renderSection();
|
|
96
|
+
}
|
|
97
|
+
/** 把 `memory` 节并进静态系统输入(未开启时原样返回同一对象,字节不变)。 */
|
|
98
|
+
export function withMemorySection(system, runtime, manager) {
|
|
99
|
+
const section = initialMemorySection(runtime, manager);
|
|
100
|
+
return section === undefined ? system : { ...system, memory: section };
|
|
101
|
+
}
|
|
102
|
+
/** 会话建好后:登记运行期,压缩结束后重渲染 `memory` 节。 */
|
|
103
|
+
export function attachMemory(session, runtime) {
|
|
104
|
+
if (runtime === undefined)
|
|
105
|
+
return;
|
|
106
|
+
attached.set(session, runtime);
|
|
107
|
+
session.subscribe((event) => {
|
|
108
|
+
if (event.type === "compaction_end" && event.result !== undefined)
|
|
109
|
+
session.updateSystem({ memory: runtime.renderSection() ?? "" });
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* `/memory reload`:按磁盘重渲染 `memory` 节。返回 undefined = 会话未开启记忆;`changed` = 节有变化
|
|
114
|
+
* (下次请求产生一条 system 补丁,缓存前缀断一次)。
|
|
115
|
+
*/
|
|
116
|
+
export function reloadMemorySection(session) {
|
|
117
|
+
const runtime = memoryOf(session);
|
|
118
|
+
if (runtime === undefined)
|
|
119
|
+
return undefined;
|
|
120
|
+
const impl = session;
|
|
121
|
+
const before = impl.childBase().system?.memory;
|
|
122
|
+
const next = runtime.renderSection() ?? "";
|
|
123
|
+
if ((before ?? "") === next)
|
|
124
|
+
return { changed: false };
|
|
125
|
+
impl.updateSystem({ memory: next });
|
|
126
|
+
return { changed: true };
|
|
127
|
+
}
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
* - SDK 追加的供应商(`ProviderData[]`)折成 `config.providers` 条目,走同一条合并路径。
|
|
10
10
|
* - 零配置(设计 §10.0):没有 `defaultModel`、也没有任何需要 key 的供应商配了 key 时,探测本地
|
|
11
11
|
* ollama / lmstudio(短超时),把枚举到的模型加进注册表,供 `pickDefaultModel` 选用。
|
|
12
|
+
* - [W6-O] ChatGPT 登录(docs/wave6-plan.md D14):`chatgpt` 的缺省渠道按 auth.json 条目的 flavor 定(用户写了
|
|
13
|
+
* `defaultChannel` 时不动);`AMA_CHATGPT_BASE_URL` 改该渠道地址;`auth.chatgpt.originator` 改 codex 渠道的
|
|
14
|
+
* `originator` 头;OAuth 刷新拿到 `auth.chatgpt` 配置与同一份 env。
|
|
15
|
+
* - 发现缓存(`<dataDir>/models/discovered/<provider>.json`)并入模型表为空的供应商(discovered-cache.ts)。
|
|
12
16
|
*/
|
|
13
17
|
import type { ApiRegistry } from "../ai/apis/api.js";
|
|
14
18
|
import { ProviderRegistry } from "../ai/providers/registry.js";
|
|
@@ -32,6 +36,8 @@ export interface ProviderComposeOptions {
|
|
|
32
36
|
}
|
|
33
37
|
export declare function providerConfigOf(provider: ProviderData): ProviderConfig;
|
|
34
38
|
export declare function withExtraProviders(config: AmaConfig, providers: readonly ProviderData[] | undefined): AmaConfig;
|
|
39
|
+
/** [W6-O] 按 auth.json 的 ChatGPT 条目与 `AMA_CHATGPT_BASE_URL` / `auth.chatgpt.originator` 补 chatgpt 的渠道配置。 */
|
|
40
|
+
export declare function withChatGptChannels(config: AmaConfig, authFile: string, env: Readonly<Record<string, string | undefined>>): AmaConfig;
|
|
35
41
|
export declare function buildProviderRegistry(input: ProviderBuildInput, options?: ProviderComposeOptions): Promise<ProviderRegistry>;
|
|
36
42
|
/** 本地服务(无需 key、模型表为空)的模型枚举;连不上静默跳过。 */
|
|
37
43
|
export declare function probeLocalProviders(registry: ProviderRegistry, timeoutMs?: number): Promise<string[]>;
|