feat(messaging): rebuild new manifest-style messaging architecture#4050
Conversation
Signed-off-by: San Dang <sdang@nvidia.com>
📝 WalkthroughWalkthroughAdds a messaging hook subsystem (types, registry, runner, fakes, tests), complete channel manifests (Telegram, Slack, Discord, WeChat, WhatsApp) with built-in registry, a ManifestCompiler and workflow planner with engine modules, and a MessagingSetupApplier (plus comprehensive tests and package export wiring). ChangesMessaging hooks and built-in channel manifests
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches🧪 Generate unit tests (beta)
|
E2E Advisor RecommendationRequired E2E: Dispatch hint: Full advisor summaryE2E Recommendation AdvisorBase: Required E2E
Optional E2E
New E2E recommendations
Dispatch hint
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/lib/messaging/hooks/hook-runner.ts`:
- Around line 82-105: The function isMessagingSerializableValue currently treats
any repeated object as a cycle by using a single WeakSet; change it to track the
current recursion path (visiting) so shared references like [sameObj, sameObj]
are allowed while real reference cycles still fail. In
isMessagingSerializableValue, rename the second parameter to something like
visiting (WeakSet<object>), replace the early "if (seen.has(objectValue)) return
false" with "if (visiting.has(objectValue)) return false" to detect cycles only
on the current stack, add the object to visiting before recursing into arrays or
object values, and remove it from visiting after recursion returns; do not
reject objects just because they were seen earlier in a different branch. Keep
all other logic (primitive checks, prototype check using Object.getPrototypeOf)
the same and ensure recursive calls pass the visiting set.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: f26d3f6a-bab2-4b28-aa67-eb5273dd95be
📒 Files selected for processing (14)
src/lib/messaging/channels/discord/manifest.tssrc/lib/messaging/channels/index.tssrc/lib/messaging/channels/manifests.test.tssrc/lib/messaging/channels/slack/manifest.tssrc/lib/messaging/channels/telegram/manifest.tssrc/lib/messaging/channels/whatsapp/manifest.tssrc/lib/messaging/hooks/hook-runner.test.tssrc/lib/messaging/hooks/hook-runner.tssrc/lib/messaging/hooks/index.tssrc/lib/messaging/hooks/registry.tssrc/lib/messaging/hooks/types.tssrc/lib/messaging/index.tssrc/lib/messaging/manifest/registry.test.tssrc/lib/messaging/manifest/types.test.ts
PR Review AdvisorFindings: 4 needs attention, 8 worth checking, 0 nice ideas Review findings🛠️ Needs attention
🔎 Worth checking
🌱 Nice ideas
Since last review detailsCurrent findings:
This is an automated advisory review. A human maintainer must make the final merge decision. |
Signed-off-by: San Dang <sdang@nvidia.com>
Signed-off-by: San Dang <sdang@nvidia.com>
E2E Scenario Advisor RecommendationRequired scenario E2E: Dispatch required scenario E2E:
Full scenario advisor summaryE2E Scenario AdvisorBase: Required scenario E2E
Optional scenario E2E
Relevant changed files
|
# Conflicts: # src/lib/messaging/manifest/types.test.ts
## Summary Adds the phase-1 messaging manifest compiler that converts channel manifests into a serializable sandbox messaging plan. The compiler resolves channel inputs through env keys and interactive enrollment hooks, then delegates credential, policy, render, build-step, state-update, and health-check planning to small pure engines. ## Related Issue Fixes #3994 ## Changes - Add `ManifestCompiler` with interactive enrollment-hook input resolution and env-key input initialization. - Add compiler plan engines for credential bindings, network policy, agent render fragments, build steps, state updates, and health checks. - Expand `SandboxMessagingPlan` and related manifest plan types to the top-level plan shape required by #3994. - Add coverage for built-in Telegram/Discord/Slack/WeChat/WhatsApp plans, Hermes WeChat policy aliasing, non-interactive env input behavior, secret-free JSON plans, disabled channels, and a synthetic non-built-in channel. ## Type of Change - [x] Code change (feature, bug fix, or refactor) - [ ] Code change with doc updates - [ ] Doc only (prose changes, no code sample modifications) - [ ] Doc only (includes code sample changes) ## Verification - [ ] `npx prek run --all-files` passes - [ ] `npm test` passes - [x] Tests added or updated for new or changed behavior - [x] No secrets, API keys, or credentials committed - [ ] Docs updated for user-facing behavior changes - [ ] `make docs` builds without warnings (doc changes only) - [ ] Doc pages follow the [style guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md) (doc changes only) - [ ] New doc pages include SPDX header and frontmatter (new pages only) Additional verification performed: - `npm test -- --project cli src/lib/messaging` passes. - `npm run typecheck:cli` passes. - `npm run lint -- src/lib/messaging` passes with the existing unrelated warning in `src/lib/onboard/child-exit-tracker.test.ts`. - `git diff --check` passes. - `npm run source-shape:check` passes. - `npx prek run --all-files` and the normal pre-push hook were attempted and currently fail in unrelated full CLI doctor/debug/snapshot tests outside the messaging compiler changes. --- Signed-off-by: San Dang <sdang@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added manifest compilation system for messaging channels with support for multiple agents and workflows * Implemented credential binding and authentication management * Added network policy configuration and agent rendering capabilities * Introduced health check and build step planning * Added state persistence and hydration management * Implemented placeholder resolution for sandbox names and credentials * **Tests** * Added comprehensive test suite validating compilation behavior, credential handling, and plan serialization <!-- review_stack_entry_start --> [](https://app.coderabbit.ai/change-stack/NVIDIA/NemoClaw/pull/4069?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: San Dang <sdang@nvidia.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/lib/messaging/compiler/manifest-compiler.ts`:
- Around line 124-127: The current hooks selection includes hooks for channels
that may be disabled; update the filter applied to manifest.hooks (the chain
that calls isHookForAgent(manifest.hooks, context.agent) and then
cloneHookReference(manifest.id,...)) to also exclude hooks whose channel is
inactive/disabled. Concretely, extend the existing filter predicate in the
manifest.hooks pipeline to require the channel active flag (e.g., check
hook.channel?.active !== false or hook.active !== false depending on your hook
shape) so only hooks for active channels are passed to
cloneHookReference(manifest.id, hook).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 993d082f-9a7f-480a-bd1b-f7ecce7df3ca
📒 Files selected for processing (27)
src/lib/messaging/applier/index.tssrc/lib/messaging/applier/setup-applier.test.tssrc/lib/messaging/applier/setup-applier.tssrc/lib/messaging/applier/types.tssrc/lib/messaging/channels/manifests.test.tssrc/lib/messaging/channels/telegram/hooks/fakes.test.tssrc/lib/messaging/channels/telegram/hooks/fakes.tssrc/lib/messaging/channels/telegram/manifest.tssrc/lib/messaging/channels/wechat/hooks/fakes.test.tssrc/lib/messaging/channels/wechat/hooks/fakes.tssrc/lib/messaging/channels/wechat/manifest.tssrc/lib/messaging/compiler/engines/agent-render-engine.tssrc/lib/messaging/compiler/engines/build-step-engine.tssrc/lib/messaging/compiler/engines/credential-binding-engine.tssrc/lib/messaging/compiler/engines/health-check-engine.tssrc/lib/messaging/compiler/engines/policy-resolver.tssrc/lib/messaging/compiler/engines/state-update-engine.tssrc/lib/messaging/compiler/engines/template.tssrc/lib/messaging/compiler/index.tssrc/lib/messaging/compiler/manifest-compiler.test.tssrc/lib/messaging/compiler/manifest-compiler.tssrc/lib/messaging/compiler/types.tssrc/lib/messaging/compiler/workflow-planner.test.tssrc/lib/messaging/compiler/workflow-planner.tssrc/lib/messaging/index.tssrc/lib/messaging/manifest/types.test.tssrc/lib/messaging/manifest/types.ts
✅ Files skipped from review due to trivial changes (1)
- src/lib/messaging/applier/index.ts
Signed-off-by: San Dang <sdang@nvidia.com>
Unapproving per maintainer request.
Summary
Adds the phase-1 manifest-first messaging architecture foundation. This PR now folds the channel manifest/hook work together with the manifest compiler/planner engines and the serializable setup-applier boundary, while keeping the new path isolated from production workflows.
The current user-facing channel lifecycle is unchanged. The new module gives us typed, serializable planning pieces that can be migrated into onboarding, rebuild, and channel commands in later PRs.
Related Issue
Fixes #3993
Fixes #3994
Fixes #3995
Fixes #3996
Part of #3896
Changes
ChannelManifestdeclarations for Telegram, Discord, Slack, WeChat, and WhatsApp with current env keys, provider placeholders, policy presets, supported agents, render intent, persisted state fields, and rebuild hydration rules.ManifestCompilerandMessagingWorkflowPlannerto compile selected/configured channels into a serializableSandboxMessagingPlan.MessagingSetupApplierscaffolding for plan serialization, OpenShell provider upsert planning/application, policy preset application, agent config writes, build-file hook output application, and hook request listing.Type of Change
Verification
make docsbuilds without warnings (doc changes only)Additional verification:
npm test -- --project cli src/lib/messagingpasses on the synced branch.npm run typecheck:cliwas attempted on the synced branch but currently fails in broader branch/dist-generated test imports and non-messaging type drift, including missingdist/commands/resources.js, missing generateddist/lib/inference/ollama-model-registry, and unrelated onboard/inference test type mismatches.Signed-off-by: San Dang sdang@nvidia.com
Summary by CodeRabbit