Skip to content

fix(agent): improve handler edits and mcp gateway load#88

Merged
simongdavies merged 2 commits intohyperlight-dev:mainfrom
simongdavies:fix-handler-edit-and-mcp-gateway
Apr 28, 2026
Merged

fix(agent): improve handler edits and mcp gateway load#88
simongdavies merged 2 commits intohyperlight-dev:mainfrom
simongdavies:fix-handler-edit-and-mcp-gateway

Conversation

@simongdavies
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings April 28, 2026 21:51
@simongdavies simongdavies added the bug Something isn't working label Apr 28, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_handler tool 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 to loadSource() 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

Comment thread src/sandbox/tool.js
Comment thread README.md Outdated
Comment thread README.md Outdated
@simongdavies simongdavies merged commit df1a03c into hyperlight-dev:main Apr 28, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants