agenticros 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +192 -0
- package/README.md +90 -4
- package/dist/commands/config.d.ts +20 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +179 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/doctor.d.ts +33 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +232 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/down.d.ts +15 -0
- package/dist/commands/down.d.ts.map +1 -0
- package/dist/commands/down.js +91 -0
- package/dist/commands/down.js.map +1 -0
- package/dist/commands/init.d.ts +21 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +259 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/logs.d.ts +18 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +67 -0
- package/dist/commands/logs.js.map +1 -0
- package/dist/commands/status.d.ts +12 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +56 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/up.d.ts +20 -0
- package/dist/commands/up.d.ts.map +1 -0
- package/dist/commands/up.js +70 -0
- package/dist/commands/up.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +107 -0
- package/dist/index.js.map +1 -0
- package/dist/menu.d.ts +9 -0
- package/dist/menu.d.ts.map +1 -0
- package/dist/menu.js +96 -0
- package/dist/menu.js.map +1 -0
- package/dist/runners/real-robot.d.ts +15 -0
- package/dist/runners/real-robot.d.ts.map +1 -0
- package/dist/runners/real-robot.js +46 -0
- package/dist/runners/real-robot.js.map +1 -0
- package/dist/runners/sim.d.ts +19 -0
- package/dist/runners/sim.d.ts.map +1 -0
- package/dist/runners/sim.js +53 -0
- package/dist/runners/sim.js.map +1 -0
- package/dist/util/env.d.ts +24 -0
- package/dist/util/env.d.ts.map +1 -0
- package/dist/util/env.js +53 -0
- package/dist/util/env.js.map +1 -0
- package/dist/util/logger.d.ts +24 -0
- package/dist/util/logger.d.ts.map +1 -0
- package/dist/util/logger.js +62 -0
- package/dist/util/logger.js.map +1 -0
- package/dist/util/paths.d.ts +57 -0
- package/dist/util/paths.d.ts.map +1 -0
- package/dist/util/paths.js +132 -0
- package/dist/util/paths.js.map +1 -0
- package/dist/util/pidfile.d.ts +16 -0
- package/dist/util/pidfile.d.ts.map +1 -0
- package/dist/util/pidfile.js +63 -0
- package/dist/util/pidfile.js.map +1 -0
- package/dist/util/state.d.ts +26 -0
- package/dist/util/state.d.ts.map +1 -0
- package/dist/util/state.js +55 -0
- package/dist/util/state.js.map +1 -0
- package/package.json +60 -1
- package/runtime/BUNDLE.json +11 -0
- package/runtime/LICENSE +192 -0
- package/runtime/README.md +273 -0
- package/runtime/docs/architecture.md +366 -0
- package/runtime/docs/cli.md +140 -0
- package/runtime/docs/memory.md +292 -0
- package/runtime/docs/robot-setup.md +347 -0
- package/runtime/package.json +28 -0
- package/runtime/packages/agenticros/agenticros-agenticros-0.0.1.tgz +0 -0
- package/runtime/packages/agenticros/openclaw.plugin.json +451 -0
- package/runtime/packages/agenticros/package.json +41 -0
- package/runtime/packages/agenticros/src/camera-snapshot-cache.ts +59 -0
- package/runtime/packages/agenticros/src/camera-snapshot-routes.ts +44 -0
- package/runtime/packages/agenticros/src/commands/estop.ts +41 -0
- package/runtime/packages/agenticros/src/commands/transport.ts +195 -0
- package/runtime/packages/agenticros/src/config-file.ts +136 -0
- package/runtime/packages/agenticros/src/config-page.ts +498 -0
- package/runtime/packages/agenticros/src/context/robot-context.ts +373 -0
- package/runtime/packages/agenticros/src/depth.ts +313 -0
- package/runtime/packages/agenticros/src/describer.ts +157 -0
- package/runtime/packages/agenticros/src/image-binary-trim.ts +16 -0
- package/runtime/packages/agenticros/src/index.ts +85 -0
- package/runtime/packages/agenticros/src/landing-page.ts +38 -0
- package/runtime/packages/agenticros/src/memory.ts +44 -0
- package/runtime/packages/agenticros/src/plugin-api.ts +173 -0
- package/runtime/packages/agenticros/src/plugin-image-base64.ts +69 -0
- package/runtime/packages/agenticros/src/preflight.ts +110 -0
- package/runtime/packages/agenticros/src/routes.ts +328 -0
- package/runtime/packages/agenticros/src/safety/validator.ts +43 -0
- package/runtime/packages/agenticros/src/service.ts +359 -0
- package/runtime/packages/agenticros/src/skill-api.ts +65 -0
- package/runtime/packages/agenticros/src/skill-loader.ts +146 -0
- package/runtime/packages/agenticros/src/teleop/page.ts +498 -0
- package/runtime/packages/agenticros/src/teleop/routes.ts +650 -0
- package/runtime/packages/agenticros/src/tools/index.ts +26 -0
- package/runtime/packages/agenticros/src/tools/ros2-action.ts +50 -0
- package/runtime/packages/agenticros/src/tools/ros2-camera.ts +221 -0
- package/runtime/packages/agenticros/src/tools/ros2-depth-distance.ts +58 -0
- package/runtime/packages/agenticros/src/tools/ros2-introspect.ts +62 -0
- package/runtime/packages/agenticros/src/tools/ros2-memory.ts +158 -0
- package/runtime/packages/agenticros/src/tools/ros2-param.ts +87 -0
- package/runtime/packages/agenticros/src/tools/ros2-publish.ts +52 -0
- package/runtime/packages/agenticros/src/tools/ros2-service.ts +46 -0
- package/runtime/packages/agenticros/src/tools/ros2-subscribe.ts +71 -0
- package/runtime/packages/agenticros/tsconfig.json +9 -0
- package/runtime/packages/agenticros-claude-code/README.md +260 -0
- package/runtime/packages/agenticros-claude-code/config.example.json +9 -0
- package/runtime/packages/agenticros-claude-code/dist/config.d.ts +8 -0
- package/runtime/packages/agenticros-claude-code/dist/config.d.ts.map +1 -0
- package/runtime/packages/agenticros-claude-code/dist/config.js +93 -0
- package/runtime/packages/agenticros-claude-code/dist/config.js.map +1 -0
- package/runtime/packages/agenticros-claude-code/dist/depth.d.ts +20 -0
- package/runtime/packages/agenticros-claude-code/dist/depth.d.ts.map +1 -0
- package/runtime/packages/agenticros-claude-code/dist/depth.js +126 -0
- package/runtime/packages/agenticros-claude-code/dist/depth.js.map +1 -0
- package/runtime/packages/agenticros-claude-code/dist/find-object/coco-classes.d.ts +6 -0
- package/runtime/packages/agenticros-claude-code/dist/find-object/coco-classes.d.ts.map +1 -0
- package/runtime/packages/agenticros-claude-code/dist/find-object/coco-classes.js +36 -0
- package/runtime/packages/agenticros-claude-code/dist/find-object/coco-classes.js.map +1 -0
- package/runtime/packages/agenticros-claude-code/dist/find-object/find-object.d.ts +33 -0
- package/runtime/packages/agenticros-claude-code/dist/find-object/find-object.d.ts.map +1 -0
- package/runtime/packages/agenticros-claude-code/dist/find-object/find-object.js +134 -0
- package/runtime/packages/agenticros-claude-code/dist/find-object/find-object.js.map +1 -0
- package/runtime/packages/agenticros-claude-code/dist/follow-me/controller.d.ts +43 -0
- package/runtime/packages/agenticros-claude-code/dist/follow-me/controller.d.ts.map +1 -0
- package/runtime/packages/agenticros-claude-code/dist/follow-me/controller.js +73 -0
- package/runtime/packages/agenticros-claude-code/dist/follow-me/controller.js.map +1 -0
- package/runtime/packages/agenticros-claude-code/dist/follow-me/detector.d.ts +58 -0
- package/runtime/packages/agenticros-claude-code/dist/follow-me/detector.d.ts.map +1 -0
- package/runtime/packages/agenticros-claude-code/dist/follow-me/detector.js +251 -0
- package/runtime/packages/agenticros-claude-code/dist/follow-me/detector.js.map +1 -0
- package/runtime/packages/agenticros-claude-code/dist/follow-me/loop.d.ts +61 -0
- package/runtime/packages/agenticros-claude-code/dist/follow-me/loop.d.ts.map +1 -0
- package/runtime/packages/agenticros-claude-code/dist/follow-me/loop.js +268 -0
- package/runtime/packages/agenticros-claude-code/dist/follow-me/loop.js.map +1 -0
- package/runtime/packages/agenticros-claude-code/dist/index.d.ts +3 -0
- package/runtime/packages/agenticros-claude-code/dist/index.d.ts.map +1 -0
- package/runtime/packages/agenticros-claude-code/dist/index.js +111 -0
- package/runtime/packages/agenticros-claude-code/dist/index.js.map +1 -0
- package/runtime/packages/agenticros-claude-code/dist/memory.d.ts +17 -0
- package/runtime/packages/agenticros-claude-code/dist/memory.d.ts.map +1 -0
- package/runtime/packages/agenticros-claude-code/dist/memory.js +44 -0
- package/runtime/packages/agenticros-claude-code/dist/memory.js.map +1 -0
- package/runtime/packages/agenticros-claude-code/dist/safety.d.ts +10 -0
- package/runtime/packages/agenticros-claude-code/dist/safety.d.ts.map +1 -0
- package/runtime/packages/agenticros-claude-code/dist/safety.js +34 -0
- package/runtime/packages/agenticros-claude-code/dist/safety.js.map +1 -0
- package/runtime/packages/agenticros-claude-code/dist/tools.d.ts +36 -0
- package/runtime/packages/agenticros-claude-code/dist/tools.d.ts.map +1 -0
- package/runtime/packages/agenticros-claude-code/dist/tools.js +777 -0
- package/runtime/packages/agenticros-claude-code/dist/tools.js.map +1 -0
- package/runtime/packages/agenticros-claude-code/dist/transport.d.ts +17 -0
- package/runtime/packages/agenticros-claude-code/dist/transport.d.ts.map +1 -0
- package/runtime/packages/agenticros-claude-code/dist/transport.js +46 -0
- package/runtime/packages/agenticros-claude-code/dist/transport.js.map +1 -0
- package/runtime/packages/agenticros-claude-code/dist/zero-shot/detector.d.ts +42 -0
- package/runtime/packages/agenticros-claude-code/dist/zero-shot/detector.d.ts.map +1 -0
- package/runtime/packages/agenticros-claude-code/dist/zero-shot/detector.js +114 -0
- package/runtime/packages/agenticros-claude-code/dist/zero-shot/detector.js.map +1 -0
- package/runtime/packages/agenticros-claude-code/package.json +29 -0
- package/runtime/packages/agenticros-claude-code/src/config.ts +96 -0
- package/runtime/packages/agenticros-claude-code/src/depth.ts +173 -0
- package/runtime/packages/agenticros-claude-code/src/find-object/coco-classes.ts +38 -0
- package/runtime/packages/agenticros-claude-code/src/find-object/find-object.ts +190 -0
- package/runtime/packages/agenticros-claude-code/src/follow-me/controller.ts +109 -0
- package/runtime/packages/agenticros-claude-code/src/follow-me/depth-loop.ts +420 -0
- package/runtime/packages/agenticros-claude-code/src/follow-me/detector.ts +303 -0
- package/runtime/packages/agenticros-claude-code/src/follow-me/loop.ts +330 -0
- package/runtime/packages/agenticros-claude-code/src/index.ts +125 -0
- package/runtime/packages/agenticros-claude-code/src/memory.ts +51 -0
- package/runtime/packages/agenticros-claude-code/src/safety.ts +44 -0
- package/runtime/packages/agenticros-claude-code/src/tools.ts +891 -0
- package/runtime/packages/agenticros-claude-code/src/transport.ts +58 -0
- package/runtime/packages/agenticros-claude-code/src/zero-shot/detector.ts +169 -0
- package/runtime/packages/agenticros-claude-code/tsconfig.json +9 -0
- package/runtime/packages/agenticros-claude-code/yolo-debug.mjs +106 -0
- package/runtime/packages/agenticros-gemini/README.md +139 -0
- package/runtime/packages/agenticros-gemini/package.json +28 -0
- package/runtime/packages/agenticros-gemini/scripts/smoke-api.mjs +42 -0
- package/runtime/packages/agenticros-gemini/src/chat.ts +139 -0
- package/runtime/packages/agenticros-gemini/src/config.ts +92 -0
- package/runtime/packages/agenticros-gemini/src/depth.ts +173 -0
- package/runtime/packages/agenticros-gemini/src/index.ts +58 -0
- package/runtime/packages/agenticros-gemini/src/memory.ts +32 -0
- package/runtime/packages/agenticros-gemini/src/safety.ts +44 -0
- package/runtime/packages/agenticros-gemini/src/tools.ts +516 -0
- package/runtime/packages/agenticros-gemini/src/transport.ts +58 -0
- package/runtime/packages/agenticros-gemini/tsconfig.json +8 -0
- package/runtime/packages/core/package.json +47 -0
- package/runtime/packages/core/src/banner.ts +32 -0
- package/runtime/packages/core/src/cmd-vel-twist.ts +31 -0
- package/runtime/packages/core/src/config.ts +279 -0
- package/runtime/packages/core/src/index.ts +54 -0
- package/runtime/packages/core/src/memory/__tests__/factory.test.ts +70 -0
- package/runtime/packages/core/src/memory/__tests__/local-provider.test.ts +195 -0
- package/runtime/packages/core/src/memory/__tests__/mem0-provider.test.ts +192 -0
- package/runtime/packages/core/src/memory/__tests__/smart-defaults.test.ts +46 -0
- package/runtime/packages/core/src/memory/factory.ts +63 -0
- package/runtime/packages/core/src/memory/index.ts +10 -0
- package/runtime/packages/core/src/memory/local/provider.ts +229 -0
- package/runtime/packages/core/src/memory/mem0/provider.ts +379 -0
- package/runtime/packages/core/src/memory/types.ts +96 -0
- package/runtime/packages/core/src/topic-utils.ts +95 -0
- package/runtime/packages/core/src/transport/factory.ts +47 -0
- package/runtime/packages/core/src/transport/local/conversion.ts +333 -0
- package/runtime/packages/core/src/transport/local/entities.ts +129 -0
- package/runtime/packages/core/src/transport/local/transport.ts +406 -0
- package/runtime/packages/core/src/transport/rosbridge/actions.ts +81 -0
- package/runtime/packages/core/src/transport/rosbridge/adapter.ts +157 -0
- package/runtime/packages/core/src/transport/rosbridge/client.ts +438 -0
- package/runtime/packages/core/src/transport/rosbridge/services.ts +41 -0
- package/runtime/packages/core/src/transport/rosbridge/topics.ts +60 -0
- package/runtime/packages/core/src/transport/rosbridge/types.ts +118 -0
- package/runtime/packages/core/src/transport/transport.ts +77 -0
- package/runtime/packages/core/src/transport/types.ts +137 -0
- package/runtime/packages/core/src/transport/webrtc/signaling-client.ts +196 -0
- package/runtime/packages/core/src/transport/webrtc/signaling-types.ts +130 -0
- package/runtime/packages/core/src/transport/webrtc/transport.ts +516 -0
- package/runtime/packages/core/src/transport/zenoh/adapter.ts +357 -0
- package/runtime/packages/core/src/transport/zenoh/cdr.ts +183 -0
- package/runtime/packages/core/src/transport/zenoh/keys.ts +51 -0
- package/runtime/packages/core/tsconfig.json +9 -0
- package/runtime/packages/ros-camera/package.json +30 -0
- package/runtime/packages/ros-camera/src/index.ts +13 -0
- package/runtime/packages/ros-camera/src/snapshot.ts +372 -0
- package/runtime/packages/ros-camera/tsconfig.json +9 -0
- package/runtime/pnpm-lock.yaml +5260 -0
- package/runtime/pnpm-workspace.yaml +2 -0
- package/runtime/ros2_ws/src/agenticros_agent/agenticros_agent/__init__.py +0 -0
- package/runtime/ros2_ws/src/agenticros_agent/agenticros_agent/agent_node.py +561 -0
- package/runtime/ros2_ws/src/agenticros_agent/package.xml +25 -0
- package/runtime/ros2_ws/src/agenticros_agent/resource/agenticros_agent +0 -0
- package/runtime/ros2_ws/src/agenticros_agent/setup.cfg +4 -0
- package/runtime/ros2_ws/src/agenticros_agent/setup.py +25 -0
- package/runtime/ros2_ws/src/agenticros_bringup/README.md +128 -0
- package/runtime/ros2_ws/src/agenticros_bringup/agenticros_bringup/__init__.py +1 -0
- package/runtime/ros2_ws/src/agenticros_bringup/agenticros_bringup/cmd_vel_relay.py +33 -0
- package/runtime/ros2_ws/src/agenticros_bringup/launch/cmd_vel_bridge.launch.py +58 -0
- package/runtime/ros2_ws/src/agenticros_bringup/launch/gazebo_turtlebot3.launch.py +69 -0
- package/runtime/ros2_ws/src/agenticros_bringup/launch/mode_a_gazebo.launch.py +55 -0
- package/runtime/ros2_ws/src/agenticros_bringup/launch/mode_a_gazebo_rviz.launch.py +48 -0
- package/runtime/ros2_ws/src/agenticros_bringup/launch/realsense_rosbridge.launch.py +154 -0
- package/runtime/ros2_ws/src/agenticros_bringup/launch/rosbridge_gazebo.launch.py +54 -0
- package/runtime/ros2_ws/src/agenticros_bringup/launch/rviz.launch.py +38 -0
- package/runtime/ros2_ws/src/agenticros_bringup/launch/turtlebot3_gazebo_rviz.launch.py +42 -0
- package/runtime/ros2_ws/src/agenticros_bringup/package.xml +24 -0
- package/runtime/ros2_ws/src/agenticros_bringup/resource/agenticros_bringup +0 -0
- package/runtime/ros2_ws/src/agenticros_bringup/rviz/turtlebot3_agenticros.rviz +174 -0
- package/runtime/ros2_ws/src/agenticros_bringup/setup.cfg +4 -0
- package/runtime/ros2_ws/src/agenticros_bringup/setup.py +28 -0
- package/runtime/ros2_ws/src/agenticros_discovery/agenticros_discovery/__init__.py +0 -0
- package/runtime/ros2_ws/src/agenticros_discovery/agenticros_discovery/discovery_node.py +172 -0
- package/runtime/ros2_ws/src/agenticros_discovery/package.xml +22 -0
- package/runtime/ros2_ws/src/agenticros_discovery/resource/agenticros_discovery +0 -0
- package/runtime/ros2_ws/src/agenticros_discovery/setup.cfg +5 -0
- package/runtime/ros2_ws/src/agenticros_discovery/setup.py +25 -0
- package/runtime/ros2_ws/src/agenticros_follow_me/README.md +66 -0
- package/runtime/ros2_ws/src/agenticros_follow_me/agenticros_follow_me/__init__.py +1 -0
- package/runtime/ros2_ws/src/agenticros_follow_me/agenticros_follow_me/__main__.py +5 -0
- package/runtime/ros2_ws/src/agenticros_follow_me/agenticros_follow_me/follow_me_node.py +278 -0
- package/runtime/ros2_ws/src/agenticros_follow_me/agenticros_follow_me/follower_controller.py +631 -0
- package/runtime/ros2_ws/src/agenticros_follow_me/agenticros_follow_me/person_tracker.py +635 -0
- package/runtime/ros2_ws/src/agenticros_follow_me/package.xml +22 -0
- package/runtime/ros2_ws/src/agenticros_follow_me/resource/agenticros_follow_me +0 -0
- package/runtime/ros2_ws/src/agenticros_follow_me/setup.py +25 -0
- package/runtime/ros2_ws/src/agenticros_msgs/CMakeLists.txt +26 -0
- package/runtime/ros2_ws/src/agenticros_msgs/msg/CapabilityManifest.msg +9 -0
- package/runtime/ros2_ws/src/agenticros_msgs/package.xml +22 -0
- package/runtime/ros2_ws/src/agenticros_msgs/srv/FollowMeGetStatus.srv +11 -0
- package/runtime/ros2_ws/src/agenticros_msgs/srv/FollowMeSetDistance.srv +4 -0
- package/runtime/ros2_ws/src/agenticros_msgs/srv/FollowMeSetTarget.srv +6 -0
- package/runtime/ros2_ws/src/agenticros_msgs/srv/FollowMeStart.srv +5 -0
- package/runtime/ros2_ws/src/agenticros_msgs/srv/FollowMeStop.srv +3 -0
- package/runtime/ros2_ws/src/agenticros_msgs/srv/GetCapabilities.srv +5 -0
- package/runtime/ros2_ws/src/agenticros_sim/CMakeLists.txt +24 -0
- package/runtime/ros2_ws/src/agenticros_sim/README.md +120 -0
- package/runtime/ros2_ws/src/agenticros_sim/config/agenticros-sim.config.json +28 -0
- package/runtime/ros2_ws/src/agenticros_sim/config/amr_bridge.yaml +111 -0
- package/runtime/ros2_ws/src/agenticros_sim/config/amr_view.rviz +172 -0
- package/runtime/ros2_ws/src/agenticros_sim/env-hooks/gz_resource_path.dsv.in +3 -0
- package/runtime/ros2_ws/src/agenticros_sim/env-hooks/gz_resource_path.sh.in +7 -0
- package/runtime/ros2_ws/src/agenticros_sim/launch/sim_amr.launch.py +159 -0
- package/runtime/ros2_ws/src/agenticros_sim/models/agenticros_amr/model.config +17 -0
- package/runtime/ros2_ws/src/agenticros_sim/models/agenticros_amr/model.sdf +244 -0
- package/runtime/ros2_ws/src/agenticros_sim/package.xml +27 -0
- package/runtime/ros2_ws/src/agenticros_sim/worlds/agenticros_indoor.sdf +183 -0
- package/runtime/scripts/activate_workspace.sh +285 -0
- package/runtime/scripts/agenticros-describer.policy.yaml +96 -0
- package/runtime/scripts/agenticros-proxy.cjs +99 -0
- package/runtime/scripts/agenticros-rosbridge.policy.yaml +62 -0
- package/runtime/scripts/check-cli-tarball-size.mjs +42 -0
- package/runtime/scripts/configure_agenticros.sh +200 -0
- package/runtime/scripts/configure_for_sim.sh +64 -0
- package/runtime/scripts/fix-openclaw-control-ui-path.sh +20 -0
- package/runtime/scripts/install_cli.sh +94 -0
- package/runtime/scripts/install_rosbridge_from_source.sh +67 -0
- package/runtime/scripts/lib/agenticros-banner.sh +28 -0
- package/runtime/scripts/onboard_robot.sh +75 -0
- package/runtime/scripts/openai.policy.yaml +77 -0
- package/runtime/scripts/openclaw-dashboard-url.cjs +49 -0
- package/runtime/scripts/pack-runtime.mjs +245 -0
- package/runtime/scripts/run_demo_native.sh +43 -0
- package/runtime/scripts/run_nemoclaw_host_stack.sh +91 -0
- package/runtime/scripts/run_robot_rosbridge.sh +36 -0
- package/runtime/scripts/sandbox_rosbridge_relay.py +137 -0
- package/runtime/scripts/setup-openclaw-local.cjs +75 -0
- package/runtime/scripts/setup_gateway_plugin.sh +329 -0
- package/runtime/scripts/setup_robot.sh +113 -0
- package/runtime/scripts/setup_workspace.sh +484 -0
- package/runtime/scripts/sim/run_sim.sh +146 -0
- package/runtime/scripts/smoke_test_nemoclaw.sh +123 -0
- package/runtime/scripts/start_demo.sh +55 -0
- package/runtime/scripts/sync-skill-tools.mjs +335 -0
- package/runtime/scripts/test-follow-me-sim.mjs +135 -0
- package/runtime/scripts/test-mcp-e2e.mjs +184 -0
- package/runtime/scripts/test-rclnodejs.mts +129 -0
- package/runtime/scripts/use-openclaw-2026.2.26.sh +19 -0
- package/runtime/scripts/use-openclaw-2026.3.11.sh +19 -0
- package/runtime/scripts/zenoh-bridge-ros2dds-robot.json5 +30 -0
- package/runtime/scripts/zenohd-agenticros.json5 +11 -0
- package/runtime/scripts/zenohd-rosclaw.json5 +11 -0
- package/runtime/tsconfig.base.json +19 -0
- package/index.js +0 -6
|
@@ -0,0 +1,891 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool definitions and handler. Mirrors OpenClaw adapter tools.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { AgenticROSConfig } from "@agenticros/core";
|
|
6
|
+
import { resolveCameraSubscribeTopic, toNamespacedTopic, toNamespacedTopicFull } from "@agenticros/core";
|
|
7
|
+
import {
|
|
8
|
+
ROS_MSG_COMPRESSED_IMAGE,
|
|
9
|
+
ROS_MSG_IMAGE,
|
|
10
|
+
cameraSnapshotFromPlainMessage,
|
|
11
|
+
mimeTypeForSnapshotBase64,
|
|
12
|
+
rosNumericField,
|
|
13
|
+
} from "@agenticros/ros-camera";
|
|
14
|
+
import { resolveMemoryNamespace } from "@agenticros/core";
|
|
15
|
+
import { getTransport } from "./transport.js";
|
|
16
|
+
import { checkPublishSafety } from "./safety.js";
|
|
17
|
+
import { getDepthDistance } from "./depth.js";
|
|
18
|
+
import { getFollowMeLocal } from "./follow-me/loop.js";
|
|
19
|
+
import { getFollowMeDepth } from "./follow-me/depth-loop.js";
|
|
20
|
+
import { findObject } from "./find-object/find-object.js";
|
|
21
|
+
import { ensureMemory } from "./memory.js";
|
|
22
|
+
|
|
23
|
+
const DEFAULT_DEPTH_TOPIC = "/camera/camera/depth/image_rect_raw";
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Names of memory tools — dispatched separately from ROS tools so they can
|
|
27
|
+
* work without the Zenoh/ROS transport.
|
|
28
|
+
*/
|
|
29
|
+
export const MEMORY_TOOL_NAMES = new Set<string>([
|
|
30
|
+
"memory_remember",
|
|
31
|
+
"memory_recall",
|
|
32
|
+
"memory_forget",
|
|
33
|
+
"memory_status",
|
|
34
|
+
]);
|
|
35
|
+
|
|
36
|
+
export interface McpTool {
|
|
37
|
+
name: string;
|
|
38
|
+
description: string;
|
|
39
|
+
inputSchema: {
|
|
40
|
+
type: "object";
|
|
41
|
+
properties?: Record<string, { type: string; description?: string; default?: unknown }>;
|
|
42
|
+
required?: string[];
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const TOOLS: McpTool[] = [
|
|
47
|
+
{
|
|
48
|
+
name: "ros2_list_topics",
|
|
49
|
+
description:
|
|
50
|
+
"List all available ROS2 topics and their message types. Use this to discover what data the robot publishes and what commands it accepts.",
|
|
51
|
+
inputSchema: { type: "object", properties: {} },
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "ros2_publish",
|
|
55
|
+
description:
|
|
56
|
+
"Publish a message to a ROS2 topic. Use this to send commands to the robot (e.g., velocity commands to /cmd_vel, navigation goals).",
|
|
57
|
+
inputSchema: {
|
|
58
|
+
type: "object",
|
|
59
|
+
properties: {
|
|
60
|
+
topic: { type: "string", description: "The ROS2 topic name (e.g., '/cmd_vel')" },
|
|
61
|
+
type: { type: "string", description: "The ROS2 message type (e.g., 'geometry_msgs/msg/Twist')" },
|
|
62
|
+
message: { type: "object", description: "The message payload matching the ROS2 message type schema" },
|
|
63
|
+
},
|
|
64
|
+
required: ["topic", "type", "message"],
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "ros2_subscribe_once",
|
|
69
|
+
description:
|
|
70
|
+
"Subscribe to a ROS2 topic and return the next message. Use this to read sensor data, check robot state, or get the current value of a topic.",
|
|
71
|
+
inputSchema: {
|
|
72
|
+
type: "object",
|
|
73
|
+
properties: {
|
|
74
|
+
topic: { type: "string", description: "The ROS2 topic name (e.g., '/battery_state')" },
|
|
75
|
+
type: { type: "string", description: "The ROS2 message type (optional)" },
|
|
76
|
+
timeout: { type: "number", description: "Timeout in milliseconds (default: 5000)" },
|
|
77
|
+
},
|
|
78
|
+
required: ["topic"],
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "ros2_service_call",
|
|
83
|
+
description:
|
|
84
|
+
"Call a ROS2 service and return the response. Use for request/response operations like setting parameters or querying node state.",
|
|
85
|
+
inputSchema: {
|
|
86
|
+
type: "object",
|
|
87
|
+
properties: {
|
|
88
|
+
service: { type: "string", description: "The ROS2 service name (e.g., '/spawn_entity')" },
|
|
89
|
+
type: { type: "string", description: "The ROS2 service type (optional)" },
|
|
90
|
+
args: { type: "object", description: "The service request arguments" },
|
|
91
|
+
},
|
|
92
|
+
required: ["service"],
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "ros2_action_goal",
|
|
97
|
+
description:
|
|
98
|
+
"Send a goal to a ROS2 action server. Use for long-running operations like navigation or arm movements.",
|
|
99
|
+
inputSchema: {
|
|
100
|
+
type: "object",
|
|
101
|
+
properties: {
|
|
102
|
+
action: { type: "string", description: "The ROS2 action server name (e.g., '/navigate_to_pose')" },
|
|
103
|
+
actionType: { type: "string", description: "The ROS2 action type (e.g., 'nav2_msgs/action/NavigateToPose')" },
|
|
104
|
+
goal: { type: "object", description: "The action goal parameters" },
|
|
105
|
+
},
|
|
106
|
+
required: ["action", "actionType", "goal"],
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "ros2_param_get",
|
|
111
|
+
description: "Get the value of a ROS2 parameter from a node. Use to check robot configuration values.",
|
|
112
|
+
inputSchema: {
|
|
113
|
+
type: "object",
|
|
114
|
+
properties: {
|
|
115
|
+
node: { type: "string", description: "The fully qualified node name (e.g., '/turtlebot3/controller')" },
|
|
116
|
+
parameter: { type: "string", description: "The parameter name (e.g., 'max_velocity')" },
|
|
117
|
+
},
|
|
118
|
+
required: ["node", "parameter"],
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: "ros2_param_set",
|
|
123
|
+
description: "Set the value of a ROS2 parameter on a node. Use to change robot configuration at runtime.",
|
|
124
|
+
inputSchema: {
|
|
125
|
+
type: "object",
|
|
126
|
+
properties: {
|
|
127
|
+
node: { type: "string", description: "The fully qualified node name" },
|
|
128
|
+
parameter: { type: "string", description: "The parameter name" },
|
|
129
|
+
value: { type: "object", description: "The new parameter value" },
|
|
130
|
+
},
|
|
131
|
+
required: ["node", "parameter", "value"],
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "ros2_camera_snapshot",
|
|
136
|
+
description:
|
|
137
|
+
"Capture a single image from a ROS2 camera topic. Use when the user asks what the robot sees or requests a photo. Supports CompressedImage and raw Image.",
|
|
138
|
+
inputSchema: {
|
|
139
|
+
type: "object",
|
|
140
|
+
properties: {
|
|
141
|
+
topic: { type: "string", description: "Camera image topic (default from robot.cameraTopic in ~/.agenticros/config.json). Run ros2 topic list and match your driver." },
|
|
142
|
+
message_type: { type: "string", description: "'CompressedImage' (JPEG topics, names often contain /compressed) or 'Image' for raw sensor_msgs/Image—required if there is no compressed topic." },
|
|
143
|
+
timeout: { type: "number", description: "Timeout in milliseconds (default: 10000)" },
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: "ros2_depth_distance",
|
|
149
|
+
description:
|
|
150
|
+
"Get distance in meters from the robot's depth camera. Samples the center of the depth image. Use when the user asks how far they are from the robot.",
|
|
151
|
+
inputSchema: {
|
|
152
|
+
type: "object",
|
|
153
|
+
properties: {
|
|
154
|
+
topic: { type: "string", description: `Depth image topic (default: ${DEFAULT_DEPTH_TOPIC})` },
|
|
155
|
+
timeout: { type: "number", description: "Timeout in ms (default 5000)" },
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: "ros2_follow_me_start",
|
|
161
|
+
description:
|
|
162
|
+
"Start the follow-me skill — the robot follows a person. Optional target description to lock onto a specific person; otherwise follows the closest. Modes: 'depth' (default) runs an in-process depth-only loop in the MCP server (no neural net, no model file, just RealSense depth — drives toward the closest blob in [0.5, 4.0] m); 'node' sends a command to the agenticros_follow_me ROS2 node running on the robot; 'local' runs an in-process YOLOv8n loop (requires yolov8n.onnx, ~8 Hz).",
|
|
163
|
+
inputSchema: {
|
|
164
|
+
type: "object",
|
|
165
|
+
properties: {
|
|
166
|
+
mode: {
|
|
167
|
+
type: "string",
|
|
168
|
+
description: "'depth' (default) for the in-process depth-only loop, 'node' for the ROS2 node, or 'local' for the in-process YOLO loop.",
|
|
169
|
+
},
|
|
170
|
+
target_description: {
|
|
171
|
+
type: "string",
|
|
172
|
+
description: "Optional description of the person to follow (e.g., 'person in red shirt'). Empty = follow closest. Note: depth mode ignores this — it always follows the closest object.",
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: "ros2_follow_me_stop",
|
|
179
|
+
description: "Stop the follow-me skill. Robot will stop sending follow velocity commands. Pass mode='local' for the YOLO loop or mode='depth' for the depth-only loop.",
|
|
180
|
+
inputSchema: {
|
|
181
|
+
type: "object",
|
|
182
|
+
properties: {
|
|
183
|
+
mode: { type: "string", description: "'depth' (default), 'node', or 'local'." },
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
name: "ros2_follow_me_status",
|
|
189
|
+
description:
|
|
190
|
+
"Read the current follow-me status (enabled, tracking, target distance, persons detected). For mode='node' returns the latest message from follow_me/status; for mode='depth' or 'local' returns the in-process loop status.",
|
|
191
|
+
inputSchema: {
|
|
192
|
+
type: "object",
|
|
193
|
+
properties: {
|
|
194
|
+
mode: { type: "string", description: "'depth' (default), 'node', or 'local'." },
|
|
195
|
+
timeout: { type: "number", description: "Timeout in milliseconds (default: 3000). Only used for mode='node'." },
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
name: "ros2_follow_me_set_distance",
|
|
201
|
+
description: "Set the follow-me target distance in meters. Clamped server-side to [0.2, 5.0].",
|
|
202
|
+
inputSchema: {
|
|
203
|
+
type: "object",
|
|
204
|
+
properties: {
|
|
205
|
+
mode: { type: "string", description: "'depth' (default), 'node', or 'local'." },
|
|
206
|
+
distance: { type: "number", description: "Target distance in meters (0.2 to 5.0)" },
|
|
207
|
+
},
|
|
208
|
+
required: ["distance"],
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
name: "ros2_follow_me_set_target",
|
|
213
|
+
description:
|
|
214
|
+
"Lock the follow-me tracker onto a person described by text. Locks onto the closest visible person and stores the description for future re-identification.",
|
|
215
|
+
inputSchema: {
|
|
216
|
+
type: "object",
|
|
217
|
+
properties: {
|
|
218
|
+
mode: { type: "string", description: "'depth' (default), 'node', or 'local'." },
|
|
219
|
+
description: { type: "string", description: "Description of the person to follow" },
|
|
220
|
+
},
|
|
221
|
+
required: ["description"],
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
name: "memory_remember",
|
|
226
|
+
description:
|
|
227
|
+
"Store a durable fact in long-term memory. Call this when the user says \"remember that ...\", \"note that ...\", \"from now on ...\", or shares a stable personal fact (preferences, names, places, routines, robot hardware like the camera/eyes the robot has). The store is shared across all AgenticROS adapters talking to this robot (OpenClaw, Claude Desktop, Claude Code, Gemini). Do NOT auto-store chat transcripts or transient state. Namespace defaults to the robot namespace. Only available when memory is enabled in config.",
|
|
228
|
+
inputSchema: {
|
|
229
|
+
type: "object",
|
|
230
|
+
properties: {
|
|
231
|
+
content: { type: "string", description: "The fact to remember, written as a self-contained sentence." },
|
|
232
|
+
tags: { type: "array", description: "Optional list of tag strings for filtering later (e.g. ['preference', 'speed'])." },
|
|
233
|
+
path: { type: "string", description: "Optional hierarchical hint (e.g. 'preferences.movement.speed')." },
|
|
234
|
+
namespace: { type: "string", description: "Optional namespace override; defaults to the robot namespace." },
|
|
235
|
+
},
|
|
236
|
+
required: ["content"],
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
name: "memory_recall",
|
|
241
|
+
description:
|
|
242
|
+
"Semantic search of long-term memory. ALWAYS call this BEFORE answering a personal-context question, including: \"what do I have for X?\", \"what's my Y?\", \"where is the Z?\", \"what did I tell you about ...?\", \"do you remember ...?\". The store is shared across every adapter for this robot — a fact saved from Claude Desktop or Claude Code lives in the same store. Returns the top matches ranked by relevance. Only available when memory is enabled in config.",
|
|
243
|
+
inputSchema: {
|
|
244
|
+
type: "object",
|
|
245
|
+
properties: {
|
|
246
|
+
query: { type: "string", description: "Free-text query describing what you want to recall." },
|
|
247
|
+
limit: { type: "number", description: "Max number of matches to return (default 5)." },
|
|
248
|
+
namespace: { type: "string", description: "Optional namespace override; defaults to the robot namespace." },
|
|
249
|
+
},
|
|
250
|
+
required: ["query"],
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
name: "memory_forget",
|
|
255
|
+
description:
|
|
256
|
+
"Delete memories. Provide either an `id` (delete one), a `query` (delete all matches in the namespace), or just `namespace` (delete every memory in that namespace). Use sparingly — irreversible.",
|
|
257
|
+
inputSchema: {
|
|
258
|
+
type: "object",
|
|
259
|
+
properties: {
|
|
260
|
+
id: { type: "string", description: "Record id (returned by memory_remember)." },
|
|
261
|
+
query: { type: "string", description: "Free-text query; deletes every matching memory in the namespace." },
|
|
262
|
+
namespace: { type: "string", description: "Namespace to delete from (defaults to the robot namespace)." },
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
name: "memory_status",
|
|
268
|
+
description:
|
|
269
|
+
"One-call health check for the memory subsystem. Returns whether memory is enabled, which backend is active, how many memories exist for the current namespace, the last write timestamp, and the embedder configuration when applicable.",
|
|
270
|
+
inputSchema: {
|
|
271
|
+
type: "object",
|
|
272
|
+
properties: {
|
|
273
|
+
namespace: { type: "string", description: "Optional namespace override; defaults to the robot namespace." },
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
name: "ros2_find_object",
|
|
279
|
+
description:
|
|
280
|
+
"Rotate the robot in place (clockwise by default) until a target object is detected by YOLOv8n in the camera feed, then stop. Target must be a COCO class name (e.g., 'cell phone', 'chair', 'bottle', 'cup', 'laptop'). Returns whether the object was found, its confidence, bounding box, and horizontal offset from image center (-1=left edge, 0=center, +1=right edge).",
|
|
281
|
+
inputSchema: {
|
|
282
|
+
type: "object",
|
|
283
|
+
properties: {
|
|
284
|
+
target: {
|
|
285
|
+
type: "string",
|
|
286
|
+
description:
|
|
287
|
+
"COCO class name to search for (e.g., 'cell phone', 'chair', 'bottle').",
|
|
288
|
+
},
|
|
289
|
+
angular_speed: {
|
|
290
|
+
type: "number",
|
|
291
|
+
description: "Rotation speed in rad/s (default 0.3). Clamped to safety.maxAngularVelocity.",
|
|
292
|
+
},
|
|
293
|
+
clockwise: {
|
|
294
|
+
type: "boolean",
|
|
295
|
+
description: "Rotate clockwise (default true). Set false for counterclockwise.",
|
|
296
|
+
},
|
|
297
|
+
timeout_seconds: {
|
|
298
|
+
type: "number",
|
|
299
|
+
description: "Give up after this many seconds (default 30).",
|
|
300
|
+
},
|
|
301
|
+
min_confidence: {
|
|
302
|
+
type: "number",
|
|
303
|
+
description: "Minimum detection confidence to accept (default 0.5).",
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
required: ["target"],
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
];
|
|
310
|
+
|
|
311
|
+
export type ToolContent = { type: "text"; text: string } | { type: "image"; data: string; mimeType: string };
|
|
312
|
+
|
|
313
|
+
function followMeMode(args: Record<string, unknown>): "node" | "local" | "depth" {
|
|
314
|
+
const raw = String(args["mode"] ?? "depth").toLowerCase().trim();
|
|
315
|
+
if (raw === "local") return "local";
|
|
316
|
+
if (raw === "depth") return "depth";
|
|
317
|
+
return "node";
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
async function publishFollowMeCmd(
|
|
321
|
+
config: AgenticROSConfig,
|
|
322
|
+
payload: Record<string, unknown>,
|
|
323
|
+
): Promise<{ topic: string; payload: Record<string, unknown> }> {
|
|
324
|
+
const transport = getTransport();
|
|
325
|
+
if (transport.getStatus() !== "connected") {
|
|
326
|
+
throw new Error(
|
|
327
|
+
"Transport not connected. Check zenohd (ws://localhost:10000) and config in ~/.agenticros/config.json.",
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
const topic = toNamespacedTopicFull(config, "/follow_me/cmd");
|
|
331
|
+
const data = JSON.stringify(payload);
|
|
332
|
+
const PUBLISH_TIMEOUT_MS = 5_000;
|
|
333
|
+
const timeoutPromise = new Promise<never>((_, reject) => {
|
|
334
|
+
setTimeout(
|
|
335
|
+
() => reject(new Error(`Publish to ${topic} timed out after ${PUBLISH_TIMEOUT_MS / 1000}s`)),
|
|
336
|
+
PUBLISH_TIMEOUT_MS,
|
|
337
|
+
);
|
|
338
|
+
});
|
|
339
|
+
await Promise.race([
|
|
340
|
+
transport.publish({ topic, type: "std_msgs/msg/String", msg: { data } }),
|
|
341
|
+
timeoutPromise,
|
|
342
|
+
]);
|
|
343
|
+
return { topic, payload };
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export async function handleToolCall(
|
|
347
|
+
name: string,
|
|
348
|
+
args: Record<string, unknown>,
|
|
349
|
+
config: AgenticROSConfig,
|
|
350
|
+
): Promise<{ content: ToolContent[]; isError?: boolean }> {
|
|
351
|
+
// Memory tools are self-contained — they never touch the ROS transport, so
|
|
352
|
+
// dispatch them before getTransport() (which throws when zenohd is down).
|
|
353
|
+
if (MEMORY_TOOL_NAMES.has(name)) {
|
|
354
|
+
return handleMemoryToolCall(name, args, config);
|
|
355
|
+
}
|
|
356
|
+
const transport = getTransport();
|
|
357
|
+
|
|
358
|
+
switch (name) {
|
|
359
|
+
case "ros2_list_topics": {
|
|
360
|
+
const topics = await transport.listTopics();
|
|
361
|
+
const MAX = 50;
|
|
362
|
+
const truncated = topics.length > MAX ? topics.slice(0, MAX) : topics;
|
|
363
|
+
const text = JSON.stringify({
|
|
364
|
+
success: true,
|
|
365
|
+
topics: truncated,
|
|
366
|
+
total: topics.length,
|
|
367
|
+
truncated: topics.length > MAX,
|
|
368
|
+
});
|
|
369
|
+
return { content: [{ type: "text", text }] };
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
case "ros2_publish": {
|
|
373
|
+
const rawTopicIn = String(args["topic"] ?? "").trim();
|
|
374
|
+
if (process.stderr?.write) {
|
|
375
|
+
process.stderr.write(`[AgenticROS] ros2_publish called topic=${JSON.stringify(rawTopicIn)}\n`);
|
|
376
|
+
}
|
|
377
|
+
if (transport.getStatus() !== "connected") {
|
|
378
|
+
if (process.stderr?.write) {
|
|
379
|
+
process.stderr.write(`[AgenticROS] ros2_publish abort: transport not connected\n`);
|
|
380
|
+
}
|
|
381
|
+
return {
|
|
382
|
+
content: [{ type: "text", text: "Transport not connected to Zenoh/ROS2. Check zenohd is running (ws://localhost:10000) and config in ~/.agenticros/config.json." }],
|
|
383
|
+
isError: true,
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
const safe = checkPublishSafety(config, args);
|
|
387
|
+
if (safe.block) {
|
|
388
|
+
return { content: [{ type: "text", text: safe.blockReason ?? "Blocked by safety." }], isError: true };
|
|
389
|
+
}
|
|
390
|
+
// Unconditionally rewrite /<uuid>/cmd_vel → /robot<uuid-no-dashes>/cmd_vel (robot often expects UUID without dashes)
|
|
391
|
+
const cmdVelMatch = rawTopicIn.match(/^\/([^/]+)\/cmd_vel$/i);
|
|
392
|
+
const segment = cmdVelMatch?.[1] ?? "";
|
|
393
|
+
const topic =
|
|
394
|
+
cmdVelMatch && !segment.toLowerCase().startsWith("robot")
|
|
395
|
+
? `/robot${segment.replace(/-/g, "")}/cmd_vel`
|
|
396
|
+
: toNamespacedTopic(config, rawTopicIn);
|
|
397
|
+
if (process.stderr?.write) {
|
|
398
|
+
process.stderr.write(`[AgenticROS] ros2_publish: → topic=${topic}\n`);
|
|
399
|
+
}
|
|
400
|
+
const type = args["type"] as string;
|
|
401
|
+
const message = args["message"] as Record<string, unknown>;
|
|
402
|
+
const PUBLISH_TIMEOUT_MS = 10_000;
|
|
403
|
+
const timeoutPromise = new Promise<never>((_, reject) => {
|
|
404
|
+
setTimeout(() => reject(new Error("Publish timed out after " + PUBLISH_TIMEOUT_MS / 1000 + "s (Zenoh put may be hanging). Check zenohd and MCP server logs.")), PUBLISH_TIMEOUT_MS);
|
|
405
|
+
});
|
|
406
|
+
try {
|
|
407
|
+
await Promise.race([transport.publish({ topic, type, msg: message }), timeoutPromise]);
|
|
408
|
+
} catch (err) {
|
|
409
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
410
|
+
return { content: [{ type: "text", text: `Publish failed: ${msg}` }], isError: true };
|
|
411
|
+
}
|
|
412
|
+
const summary = cmdVelMatch && topic.startsWith("/robot") ? `Published to ${topic} (robot prefix applied).` : `Published to ${topic}.`;
|
|
413
|
+
return { content: [{ type: "text", text: summary + "\n" + JSON.stringify({ success: true, topic, type }) }] };
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
case "ros2_subscribe_once": {
|
|
417
|
+
const rawTopic = args["topic"] as string;
|
|
418
|
+
const topic = toNamespacedTopic(config, rawTopic);
|
|
419
|
+
let msgType = args["type"] as string | undefined;
|
|
420
|
+
const timeout = (args["timeout"] as number | undefined) ?? 5000;
|
|
421
|
+
if (!msgType && /\/?(camera|image|color|depth)/i.test(rawTopic)) {
|
|
422
|
+
msgType = rawTopic.includes("compressed") ? "sensor_msgs/msg/CompressedImage" : "sensor_msgs/msg/Image";
|
|
423
|
+
}
|
|
424
|
+
const result = await new Promise<Record<string, unknown>>((resolve, reject) => {
|
|
425
|
+
const sub = transport.subscribe(
|
|
426
|
+
{ topic, type: msgType },
|
|
427
|
+
(msg: Record<string, unknown>) => {
|
|
428
|
+
clearTimeout(timer);
|
|
429
|
+
sub.unsubscribe();
|
|
430
|
+
resolve({ success: true, topic, message: msg });
|
|
431
|
+
},
|
|
432
|
+
);
|
|
433
|
+
const timer = setTimeout(() => {
|
|
434
|
+
sub.unsubscribe();
|
|
435
|
+
reject(new Error(`Timeout waiting for message on ${topic}`));
|
|
436
|
+
}, timeout);
|
|
437
|
+
});
|
|
438
|
+
let text = JSON.stringify(result);
|
|
439
|
+
const MAX_CHARS = 8000;
|
|
440
|
+
if (text.length > MAX_CHARS) {
|
|
441
|
+
text = JSON.stringify({
|
|
442
|
+
success: true,
|
|
443
|
+
topic,
|
|
444
|
+
message: "[truncated: message too large]",
|
|
445
|
+
originalSize: text.length,
|
|
446
|
+
}) + "\n(Use ros2_camera_snapshot for image topics.)";
|
|
447
|
+
}
|
|
448
|
+
return { content: [{ type: "text", text }] };
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
case "ros2_service_call": {
|
|
452
|
+
const rawService = args["service"] as string;
|
|
453
|
+
const service = toNamespacedTopic(config, rawService);
|
|
454
|
+
const type = args["type"] as string | undefined;
|
|
455
|
+
const reqArgs = args["args"] as Record<string, unknown> | undefined;
|
|
456
|
+
const response = await transport.callService({ service, type, args: reqArgs });
|
|
457
|
+
const text = JSON.stringify({
|
|
458
|
+
success: response.result,
|
|
459
|
+
service,
|
|
460
|
+
response: response.values,
|
|
461
|
+
});
|
|
462
|
+
return { content: [{ type: "text", text }] };
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
case "ros2_action_goal": {
|
|
466
|
+
const rawAction = args["action"] as string;
|
|
467
|
+
const action = toNamespacedTopic(config, rawAction);
|
|
468
|
+
const actionType = args["actionType"] as string;
|
|
469
|
+
const goal = args["goal"] as Record<string, unknown>;
|
|
470
|
+
const actionResult = await transport.sendActionGoal({ action, actionType, args: goal });
|
|
471
|
+
const text = JSON.stringify({
|
|
472
|
+
success: actionResult.result,
|
|
473
|
+
action,
|
|
474
|
+
result: actionResult.values,
|
|
475
|
+
});
|
|
476
|
+
return { content: [{ type: "text", text }] };
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
case "ros2_param_get": {
|
|
480
|
+
const rawNode = args["node"] as string;
|
|
481
|
+
const node = toNamespacedTopic(config, rawNode);
|
|
482
|
+
const parameter = args["parameter"] as string;
|
|
483
|
+
const response = await transport.callService({
|
|
484
|
+
service: `${node}/get_parameters`,
|
|
485
|
+
type: "rcl_interfaces/srv/GetParameters",
|
|
486
|
+
args: { names: [parameter] },
|
|
487
|
+
});
|
|
488
|
+
const text = JSON.stringify({
|
|
489
|
+
success: response.result,
|
|
490
|
+
node,
|
|
491
|
+
parameter,
|
|
492
|
+
value: response.values,
|
|
493
|
+
});
|
|
494
|
+
return { content: [{ type: "text", text }] };
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
case "ros2_param_set": {
|
|
498
|
+
const rawNode = args["node"] as string;
|
|
499
|
+
const node = toNamespacedTopic(config, rawNode);
|
|
500
|
+
const parameter = args["parameter"] as string;
|
|
501
|
+
const value = args["value"];
|
|
502
|
+
const response = await transport.callService({
|
|
503
|
+
service: `${node}/set_parameters`,
|
|
504
|
+
type: "rcl_interfaces/srv/SetParameters",
|
|
505
|
+
args: { parameters: [{ name: parameter, value }] },
|
|
506
|
+
});
|
|
507
|
+
const text = JSON.stringify({
|
|
508
|
+
success: response.result,
|
|
509
|
+
node,
|
|
510
|
+
parameter,
|
|
511
|
+
});
|
|
512
|
+
return { content: [{ type: "text", text }] };
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
case "ros2_camera_snapshot": {
|
|
516
|
+
const defaultTopic =
|
|
517
|
+
(config.robot?.cameraTopic ?? "").trim() || "/camera/camera/color/image_raw/compressed";
|
|
518
|
+
const rawTopic = (args["topic"] as string | undefined) ?? defaultTopic;
|
|
519
|
+
const topic = resolveCameraSubscribeTopic(config, rawTopic);
|
|
520
|
+
const rawMsgType = args["message_type"] as string | undefined;
|
|
521
|
+
const messageType: "CompressedImage" | "Image" = rawMsgType === "Image" ? "Image" : "CompressedImage";
|
|
522
|
+
const timeout = (args["timeout"] as number | undefined) ?? 10000;
|
|
523
|
+
const type = messageType === "Image" ? ROS_MSG_IMAGE : ROS_MSG_COMPRESSED_IMAGE;
|
|
524
|
+
|
|
525
|
+
try {
|
|
526
|
+
const result = await new Promise<Record<string, unknown>>((resolve, reject) => {
|
|
527
|
+
const subscription = transport.subscribe(
|
|
528
|
+
{ topic, type },
|
|
529
|
+
(msg: Record<string, unknown>) => {
|
|
530
|
+
clearTimeout(timer);
|
|
531
|
+
subscription.unsubscribe();
|
|
532
|
+
try {
|
|
533
|
+
const payload = cameraSnapshotFromPlainMessage(messageType, msg);
|
|
534
|
+
resolve({
|
|
535
|
+
success: true,
|
|
536
|
+
topic,
|
|
537
|
+
format: payload.formatLabel,
|
|
538
|
+
data: payload.dataBase64,
|
|
539
|
+
width: payload.width,
|
|
540
|
+
height: payload.height,
|
|
541
|
+
});
|
|
542
|
+
} catch (e) {
|
|
543
|
+
reject(e instanceof Error ? e : new Error(String(e)));
|
|
544
|
+
}
|
|
545
|
+
},
|
|
546
|
+
);
|
|
547
|
+
const timer = setTimeout(() => {
|
|
548
|
+
subscription.unsubscribe();
|
|
549
|
+
reject(new Error(`Timeout waiting for camera frame on ${topic}`));
|
|
550
|
+
}, timeout);
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
const base64 = (result.data as string) ?? "";
|
|
554
|
+
const format = String((result.format as string) ?? "jpeg").toLowerCase();
|
|
555
|
+
const mimeType = mimeTypeForSnapshotBase64(base64, format);
|
|
556
|
+
const wNum = result.width != null ? rosNumericField(result.width, "width") : undefined;
|
|
557
|
+
const hNum = result.height != null ? rosNumericField(result.height, "height") : undefined;
|
|
558
|
+
const summary = `Captured one frame from ${topic}${wNum != null && hNum != null ? ` (${wNum}×${hNum})` : ""}.`;
|
|
559
|
+
const content: ToolContent[] = [{ type: "text", text: summary }];
|
|
560
|
+
if (base64 && /^[A-Za-z0-9+/=]+$/.test(base64) && base64.length >= 100) {
|
|
561
|
+
content.push({ type: "image", data: base64, mimeType });
|
|
562
|
+
} else if (base64 && (!/^[A-Za-z0-9+/=]+$/.test(base64) || base64.length < 100)) {
|
|
563
|
+
content.push({
|
|
564
|
+
type: "text",
|
|
565
|
+
text: " (Image payload was present but not valid base64 or too small—check topic, message_type, or transport.)",
|
|
566
|
+
});
|
|
567
|
+
} else if (!base64) {
|
|
568
|
+
content.push({
|
|
569
|
+
type: "text",
|
|
570
|
+
text: " (No image data received—topic may be idle or transport returned empty.)",
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
return { content };
|
|
574
|
+
} catch (err) {
|
|
575
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
576
|
+
return {
|
|
577
|
+
content: [
|
|
578
|
+
{
|
|
579
|
+
type: "text",
|
|
580
|
+
text:
|
|
581
|
+
`Camera snapshot failed: ${message}. Check robot.cameraTopic and transport in ~/.agenticros/config.json; try ros2_camera_snapshot with topic=<exact topic from ros2 topic list> and message_type=Image if you only have raw Image (not /compressed).`,
|
|
582
|
+
},
|
|
583
|
+
],
|
|
584
|
+
isError: true,
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
case "ros2_depth_distance": {
|
|
590
|
+
const rawTopic = (args["topic"] as string | undefined)?.trim() || DEFAULT_DEPTH_TOPIC;
|
|
591
|
+
const topic = resolveCameraSubscribeTopic(config, rawTopic);
|
|
592
|
+
const timeout = (args["timeout"] as number | undefined) ?? 5000;
|
|
593
|
+
try {
|
|
594
|
+
const result = await getDepthDistance(transport, topic, timeout);
|
|
595
|
+
const text = result.valid
|
|
596
|
+
? `Distance at center (~12th percentile, nearer surfaces): **${result.distance_m} m** (median: ${result.median_m} m; range ${result.min_m}–${result.max_m} m; ${result.sample_count} pixels). Topic: ${result.topic}.`
|
|
597
|
+
: `No valid depth in center region (topic: ${result.topic}, ${result.width}×${result.height}, encoding ${result.encoding}).`;
|
|
598
|
+
return { content: [{ type: "text", text }] };
|
|
599
|
+
} catch (err) {
|
|
600
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
601
|
+
return {
|
|
602
|
+
content: [{ type: "text", text: `Depth distance failed: ${message}` }],
|
|
603
|
+
isError: true,
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
case "ros2_follow_me_start": {
|
|
609
|
+
const mode = followMeMode(args);
|
|
610
|
+
const desc = String(args["target_description"] ?? "").trim();
|
|
611
|
+
if (mode === "local") {
|
|
612
|
+
if (transport.getStatus() !== "connected") {
|
|
613
|
+
return {
|
|
614
|
+
content: [{ type: "text", text: "Transport not connected. Check zenohd and config." }],
|
|
615
|
+
isError: true,
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
try {
|
|
619
|
+
const loop = getFollowMeLocal(config, transport);
|
|
620
|
+
await loop.start({ targetDescription: desc || undefined });
|
|
621
|
+
const text = `Follow-me (local) started${desc ? ` (target: ${desc})` : " (closest person)"}. Use ros2_follow_me_status with mode='local' to check tracking state.`;
|
|
622
|
+
return { content: [{ type: "text", text }] };
|
|
623
|
+
} catch (err) {
|
|
624
|
+
return { content: [{ type: "text", text: `Follow-me local start failed: ${err instanceof Error ? err.message : String(err)}` }], isError: true };
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
if (mode === "depth") {
|
|
628
|
+
if (transport.getStatus() !== "connected") {
|
|
629
|
+
return {
|
|
630
|
+
content: [{ type: "text", text: "Transport not connected. Check ROS2/transport and config." }],
|
|
631
|
+
isError: true,
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
try {
|
|
635
|
+
const loop = getFollowMeDepth(config, transport);
|
|
636
|
+
await loop.start({ targetDescription: desc || undefined });
|
|
637
|
+
const text = `Follow-me (depth-only) started — driving toward the closest blob in [0.5, 4.0] m. No person recognition; will follow whatever object is closest. Use ros2_follow_me_status with mode='depth' to check tracking state.`;
|
|
638
|
+
return { content: [{ type: "text", text }] };
|
|
639
|
+
} catch (err) {
|
|
640
|
+
return { content: [{ type: "text", text: `Follow-me depth start failed: ${err instanceof Error ? err.message : String(err)}` }], isError: true };
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
try {
|
|
644
|
+
const { topic } = await publishFollowMeCmd(config, {
|
|
645
|
+
action: "start",
|
|
646
|
+
...(desc ? { target: desc } : {}),
|
|
647
|
+
});
|
|
648
|
+
const text = `Follow-me start sent to ${topic}${desc ? ` (target: ${desc})` : " (closest person)"}. Use ros2_follow_me_status to verify the node received it.`;
|
|
649
|
+
return { content: [{ type: "text", text }] };
|
|
650
|
+
} catch (err) {
|
|
651
|
+
return { content: [{ type: "text", text: `Follow-me start failed: ${err instanceof Error ? err.message : String(err)}` }], isError: true };
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
case "ros2_follow_me_stop": {
|
|
656
|
+
const mode = followMeMode(args);
|
|
657
|
+
if (mode === "local") {
|
|
658
|
+
try {
|
|
659
|
+
const loop = getFollowMeLocal(config, transport);
|
|
660
|
+
await loop.stop();
|
|
661
|
+
return { content: [{ type: "text", text: "Follow-me (local) stopped. cmd_vel zeroed." }] };
|
|
662
|
+
} catch (err) {
|
|
663
|
+
return { content: [{ type: "text", text: `Follow-me local stop failed: ${err instanceof Error ? err.message : String(err)}` }], isError: true };
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
if (mode === "depth") {
|
|
667
|
+
try {
|
|
668
|
+
const loop = getFollowMeDepth(config, transport);
|
|
669
|
+
await loop.stop();
|
|
670
|
+
return { content: [{ type: "text", text: "Follow-me (depth) stopped. cmd_vel zeroed." }] };
|
|
671
|
+
} catch (err) {
|
|
672
|
+
return { content: [{ type: "text", text: `Follow-me depth stop failed: ${err instanceof Error ? err.message : String(err)}` }], isError: true };
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
try {
|
|
676
|
+
const { topic } = await publishFollowMeCmd(config, { action: "stop" });
|
|
677
|
+
return { content: [{ type: "text", text: `Follow-me stop sent to ${topic}.` }] };
|
|
678
|
+
} catch (err) {
|
|
679
|
+
return { content: [{ type: "text", text: `Follow-me stop failed: ${err instanceof Error ? err.message : String(err)}` }], isError: true };
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
case "ros2_follow_me_set_distance": {
|
|
684
|
+
const distance = Number(args["distance"]);
|
|
685
|
+
if (!Number.isFinite(distance)) {
|
|
686
|
+
return { content: [{ type: "text", text: "distance must be a finite number" }], isError: true };
|
|
687
|
+
}
|
|
688
|
+
if (distance < 0.2 || distance > 5.0) {
|
|
689
|
+
return { content: [{ type: "text", text: `distance ${distance} out of range [0.2, 5.0]` }], isError: true };
|
|
690
|
+
}
|
|
691
|
+
const mode = followMeMode(args);
|
|
692
|
+
if (mode === "local") {
|
|
693
|
+
getFollowMeLocal(config, transport).setTargetDistance(distance);
|
|
694
|
+
return { content: [{ type: "text", text: `Follow-me (local) target distance set to ${distance} m.` }] };
|
|
695
|
+
}
|
|
696
|
+
if (mode === "depth") {
|
|
697
|
+
getFollowMeDepth(config, transport).setTargetDistance(distance);
|
|
698
|
+
return { content: [{ type: "text", text: `Follow-me (depth) target distance set to ${distance} m.` }] };
|
|
699
|
+
}
|
|
700
|
+
try {
|
|
701
|
+
const { topic } = await publishFollowMeCmd(config, { action: "set_distance", distance });
|
|
702
|
+
return { content: [{ type: "text", text: `Follow-me set_distance=${distance} sent to ${topic}.` }] };
|
|
703
|
+
} catch (err) {
|
|
704
|
+
return { content: [{ type: "text", text: `Follow-me set_distance failed: ${err instanceof Error ? err.message : String(err)}` }], isError: true };
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
case "ros2_follow_me_set_target": {
|
|
709
|
+
const description = String(args["description"] ?? "").trim();
|
|
710
|
+
if (!description) {
|
|
711
|
+
return { content: [{ type: "text", text: "description is required" }], isError: true };
|
|
712
|
+
}
|
|
713
|
+
const mode = followMeMode(args);
|
|
714
|
+
if (mode === "local") {
|
|
715
|
+
getFollowMeLocal(config, transport).setTargetDescription(description);
|
|
716
|
+
return { content: [{ type: "text", text: `Follow-me (local) target description set: ${description}. (Note: local mode currently follows the largest person; description is recorded but not yet used for re-id.)` }] };
|
|
717
|
+
}
|
|
718
|
+
if (mode === "depth") {
|
|
719
|
+
getFollowMeDepth(config, transport).setTargetDescription(description);
|
|
720
|
+
return { content: [{ type: "text", text: `Follow-me (depth) target description recorded: ${description}. (Depth mode has no semantic recognition; it always follows the closest blob.)` }] };
|
|
721
|
+
}
|
|
722
|
+
try {
|
|
723
|
+
const { topic } = await publishFollowMeCmd(config, { action: "set_target", description });
|
|
724
|
+
return { content: [{ type: "text", text: `Follow-me set_target sent to ${topic} (description: ${description}).` }] };
|
|
725
|
+
} catch (err) {
|
|
726
|
+
return { content: [{ type: "text", text: `Follow-me set_target failed: ${err instanceof Error ? err.message : String(err)}` }], isError: true };
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
case "ros2_follow_me_status": {
|
|
731
|
+
const mode = followMeMode(args);
|
|
732
|
+
if (mode === "local") {
|
|
733
|
+
const status = getFollowMeLocal(config, transport).status();
|
|
734
|
+
return { content: [{ type: "text", text: JSON.stringify({ success: true, mode: "local", status }) }] };
|
|
735
|
+
}
|
|
736
|
+
if (mode === "depth") {
|
|
737
|
+
const status = getFollowMeDepth(config, transport).status();
|
|
738
|
+
return { content: [{ type: "text", text: JSON.stringify({ success: true, mode: "depth", status }) }] };
|
|
739
|
+
}
|
|
740
|
+
const topic = toNamespacedTopicFull(config, "/follow_me/status");
|
|
741
|
+
const timeout = (args["timeout"] as number | undefined) ?? 3000;
|
|
742
|
+
try {
|
|
743
|
+
const message = await new Promise<Record<string, unknown>>((resolve, reject) => {
|
|
744
|
+
const sub = transport.subscribe(
|
|
745
|
+
{ topic, type: "std_msgs/msg/String" },
|
|
746
|
+
(msg: Record<string, unknown>) => {
|
|
747
|
+
clearTimeout(timer);
|
|
748
|
+
sub.unsubscribe();
|
|
749
|
+
resolve(msg);
|
|
750
|
+
},
|
|
751
|
+
);
|
|
752
|
+
const timer = setTimeout(() => {
|
|
753
|
+
sub.unsubscribe();
|
|
754
|
+
reject(new Error(`Timeout waiting for status on ${topic} — is the agenticros_follow_me node running?`));
|
|
755
|
+
}, timeout);
|
|
756
|
+
});
|
|
757
|
+
let parsed: unknown = null;
|
|
758
|
+
const data = (message["data"] as string | undefined) ?? "";
|
|
759
|
+
try {
|
|
760
|
+
parsed = data ? JSON.parse(data) : null;
|
|
761
|
+
} catch {
|
|
762
|
+
parsed = null;
|
|
763
|
+
}
|
|
764
|
+
const text = JSON.stringify({ success: true, topic, status: parsed ?? data });
|
|
765
|
+
return { content: [{ type: "text", text }] };
|
|
766
|
+
} catch (err) {
|
|
767
|
+
return { content: [{ type: "text", text: `Follow-me status failed: ${err instanceof Error ? err.message : String(err)}` }], isError: true };
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
case "ros2_find_object": {
|
|
772
|
+
if (transport.getStatus() !== "connected") {
|
|
773
|
+
return {
|
|
774
|
+
content: [{ type: "text", text: "Transport not connected to Zenoh/ROS2." }],
|
|
775
|
+
isError: true,
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
const target = String(args["target"] ?? "").trim();
|
|
779
|
+
if (!target) {
|
|
780
|
+
return { content: [{ type: "text", text: "Missing required argument: target" }], isError: true };
|
|
781
|
+
}
|
|
782
|
+
const result = await findObject(config, transport, {
|
|
783
|
+
target,
|
|
784
|
+
angularSpeed: args["angular_speed"] as number | undefined,
|
|
785
|
+
clockwise: args["clockwise"] as boolean | undefined,
|
|
786
|
+
timeoutSeconds: args["timeout_seconds"] as number | undefined,
|
|
787
|
+
minConfidence: args["min_confidence"] as number | undefined,
|
|
788
|
+
});
|
|
789
|
+
const summary = result.error
|
|
790
|
+
? result.error
|
|
791
|
+
: result.found
|
|
792
|
+
? `Found ${target} after ${result.elapsedSeconds.toFixed(1)}s rotating ${result.rotationDirection}. ` +
|
|
793
|
+
`Confidence ${(result.detection!.confidence * 100).toFixed(0)}%, ` +
|
|
794
|
+
`horizontal offset ${result.detection!.horizontalOffset.toFixed(2)} ` +
|
|
795
|
+
`(${result.detection!.horizontalOffset < 0 ? "left" : "right"} of center). Robot stopped.`
|
|
796
|
+
: `${target} not found within ${result.elapsedSeconds.toFixed(1)}s. Robot stopped.`;
|
|
797
|
+
return {
|
|
798
|
+
content: [{ type: "text", text: summary + "\n" + JSON.stringify(result) }],
|
|
799
|
+
isError: !!result.error,
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
default:
|
|
804
|
+
return {
|
|
805
|
+
content: [{ type: "text", text: `Unknown tool: ${name}` }],
|
|
806
|
+
isError: true,
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* Dispatcher for the four memory_* tools. Kept separate from the ROS tool
|
|
813
|
+
* switch because memory tools must work without the ROS transport (zenohd
|
|
814
|
+
* may not be running on the agent host).
|
|
815
|
+
*/
|
|
816
|
+
async function handleMemoryToolCall(
|
|
817
|
+
name: string,
|
|
818
|
+
args: Record<string, unknown>,
|
|
819
|
+
config: AgenticROSConfig,
|
|
820
|
+
): Promise<{ content: ToolContent[]; isError?: boolean }> {
|
|
821
|
+
const memory = await ensureMemory(config);
|
|
822
|
+
if (!memory) {
|
|
823
|
+
return {
|
|
824
|
+
content: [
|
|
825
|
+
{
|
|
826
|
+
type: "text",
|
|
827
|
+
text:
|
|
828
|
+
"Memory is not enabled. Set memory.enabled=true in ~/.agenticros/config.json (backend: 'local' for zero deps, 'mem0' for semantic search). See docs/memory.md.",
|
|
829
|
+
},
|
|
830
|
+
],
|
|
831
|
+
isError: true,
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
const namespace = resolveMemoryNamespace(config, args["namespace"] as string | undefined);
|
|
835
|
+
try {
|
|
836
|
+
if (name === "memory_remember") {
|
|
837
|
+
const content = String(args["content"] ?? "").trim();
|
|
838
|
+
if (!content) {
|
|
839
|
+
return { content: [{ type: "text", text: "memory_remember requires 'content'." }], isError: true };
|
|
840
|
+
}
|
|
841
|
+
const tags = Array.isArray(args["tags"]) ? (args["tags"] as unknown[]).map(String) : undefined;
|
|
842
|
+
const pathHint = typeof args["path"] === "string" ? (args["path"] as string) : undefined;
|
|
843
|
+
const record = await memory.remember({ content, namespace, tags, path: pathHint });
|
|
844
|
+
return {
|
|
845
|
+
content: [
|
|
846
|
+
{
|
|
847
|
+
type: "text",
|
|
848
|
+
text: JSON.stringify({ success: true, id: record.id, namespace: record.namespace, backend: memory.backend }),
|
|
849
|
+
},
|
|
850
|
+
],
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
if (name === "memory_recall") {
|
|
854
|
+
const query = String(args["query"] ?? "").trim();
|
|
855
|
+
if (!query) {
|
|
856
|
+
return { content: [{ type: "text", text: "memory_recall requires 'query'." }], isError: true };
|
|
857
|
+
}
|
|
858
|
+
const limit = typeof args["limit"] === "number" ? (args["limit"] as number) : 5;
|
|
859
|
+
const hits = await memory.recall({ query, namespace, limit });
|
|
860
|
+
return {
|
|
861
|
+
content: [
|
|
862
|
+
{
|
|
863
|
+
type: "text",
|
|
864
|
+
text: JSON.stringify({
|
|
865
|
+
success: true,
|
|
866
|
+
namespace,
|
|
867
|
+
backend: memory.backend,
|
|
868
|
+
count: hits.length,
|
|
869
|
+
results: hits,
|
|
870
|
+
}),
|
|
871
|
+
},
|
|
872
|
+
],
|
|
873
|
+
};
|
|
874
|
+
}
|
|
875
|
+
if (name === "memory_forget") {
|
|
876
|
+
const id = typeof args["id"] === "string" ? (args["id"] as string) : undefined;
|
|
877
|
+
const query = typeof args["query"] === "string" ? (args["query"] as string) : undefined;
|
|
878
|
+
const result = await memory.forget({ id, query, namespace });
|
|
879
|
+
return {
|
|
880
|
+
content: [
|
|
881
|
+
{ type: "text", text: JSON.stringify({ success: true, ...result, namespace, backend: memory.backend }) },
|
|
882
|
+
],
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
const status = await memory.status(namespace);
|
|
886
|
+
return { content: [{ type: "text", text: JSON.stringify({ success: true, ...status }) }] };
|
|
887
|
+
} catch (err) {
|
|
888
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
889
|
+
return { content: [{ type: "text", text: `${name} failed: ${message}` }], isError: true };
|
|
890
|
+
}
|
|
891
|
+
}
|