Repository navigation
Description
Overview
Create @nodespace/agent-tools, a TypeScript npm package that exposes NodeSpace knowledge graph operations as callable functions backed by a gRPC client to nodespaced. This is the shared foundation that all per-agent extension shims (next issue) depend on. There is no MCP server — all tool access goes through gRPC directly.
Problem Statement
PTY-spawned agents (Claude Code, Codex, Gemini CLI, Pi, OpenCode) need a way to read and write the NodeSpace knowledge graph during a session. Each agent has its own native extension API, but they all need the same underlying operations. A single shared package avoids duplicating the gRPC client and tool logic in every per-agent shim.
Proposed Solution
A pure TypeScript npm package using @grpc/grpc-js (no native bindings) that connects to nodespaced on localhost:50051. It exports five functions matching the most agent-relevant NodeService operations. Per-agent shims import this package and register the functions as native tools using each agent's extension API.
Acceptance Criteria
-
packages/agent-tools/npm package created and added to the Bun workspace -
@grpc/grpc-jsclient connects tonodespacedonlocalhost:50051 -
searchSemantic(query: string, limit?: number)callsSearchNodesin semantic mode and returns results -
getNode(nodeId: string)callsGetNodeand returns the node with content -
createNode(type: string, content: string, parentId?: string)callsCreateNodeand returns the new node -
updateNode(nodeId: string, content: string)callsUpdateNodeand returns the updated node -
getChildren(nodeId: string)callsGetChildrenand returns the child node list - Connection error (nodespaced not running) returns a structured error object, not an uncaught exception
- Package builds cleanly (
bun run buildin the package directory) - Unit tests cover: each tool function, connection error handling
- All workspace tests pass (
bun run test:allfrom repo root) - Code passes
bun run quality:fix
Technical Specifications
Package location and structure
packages/agent-tools/
├── package.json
├── tsconfig.json
├── src/
│ ├── client.ts # gRPC channel init, NodeServiceClient
│ ├── tools.ts # searchSemantic, getNode, createNode, updateNode, getChildren
│ ├── types.ts # NodeResult, SearchResult, ToolError
│ └── index.ts # re-exports
└── src/tests/
└── tools.test.ts
package.json
{
"name": "@nodespace/agent-tools",
"version": "0.1.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"dependencies": {
"@grpc/grpc-js": "^1.10",
"@grpc/proto-loader": "^0.7"
}
}Proto loading
Load the node_service.proto at runtime using @grpc/proto-loader pointing to packages/daemon/proto/node_service.proto (resolved relative to the package). This avoids duplicating the proto file.
// client.ts
import * as protoLoader from '@grpc/proto-loader';
import * as grpc from '@grpc/grpc-js';
const PROTO_PATH = path.resolve(__dirname, '../../daemon/proto/node_service.proto');Tool function signatures
export interface NodeResult {
id: string;
nodeType: string;
content: string;
parentId?: string;
}
export interface SearchResult {
nodes: NodeResult[];
query: string;
}
export async function searchSemantic(query: string, limit?: number): Promise<SearchResult>
export async function getNode(nodeId: string): Promise<NodeResult>
export async function createNode(type: string, content: string, parentId?: string): Promise<NodeResult>
export async function updateNode(nodeId: string, content: string): Promise<NodeResult>
export async function getChildren(nodeId: string): Promise<NodeResult[]>Error handling
All functions catch gRPC errors and rethrow as a typed ToolError:
export class ToolError extends Error {
constructor(public code: string, message: string) { super(message); }
}
// e.g. new ToolError('UNAVAILABLE', 'nodespaced is not running on localhost:50051')Connection singleton
The gRPC channel is created once (lazy singleton) and reused across calls. Connection is not established until the first call.
Reference files
packages/daemon/proto/node_service.proto— gRPC interface (from Define protobuf schema and set up tonic/prost build pipeline for nodespaced #1111)
Dependencies
- Define protobuf schema and set up tonic/prost build pipeline for nodespaced #1111
- Implement AgentSessionService gRPC handler in nodespaced #1119
Non-Goals
- Per-agent shims that register these functions as native tools (next issue)
AgentSessionServiceoperations in this package (session management is done by the desktop UI / CLI, not by agents calling tools)- Authentication or API keys (gRPC is local-only, no auth needed)
Activity
malibio commentedon May 18, 2026
Test baseline before starting work: 128 test files, 3918 tests passed (frontend).
Add @nodespace/agent-tools TypeScript gRPC client package (closes #1122…