fix(agent): improve handler edits and mcp gateway load#88
Merged
simongdavies merged 2 commits intohyperlight-dev:mainfrom Apr 28, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends HyperAgent’s handler-edit workflow by adding a line-range edit API (better aligned with get_handler_source line numbers) and tightens MCP gateway auto-enable behavior by ensuring plugin source is loaded before source-hash verification.
Changes:
- Add
editHandlerLines()to the sandbox tool (JS +.d.ts) and cover it with new sandbox tests. - Update the agent’s
edit_handlertool to support either exact-once string replacement or line-range replacement. - Add a plugin-manager test around
verifySourceHash()behavior and adjust MCP gateway auto-enable toloadSource()before hashing/auditing.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/sandbox-tool.test.ts | Adds test coverage for line-range handler edits and out-of-range rejection. |
| tests/plugin-manager.test.ts | Tests verifySourceHash() behavior before/after loadSource(). |
| src/sandbox/tool.js | Implements editHandlerLines() and exports it from the sandbox tool. |
| src/sandbox/tool.d.ts | Adds TypeScript typings for editHandlerLines(). |
| src/agent/index.ts | Enhances edit_handler tool to support line-based edits; ensures MCP source is loaded before hashing/auditing during auto-enable. |
| README.md | Updates high-level explanation and revises an example CLI prompt. |
Comments suppressed due to low confidence (1)
src/sandbox/tool.js:129
- The SandboxTool JSDoc typedef lists getHandlerSource as
(name: string) => string | null, but the implementation returns an object{ success, code, totalLines, ... }and accepts an options param. Since this block was edited, please update the getHandlerSource JSDoc signature to match the actual API (and keep editHandlerLines consistent with it).
* @property {(name: string, code: string, options?: {isModule?: boolean}) => Promise<{success: boolean, message?: string, error?: string, handlers?: string[], codeSize?: number, mode?: string}>} registerHandler
* @property {(name: string) => Promise<{success: boolean, message?: string, error?: string, handlers?: string[]}>} deleteHandler
* @property {(name: string, startLine: number, endLine: number, replacement: string) => Promise<{success: boolean, message?: string, error?: string, handlers?: string[], codeSize?: number, contextAfter?: string}>} editHandlerLines
* @property {(name: string, event?: object) => Promise<ExecutionResult>} execute
* @property {() => string[]} getHandlers
* @property {(name: string) => string | null} getHandlerSource
* @property {() => string[]} getAvailableModules
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.
No description provided.