@armadra/agent 0.3.0 → 0.5.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 +257 -0
- package/README.md +263 -95
- package/THIRD_PARTY_NOTICES.md +34 -0
- package/dist/acp.d.ts +18 -0
- package/dist/acp.js +19 -0
- package/dist/agent/limits.d.ts +38 -0
- package/dist/agent/limits.js +127 -0
- package/dist/agent/loop-guard.d.ts +38 -0
- package/dist/agent/loop-guard.js +95 -0
- package/dist/agent/loop.d.ts +4 -0
- package/dist/agent/loop.js +7 -0
- package/dist/agent/prompt-rules.d.ts +12 -0
- package/dist/agent/prompt-rules.js +18 -0
- package/dist/agent/reminders.d.ts +59 -0
- package/dist/agent/reminders.js +327 -0
- package/dist/agent/retry.d.ts +1 -1
- package/dist/agent/retry.js +2 -1
- package/dist/agent/session-cache.d.ts +5 -0
- package/dist/agent/session-cache.js +18 -2
- package/dist/agent/session-classifier.d.ts +18 -0
- package/dist/agent/session-classifier.js +105 -0
- package/dist/agent/session-compaction.d.ts +35 -6
- package/dist/agent/session-compaction.js +157 -31
- package/dist/agent/session-core.d.ts +40 -1
- package/dist/agent/session-extensions.d.ts +61 -0
- package/dist/agent/session-extensions.js +129 -0
- package/dist/agent/session-images.d.ts +23 -0
- package/dist/agent/session-images.js +97 -0
- package/dist/agent/session-plan.d.ts +21 -0
- package/dist/agent/session-plan.js +524 -0
- package/dist/agent/session-rewind.d.ts +81 -0
- package/dist/agent/session-rewind.js +354 -0
- package/dist/agent/session-run.d.ts +28 -1
- package/dist/agent/session-run.js +157 -6
- package/dist/agent/session-settings.d.ts +49 -0
- package/dist/agent/session-settings.js +95 -0
- package/dist/agent/session-subagent.d.ts +36 -24
- package/dist/agent/session-subagent.js +259 -129
- package/dist/agent/session-sync.d.ts +10 -3
- package/dist/agent/session-sync.js +37 -8
- package/dist/agent/session-telemetry.d.ts +39 -0
- package/dist/agent/session-telemetry.js +231 -0
- package/dist/agent/session-tools.js +63 -3
- package/dist/agent/session.d.ts +33 -29
- package/dist/agent/session.js +91 -126
- package/dist/agent/subagent-registry.d.ts +91 -0
- package/dist/agent/subagent-registry.js +494 -0
- package/dist/agent/system-prompt.d.ts +6 -3
- package/dist/agent/system-prompt.js +7 -2
- package/dist/agent/tool-runner.d.ts +8 -1
- package/dist/agent/tool-runner.js +72 -6
- package/dist/agent/types-w5.d.ts +192 -0
- package/dist/agent/types-w5.js +10 -0
- package/dist/agent/types.d.ts +55 -4
- package/dist/agent/types.js +2 -0
- package/dist/agent/worktree.d.ts +36 -0
- package/dist/agent/worktree.js +86 -0
- package/dist/agents/builtin.d.ts +14 -0
- package/dist/agents/builtin.js +39 -0
- package/dist/agents/catalog.d.ts +43 -0
- package/dist/agents/catalog.js +82 -0
- package/dist/agents/discover.d.ts +35 -0
- package/dist/agents/discover.js +83 -0
- package/dist/agents/external.d.ts +82 -0
- package/dist/agents/external.js +326 -0
- package/dist/agents/parse.d.ts +18 -0
- package/dist/agents/parse.js +116 -0
- package/dist/agents/result.d.ts +32 -0
- package/dist/agents/result.js +67 -0
- package/dist/agents/task-control.d.ts +17 -0
- package/dist/agents/task-control.js +17 -0
- package/dist/agents/task-record.d.ts +78 -0
- package/dist/agents/task-record.js +141 -0
- package/dist/agents/types.d.ts +46 -0
- package/dist/agents/types.js +8 -0
- package/dist/ai/apis/anthropic-compat.d.ts +36 -0
- package/dist/ai/apis/anthropic-compat.js +92 -0
- package/dist/ai/apis/anthropic-messages.js +3 -2
- package/dist/ai/apis/anthropic-request.d.ts +7 -6
- package/dist/ai/apis/anthropic-request.js +10 -28
- package/dist/ai/apis/cache-params.d.ts +11 -2
- package/dist/ai/apis/cache-params.js +25 -6
- package/dist/ai/apis/google-generative-ai.js +3 -2
- package/dist/ai/apis/openai-compat.d.ts +4 -1
- package/dist/ai/apis/openai-compat.js +8 -1
- package/dist/ai/apis/openai-completions.js +3 -2
- package/dist/ai/apis/openai-responses.js +3 -2
- package/dist/ai/http.d.ts +28 -6
- package/dist/ai/http.js +41 -8
- package/dist/ai/image-limits.d.ts +45 -0
- package/dist/ai/image-limits.js +68 -0
- package/dist/ai/providers/builtin.d.ts +18 -6
- package/dist/ai/providers/builtin.js +135 -6
- package/dist/ai/providers/catalog-data.js +17 -13
- package/dist/ai/providers/catalog.d.ts +60 -7
- package/dist/ai/providers/catalog.js +197 -38
- package/dist/ai/providers/channels.d.ts +33 -3
- package/dist/ai/providers/channels.js +108 -7
- package/dist/ai/providers/enrich.d.ts +6 -3
- package/dist/ai/providers/enrich.js +19 -4
- package/dist/ai/providers/models-dev-cache.d.ts +28 -24
- package/dist/ai/providers/models-dev-cache.js +92 -78
- package/dist/ai/providers/models-dev-data.d.ts +7 -0
- package/dist/ai/providers/models-dev-data.js +32 -0
- package/dist/ai/providers/models-dev-snapshot.d.ts +50 -0
- package/dist/ai/providers/models-dev-snapshot.js +137 -0
- package/dist/ai/providers/models-dev.d.ts +51 -10
- package/dist/ai/providers/models-dev.js +132 -39
- package/dist/ai/providers/registry.d.ts +28 -11
- package/dist/ai/providers/registry.js +112 -65
- package/dist/ai/providers/suggest.d.ts +18 -0
- package/dist/ai/providers/suggest.js +72 -0
- package/dist/ai/sse.d.ts +6 -2
- package/dist/ai/sse.js +22 -2
- package/dist/ai/types.d.ts +37 -4
- package/dist/ai/types.js +5 -0
- package/dist/bundle/ama.cjs +41979 -21147
- package/dist/checkpoints/backend.d.ts +61 -0
- package/dist/checkpoints/backend.js +135 -0
- package/dist/checkpoints/blobs.d.ts +60 -0
- package/dist/checkpoints/blobs.js +203 -0
- package/dist/checkpoints/gc.d.ts +47 -0
- package/dist/checkpoints/gc.js +144 -0
- package/dist/checkpoints/git-head.d.ts +15 -0
- package/dist/checkpoints/git-head.js +89 -0
- package/dist/checkpoints/index.d.ts +17 -0
- package/dist/checkpoints/index.js +17 -0
- package/dist/checkpoints/replay.d.ts +48 -0
- package/dist/checkpoints/replay.js +154 -0
- package/dist/checkpoints/restore.d.ts +86 -0
- package/dist/checkpoints/restore.js +263 -0
- package/dist/checkpoints/settings.d.ts +14 -0
- package/dist/checkpoints/settings.js +23 -0
- package/dist/checkpoints/shadow-git.d.ts +108 -0
- package/dist/checkpoints/shadow-git.js +491 -0
- package/dist/checkpoints/shadow-restore.d.ts +25 -0
- package/dist/checkpoints/shadow-restore.js +128 -0
- package/dist/checkpoints/tracker.d.ts +64 -0
- package/dist/checkpoints/tracker.js +192 -0
- package/dist/checkpoints/types.d.ts +99 -0
- package/dist/checkpoints/types.js +12 -0
- package/dist/cli/args.d.ts +26 -7
- package/dist/cli/args.js +75 -82
- package/dist/cli/bootstrap.js +40 -4
- package/dist/cli/codemode-notice.d.ts +21 -0
- package/dist/cli/codemode-notice.js +56 -0
- package/dist/cli/compose-agents.d.ts +27 -0
- package/dist/cli/compose-agents.js +111 -0
- package/dist/cli/compose-extensions.d.ts +29 -0
- package/dist/cli/compose-extensions.js +44 -0
- package/dist/cli/compose-session.d.ts +8 -0
- package/dist/cli/compose-session.js +76 -2
- package/dist/cli/compose-store.d.ts +1 -1
- package/dist/cli/compose-store.js +3 -1
- package/dist/cli/compose.d.ts +17 -4
- package/dist/cli/compose.js +60 -14
- package/dist/cli/default-model.d.ts +38 -1
- package/dist/cli/default-model.js +96 -9
- package/dist/cli/deps.d.ts +42 -0
- package/dist/cli/exit-codes.d.ts +12 -0
- package/dist/cli/exit-codes.js +15 -0
- package/dist/cli/fake-visibility.d.ts +13 -0
- package/dist/cli/fake-visibility.js +26 -0
- package/dist/cli/from-prompt.d.ts +18 -0
- package/dist/cli/from-prompt.js +49 -0
- package/dist/cli/help-text.d.ts +4 -0
- package/dist/cli/help-text.js +102 -0
- package/dist/cli/main.d.ts +9 -2
- package/dist/cli/main.js +77 -3
- package/dist/cli/proxy.d.ts +51 -0
- package/dist/cli/proxy.js +135 -0
- package/dist/cli/startup-screen.d.ts +29 -0
- package/dist/cli/startup-screen.js +51 -2
- package/dist/cli/startup-steps.d.ts +1 -1
- package/dist/cli/startup-steps.js +21 -13
- package/dist/cli/subcommands/config.d.ts +22 -3
- package/dist/cli/subcommands/config.js +119 -21
- package/dist/cli/subcommands/context.js +4 -1
- package/dist/cli/subcommands/doctor.js +33 -1
- package/dist/cli/subcommands/init.js +2 -1
- package/dist/cli/subcommands/models-discover.d.ts +15 -9
- package/dist/cli/subcommands/models-discover.js +58 -52
- package/dist/cli/subcommands/models.d.ts +2 -0
- package/dist/cli/subcommands/models.js +33 -14
- package/dist/cli/subcommands/probe-runner.d.ts +96 -0
- package/dist/cli/subcommands/probe-runner.js +264 -0
- package/dist/cli/subcommands/providers-probe.d.ts +34 -0
- package/dist/cli/subcommands/providers-probe.js +87 -0
- package/dist/cli/subcommands/providers.d.ts +3 -2
- package/dist/cli/subcommands/providers.js +53 -51
- package/dist/cli/subcommands/sessions-export.d.ts +10 -0
- package/dist/cli/subcommands/sessions-export.js +59 -0
- package/dist/cli/subcommands/sessions-search.d.ts +13 -0
- package/dist/cli/subcommands/sessions-search.js +103 -0
- package/dist/cli/subcommands/sessions.d.ts +6 -3
- package/dist/cli/subcommands/sessions.js +58 -3
- package/dist/cli/subcommands/stats.d.ts +17 -0
- package/dist/cli/subcommands/stats.js +198 -0
- package/dist/cli/system-prompt-arg.d.ts +11 -0
- package/dist/cli/system-prompt-arg.js +34 -0
- package/dist/codemode/capability.d.ts +24 -7
- package/dist/codemode/capability.js +38 -10
- package/dist/codemode/host-side.d.ts +14 -0
- package/dist/codemode/host-side.js +24 -1
- package/dist/codemode/modes.d.ts +4 -11
- package/dist/codemode/modes.js +5 -27
- package/dist/codemode/tool.d.ts +18 -14
- package/dist/codemode/tool.js +76 -31
- package/dist/compaction/breaker.d.ts +25 -9
- package/dist/compaction/breaker.js +47 -17
- package/dist/compaction/estimate.d.ts +11 -3
- package/dist/compaction/estimate.js +64 -22
- package/dist/compaction/image-budget.d.ts +45 -0
- package/dist/compaction/image-budget.js +115 -0
- package/dist/compaction/post-compact.d.ts +38 -0
- package/dist/compaction/post-compact.js +152 -0
- package/dist/compaction/protect.d.ts +27 -0
- package/dist/compaction/protect.js +56 -0
- package/dist/compaction/prune-tier.d.ts +58 -12
- package/dist/compaction/prune-tier.js +120 -54
- package/dist/compaction/summarize-tier.d.ts +23 -4
- package/dist/compaction/summarize-tier.js +100 -29
- package/dist/config/checker.d.ts +28 -0
- package/dist/config/checker.js +97 -0
- package/dist/config/init.d.ts +6 -2
- package/dist/config/init.js +12 -5
- package/dist/config/json-schema.d.ts +1 -0
- package/dist/config/json-schema.js +98 -4
- package/dist/config/key-docs.d.ts +22 -0
- package/dist/config/key-docs.js +174 -0
- package/dist/config/merge.d.ts +12 -9
- package/dist/config/merge.js +102 -13
- package/dist/config/profile.d.ts +2 -0
- package/dist/config/profile.js +2 -0
- package/dist/config/schema-w5.d.ts +18 -0
- package/dist/config/schema-w5.js +109 -0
- package/dist/config/schema.d.ts +5 -9
- package/dist/config/schema.js +91 -118
- package/dist/config/types-w5.d.ts +118 -0
- package/dist/config/types-w5.js +20 -0
- package/dist/config/types.d.ts +84 -7
- package/dist/config/types.js +29 -1
- package/dist/drivers/acp/client.d.ts +57 -0
- package/dist/drivers/acp/client.js +160 -0
- package/dist/drivers/acp/driver.d.ts +31 -0
- package/dist/drivers/acp/driver.js +274 -0
- package/dist/drivers/acp/testing/fake-agent-main.d.ts +5 -0
- package/dist/drivers/acp/testing/fake-agent-main.js +7 -0
- package/dist/drivers/acp/testing/fake-agent.d.ts +27 -0
- package/dist/drivers/acp/testing/fake-agent.js +211 -0
- package/dist/drivers/acp/types.d.ts +285 -0
- package/dist/drivers/acp/types.js +36 -0
- package/dist/drivers/agents.d.ts +58 -0
- package/dist/drivers/agents.js +142 -0
- package/dist/drivers/base.d.ts +35 -0
- package/dist/drivers/base.js +59 -0
- package/dist/drivers/catalog.d.ts +46 -0
- package/dist/drivers/catalog.js +167 -0
- package/dist/drivers/env.d.ts +20 -0
- package/dist/drivers/env.js +46 -0
- package/dist/drivers/host-runners.d.ts +18 -0
- package/dist/drivers/host-runners.js +45 -0
- package/dist/drivers/jsonrpc.d.ts +58 -0
- package/dist/drivers/jsonrpc.js +180 -0
- package/dist/drivers/native/claude-normalize.d.ts +46 -0
- package/dist/drivers/native/claude-normalize.js +106 -0
- package/dist/drivers/native/claude-stream.d.ts +29 -0
- package/dist/drivers/native/claude-stream.js +456 -0
- package/dist/drivers/native/codex-app-server.d.ts +26 -0
- package/dist/drivers/native/codex-app-server.js +407 -0
- package/dist/drivers/native/codex-normalize.d.ts +38 -0
- package/dist/drivers/native/codex-normalize.js +124 -0
- package/dist/drivers/native/oneshot.d.ts +28 -0
- package/dist/drivers/native/oneshot.js +312 -0
- package/dist/drivers/permissions.d.ts +40 -0
- package/dist/drivers/permissions.js +92 -0
- package/dist/drivers/pids.d.ts +32 -0
- package/dist/drivers/pids.js +93 -0
- package/dist/drivers/pool.d.ts +28 -0
- package/dist/drivers/pool.js +96 -0
- package/dist/drivers/probe.d.ts +47 -0
- package/dist/drivers/probe.js +172 -0
- package/dist/drivers/process.d.ts +48 -0
- package/dist/drivers/process.js +100 -0
- package/dist/drivers/runner.d.ts +61 -0
- package/dist/drivers/runner.js +388 -0
- package/dist/drivers/store.d.ts +49 -0
- package/dist/drivers/store.js +91 -0
- package/dist/drivers/turn.d.ts +41 -0
- package/dist/drivers/turn.js +99 -0
- package/dist/drivers/types.d.ts +122 -0
- package/dist/drivers/types.js +11 -0
- package/dist/git/info.d.ts +75 -0
- package/dist/git/info.js +191 -0
- package/dist/hooks/protocol.js +6 -1
- package/dist/hooks/types.d.ts +10 -1
- package/dist/hooks/types.js +2 -0
- package/dist/host/api-impl.d.ts +7 -0
- package/dist/host/api-impl.js +15 -0
- package/dist/host/types.d.ts +24 -2
- package/dist/host/types.js +4 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -0
- package/dist/modes/acp/acp-events.d.ts +46 -0
- package/dist/modes/acp/acp-events.js +233 -0
- package/dist/modes/acp/acp-mode.d.ts +17 -0
- package/dist/modes/acp/acp-mode.js +47 -0
- package/dist/modes/acp/acp-server.d.ts +79 -0
- package/dist/modes/acp/acp-server.js +315 -0
- package/dist/modes/commands-core.d.ts +7 -1
- package/dist/modes/commands-core.js +61 -5
- package/dist/modes/image-input.d.ts +12 -4
- package/dist/modes/image-input.js +22 -5
- package/dist/modes/interactive/agent-panels.d.ts +14 -0
- package/dist/modes/interactive/agent-panels.js +103 -0
- package/dist/modes/interactive/agent-ui.d.ts +73 -0
- package/dist/modes/interactive/agent-ui.js +234 -0
- package/dist/modes/interactive/approval-dialog.d.ts +40 -7
- package/dist/modes/interactive/approval-dialog.js +192 -35
- package/dist/modes/interactive/approval-merge.d.ts +41 -0
- package/dist/modes/interactive/approval-merge.js +89 -0
- package/dist/modes/interactive/clipboard-paste.d.ts +18 -0
- package/dist/modes/interactive/clipboard-paste.js +28 -0
- package/dist/modes/interactive/commands.d.ts +20 -3
- package/dist/modes/interactive/commands.js +75 -16
- package/dist/modes/interactive/double-esc.d.ts +20 -0
- package/dist/modes/interactive/double-esc.js +34 -0
- package/dist/modes/interactive/event-notices.d.ts +32 -0
- package/dist/modes/interactive/event-notices.js +79 -0
- package/dist/modes/interactive/external-editor.d.ts +16 -0
- package/dist/modes/interactive/external-editor.js +39 -0
- package/dist/modes/interactive/interactive-mode.d.ts +16 -2
- package/dist/modes/interactive/interactive-mode.js +184 -202
- package/dist/modes/interactive/key-dispatch.d.ts +18 -2
- package/dist/modes/interactive/key-dispatch.js +53 -6
- package/dist/modes/interactive/line/line-mode.d.ts +3 -1
- package/dist/modes/interactive/line/line-mode.js +28 -9
- package/dist/modes/interactive/line/line-render.d.ts +6 -1
- package/dist/modes/interactive/line/line-render.js +66 -8
- package/dist/modes/interactive/message-view.d.ts +49 -10
- package/dist/modes/interactive/message-view.js +262 -46
- package/dist/modes/interactive/panels.d.ts +35 -0
- package/dist/modes/interactive/panels.js +157 -0
- package/dist/modes/interactive/pickers.d.ts +23 -2
- package/dist/modes/interactive/pickers.js +48 -15
- package/dist/modes/interactive/plan-command.d.ts +40 -0
- package/dist/modes/interactive/plan-command.js +129 -0
- package/dist/modes/interactive/plan-dialog.d.ts +98 -0
- package/dist/modes/interactive/plan-dialog.js +290 -0
- package/dist/modes/interactive/plan-flow.d.ts +34 -0
- package/dist/modes/interactive/plan-flow.js +98 -0
- package/dist/modes/interactive/rewind-command.d.ts +31 -0
- package/dist/modes/interactive/rewind-command.js +106 -0
- package/dist/modes/interactive/rewind-flow.d.ts +37 -0
- package/dist/modes/interactive/rewind-flow.js +151 -0
- package/dist/modes/interactive/rewind-list.d.ts +36 -0
- package/dist/modes/interactive/rewind-list.js +123 -0
- package/dist/modes/interactive/rewind-panel.d.ts +77 -0
- package/dist/modes/interactive/rewind-panel.js +309 -0
- package/dist/modes/interactive/rewind-text.d.ts +40 -0
- package/dist/modes/interactive/rewind-text.js +139 -0
- package/dist/modes/interactive/run-indicator.d.ts +51 -0
- package/dist/modes/interactive/run-indicator.js +189 -0
- package/dist/modes/interactive/session-events.d.ts +24 -0
- package/dist/modes/interactive/session-events.js +96 -0
- package/dist/modes/interactive/startup-header.d.ts +40 -0
- package/dist/modes/interactive/startup-header.js +169 -0
- package/dist/modes/interactive/status-area.d.ts +73 -0
- package/dist/modes/interactive/status-area.js +190 -0
- package/dist/modes/interactive/status-bar.d.ts +107 -16
- package/dist/modes/interactive/status-bar.js +306 -81
- package/dist/modes/interactive/status-line.d.ts +33 -0
- package/dist/modes/interactive/status-line.js +113 -0
- package/dist/modes/interactive/subagent-view.d.ts +56 -0
- package/dist/modes/interactive/subagent-view.js +154 -0
- package/dist/modes/interactive/tasks-report.d.ts +27 -0
- package/dist/modes/interactive/tasks-report.js +114 -0
- package/dist/modes/interactive/tool-summary.d.ts +46 -0
- package/dist/modes/interactive/tool-summary.js +218 -0
- package/dist/modes/interactive/tool-view.d.ts +58 -15
- package/dist/modes/interactive/tool-view.js +233 -145
- package/dist/modes/print/print-mode.d.ts +40 -4
- package/dist/modes/print/print-mode.js +161 -8
- package/dist/modes/rpc/commands.d.ts +9 -0
- package/dist/modes/rpc/commands.js +49 -0
- package/dist/modes/rpc/rpc-mode.js +7 -1
- package/dist/modes/session-report.d.ts +11 -0
- package/dist/modes/session-report.js +48 -1
- package/dist/permissions/auto-safe.d.ts +65 -0
- package/dist/permissions/auto-safe.js +547 -0
- package/dist/permissions/classifier.d.ts +68 -0
- package/dist/permissions/classifier.js +186 -0
- package/dist/permissions/dangerous.d.ts +5 -0
- package/dist/permissions/dangerous.js +1 -1
- package/dist/permissions/modes.d.ts +30 -0
- package/dist/permissions/modes.js +78 -0
- package/dist/permissions/pipeline.d.ts +72 -6
- package/dist/permissions/pipeline.js +306 -11
- package/dist/permissions/protected.d.ts +19 -0
- package/dist/permissions/protected.js +74 -0
- package/dist/permissions/readonly-bash.d.ts +30 -0
- package/dist/permissions/readonly-bash.js +118 -0
- package/dist/permissions/rules.js +3 -0
- package/dist/permissions/types.d.ts +92 -3
- package/dist/permissions/types.js +3 -0
- package/dist/plan/compose.d.ts +9 -0
- package/dist/plan/compose.js +19 -0
- package/dist/plan/controller.d.ts +71 -0
- package/dist/plan/controller.js +27 -0
- package/dist/plan/done-markers.d.ts +17 -0
- package/dist/plan/done-markers.js +51 -0
- package/dist/plan/extract.d.ts +29 -0
- package/dist/plan/extract.js +160 -0
- package/dist/plan/prompts.d.ts +36 -0
- package/dist/plan/prompts.js +89 -0
- package/dist/plan/store.d.ts +37 -0
- package/dist/plan/store.js +90 -0
- package/dist/rpc.d.ts +58 -2
- package/dist/rpc.js +7 -0
- package/dist/sandbox/bash.d.ts +74 -0
- package/dist/sandbox/bash.js +126 -0
- package/dist/sandbox/detect.d.ts +48 -0
- package/dist/sandbox/detect.js +149 -0
- package/dist/sandbox/index.d.ts +5 -0
- package/dist/sandbox/index.js +5 -0
- package/dist/sandbox/profile.d.ts +33 -0
- package/dist/sandbox/profile.js +76 -0
- package/dist/sandbox/wrap.d.ts +29 -0
- package/dist/sandbox/wrap.js +117 -0
- package/dist/sdk.d.ts +42 -5
- package/dist/sdk.js +34 -4
- package/dist/session/export.d.ts +32 -0
- package/dist/session/export.js +187 -0
- package/dist/session/redact.d.ts +15 -0
- package/dist/session/redact.js +55 -0
- package/dist/session/reuse.d.ts +33 -0
- package/dist/session/reuse.js +86 -0
- package/dist/session/scan.d.ts +34 -0
- package/dist/session/scan.js +140 -0
- package/dist/session/search.d.ts +52 -0
- package/dist/session/search.js +211 -0
- package/dist/session/stats-aggregate.d.ts +63 -0
- package/dist/session/stats-aggregate.js +163 -0
- package/dist/session/stats-index.d.ts +26 -0
- package/dist/session/stats-index.js +91 -0
- package/dist/session/stats-scan.d.ts +54 -0
- package/dist/session/stats-scan.js +236 -0
- package/dist/session/types.d.ts +3 -1
- package/dist/session/types.js +1 -0
- package/dist/skills/builtin.d.ts +31 -0
- package/dist/skills/builtin.js +109 -0
- package/dist/skills/discover.d.ts +2 -1
- package/dist/skills/index-prompt.js +5 -8
- package/dist/tools/background-jobs.d.ts +71 -0
- package/dist/tools/background-jobs.js +198 -0
- package/dist/tools/bash.d.ts +53 -1
- package/dist/tools/bash.js +158 -7
- package/dist/tools/clipboard-image.d.ts +44 -0
- package/dist/tools/clipboard-image.js +148 -0
- package/dist/tools/edit.d.ts +2 -0
- package/dist/tools/edit.js +18 -3
- package/dist/tools/image-file.d.ts +38 -3
- package/dist/tools/image-file.js +81 -10
- package/dist/tools/image-resize.d.ts +58 -0
- package/dist/tools/image-resize.js +97 -0
- package/dist/tools/presets.d.ts +40 -8
- package/dist/tools/presets.js +65 -19
- package/dist/tools/read.d.ts +5 -2
- package/dist/tools/read.js +13 -10
- package/dist/tools/registry.d.ts +7 -1
- package/dist/tools/registry.js +27 -4
- package/dist/tools/task-ctl.d.ts +22 -0
- package/dist/tools/task-ctl.js +116 -0
- package/dist/tools/task.d.ts +22 -10
- package/dist/tools/task.js +66 -26
- package/dist/tools/todo.d.ts +22 -2
- package/dist/tools/todo.js +58 -14
- package/dist/tools/truncate.d.ts +15 -0
- package/dist/tools/truncate.js +25 -0
- package/dist/tools/types.d.ts +113 -0
- package/dist/tools/types.js +5 -0
- package/dist/tools/write.js +3 -0
- package/dist/tui/component.d.ts +8 -2
- package/dist/tui/component.js +3 -1
- package/dist/tui/components/box.d.ts +6 -1
- package/dist/tui/components/box.js +16 -6
- package/dist/tui/components/card.d.ts +23 -0
- package/dist/tui/components/card.js +37 -0
- package/dist/tui/components/editor-history.d.ts +6 -0
- package/dist/tui/components/editor-history.js +45 -0
- package/dist/tui/components/editor-paste.d.ts +1 -1
- package/dist/tui/components/editor-paste.js +4 -4
- package/dist/tui/components/editor.d.ts +11 -5
- package/dist/tui/components/editor.js +52 -58
- package/dist/tui/components/key-value.d.ts +3 -0
- package/dist/tui/components/key-value.js +16 -6
- package/dist/tui/components/loader.d.ts +37 -7
- package/dist/tui/components/loader.js +84 -21
- package/dist/tui/components/markdown.d.ts +5 -1
- package/dist/tui/components/markdown.js +45 -21
- package/dist/tui/components/meter.d.ts +3 -3
- package/dist/tui/components/meter.js +13 -11
- package/dist/tui/components/select-list.d.ts +23 -1
- package/dist/tui/components/select-list.js +76 -13
- package/dist/tui/glyphs.d.ts +72 -0
- package/dist/tui/glyphs.js +118 -0
- package/dist/tui/keybindings.d.ts +5 -0
- package/dist/tui/keybindings.js +5 -0
- package/dist/tui/theme.d.ts +30 -6
- package/dist/tui/theme.js +103 -17
- package/dist/tui.d.ts +4 -2
- package/dist/tui.js +3 -1
- package/docs/acp.md +78 -0
- package/docs/agents.md +250 -0
- package/docs/codemode.md +28 -10
- package/docs/hooks.md +36 -32
- package/docs/permissions.md +212 -0
- package/docs/plan.md +107 -0
- package/docs/providers.md +261 -62
- package/docs/rewind-plan.md +181 -0
- package/docs/rpc.md +127 -40
- package/docs/sandbox.md +215 -0
- package/docs/session-format.md +43 -22
- package/docs/sessions.md +174 -0
- package/docs/tui-design.md +751 -0
- package/docs/tui.md +260 -64
- package/package.json +15 -2
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 运行指示与排队消息(终端界面视觉设计 v1 §3.7、§3.8):输入框上方的 Loader 动词状态机与排队列表。
|
|
3
|
+
*
|
|
4
|
+
* 动词按「当前最深状态」取,避免事件乱序时闪回:
|
|
5
|
+
* 审批打开 → `等待确认`(无 Esc 提示,Esc 由对话框消费)
|
|
6
|
+
* 有运行中的工具 → `运行 bash` / `运行 3 个工具`
|
|
7
|
+
* 自动重试等待中 → `重试 2/3 · 2s 后`(不显示已用时)
|
|
8
|
+
* 压缩中 → `压缩上下文`
|
|
9
|
+
* 助手在流式输出 → 末块是思考 `思考中`,否则 `回复中 · ↓≈1.2k`(本条输出的估算 token,4 字符 ≈ 1)
|
|
10
|
+
* 其余(等首个 token)→ `思考中`
|
|
11
|
+
* 运行或压缩时 Loader 才挂进槽位;附加项 `Esc 中断`。
|
|
12
|
+
*
|
|
13
|
+
* 排队消息:缩进 2 列(挂在当前回合下),`↳ 插话 / 之后 文本` 整体 muted、标签 dim;超过 3 条首行
|
|
14
|
+
* `… 另 N 条`;末行 `Alt+↑ 取回 · Esc 回填并中断`。
|
|
15
|
+
*/
|
|
16
|
+
import { Container, Text } from "../../tui.js";
|
|
17
|
+
import { ORIGIN_LABELS } from "./message-view.js";
|
|
18
|
+
import { formatTokens } from "./status-bar.js";
|
|
19
|
+
export const QUEUE_PREVIEW = 3;
|
|
20
|
+
function oneLine(text) {
|
|
21
|
+
return text.replace(/\s+/g, " ").trim();
|
|
22
|
+
}
|
|
23
|
+
/** 助手消息里已流出的文字(思考 + 正文)的估算 token 与末块类型。 */
|
|
24
|
+
function streamState(message) {
|
|
25
|
+
let chars = 0;
|
|
26
|
+
let last;
|
|
27
|
+
for (const block of message.content) {
|
|
28
|
+
if (block.type === "text") {
|
|
29
|
+
chars += block.text.length;
|
|
30
|
+
if (block.text !== "")
|
|
31
|
+
last = "text";
|
|
32
|
+
}
|
|
33
|
+
else if (block.type === "thinking") {
|
|
34
|
+
chars += block.thinking.length;
|
|
35
|
+
if (block.thinking !== "")
|
|
36
|
+
last = "thinking";
|
|
37
|
+
}
|
|
38
|
+
else if (block.type === "toolCall")
|
|
39
|
+
last = "toolCall";
|
|
40
|
+
}
|
|
41
|
+
return { tokens: Math.ceil(chars / 4), thinking: last === "thinking" };
|
|
42
|
+
}
|
|
43
|
+
export class RunIndicator {
|
|
44
|
+
deps;
|
|
45
|
+
running = false;
|
|
46
|
+
compacting = false;
|
|
47
|
+
approval = false;
|
|
48
|
+
retry;
|
|
49
|
+
stream;
|
|
50
|
+
constructor(deps) {
|
|
51
|
+
this.deps = deps;
|
|
52
|
+
}
|
|
53
|
+
get busy() {
|
|
54
|
+
return this.running || this.compacting;
|
|
55
|
+
}
|
|
56
|
+
setApproval(open) {
|
|
57
|
+
this.approval = open;
|
|
58
|
+
this.sync();
|
|
59
|
+
}
|
|
60
|
+
/** 会话切换后清零。 */
|
|
61
|
+
reset() {
|
|
62
|
+
this.running = false;
|
|
63
|
+
this.compacting = false;
|
|
64
|
+
this.approval = false;
|
|
65
|
+
this.retry = undefined;
|
|
66
|
+
this.stream = undefined;
|
|
67
|
+
this.sync();
|
|
68
|
+
}
|
|
69
|
+
/** 会话事件 → 状态;返回后已同步 Loader。 */
|
|
70
|
+
onEvent(event) {
|
|
71
|
+
switch (event.type) {
|
|
72
|
+
case "agent_start":
|
|
73
|
+
this.running = true;
|
|
74
|
+
break;
|
|
75
|
+
case "agent_settled":
|
|
76
|
+
this.running = false;
|
|
77
|
+
this.retry = undefined;
|
|
78
|
+
this.stream = undefined;
|
|
79
|
+
break;
|
|
80
|
+
case "message_start":
|
|
81
|
+
if (event.message.role === "assistant") {
|
|
82
|
+
this.retry = undefined;
|
|
83
|
+
this.stream = streamState(event.message);
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
case "message_update":
|
|
87
|
+
if (event.message.role === "assistant")
|
|
88
|
+
this.stream = streamState(event.message);
|
|
89
|
+
break;
|
|
90
|
+
case "message_end":
|
|
91
|
+
if (event.message.role === "assistant")
|
|
92
|
+
this.stream = undefined;
|
|
93
|
+
break;
|
|
94
|
+
case "compaction_start":
|
|
95
|
+
this.compacting = true;
|
|
96
|
+
break;
|
|
97
|
+
case "compaction_end":
|
|
98
|
+
this.compacting = false;
|
|
99
|
+
break;
|
|
100
|
+
case "auto_retry_start":
|
|
101
|
+
this.retry = { attempt: event.attempt, max: event.maxAttempts, delayMs: event.delayMs };
|
|
102
|
+
break;
|
|
103
|
+
case "auto_retry_end":
|
|
104
|
+
this.retry = undefined;
|
|
105
|
+
break;
|
|
106
|
+
case "tool_execution_start":
|
|
107
|
+
case "tool_execution_end":
|
|
108
|
+
break;
|
|
109
|
+
default:
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
this.sync();
|
|
113
|
+
}
|
|
114
|
+
/** 按当前状态换动词,并挂上 / 撤下 Loader。 */
|
|
115
|
+
sync() {
|
|
116
|
+
const { loader, slot, render } = this.deps;
|
|
117
|
+
const active = this.busy;
|
|
118
|
+
if (active)
|
|
119
|
+
this.applyVerb();
|
|
120
|
+
if (active && slot.children.length === 0) {
|
|
121
|
+
slot.addChild(loader);
|
|
122
|
+
loader.start();
|
|
123
|
+
}
|
|
124
|
+
else if (!active && slot.children.length > 0) {
|
|
125
|
+
loader.stop();
|
|
126
|
+
slot.clear();
|
|
127
|
+
}
|
|
128
|
+
render();
|
|
129
|
+
}
|
|
130
|
+
applyVerb() {
|
|
131
|
+
const { loader, tools } = this.deps;
|
|
132
|
+
const esc = ["Esc 中断"];
|
|
133
|
+
if (this.approval) {
|
|
134
|
+
loader.setVerb("等待确认");
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const running = tools.running();
|
|
138
|
+
const top = running.filter((view) => !running.some((p) => p.children.includes(view)));
|
|
139
|
+
if (top.length === 1) {
|
|
140
|
+
loader.setVerb(`运行 ${top[0].toolName}`, esc);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (top.length > 1) {
|
|
144
|
+
loader.setVerb(`运行 ${top.length} 个工具`, esc);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (this.retry !== undefined) {
|
|
148
|
+
const seconds = Math.max(1, Math.round(this.retry.delayMs / 1000));
|
|
149
|
+
loader.setVerb(`重试 ${this.retry.attempt}/${this.retry.max}`, [`${seconds}s 后`], {
|
|
150
|
+
elapsed: false,
|
|
151
|
+
});
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (this.compacting) {
|
|
155
|
+
loader.setVerb("压缩上下文", esc);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const stream = this.stream;
|
|
159
|
+
if (stream !== undefined && !stream.thinking && stream.tokens > 0) {
|
|
160
|
+
loader.setVerb("回复中", [`↓≈${formatTokens(stream.tokens)}`, ...esc]);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
loader.setVerb("思考中", esc);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/** 排队消息(插话 / 之后),挂在 Loader 之上。 */
|
|
167
|
+
export class QueueView extends Text {
|
|
168
|
+
theme;
|
|
169
|
+
constructor(theme) {
|
|
170
|
+
super("");
|
|
171
|
+
this.theme = theme;
|
|
172
|
+
}
|
|
173
|
+
setQueue(steering, followUp) {
|
|
174
|
+
const t = this.theme;
|
|
175
|
+
const row = (origin, text) => ` ${t.fg("dim", `${t.glyphs.queued} ${ORIGIN_LABELS[origin]}`)} ${t.fg("muted", oneLine(text))}`;
|
|
176
|
+
const rows = [
|
|
177
|
+
...steering.map((text) => row("steer", text)),
|
|
178
|
+
...followUp.map((text) => row("followUp", text)),
|
|
179
|
+
];
|
|
180
|
+
const shown = rows.slice(-QUEUE_PREVIEW);
|
|
181
|
+
if (rows.length > shown.length) {
|
|
182
|
+
shown.unshift(" " + t.fg("dim", `${t.glyphs.ellipsis} 另 ${rows.length - shown.length} 条`));
|
|
183
|
+
}
|
|
184
|
+
if (rows.length > 0) {
|
|
185
|
+
shown.push(" " + t.fg("dim", `Alt+${t.glyphs.arrowUp} 取回 · Esc 回填并中断`));
|
|
186
|
+
}
|
|
187
|
+
this.setText(shown.join("\n"));
|
|
188
|
+
}
|
|
189
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 交互界面的会话事件分派:`SessionEvent` → 消息区、工具视图、状态栏、运行指示。[B7]
|
|
3
|
+
* 从 interactive-mode.ts 拆出(W5-U:第五波事件先交给 agent-ui.ts,预算到限的 agent_settled warning 不重复显示)。
|
|
4
|
+
*/
|
|
5
|
+
import type { AgentSession, SessionEvent } from "../../agent/types.js";
|
|
6
|
+
import type { AgentUi } from "./agent-ui.js";
|
|
7
|
+
import type { MessageView, NoticeLevel } from "./message-view.js";
|
|
8
|
+
import type { RunIndicator } from "./run-indicator.js";
|
|
9
|
+
import type { StatusArea } from "./status-area.js";
|
|
10
|
+
import type { StatusBar } from "./status-bar.js";
|
|
11
|
+
import type { ToolTracker } from "./tool-view.js";
|
|
12
|
+
export interface SessionEventDeps {
|
|
13
|
+
view: MessageView;
|
|
14
|
+
tools: ToolTracker;
|
|
15
|
+
status: StatusBar;
|
|
16
|
+
area: StatusArea;
|
|
17
|
+
agentUi(): AgentUi;
|
|
18
|
+
indicator: RunIndicator;
|
|
19
|
+
session(): AgentSession;
|
|
20
|
+
setQueue(steering: readonly string[], followUp: readonly string[]): void;
|
|
21
|
+
notice(level: NoticeLevel, text: string): void;
|
|
22
|
+
render(): void;
|
|
23
|
+
}
|
|
24
|
+
export declare function createSessionEventHandler(deps: SessionEventDeps): (event: SessionEvent) => void;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 交互界面的会话事件分派:`SessionEvent` → 消息区、工具视图、状态栏、运行指示。[B7]
|
|
3
|
+
* 从 interactive-mode.ts 拆出(W5-U:第五波事件先交给 agent-ui.ts,预算到限的 agent_settled warning 不重复显示)。
|
|
4
|
+
*/
|
|
5
|
+
import { cacheEventNotice, cacheNoticesEnabled } from "../session-report.js";
|
|
6
|
+
import { compactionErrorText, ImageBudgetNotices, LIMIT_WARNING } from "./event-notices.js";
|
|
7
|
+
export function createSessionEventHandler(deps) {
|
|
8
|
+
const { view, tools, status, area, agentUi, indicator, session, setQueue, notice, render } = deps;
|
|
9
|
+
const images = new ImageBudgetNotices((text) => notice("info", text));
|
|
10
|
+
return (event) => {
|
|
11
|
+
if (area.onEvent(event) || agentUi().onEvent(event))
|
|
12
|
+
return render();
|
|
13
|
+
images.onEvent(event);
|
|
14
|
+
switch (event.type) {
|
|
15
|
+
case "agent_settled":
|
|
16
|
+
// 预算到限已由 limit_reached 给出友好提示
|
|
17
|
+
if (event.warning !== undefined && event.warning !== LIMIT_WARNING)
|
|
18
|
+
view.addNotice("warn", event.warning);
|
|
19
|
+
status.refresh();
|
|
20
|
+
break;
|
|
21
|
+
case "message_start": {
|
|
22
|
+
const message = event.message;
|
|
23
|
+
if (message.role === "user")
|
|
24
|
+
view.addUser(message);
|
|
25
|
+
else if (message.role === "assistant")
|
|
26
|
+
view.startAssistant(message);
|
|
27
|
+
else if (message.role === "custom" && message.display) {
|
|
28
|
+
view.addNotice("info", typeof message.content === "string" ? message.content : "");
|
|
29
|
+
}
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
case "message_update":
|
|
33
|
+
view.updateAssistant(event.message);
|
|
34
|
+
break;
|
|
35
|
+
case "message_end":
|
|
36
|
+
if (event.message.role === "assistant") {
|
|
37
|
+
view.endAssistant(event.message);
|
|
38
|
+
status.refresh();
|
|
39
|
+
}
|
|
40
|
+
break;
|
|
41
|
+
case "tool_execution_start": {
|
|
42
|
+
const started = tools.start(event);
|
|
43
|
+
if (started.topLevel)
|
|
44
|
+
view.addTool(started.view);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
case "tool_execution_update":
|
|
48
|
+
tools.update(event.toolCallId, event.partial);
|
|
49
|
+
render();
|
|
50
|
+
return;
|
|
51
|
+
case "tool_execution_end":
|
|
52
|
+
tools.end(event.toolCallId, event.result, event.isError);
|
|
53
|
+
break;
|
|
54
|
+
case "queue_update":
|
|
55
|
+
setQueue(event.steering, event.followUp);
|
|
56
|
+
return;
|
|
57
|
+
case "compaction_end":
|
|
58
|
+
if (event.result !== undefined)
|
|
59
|
+
view.addCompaction(event.result);
|
|
60
|
+
else if (event.error !== undefined)
|
|
61
|
+
view.addNotice("error", `压缩失败:${compactionErrorText(event.error)}`);
|
|
62
|
+
else if (event.aborted)
|
|
63
|
+
view.addNotice("info", "压缩已取消");
|
|
64
|
+
status.refresh();
|
|
65
|
+
break;
|
|
66
|
+
case "auto_retry_start":
|
|
67
|
+
view.addRetry(event.attempt, event.maxAttempts, event.delayMs, event.errorMessage);
|
|
68
|
+
break;
|
|
69
|
+
case "auto_retry_end":
|
|
70
|
+
if (!event.success)
|
|
71
|
+
view.addRetryFailed(event.finalError);
|
|
72
|
+
break;
|
|
73
|
+
case "cache_miss":
|
|
74
|
+
case "context_pressure": {
|
|
75
|
+
const shown = cacheEventNotice(event, cacheNoticesEnabled(session()));
|
|
76
|
+
if (shown !== undefined)
|
|
77
|
+
view.addNotice(shown.level, shown.text);
|
|
78
|
+
status.refresh();
|
|
79
|
+
render();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
case "cache_warm":
|
|
83
|
+
case "permission_mode_changed":
|
|
84
|
+
case "model_changed":
|
|
85
|
+
case "thinking_level_changed":
|
|
86
|
+
case "session_changed":
|
|
87
|
+
status.refresh();
|
|
88
|
+
render();
|
|
89
|
+
return;
|
|
90
|
+
default:
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
indicator.onEvent(event);
|
|
94
|
+
render();
|
|
95
|
+
};
|
|
96
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 交互模式启动头(终端界面视觉设计 v1 §3.1)。
|
|
3
|
+
*
|
|
4
|
+
* - `normal`:宽度 ≥ 56 且非 `ui.compact` 时画框(宽 `min(width, 64)`,左对齐)——标题 `✻ ama x.y.z`、
|
|
5
|
+
* 键值行(模型 / 目录 / 模式 / 已加载 / 宿主 / 警告)、按键提示;否则去框去键列,每项一行。
|
|
6
|
+
* - `header`:一行 `✻ ama x.y.z · 模型 · 模式 · /help`,无框。`silent` 不输出(调用方不加本组件)。
|
|
7
|
+
* - 着色:`✻` accent、标题粗体;键列 dim;模型 accent;已信任 success / 未信任 warning;Bypass 模式 warning;
|
|
8
|
+
* 按键提示 dim。路径过长时从左截断(`…/armadra-agent`)。宽度变化时按新宽重算是否去框。
|
|
9
|
+
*/
|
|
10
|
+
import type { StartupInfo } from "../../cli/startup-screen.js";
|
|
11
|
+
import { type Component, type Theme } from "../../tui.js";
|
|
12
|
+
/** 画框的最小宽度;更窄时去框去键列。 */
|
|
13
|
+
export declare const HEADER_BOX_MIN_WIDTH = 56;
|
|
14
|
+
/** 设计稿写 60;常见的「供应商/模型@渠道 · 思考 级别」要 62 列左右才不截断,取 64。 */
|
|
15
|
+
export declare const HEADER_BOX_MAX_WIDTH = 64;
|
|
16
|
+
export interface StartupHeaderOptions {
|
|
17
|
+
theme: Theme;
|
|
18
|
+
level: "normal" | "header";
|
|
19
|
+
/** `ui.compact`:normal 也不画框。 */
|
|
20
|
+
compact?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** 从左截断到 `width` 列(保留末尾,前面加省略号)。 */
|
|
23
|
+
export declare function truncateLeft(text: string, width: number, ellipsis?: string): string;
|
|
24
|
+
export declare class StartupHeader implements Component {
|
|
25
|
+
private readonly info;
|
|
26
|
+
private readonly options;
|
|
27
|
+
private cache;
|
|
28
|
+
constructor(info: StartupInfo, options: StartupHeaderOptions);
|
|
29
|
+
private get theme();
|
|
30
|
+
private title;
|
|
31
|
+
private modeText;
|
|
32
|
+
private trustText;
|
|
33
|
+
private loadedText;
|
|
34
|
+
private codemodeText;
|
|
35
|
+
render(width: number): string[];
|
|
36
|
+
private headerLine;
|
|
37
|
+
private plainLines;
|
|
38
|
+
private boxLines;
|
|
39
|
+
invalidate(): void;
|
|
40
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 交互模式启动头(终端界面视觉设计 v1 §3.1)。
|
|
3
|
+
*
|
|
4
|
+
* - `normal`:宽度 ≥ 56 且非 `ui.compact` 时画框(宽 `min(width, 64)`,左对齐)——标题 `✻ ama x.y.z`、
|
|
5
|
+
* 键值行(模型 / 目录 / 模式 / 已加载 / 宿主 / 警告)、按键提示;否则去框去键列,每项一行。
|
|
6
|
+
* - `header`:一行 `✻ ama x.y.z · 模型 · 模式 · /help`,无框。`silent` 不输出(调用方不加本组件)。
|
|
7
|
+
* - 着色:`✻` accent、标题粗体;键列 dim;模型 accent;已信任 success / 未信任 warning;Bypass 模式 warning;
|
|
8
|
+
* 按键提示 dim。路径过长时从左截断(`…/armadra-agent`)。宽度变化时按新宽重算是否去框。
|
|
9
|
+
*/
|
|
10
|
+
import { permissionModeLabel } from "../../permissions/modes.js";
|
|
11
|
+
import { Box, KeyValue, padToWidth, truncateToWidth, visibleWidth, } from "../../tui.js";
|
|
12
|
+
/** 画框的最小宽度;更窄时去框去键列。 */
|
|
13
|
+
export const HEADER_BOX_MIN_WIDTH = 56;
|
|
14
|
+
/** 设计稿写 60;常见的「供应商/模型@渠道 · 思考 级别」要 62 列左右才不截断,取 64。 */
|
|
15
|
+
export const HEADER_BOX_MAX_WIDTH = 64;
|
|
16
|
+
/** 从左截断到 `width` 列(保留末尾,前面加省略号)。 */
|
|
17
|
+
export function truncateLeft(text, width, ellipsis = "…") {
|
|
18
|
+
if (visibleWidth(text) <= width)
|
|
19
|
+
return text;
|
|
20
|
+
const room = width - visibleWidth(ellipsis);
|
|
21
|
+
if (room <= 0)
|
|
22
|
+
return truncateToWidth(ellipsis, width);
|
|
23
|
+
const chars = [...text];
|
|
24
|
+
let out = "";
|
|
25
|
+
let used = 0;
|
|
26
|
+
for (let i = chars.length - 1; i >= 0; i--) {
|
|
27
|
+
const w = visibleWidth(chars[i]);
|
|
28
|
+
if (used + w > room)
|
|
29
|
+
break;
|
|
30
|
+
out = chars[i] + out;
|
|
31
|
+
used += w;
|
|
32
|
+
}
|
|
33
|
+
return ellipsis + out;
|
|
34
|
+
}
|
|
35
|
+
/** 去掉模型引用里的渠道(`@messages`)。 */
|
|
36
|
+
function withoutChannel(model) {
|
|
37
|
+
const at = model.indexOf("@");
|
|
38
|
+
return at === -1 ? model : model.slice(0, at);
|
|
39
|
+
}
|
|
40
|
+
export class StartupHeader {
|
|
41
|
+
info;
|
|
42
|
+
options;
|
|
43
|
+
cache = null;
|
|
44
|
+
constructor(info, options) {
|
|
45
|
+
this.info = info;
|
|
46
|
+
this.options = options;
|
|
47
|
+
}
|
|
48
|
+
get theme() {
|
|
49
|
+
return this.options.theme;
|
|
50
|
+
}
|
|
51
|
+
title() {
|
|
52
|
+
const t = this.theme;
|
|
53
|
+
return `${t.fg("accent", t.glyphs.thinking)} ${t.bold(`ama ${this.info.version}`)}`;
|
|
54
|
+
}
|
|
55
|
+
modeText() {
|
|
56
|
+
const label = permissionModeLabel(this.info.permissionMode);
|
|
57
|
+
return this.info.permissionMode === "full-auto" ? this.theme.fg("warning", label) : label;
|
|
58
|
+
}
|
|
59
|
+
trustText(withSource) {
|
|
60
|
+
const { trusted, trustSource } = this.info;
|
|
61
|
+
const text = `${trusted ? "已信任" : "未信任"}${withSource ? `(${trustSource})` : ""}`;
|
|
62
|
+
return this.theme.fg(trusted ? "success" : "warning", text);
|
|
63
|
+
}
|
|
64
|
+
loadedText() {
|
|
65
|
+
const { contextFiles, skills, prompts, hooks } = this.info;
|
|
66
|
+
const parts = [];
|
|
67
|
+
if (contextFiles.length > 0)
|
|
68
|
+
parts.push(contextFiles.join(", "));
|
|
69
|
+
if (skills > 0)
|
|
70
|
+
parts.push(`${skills} Skill`);
|
|
71
|
+
if (prompts > 0)
|
|
72
|
+
parts.push(`${prompts} 模板`);
|
|
73
|
+
if (hooks > 0)
|
|
74
|
+
parts.push(`${hooks} Hook`);
|
|
75
|
+
return parts.length === 0 ? undefined : parts.join(" · ");
|
|
76
|
+
}
|
|
77
|
+
codemodeText() {
|
|
78
|
+
return this.info.codemode === "off" ? undefined : `codemode ${this.info.codemode}`;
|
|
79
|
+
}
|
|
80
|
+
render(width) {
|
|
81
|
+
if (this.cache?.width === width)
|
|
82
|
+
return this.cache.lines;
|
|
83
|
+
const lines = this.options.level === "header"
|
|
84
|
+
? [this.headerLine(width)]
|
|
85
|
+
: this.options.compact === true || width < HEADER_BOX_MIN_WIDTH
|
|
86
|
+
? this.plainLines(width)
|
|
87
|
+
: this.boxLines(width);
|
|
88
|
+
this.cache = { width, lines };
|
|
89
|
+
return lines;
|
|
90
|
+
}
|
|
91
|
+
headerLine(width) {
|
|
92
|
+
const t = this.theme;
|
|
93
|
+
const sep = t.fg("dim", " · ");
|
|
94
|
+
const parts = [
|
|
95
|
+
this.title(),
|
|
96
|
+
t.fg("accent", withoutChannel(this.info.model)),
|
|
97
|
+
this.modeText(),
|
|
98
|
+
t.fg("dim", "/help"),
|
|
99
|
+
];
|
|
100
|
+
return truncateToWidth(parts.join(sep), width);
|
|
101
|
+
}
|
|
102
|
+
plainLines(width) {
|
|
103
|
+
const t = this.theme;
|
|
104
|
+
const sep = t.fg("dim", " · ");
|
|
105
|
+
const ellipsis = t.glyphs.ellipsis;
|
|
106
|
+
const { info } = this;
|
|
107
|
+
const lines = [this.title()];
|
|
108
|
+
lines.push(t.fg("accent", withoutChannel(info.model)) + sep + info.thinking);
|
|
109
|
+
const trust = this.trustText(false);
|
|
110
|
+
const room = Math.max(4, width - visibleWidth(trust) - 3);
|
|
111
|
+
lines.push(truncateLeft(info.cwd, room, ellipsis) + sep + trust);
|
|
112
|
+
const mode = [this.modeText(), info.preset, this.codemodeText()].filter((p) => p !== undefined);
|
|
113
|
+
lines.push(mode.join(sep));
|
|
114
|
+
const loaded = this.loadedText();
|
|
115
|
+
if (loaded !== undefined)
|
|
116
|
+
lines.push(loaded);
|
|
117
|
+
if (info.host !== undefined)
|
|
118
|
+
lines.push(`宿主 ${info.host}`);
|
|
119
|
+
if (info.warnings > 0)
|
|
120
|
+
lines.push(t.fg("warning", `警告 ${info.warnings} 条(ama doctor)`));
|
|
121
|
+
lines.push(t.fg("dim", "/help · Shift+Tab 切模式"));
|
|
122
|
+
return lines.map((line) => truncateToWidth(line, width));
|
|
123
|
+
}
|
|
124
|
+
boxLines(width) {
|
|
125
|
+
const t = this.theme;
|
|
126
|
+
const sep = t.fg("dim", " · ");
|
|
127
|
+
const { info } = this;
|
|
128
|
+
const boxWidth = Math.min(width, HEADER_BOX_MAX_WIDTH);
|
|
129
|
+
/** 框内文本宽:边框 2 + 内边距 2;键列 6 + 间隔 1。 */
|
|
130
|
+
const valueWidth = boxWidth - 4 - 7;
|
|
131
|
+
const trust = this.trustText(true);
|
|
132
|
+
const cwdRoom = Math.max(4, valueWidth - visibleWidth(trust) - 3);
|
|
133
|
+
const rows = [
|
|
134
|
+
{ key: "模型", value: t.fg("accent", info.model) + sep + `思考 ${info.thinking}` },
|
|
135
|
+
{ key: "目录", value: truncateLeft(info.cwd, cwdRoom, t.glyphs.ellipsis) + sep + trust },
|
|
136
|
+
{
|
|
137
|
+
key: "模式",
|
|
138
|
+
value: [this.modeText(), `预设 ${info.preset}`, this.codemodeText()]
|
|
139
|
+
.filter((p) => p !== undefined)
|
|
140
|
+
.join(sep),
|
|
141
|
+
},
|
|
142
|
+
];
|
|
143
|
+
const loaded = this.loadedText();
|
|
144
|
+
if (loaded !== undefined)
|
|
145
|
+
rows.push({ key: "已加载", value: loaded });
|
|
146
|
+
if (info.host !== undefined)
|
|
147
|
+
rows.push({ key: "宿主", value: info.host });
|
|
148
|
+
if (info.warnings > 0) {
|
|
149
|
+
rows.push({ key: "警告", value: t.fg("warning", `${info.warnings} 条(ama doctor 查看)`) });
|
|
150
|
+
}
|
|
151
|
+
// 键列固定 6 列(「已加载」的宽度),没有这一行时也对齐
|
|
152
|
+
const padded = rows.map((row) => ({ ...row, key: padToWidth(row.key, 6) }));
|
|
153
|
+
const kv = new KeyValue(padded, { theme: t, gap: 1, maxKeyRatio: 1 });
|
|
154
|
+
const body = {
|
|
155
|
+
render: (inner) => [
|
|
156
|
+
this.title(),
|
|
157
|
+
"",
|
|
158
|
+
...kv.render(inner),
|
|
159
|
+
"",
|
|
160
|
+
t.fg("dim", "/help 命令 · Shift+Tab 切模式 · Ctrl+O 展开工具输出"),
|
|
161
|
+
],
|
|
162
|
+
invalidate: () => kv.invalidate(),
|
|
163
|
+
};
|
|
164
|
+
return new Box(body, { theme: t }).render(boxWidth);
|
|
165
|
+
}
|
|
166
|
+
invalidate() {
|
|
167
|
+
this.cache = null;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 交互界面的底部区域:提示行、速率行(status-line.ts)与状态栏(status-bar.ts)的装配。[W5-A]
|
|
3
|
+
*
|
|
4
|
+
* - 布局 `ui.statusLine`(独立终端缺省 full;有 profile 时 PROFILE_DEFAULTS 给 compact);运行时 Ctrl+G
|
|
5
|
+
* (`app.statusLine.toggle`)或 `/statusline [full|compact]` 切换,只影响本会话(本进程),不写配置。
|
|
6
|
+
* - 会话时长从本进程打开当前会话(含 /new /resume /fork 切换)起算,用界面的时钟。
|
|
7
|
+
* - git:`GitInfoWatcher` 在回合边界刷新——agent_settled、写类工具(write / edit / bash / task)结束、
|
|
8
|
+
* session_rewound、/tree 之后;结果变化时重画。
|
|
9
|
+
* - [W5-U] `model_fallback` 之后状态栏模型项显示 `主模型 → 回退模型`,切回主模型(`model_changed`)后消失。
|
|
10
|
+
* - `telemetry_tick`(流式中 ≤ 2 Hz)只重取统计并重画(速率行),状态栏的内容这时不变。
|
|
11
|
+
*/
|
|
12
|
+
import type { AgentSession, SessionEvent } from "../../agent/types.js";
|
|
13
|
+
import type { Runtime } from "../../cli/runtime.js";
|
|
14
|
+
import type { StatusLineMode } from "../../config/types.js";
|
|
15
|
+
import { type Component, type Theme } from "../../tui.js";
|
|
16
|
+
import { StatusBar } from "./status-bar.js";
|
|
17
|
+
import { StatusLine } from "./status-line.js";
|
|
18
|
+
/** 一行提示;空时不占行。 */
|
|
19
|
+
export declare class HintLine implements Component {
|
|
20
|
+
private text;
|
|
21
|
+
setText(text: string): void;
|
|
22
|
+
render(width: number): string[];
|
|
23
|
+
invalidate(): void;
|
|
24
|
+
}
|
|
25
|
+
export interface StatusAreaDeps {
|
|
26
|
+
runtime: Runtime;
|
|
27
|
+
theme: Theme;
|
|
28
|
+
session(): AgentSession;
|
|
29
|
+
now(): number;
|
|
30
|
+
render(): void;
|
|
31
|
+
/**
|
|
32
|
+
* 布局切换后整屏重画(行数变了,差分渲染会在屏底留一空行,宿主按「最后一行 = 状态栏」锚定会错位);
|
|
33
|
+
* 缺省 render。
|
|
34
|
+
*/
|
|
35
|
+
redraw?(): void;
|
|
36
|
+
/** 初始布局(缺省按配置)。 */
|
|
37
|
+
layout?: StatusLineMode;
|
|
38
|
+
env?: NodeJS.ProcessEnv;
|
|
39
|
+
}
|
|
40
|
+
export declare class StatusArea {
|
|
41
|
+
private readonly deps;
|
|
42
|
+
readonly hint: HintLine;
|
|
43
|
+
readonly bar: StatusBar;
|
|
44
|
+
readonly rate: StatusLine;
|
|
45
|
+
private mode;
|
|
46
|
+
private startedAt;
|
|
47
|
+
private git;
|
|
48
|
+
private gitCwd;
|
|
49
|
+
private offGit;
|
|
50
|
+
private sandboxStrict;
|
|
51
|
+
/** [W5-U] 模型回退中(`model_fallback` 到切回主模型)。 */
|
|
52
|
+
private fallback;
|
|
53
|
+
private bashSandbox;
|
|
54
|
+
constructor(deps: StatusAreaDeps);
|
|
55
|
+
layout(): StatusLineMode;
|
|
56
|
+
setLayout(mode: StatusLineMode): void;
|
|
57
|
+
toggle(): StatusLineMode;
|
|
58
|
+
refresh(): void;
|
|
59
|
+
/** 换了会话(/new /resume /fork):时长重新起算,cwd 变了就换 git 监视。 */
|
|
60
|
+
rebind(): void;
|
|
61
|
+
refreshGit(): void;
|
|
62
|
+
/** 返回 true:事件已处理完(只需重画),调用方不再分派。 */
|
|
63
|
+
onEvent(event: SessionEvent): boolean;
|
|
64
|
+
dispose(): void;
|
|
65
|
+
private gitView;
|
|
66
|
+
private watchGit;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* `/statusline [full|compact]`(无参数切换):是这条命令就处理并返回 true,否则 false 交给其它命令。
|
|
70
|
+
* line 模式没有底部信息行,commands-core 只登记命令名、回一句说明。
|
|
71
|
+
*/
|
|
72
|
+
export declare function statusLineSlash(area: StatusArea, line: string, notice: (level: "info" | "error", text: string) => void): boolean;
|
|
73
|
+
export declare function statusLineText(mode: StatusLineMode): string;
|