Repository navigation
Add @nodespace/agent-tools TypeScript gRPC client package (closes #1122) - #1146
Conversation
Create the shared TypeScript foundation that per-agent shims (Claude Code, Codex, Gemini, Pi, OpenCode) will use to read and write the NodeSpace knowledge graph during a session. Exposes five tool functions backed by a pure-TS @grpc/grpc-js client against nodespaced on localhost:50051. - searchSemantic(query, limit?) → SearchNodes in semantic mode - getNode(nodeId) → GetNode - createNode(type, content, parentId?) → CreateNode - updateNode(nodeId, content) → UpdateNode - getChildren(nodeId) → GetChildren The gRPC channel is a lazy singleton; address is overridable via NODESPACED_ADDR. All gRPC errors are normalized into a typed ToolError with the grpc.status code as the error code, so connection failures surface as structured errors instead of uncaught exceptions. Proto is loaded at runtime via @grpc/proto-loader against packages/daemon/proto/node_service.proto — no duplication, no codegen step. 15 tests cover each tool function, proto loading, client caching, and a real connection failure against an unused port. Closes #1122 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Code Review SummaryInitial review of #1146 (closes #1122). The change introduces Recommendation: Approve. All acceptance criteria are met, the design is appropriately minimal (KISS/YAGNI), and the few concerns below are non-blocking improvements / nits that can be addressed in a follow-up if desired. Strengths
Acceptance criteria mapping
FindingsSuggested Improvements
Nitpicks
Security & Performance
Net AssessmentThis is a textbook example of a self-contained, scope-disciplined foundation package. The implementation makes good tradeoffs (runtime proto loading vs codegen, lazy singleton vs DI, manual TS interfaces vs ts-proto). The findings above are all polish-level — none of them affect correctness or the next-issue work that builds on top of this. |
malibio
left a comment
There was a problem hiding this comment.
Reviewed. Recommendation: approve (cannot self-approve via gh). All acceptance criteria met, implementation is clean and scope-disciplined. See the detailed review comment on the PR for findings — all are non-blocking improvements/nits. The one worth following up before downstream consumers land: wire agent-tools tests into the root test:all so regressions are caught in CI.
Implementation changes:
- Replace stringly-typed `callUnary` dispatch with a typed `promisify`
helper that takes a bound method reference. Eliminates the
`Record<string, Function>` cast and the dead "method not found" branch.
- Fix `NodeServiceClient` interface: the methods are *client-side*
unary calls (request + callback → ClientUnaryCall), not server-side
`handleUnaryCall` handlers. Add a `UnaryMethod` type alias.
- `fromNodeResponse` now throws `ToolError('INTERNAL', ...)` when
`nodeData` is missing instead of silently substituting empty content.
The proto guarantees this field is populated; surface the bug.
- Export `PROTO_PATH` from client.ts and add a test that asserts the
file exists on disk — guards against silent breakage if
`packages/daemon` is ever relocated.
- Add comment in tools.ts pointing to `node_service.proto` as the
source of truth for the `Proto*` interfaces (codegen was avoided
per the issue; the drift risk is now documented).
- Add comment in `updateNode` explaining the empty-string semantics
for the non-optional enum-like fields (proto3 treats empty as
"no change", matching the proto's inline comments).
- Wire `agent-tools` into root `test:all` (new `test:agent-tools`
script) and root `quality:fix` so regressions in this package
fail CI from the repo root, not just from the package directory.
- Tests: use top-level imports instead of 12 dynamic re-imports;
add a test for the new fail-loud behavior on missing node_data.
Skipped (with reasoning):
- `setPrototypeOf` in ToolError — with ES2022 target this is genuinely
unnecessary (the reviewer flagged it as "generally unnecessary");
adding it is cargo-cult belt-and-suspenders.
- Switching connection-error.test from port 1 to never-routable
address — speculative flake mitigation; test currently passes in
~100ms. Revisit only if it actually goes flaky.
- Renaming `quality:fix` to `typecheck` — the issue AC names
`quality:fix` verbatim; keeping the name. The script does what
it can without an ESLint config in this package yet.
Test results:
- agent-tools: 17/17 passing (was 15; +2 new tests)
- desktop-app: 128/128 files, 3918/3918 tests (baseline preserved)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Review feedback addressedPushed Addressed (7)
Workspace wiring
Regressions in this package will now fail CI from the repo root, not just from the package directory. Skipped (with reasoning, 3)
Test results
Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: The changes are all polish-level refactors (typed dispatch, accurate types, comments, test coverage of an existing branch) plus workspace wiring. No new functionality, no architectural shifts, no API changes. The test suite expanded by 2 tests, both directly covering the new behavior (proto-path existence, fail-loud on missing node_data). Frontend baseline preserved exactly. Ready for merge pending approval. |
…) (#1146) * Add @nodespace/agent-tools TypeScript gRPC client package Create the shared TypeScript foundation that per-agent shims (Claude Code, Codex, Gemini, Pi, OpenCode) will use to read and write the NodeSpace knowledge graph during a session. Exposes five tool functions backed by a pure-TS @grpc/grpc-js client against nodespaced on localhost:50051. - searchSemantic(query, limit?) → SearchNodes in semantic mode - getNode(nodeId) → GetNode - createNode(type, content, parentId?) → CreateNode - updateNode(nodeId, content) → UpdateNode - getChildren(nodeId) → GetChildren The gRPC channel is a lazy singleton; address is overridable via NODESPACED_ADDR. All gRPC errors are normalized into a typed ToolError with the grpc.status code as the error code, so connection failures surface as structured errors instead of uncaught exceptions. Proto is loaded at runtime via @grpc/proto-loader against packages/daemon/proto/node_service.proto — no duplication, no codegen step. 15 tests cover each tool function, proto loading, client caching, and a real connection failure against an unused port. Closes #1122 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Address PR #1146 review feedback Implementation changes: - Replace stringly-typed `callUnary` dispatch with a typed `promisify` helper that takes a bound method reference. Eliminates the `Record<string, Function>` cast and the dead "method not found" branch. - Fix `NodeServiceClient` interface: the methods are *client-side* unary calls (request + callback → ClientUnaryCall), not server-side `handleUnaryCall` handlers. Add a `UnaryMethod` type alias. - `fromNodeResponse` now throws `ToolError('INTERNAL', ...)` when `nodeData` is missing instead of silently substituting empty content. The proto guarantees this field is populated; surface the bug. - Export `PROTO_PATH` from client.ts and add a test that asserts the file exists on disk — guards against silent breakage if `packages/daemon` is ever relocated. - Add comment in tools.ts pointing to `node_service.proto` as the source of truth for the `Proto*` interfaces (codegen was avoided per the issue; the drift risk is now documented). - Add comment in `updateNode` explaining the empty-string semantics for the non-optional enum-like fields (proto3 treats empty as "no change", matching the proto's inline comments). - Wire `agent-tools` into root `test:all` (new `test:agent-tools` script) and root `quality:fix` so regressions in this package fail CI from the repo root, not just from the package directory. - Tests: use top-level imports instead of 12 dynamic re-imports; add a test for the new fail-loud behavior on missing node_data. Skipped (with reasoning): - `setPrototypeOf` in ToolError — with ES2022 target this is genuinely unnecessary (the reviewer flagged it as "generally unnecessary"); adding it is cargo-cult belt-and-suspenders. - Switching connection-error.test from port 1 to never-routable address — speculative flake mitigation; test currently passes in ~100ms. Revisit only if it actually goes flaky. - Renaming `quality:fix` to `typecheck` — the issue AC names `quality:fix` verbatim; keeping the name. The script does what it can without an ESLint config in this package yet. Test results: - agent-tools: 17/17 passing (was 15; +2 new tests) - desktop-app: 128/128 files, 3918/3918 tests (baseline preserved) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Michael Libio <[email protected]> Co-authored-by: Claude <[email protected]>
Summary
@nodespace/agent-tools, a pure-TypeScript npm package that exposes NodeSpace knowledge graph operations as callable functions for PTY-spawned agents (Claude Code, Codex, Gemini CLI, Pi, OpenCode).@grpc/grpc-jsagainstnodespacedonlocalhost:50051— no MCP server, no native bindings, no codegen step (proto is loaded at runtime via@grpc/proto-loader).searchSemantic,getNode,createNode,updateNode,getChildren, plus a typedToolErrorfor structured connection/RPC error handling.Design Notes
NODESPACED_ADDRenv var, matching the daemon's own convention.packages/daemon/proto/node_service.protoand is loaded at runtime — no duplication, and the agent-tools package automatically stays in sync with the daemon's wire format.ToolError(code, message)wherecodeis thegrpc.statusenum name (UNAVAILABLE,NOT_FOUND, etc.). Callers can branch oncodewithout importing grpc-js.parent_id === ''from the wire is normalized toundefinedon the JS side so root nodes have a cleanNodeResultshape.Test plan
tools.test.ts— each tool function (happy path + error wrapping) using a spy ongetClientclient.test.ts— proto loads, client is cached,resetClientreturns a fresh instanceconnection-error.test.ts— real call against an unused port surfaces as aToolError(not an uncaught exception)bun run buildproduces cleandist/with .d.ts + sourcemapsbunx tsc --noEmitpasses strict type-checkbun run quality:fixclean (0 errors, 0 warnings)bun run rust:test) skipped per CLAUDE.md guidance (no Rust changes in this PR)Acceptance criteria
packages/agent-tools/npm package created and added to the Bun workspace@grpc/grpc-jsclient connects tonodespacedonlocalhost:50051searchSemantic(query, limit?)callsSearchNodesin semantic modegetNode(nodeId)callsGetNodecreateNode(type, content, parentId?)callsCreateNodeupdateNode(nodeId, content)callsUpdateNodegetChildren(nodeId)callsGetChildrenToolError, not an uncaught exceptionbun run quality:fix🤖 Generated with Claude Code