fix: derive runtime ports from cli port#795
Conversation
|
@mturac is attempting to deploy a commit to the rohitg00's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds runtime port utilities and integrates them into CLI startup: a centralized applyPortFlag, computed rest/stream/engine/viewer ports from env/flags, runtime rendering of iii-config.yaml, and updated engine/viewer port resolution and startup to use rendered configs. ChangesRuntime Port Configuration for Multi-Agent Deployment
Sequence DiagramsequenceDiagram
participant CLI as CLI Startup
participant applyPortFlag
participant configuredRuntimePorts
participant prepareRuntimeIiiConfig
participant renderRuntimeIiiConfig
participant startEngine as Start Engine
CLI->>applyPortFlag: Apply --port flag if provided
applyPortFlag->>configuredRuntimePorts: Derive ports from env
configuredRuntimePorts-->>applyPortFlag: restPort, streamPort, enginePort
applyPortFlag->>applyPortFlag: Write III_REST_PORT and sibling vars
CLI->>prepareRuntimeIiiConfig: Prepare config for startup
prepareRuntimeIiiConfig->>renderRuntimeIiiConfig: Render config with runtime ports
renderRuntimeIiiConfig-->>prepareRuntimeIiiConfig: Updated YAML
prepareRuntimeIiiConfig->>prepareRuntimeIiiConfig: Write to ~/.agentmemory/iii-runtime-config.yaml if changed
prepareRuntimeIiiConfig-->>CLI: Rendered config path
CLI->>startEngine: Boot with rendered config
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/cli/runtime-ports.ts`:
- Around line 41-55: applyPortFlag currently sets III_REST_PORT before
computing/validating sibling ports, causing a partial configuration if
enginePort overflows; change applyPortFlag to first compute restPort, streamPort
(restPort+1), viewerPort (restPort+2) and enginePort (restPort+3), validate that
all are within 1..65535 (or <=65535) before mutating env, and if validation
fails either log a clear warning or return an error without setting any env
variables (do not leave III_REST_PORT set alone); keep parsePort and
DEFAULT_REST_PORT usage but move env["III_REST_PORT"] assignment to after the
full-range check.
In `@test/runtime-ports.test.ts`:
- Around line 5-50: Add a unit test for the port overflow edge case: call
applyPortFlag(["--port","65533"], env) and assert that III_REST_PORT is set to
"65533" while all derived sibling ports and derived values (III_STREAMS_PORT,
III_STREAM_PORT, AGENTMEMORY_VIEWER_PORT, III_VIEWER_PORT, III_PORT,
III_ENGINE_PORT, III_ENGINE_URL) remain undefined, verifying the early-return
behavior in runtime-ports.ts (around the enginePort overflow check) to prevent
regressions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 10edccf5-4ed8-4bd9-9549-f45df39fa1cc
📒 Files selected for processing (5)
src/cli.tssrc/cli/runtime-ports.tssrc/config.tssrc/index.tstest/runtime-ports.test.ts
Summary
--portvalueTests
Closes #750
Summary by CodeRabbit
New Features
Tests