LearnNewsExamplesServices
Frontmatter
id8309
titleFeat: Neural Link - Get Method Source
stateClosed
labels
enhancementaiarchitecture
assigneestobiu
createdAtJan 4, 2026, 1:54 PM
updatedAtJan 4, 2026, 2:07 PM
githubUrlhttps://github.com/neomjs/neo/issues/8309
authortobiu
commentsCount1
parentIssue8169
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtJan 4, 2026, 2:07 PM

Feat: Neural Link - Get Method Source

Closed v11.18.0/archive-v11-18-0-chunk-2 enhancementaiarchitecture
tobiu
tobiu commented on Jan 4, 2026, 1:54 PM

Context: To safely hot-patch code (Issue #8190), agents need to read the current implementation of a method. This is critical for "read-modify-write" workflows and works across all environments (dev, dist/esm, prod) by retrieving the actual runtime source via Function.toString().

Scope:

  1. Client (RuntimeService.mjs):
    • Implement getMethodSource({className, methodName}).
    • Logic: Neo.ns(className).prototype[methodName].toString().
  2. Server (MCP):
    • Expose get_method_source tool.
    • Update OpenAPI definition.

Goal: Enable agents to see the code they are about to patch.

tobiu
tobiu Jan 4, 2026, 2:06 PM

Input from Gemini 3 pro:

✦ Implemented get_method_source tool.

Key Implementation Details:

  • Robust Type Detection: The client-side implementation in RuntimeService.mjs uses Neo.typeOf(cls) to correctly differentiate between NeoClass (using cls.prototype) and NeoInstance (using cls.constructor.prototype). This ensures it works for both standard classes and singletons (like Neo.worker.App).
  • Source Retrieval: Uses Function.prototype.toString() to retrieve the exact runtime source code of the method.
  • Workflow: This tool is explicitly documented in OpenAPI as the prerequisite step for the patch_code tool, enabling a safe "read-modify-write" hot-patching cycle.
  • Full Stack: Exposed via Neo.ai.Client mapping and the Neural Link MCP Server proxy.