Registry Mirror
Skip to content

Conversation

@chaodu-agent

@chaodu-agent chaodu-agent commented Jun 12, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Split the 2143-line monolithic main.rs into focused modules (inspired by hicder/agy-acp):

Module Lines Responsibility
types.rs 74 Struct definitions (JsonRpc*, Session, StreamingState, StopGuard)
protobuf.rs 94 Proto parsing (extract_text, get_proto_field, read_varint, tool extraction)
db.rs 84 SQLite reading + narration filtering
streaming.rs 168 poll_streaming_delta
adapter.rs 373 Adapter struct, session/model/state management, JSON-RPC handlers
main.rs 600 Event loop, dispatch, execute_prompt, tests

Additional fixes (from e2e testing)

  • PATH resolution: augmented_path() prepends $HOME/bin, $HOME/.local/bin, and fnm node path so agy can find Node.js at runtime
  • Model fetch: replaced 5s timeout poll with blocking .output() — agy models takes ~7s in ECS
  • agy binary path: hardcoded /usr/local/bin/agy (matches Docker image install location)
  • Static fallback models: real model names (Gemini 3.5 Flash/Pro) when agy models fails

Tests

All 15 tests pass (10 unit + 5 integration/e2e).

E2E verified

  • ✅ agy-acp initializes and fetches 8 models
  • ✅ configOptions parsed by OAB, /models shows full list
  • ✅ Prompt/response works (Gemini replies via agy)
  • ⚠️ setConfigOption sends None terminator (kills session) — next message auto-recovers with fresh session

Split 2143-line monolithic main.rs into focused modules:
- types.rs: struct definitions (JsonRpc*, Session, StreamingState, etc.)
- protobuf.rs: proto parsing (extract_text, get_proto_field, read_varint)
- db.rs: SQLite reading + narration filtering
- streaming.rs: poll_streaming_delta
- adapter.rs: Adapter struct, session/model/state management
- main.rs: event loop, JSON-RPC dispatch, execute_prompt

No behavioral changes. All tests pass.
- Add agy_bin() → always resolves to $HOME/.local/bin/agy
- Replace 5s timeout poll with blocking .output()
- Update static fallback to real model names
agy requires Node.js in PATH (set up by fnm in .bashrc).
Without a login shell, agy models returns empty.
Spawn all agy invocations through bash -lc to get the full env.
bash -lc breaks on shell metacharacters in prompt text.
Instead, prepend standard agent paths (bin, .local/bin, fnm node)
to PATH env when spawning agy. No shell escaping needed.
@chaodu-agent
chaodu-agent force-pushed the refactor/agy-acp-modules branch from 5e7e35b to 762d86e Compare June 12, 2026 19:04
@thepagent
thepagent merged commit 0daf40c into main Jun 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants