Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

@ammar-agent ammar-agent commented Dec 3, 2025

Summary

Replace the internal agentSessionCli.ts with a user-facing mux run command for running agent sessions from the command line, with unified logging across backend and CLI.

Changes

New mux run Command

# Simple usage
mux run "Fix the failing tests"

# With options
mux run --dir /path/to/project --runtime "ssh user@host" "Deploy changes"

# Scripted
echo "Add logging" | mux run --json | jq '.type'

Key improvements over the old CLI:

Old (agentSessionCli.ts) New (mux run)
--workspace-path X --workspace-id Y Auto-derived from --dir
--json-streaming --json
No --help Full --help with examples
Buried in debug/ Top-level subcommand
--thinking-level -t, --thinking
Timeout in ms only --timeout 5m (human-friendly)
Very verbose output Quiet by default (--verbose for info)

Unified Logging with Log Levels

  • Log levels: error, warn, info, debug (hierarchical)
  • CLI default: error (quiet - only errors shown)
  • Desktop default: info (current behavior preserved)
  • Environment override: MUX_LOG_LEVEL=warn or MUX_DEBUG=1
# Quiet by default
mux run "task"

# Verbose output
mux run --verbose "task"

# Explicit level
mux run --log-level debug "task"

Migrated ~30 files from raw console.error/warn/log to unified log.* calls.

CLI Routing with Commander.js

Top-level routing uses Commander.js with lazy loading to avoid importing Electron/AI SDK until needed:

  • mux run - agent sessions
  • mux server - oRPC server
  • mux api - API utilities
  • mux desktop - launch GUI (auto-detected when running under Electron)

Other Improvements

  • Default model: Centralized to Opus 4.5 (DEFAULT_MODEL constant)
  • Timeout parsing: Uses parse-duration library for robust handling (1h30m, 5min, etc.)
  • Terminal-bench: Updated to use new CLI entry point

Testing

  • CLI integration tests in src/cli/run.test.ts
  • All static checks pass
  • E2E tests updated for new default model

Generated with mux

@ammar-agent ammar-agent force-pushed the ephemeral-mux-cli-runtime branch 11 times, most recently from 888f233 to ed5bf69 Compare December 3, 2025 17:09
Replace the internal agentSessionCli.ts with a user-facing `mux run` command:

- Add `mux run` subcommand with Commander.js for proper --help
- Smart defaults: local runtime, medium thinking, auto-generated workspace ID
- Human-friendly timeout parsing (5m, 300s, etc.)
- Clean flag names (--json, --thinking, --dir)
- Full documentation in docs/cli.md

Update terminal-bench to use the new entry point:
- benchmarks/terminal_bench/mux-run.sh now invokes src/cli/run.ts
- Simpler invocation with fewer verbose flags

Usage:
  mux run "Fix the tests"
  mux run --dir /project --runtime "ssh user@host" "Deploy"
  echo "Add logging" | mux run --json

_Generated with `mux`_
Replace the janky hand-rolled duration regex with the well-tested
parse-duration library. This supports more formats including:
- Compound expressions: '1h30m', '1hr 20mins'
- All common units: ms, s, m, h, d, w
- Plain numbers as milliseconds

_Generated with `mux`_
- Change default model from Sonnet to Opus 4.5
- Remove isDefault boolean from model definitions (no static guarantee)
- Add DEFAULT_MODEL_KEY const that directly references a KnownModelKey
- Update all hardcoded model strings to use the centralized DEFAULT_MODEL
- Fix WORKSPACE_DEFAULTS to import from knownModels.ts

The default model is now defined in one place:
  src/common/constants/knownModels.ts -> DEFAULT_MODEL_KEY = "OPUS"

_Generated with `mux`_
- Replace manual argv parsing with proper Commander.js subcommands
- Add --version flag with proper version info
- Subcommands (run, server) now properly routed via executableFile
- Default action launches desktop app when no subcommand given
- Update docs to reflect --version flag instead of subcommand
- Add log levels: error, warn, info, debug (hierarchical)
- Add log.warn() method and log.setLevel()/getLevel() for programmatic control
- CLI defaults to 'error' level (quiet), Desktop defaults to 'info'
- Add --verbose/-v flag to mux run to enable info-level logs
- Add --log-level flag for explicit level control
- Migrate all console.error/warn calls in src/node/ to log.*
- Migrate ORPC error handler to use log.error
- Fix circular dependency: log.ts no longer imports defaultConfig

Environment variable MUX_LOG_LEVEL=error|warn|info|debug overrides defaults.
MUX_DEBUG=1 enables debug level as before.

_Generated with mux_
@ammar-agent ammar-agent force-pushed the ephemeral-mux-cli-runtime branch from f7fc7d7 to ce920e4 Compare December 3, 2025 17:38
@ammario ammario merged commit ac30c74 into main Dec 3, 2025
26 of 27 checks passed
@ammario ammario deleted the ephemeral-mux-cli-runtime branch December 3, 2025 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants