refactor(agent): split veryfront-cloud-agent-service into concern modules - #3054
Merged
Merged
Conversation
…ules Decompose the 1551-line monolith into five sibling modules under src/agent/hosted/, each owning one concern: - cloud-agent-paths.ts — path/dir resolution, service naming, env - cloud-agent-provider-bootstrap.ts — schema/auth/telemetry/bash defaults - cloud-agent-config.ts — context creation, agent-config resolution, steering - cloud-agent-child-tools.ts — MCP resolution, delegation, invoke-agent, skill/steering accessors - cloud-agent-chat-execution.ts — chat execution preparation, runtime wiring veryfront-cloud-agent-service.ts retains all 7 public function/const exports and all public types as thin re-exports; no importer of the file changes. Zero behavior change. All 26 tests pass.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the hosted cloud agent service by splitting the former veryfront-cloud-agent-service.ts monolith into focused concern modules, while keeping the original file as a thin public wiring layer that preserves the existing public exports and types.
Changes:
- Extracted provider/bootstrap logic (schema, auth, telemetry, bash tooling) into
cloud-agent-provider-bootstrap.ts. - Extracted path/project/service-name resolution into
cloud-agent-paths.ts, and agent config/context initialization intocloud-agent-config.ts. - Extracted hosted child-tool assembly and chat execution preparation/runtime wiring into
cloud-agent-child-tools.tsandcloud-agent-chat-execution.ts.
Verification
- Not run in this review environment.
- Next step: run
deno test --no-check --allow-all --parallel(or the repo’sdeno task verify:quickif available) to ensure the refactor stays behavior-neutral.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/agent/hosted/veryfront-cloud-agent-service.ts | Reduced to a thin public wiring layer that re-exports the existing public surface and delegates to concern modules. |
| src/agent/hosted/cloud-agent-provider-bootstrap.ts | Centralizes default extension/provider bootstrap and option resolution. |
| src/agent/hosted/cloud-agent-paths.ts | Centralizes baseDir/projectDir/environment/serviceName resolution helpers. |
| src/agent/hosted/cloud-agent-config.ts | Centralizes agent discovery, default agent selection, and cached project-steering/config access. |
| src/agent/hosted/cloud-agent-child-tools.ts | Centralizes MCP server resolution, invoke-agent wiring, and hosted child tool/context helpers. |
| src/agent/hosted/cloud-agent-chat-execution.ts | Centralizes chat execution preparation, runtime creation, and control-plane registration lifecycle wiring. |
Comments suppressed due to low confidence (1)
src/agent/hosted/cloud-agent-chat-execution.ts:116
- Avoid
taskContext as unknown as ChildRunContextwhen wiringinvoke_agent. Theunknownhop bypasses type checking, so future changes could accidentally rely on properties that aren't present on the root chat runtime task context. Align the context types so this call can passtaskContextwithout a double assertion.
// child-fork tool. Explicit scoped delegate bindings opt out.
tools.invoke_agent = createInvokeAgentTool(
context,
taskContext as unknown as ChildRunContext,
);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
src/agent/hosted/cloud-agent-chat-execution.ts:27
- This import becomes redundant once "createRemoteMCPToolSource" is included in the top-level "#veryfront/tool" import.
import { createRemoteMCPToolSource } from "#veryfront/tool";
kwakayama
approved these changes
Jul 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Candidate #4 from the architecture review.
veryfront-cloud-agent-service.tswas 1551 lines / 57 internal functions / 7 exports — five concerns fused into one file, and the mandatory read for nearly every hosted change (the second-hottest area of the repo).Changes
Pure move refactor into five concern modules, with the original file keeping all 7 public exports (and public types) as thin wiring — no importer changes:
cloud-agent-chat-execution.tscloud-agent-child-tools.tscloud-agent-config.tscloud-agent-provider-bootstrap.tscloud-agent-paths.tsveryfront-cloud-agent-service.tsAccounting
Net +197 lines — move-refactor overhead (imports, module headers). Shipped as-is per explicit approval: the reduction rule keeps applying to dedup PRs, while this one buys locality (a provider-bootstrap change no longer means navigating 1500 lines) and per-concern testability.
Verification
deno task verify:quickexit 0 · pre-push (fmt + full suite) passedImplemented by a worktree executor from the review spec; verified, with five unused-import leftovers removed on review.