Skip to content

feat: add Thenvoi Platform channel integration#2

Closed
darvell-thenvoi wants to merge 3 commits intothenvoi:feat/thenvoi-channelfrom
darvell-thenvoi:feat/thenvoi-channel
Closed

feat: add Thenvoi Platform channel integration#2
darvell-thenvoi wants to merge 3 commits intothenvoi:feat/thenvoi-channelfrom
darvell-thenvoi:feat/thenvoi-channel

Conversation

@darvell-thenvoi
Copy link
Copy Markdown

@darvell-thenvoi darvell-thenvoi commented Mar 25, 2026

Summary

Adds Thenvoi Platform as a NanoClaw channel with full extension support, installable via the /add-thenvoi skill.

  • Channel (src/channels/thenvoi.ts): WebSocket connection via SDK's AgentRuntime, room subscription, message routing to/from NanoClaw's container agents
  • SDK MCP bridge: Thenvoi tools run as an in-process MCP server via createThenvoiSdkMcpServer() from @thenvoi/sdk/mcp/claude — tool schemas and dispatch stay in sync with the SDK automatically
  • Contacts extension: Three strategies (disabled, callback/auto-approve, hub room/LLM-managed) configurable via THENVOI_CONTACT_STRATEGY
  • Memory extension: Platform memory tools (store, list, get, supersede, archive) toggled via THENVOI_MEMORY_TOOLS=true
  • Credential proxy: Routes container API calls through the host proxy so containers never hold real keys
  • Platform instructions: System prompt guidance for mentions, delegation, thoughts, and memory usage
  • Skills: /add-thenvoi, /add-thenvoi-contacts, /add-thenvoi-memory for guided setup
  • Tests: Unit tests for channel registration, contact strategies, remote control integration

Uses @thenvoi/sdk@0.1.3 from npm. Owner identity resolved via SDK's getAgentMe().ownerUuid with THENVOI_OWNER_ID as an explicit override.

Test plan

  • Install channel via /add-thenvoi skill on a fresh NanoClaw instance
  • Verify agent responds on the platform (thenvoi_send_message works)
  • Verify delegation (thenvoi_lookup_peers + thenvoi_add_participant)
  • Enable memory tools and verify store/list/get cycle
  • Test contact strategies (disabled, callback, hub_room)
  • Verify NanoClaw IPC tools (send_message, schedule_task) still work alongside Thenvoi tools
  • Run unit tests: npm test

🤖 Generated with Claude Code

darvell-thenvoi and others added 2 commits March 25, 2026 11:58
Replace manual tool registration (thenvoi-tools.ts) with the SDK's
createThenvoiSdkMcpServer() from @thenvoi/sdk/mcp/claude. Thenvoi
platform tools now run as an in-process MCP server managed by the SDK,
keeping tool schemas and dispatch in sync automatically.

- Add SDK MCP bridge setup in container agent runner
- Register thenvoi as separate MCP server alongside nanoclaw IPC server
- Remove manual JSON Schema-to-Zod conversion and tool dispatch
- Delete thenvoi-tools.ts (120 lines replaced by SDK bridge)
- Add add-thenvoi-memory skill for enabling platform memory tools

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@darvell-thenvoi darvell-thenvoi changed the title fix: use published thenvoi sdk owner identity feat: add Thenvoi Platform channel integration Mar 26, 2026
@roi-shikler-thenvoi
Copy link
Copy Markdown

roi-shikler-thenvoi commented Mar 31, 2026

**Tried this out, and Claude spiraled for ~17 minutes, repeatedly fixing and re-fixing things.

Can you review its summary of what it did? It really should be much simpler than this.**
@darvell-thenvoi

Here's a comprehensive summary of every issue that deviated from the standard install process, in
order of occurrence:


Issue #1: Container build fails — @thenvoi/rest-client tarball missing

Error: ENOENT: no such file or directory, open '/app/vendor/thenvoi-rest-client.tgz'

Cause: container/build.sh tries to npm pack the rest-client from ../fern-javascript-sdk, which
doesn't exist on this machine. The build script warns ("Warning: @thenvoi/rest-client not found ...
skipping") but the container/agent-runner/package.json still references
file:./vendor/thenvoi-rest-client.tgz, so Docker npm install fails.

Fix applied: Changed the container's package.json to use the npm registry version
("@thenvoi/rest-client": "0.0.112-rc.0") instead of the local tarball. This is fragile — the build
script should either fail hard when the local repo is missing or fall back to the npm version
automatically.

Ticket: build.sh should handle missing fern-javascript-sdk gracefully (either fail with clear error
or fallback to npm registry)


Issue #2: SDK missing mcp/claude subpath export

Error: Cannot find module '@thenvoi/sdk/mcp/claude' (container TypeScript build)

Cause: The container code imports createThenvoiMcpBridge from @thenvoi/sdk/mcp/claude, but the SDK
(v0.1.0) has no such entry point. The function exists at src/adapters/claude-sdk/mcp.ts but:

  • It's not exported from the adapters barrel (tsup tree-shakes it out even when added to the barrel)
  • There's no mcp/claude entry in tsup.config.ts or package.json exports

Fix applied (SDK source change): Added "mcp/claude": "src/adapters/claude-sdk/mcp.ts" to
tsup.config.ts entry points and added "./mcp/claude" to package.json exports map.

Ticket: SDK needs mcp/claude subpath export in tsup.config.ts and package.json exports


Issue #3: Published SDK v0.1.3 crashes NanoClaw at startup

Error: ERR_MODULE_NOT_FOUND: Cannot find package '@agentclientprotocol/sdk' then Cannot find package
'@anthropic-ai/claude-agent-sdk'

Cause: The npm-published @thenvoi/sdk@0.1.3 bundles all adapter code (OpenAI, Anthropic, LangGraph,
ACP, etc.) into shared ESM chunks. ESM eagerly resolves ALL imports in loaded chunks, so even though
NanoClaw only uses AgentRuntime, the chunk loading triggers resolution of every optional peer
dependency. Missing optional peers crash the process.

Fix applied: Switched from npm v0.1.3 to the local SDK build (npm install
/path/to/thenvoi-sdk-typescript).

Ticket: Published SDK v0.1.3 ESM chunks cause crashes when optional peer deps are missing. Need
either: (a) separate chunk-splitting strategy that isolates adapters, or (b) dynamic imports for
adapter-specific code


Issue #4: Local SDK install creates broken @thenvoi/rest-client symlink

Error: REST API calls fail at runtime — symlink at node_modules/@thenvoi/rest-client points to
nonexistent ../../../fern-javascript-sdk

Cause: When installing the local SDK via npm install /path/to/thenvoi-sdk-typescript, npm resolves
the SDK's dependency "@thenvoi/rest-client": "0.0.112-rc.0" through the SDK's own node_modules,
creating a symlink to the SDK's local dev dependency which points to ../fern-javascript-sdk (doesn't
exist on this machine).

Fix applied: Manually removed the broken symlink and installed npm install
@thenvoi/rest-client@0.0.112-rc.0 from the registry.

Ticket: SDK's dev setup leaks local filesystem paths into dependency resolution when installed as a
local package


Issue #5: AgentIdentity.ownerUuid type mismatch

Error: TS2339: Property 'ownerUuid' does not exist on type 'AgentIdentity'

Cause: src/channels/thenvoi.ts:381 accesses identity.ownerUuid which exists in published SDK v0.1.3
but not in local SDK v0.1.0. The AgentIdentity interface in the local build only has id, name,
description, handle.

Fix applied: Cast to unknown as Record<string, unknown> for safe property access.

Ticket: Either ownerUuid needs to be added to the local SDK's AgentIdentity type, or the channel code
should handle its absence without a type assertion hack


Issue #6: UnsupportedFeatureError: Fern client missing next-message endpoint

Error: Fatal runtime error on every incoming message — Execution.processLoop crashes

Cause: The SDK's execution loop calls ThenvoiLink.getNextMessage() → RestFacade.getNextMessage() →
FernRestAdapter.getNextMessage(). The Fern rest-client (both 0.0.112 and 0.0.112-rc.0) doesn't have
chatMessages.getNextMessage or agentApiMessages.getAgentNextMessage. The adapter throws
UnsupportedFeatureError, which propagates up uncaught.

The ThenvoiLink.getNextMessage has a guard if (!this.rest.getNextMessage) that's useless because
this.rest is RestFacade which always has the method (it's a class method), but the underlying adapter
throws.

Fix applied (SDK source change): Changed ThenvoiLink.getNextMessage to catch UnsupportedFeatureError
and return null instead of propagating the error.

Ticket: ThenvoiLink.getNextMessage must gracefully handle UnsupportedFeatureError from the REST
adapter. The rest-client needs the next-message API endpoint added.


Issue #7: REST API 404 on /api/v1/chats?page=1

Warning: Thenvoi: failed to sync rooms via agent API (non-fatal)

Cause: Room sync calls link.rest.listChats() which sends a GET to
https://app.thenvoi.com/api/v1/chats?page=1. The platform returns 404 — either the endpoint path is
different in the platform version, or this API requires a different version of the rest-client.

No fix applied — the warning is non-fatal. Rooms register via WebSocket instead.

Ticket: Rest-client listChats endpoint returns 404 from the platform. Either the endpoint path
changed or the rest-client version is mismatched.


Issue #8: Room deregistration on failed REST sync

Bug: Previously registered rooms get deregistered on service restart

Cause: In connect(): activeRoomIds.clear() runs before syncRoomsFromApi(). When the sync fails (404),
activeRoomIds stays empty. Then the cleanup loop deregisters ALL existing thenvoi groups because
none are in activeRoomIds.

Fix applied: Made syncRoomsFromApi() return a boolean; cleanup loop only runs when sync succeeds.

Ticket: src/channels/thenvoi.ts — stale group cleanup should be skipped when room sync fails


Summary of SDK source changes I made (should be tickets)

All in /Users/roishikler/codebase/thenvoi-sdk-typescript:

  1. src/adapters/claude-sdk/index.ts — Added re-export of createThenvoiMcpBridge and ThenvoiMcpBridge
    from ./mcp
  2. tsup.config.ts — Added "mcp/claude" entry point
  3. package.json — Added "./mcp/claude" export path
  4. src/platform/ThenvoiLink.ts — getNextMessage() catches UnsupportedFeatureError and returns null

@roi-shikler-thenvoi
Copy link
Copy Markdown

Closing in favor of PR #1 which now includes this SDK bump (cherry-picked commit b06eb86) plus additional fixes (rest-client upgrade, container limit config, onboarding improvements).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants