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,516 @@
|
|
|
1
|
+
import { PeerConnection, DescriptionType, type DataChannel, type RtcConfig } from "node-datachannel";
|
|
2
|
+
import type { RosTransport } from "../transport.js";
|
|
3
|
+
import type {
|
|
4
|
+
ConnectionStatus,
|
|
5
|
+
ConnectionHandler,
|
|
6
|
+
Subscription,
|
|
7
|
+
PublishOptions,
|
|
8
|
+
SubscribeOptions,
|
|
9
|
+
ServiceCallOptions,
|
|
10
|
+
ServiceCallResult,
|
|
11
|
+
ActionGoalOptions,
|
|
12
|
+
ActionResult,
|
|
13
|
+
TopicInfo,
|
|
14
|
+
ServiceInfo,
|
|
15
|
+
ActionInfo,
|
|
16
|
+
MessageHandler,
|
|
17
|
+
RTCIceServerConfig,
|
|
18
|
+
} from "../types.js";
|
|
19
|
+
import { SignalingClient } from "./signaling-client.js";
|
|
20
|
+
import type {
|
|
21
|
+
SignalingMessage,
|
|
22
|
+
OfferMessage,
|
|
23
|
+
IceCandidateMessage,
|
|
24
|
+
PeerJoinedMessage,
|
|
25
|
+
} from "./signaling-types.js";
|
|
26
|
+
|
|
27
|
+
export interface WebRTCTransportOptions {
|
|
28
|
+
/** WebSocket URL of the signaling server (e.g., wss://signal-host). */
|
|
29
|
+
signalingUrl: string;
|
|
30
|
+
/** REST API URL of the signaling server (e.g., https://signal-host). */
|
|
31
|
+
apiUrl: string;
|
|
32
|
+
/** Target robot's ID on the signaling server. */
|
|
33
|
+
robotId: string;
|
|
34
|
+
/** Robot key secret — validated by the robot, not the signaling server. */
|
|
35
|
+
robotKey: string;
|
|
36
|
+
/** STUN/TURN server configuration. */
|
|
37
|
+
iceServers?: RTCIceServerConfig[];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Pending request for service calls and action goals over the data channel. */
|
|
41
|
+
interface PendingRequest {
|
|
42
|
+
resolve: (value: unknown) => void;
|
|
43
|
+
reject: (reason: Error) => void;
|
|
44
|
+
timer: ReturnType<typeof setTimeout>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Mode C transport: WebRTC data channel for cloud/remote deployments.
|
|
49
|
+
*
|
|
50
|
+
* The frontend (this class) acts as the answering peer:
|
|
51
|
+
* 1. POST /api/robots/{robotId}/connect → get session_id, room_id
|
|
52
|
+
* 2. Open signaling WebSocket → JOIN_ROOM
|
|
53
|
+
* 3. Wait for robot's SDP offer
|
|
54
|
+
* 4. Create RTCPeerConnection, set remote description, create answer
|
|
55
|
+
* 5. Exchange ICE candidates
|
|
56
|
+
* 6. Data channel opens → rosbridge JSON over WebRTC
|
|
57
|
+
*/
|
|
58
|
+
export class WebRTCTransport implements RosTransport {
|
|
59
|
+
private options: WebRTCTransportOptions;
|
|
60
|
+
private signaling: SignalingClient;
|
|
61
|
+
private pc: PeerConnection | null = null;
|
|
62
|
+
private dataChannel: DataChannel | null = null;
|
|
63
|
+
private status: ConnectionStatus = "disconnected";
|
|
64
|
+
private connectionHandlers = new Set<ConnectionHandler>();
|
|
65
|
+
private topicHandlers = new Map<string, Set<MessageHandler>>();
|
|
66
|
+
private pendingRequests = new Map<string, PendingRequest>();
|
|
67
|
+
private idCounter = 0;
|
|
68
|
+
private sessionId: string | null = null;
|
|
69
|
+
private roomId: string | null = null;
|
|
70
|
+
private peerId: string | null = null;
|
|
71
|
+
private robotPeerId: string | null = null;
|
|
72
|
+
|
|
73
|
+
constructor(options: WebRTCTransportOptions) {
|
|
74
|
+
this.options = options;
|
|
75
|
+
this.signaling = new SignalingClient(options.apiUrl, options.signalingUrl);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async connect(): Promise<void> {
|
|
79
|
+
if (this.status === "connected") return;
|
|
80
|
+
this.setStatus("connecting");
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
// Step 1: Request connection via REST API
|
|
84
|
+
const userId = `frontend_${Date.now()}`;
|
|
85
|
+
const connectRes = await this.signaling.requestConnection(this.options.robotId, {
|
|
86
|
+
user_id: userId,
|
|
87
|
+
robot_id: this.options.robotId,
|
|
88
|
+
robot_key: this.options.robotKey,
|
|
89
|
+
});
|
|
90
|
+
this.sessionId = connectRes.session.session_id;
|
|
91
|
+
this.roomId = connectRes.room_id;
|
|
92
|
+
this.peerId = userId;
|
|
93
|
+
|
|
94
|
+
// Step 2: Connect signaling WebSocket
|
|
95
|
+
await this.signaling.connectWs();
|
|
96
|
+
|
|
97
|
+
// Step 3: Set up message handler before joining room
|
|
98
|
+
const connected = new Promise<void>((resolve, reject) => {
|
|
99
|
+
const timeout = setTimeout(() => {
|
|
100
|
+
reject(new Error("WebRTC connection timed out (30s)"));
|
|
101
|
+
}, 30_000);
|
|
102
|
+
|
|
103
|
+
this.signaling.onMessage((msg: SignalingMessage) => {
|
|
104
|
+
this.handleSignalingMessage(msg, resolve, reject, timeout);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// Step 4: Join room
|
|
109
|
+
this.signaling.joinRoom(this.roomId, userId, "frontend", this.sessionId);
|
|
110
|
+
|
|
111
|
+
// Step 5: Wait for data channel to be established
|
|
112
|
+
await connected;
|
|
113
|
+
this.setStatus("connected");
|
|
114
|
+
} catch (err) {
|
|
115
|
+
this.setStatus("disconnected");
|
|
116
|
+
this.cleanup();
|
|
117
|
+
throw err;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async disconnect(): Promise<void> {
|
|
122
|
+
this.cleanup();
|
|
123
|
+
|
|
124
|
+
// Notify signaling server
|
|
125
|
+
if (this.sessionId) {
|
|
126
|
+
try {
|
|
127
|
+
await this.signaling.requestDisconnect(this.options.robotId);
|
|
128
|
+
} catch {
|
|
129
|
+
// Best-effort disconnect notification
|
|
130
|
+
}
|
|
131
|
+
this.sessionId = null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
this.signaling.close();
|
|
135
|
+
this.setStatus("disconnected");
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
getStatus(): ConnectionStatus {
|
|
139
|
+
return this.status;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
onConnection(handler: ConnectionHandler): () => void {
|
|
143
|
+
this.connectionHandlers.add(handler);
|
|
144
|
+
return () => {
|
|
145
|
+
this.connectionHandlers.delete(handler);
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
publish(options: PublishOptions): void {
|
|
150
|
+
this.sendOverDataChannel({
|
|
151
|
+
op: "publish",
|
|
152
|
+
topic: options.topic,
|
|
153
|
+
type: options.type,
|
|
154
|
+
msg: options.msg,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
subscribe(options: SubscribeOptions, handler: MessageHandler): Subscription {
|
|
159
|
+
const topic = options.topic;
|
|
160
|
+
|
|
161
|
+
if (!this.topicHandlers.has(topic)) {
|
|
162
|
+
this.topicHandlers.set(topic, new Set());
|
|
163
|
+
}
|
|
164
|
+
this.topicHandlers.get(topic)!.add(handler);
|
|
165
|
+
|
|
166
|
+
// Send rosbridge subscribe command
|
|
167
|
+
this.sendOverDataChannel({
|
|
168
|
+
op: "subscribe",
|
|
169
|
+
id: this.nextId("sub"),
|
|
170
|
+
topic,
|
|
171
|
+
type: options.type,
|
|
172
|
+
throttle_rate: options.throttleRate,
|
|
173
|
+
queue_length: options.queueLength,
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
return {
|
|
177
|
+
unsubscribe: () => {
|
|
178
|
+
this.topicHandlers.get(topic)?.delete(handler);
|
|
179
|
+
if (this.topicHandlers.get(topic)?.size === 0) {
|
|
180
|
+
this.topicHandlers.delete(topic);
|
|
181
|
+
try {
|
|
182
|
+
this.sendOverDataChannel({ op: "unsubscribe", topic });
|
|
183
|
+
} catch {
|
|
184
|
+
// Already disconnected
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
async callService(options: ServiceCallOptions): Promise<ServiceCallResult> {
|
|
192
|
+
const id = this.nextId("service");
|
|
193
|
+
|
|
194
|
+
const response = await new Promise<Record<string, unknown>>((resolve, reject) => {
|
|
195
|
+
this.registerPending(id, (v) => resolve(v as Record<string, unknown>), reject, 30_000);
|
|
196
|
+
|
|
197
|
+
this.sendOverDataChannel({
|
|
198
|
+
op: "call_service",
|
|
199
|
+
id,
|
|
200
|
+
service: options.service,
|
|
201
|
+
args: options.args,
|
|
202
|
+
type: options.type,
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
return {
|
|
207
|
+
result: response.result as boolean,
|
|
208
|
+
values: response.values as Record<string, unknown> | undefined,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
async sendActionGoal(options: ActionGoalOptions): Promise<ActionResult> {
|
|
213
|
+
const id = this.nextId("action");
|
|
214
|
+
|
|
215
|
+
// Register feedback handler if provided
|
|
216
|
+
let feedbackKey: string | null = null;
|
|
217
|
+
if (options.onFeedback) {
|
|
218
|
+
feedbackKey = `__action_feedback__${id}`;
|
|
219
|
+
if (!this.topicHandlers.has(feedbackKey)) {
|
|
220
|
+
this.topicHandlers.set(feedbackKey, new Set());
|
|
221
|
+
}
|
|
222
|
+
this.topicHandlers.get(feedbackKey)!.add((msg) => {
|
|
223
|
+
options.onFeedback!(msg.values as Record<string, unknown>);
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
try {
|
|
228
|
+
const response = await new Promise<Record<string, unknown>>((resolve, reject) => {
|
|
229
|
+
this.registerPending(id, (v) => resolve(v as Record<string, unknown>), reject, 120_000);
|
|
230
|
+
|
|
231
|
+
this.sendOverDataChannel({
|
|
232
|
+
op: "send_action_goal",
|
|
233
|
+
id,
|
|
234
|
+
action: options.action,
|
|
235
|
+
action_type: options.actionType,
|
|
236
|
+
args: options.args,
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
return {
|
|
241
|
+
result: response.result as boolean,
|
|
242
|
+
values: response.values as Record<string, unknown> | undefined,
|
|
243
|
+
};
|
|
244
|
+
} finally {
|
|
245
|
+
if (feedbackKey) {
|
|
246
|
+
this.topicHandlers.delete(feedbackKey);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
async cancelActionGoal(action: string): Promise<void> {
|
|
252
|
+
this.sendOverDataChannel({
|
|
253
|
+
op: "cancel_action_goal",
|
|
254
|
+
id: this.nextId("cancel"),
|
|
255
|
+
action,
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
async listTopics(): Promise<TopicInfo[]> {
|
|
260
|
+
const result = await this.callService({
|
|
261
|
+
service: "/rosapi/topics",
|
|
262
|
+
type: "rosapi/srv/Topics",
|
|
263
|
+
args: {},
|
|
264
|
+
});
|
|
265
|
+
const topics = (result.values?.["topics"] as string[]) ?? [];
|
|
266
|
+
const types = (result.values?.["types"] as string[]) ?? [];
|
|
267
|
+
return topics.map((name, i) => ({ name, type: types[i] ?? "" }));
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
async listServices(): Promise<ServiceInfo[]> {
|
|
271
|
+
const result = await this.callService({
|
|
272
|
+
service: "/rosapi/services",
|
|
273
|
+
type: "rosapi/srv/Services",
|
|
274
|
+
args: {},
|
|
275
|
+
});
|
|
276
|
+
const services = (result.values?.["services"] as string[]) ?? [];
|
|
277
|
+
const types = (result.values?.["types"] as string[]) ?? [];
|
|
278
|
+
return services.map((name, i) => ({ name, type: types[i] ?? "" }));
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
async listActions(): Promise<ActionInfo[]> {
|
|
282
|
+
// Same heuristic as RosbridgeTransport — extract from feedback topics
|
|
283
|
+
const topics = await this.listTopics();
|
|
284
|
+
const actions: ActionInfo[] = [];
|
|
285
|
+
const feedbackSuffix = "/_action/feedback";
|
|
286
|
+
|
|
287
|
+
for (const topic of topics) {
|
|
288
|
+
if (topic.name.endsWith(feedbackSuffix)) {
|
|
289
|
+
const actionName = topic.name.slice(0, -feedbackSuffix.length);
|
|
290
|
+
let actionType = topic.type;
|
|
291
|
+
if (actionType.endsWith("_FeedbackMessage")) {
|
|
292
|
+
actionType = actionType.slice(0, -"_FeedbackMessage".length);
|
|
293
|
+
}
|
|
294
|
+
actions.push({ name: actionName, type: actionType });
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return actions;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// --- Private helpers ---
|
|
302
|
+
|
|
303
|
+
private nextId(prefix = "agenticros"): string {
|
|
304
|
+
return `${prefix}_${++this.idCounter}`;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
private setStatus(status: ConnectionStatus): void {
|
|
308
|
+
this.status = status;
|
|
309
|
+
for (const handler of this.connectionHandlers) {
|
|
310
|
+
handler(status);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
private sendOverDataChannel(msg: Record<string, unknown>): void {
|
|
315
|
+
if (!this.dataChannel) {
|
|
316
|
+
throw new Error("Data channel is not open");
|
|
317
|
+
}
|
|
318
|
+
this.dataChannel.sendMessage(JSON.stringify(msg));
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
private registerPending(
|
|
322
|
+
id: string,
|
|
323
|
+
resolve: (value: unknown) => void,
|
|
324
|
+
reject: (reason: Error) => void,
|
|
325
|
+
timeoutMs: number,
|
|
326
|
+
): void {
|
|
327
|
+
const timer = setTimeout(() => {
|
|
328
|
+
this.pendingRequests.delete(id);
|
|
329
|
+
reject(new Error(`Request ${id} timed out after ${timeoutMs}ms`));
|
|
330
|
+
}, timeoutMs);
|
|
331
|
+
this.pendingRequests.set(id, { resolve, reject, timer });
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
private resolvePending(id: string, result: unknown): void {
|
|
335
|
+
const pending = this.pendingRequests.get(id);
|
|
336
|
+
if (pending) {
|
|
337
|
+
clearTimeout(pending.timer);
|
|
338
|
+
this.pendingRequests.delete(id);
|
|
339
|
+
pending.resolve(result);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/** Handle incoming rosbridge JSON from the data channel. */
|
|
344
|
+
private handleDataChannelMessage(data: string): void {
|
|
345
|
+
let msg: Record<string, unknown>;
|
|
346
|
+
try {
|
|
347
|
+
msg = JSON.parse(data) as Record<string, unknown>;
|
|
348
|
+
} catch {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
const op = msg.op as string | undefined;
|
|
353
|
+
if (!op) return;
|
|
354
|
+
|
|
355
|
+
switch (op) {
|
|
356
|
+
case "publish": {
|
|
357
|
+
const topic = msg.topic as string;
|
|
358
|
+
const payload = msg.msg as Record<string, unknown>;
|
|
359
|
+
const handlers = this.topicHandlers.get(topic);
|
|
360
|
+
if (handlers) {
|
|
361
|
+
for (const handler of handlers) {
|
|
362
|
+
handler(payload);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
case "service_response": {
|
|
369
|
+
const id = msg.id as string | undefined;
|
|
370
|
+
if (id) this.resolvePending(id, msg);
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
case "action_result": {
|
|
375
|
+
const id = msg.id as string | undefined;
|
|
376
|
+
if (id) this.resolvePending(id, msg);
|
|
377
|
+
break;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
case "action_feedback": {
|
|
381
|
+
const id = msg.id as string | undefined;
|
|
382
|
+
if (id) {
|
|
383
|
+
const handlers = this.topicHandlers.get(`__action_feedback__${id}`);
|
|
384
|
+
if (handlers) {
|
|
385
|
+
for (const handler of handlers) {
|
|
386
|
+
handler(msg);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
break;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/** Handle signaling messages during connection setup. */
|
|
396
|
+
private handleSignalingMessage(
|
|
397
|
+
msg: SignalingMessage,
|
|
398
|
+
onConnected: () => void,
|
|
399
|
+
onError: (err: Error) => void,
|
|
400
|
+
timeout: ReturnType<typeof setTimeout>,
|
|
401
|
+
): void {
|
|
402
|
+
switch (msg.type) {
|
|
403
|
+
case "peer_joined": {
|
|
404
|
+
const peerMsg = msg as PeerJoinedMessage;
|
|
405
|
+
if (peerMsg.peer_type === "robot") {
|
|
406
|
+
this.robotPeerId = peerMsg.peer_id;
|
|
407
|
+
}
|
|
408
|
+
break;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
case "offer": {
|
|
412
|
+
const offerMsg = msg as OfferMessage;
|
|
413
|
+
this.handleOffer(offerMsg, onConnected, onError, timeout);
|
|
414
|
+
break;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
case "ice_candidate": {
|
|
418
|
+
const iceMsg = msg as IceCandidateMessage;
|
|
419
|
+
if (this.pc) {
|
|
420
|
+
this.pc.addRemoteCandidate(iceMsg.data.candidate, iceMsg.data.sdpMid ?? "0");
|
|
421
|
+
}
|
|
422
|
+
break;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
case "error": {
|
|
426
|
+
clearTimeout(timeout);
|
|
427
|
+
onError(new Error(`Signaling error: ${(msg as unknown as { message: string }).message}`));
|
|
428
|
+
break;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/** Handle SDP offer from the robot and create an answer. */
|
|
434
|
+
private handleOffer(
|
|
435
|
+
offer: OfferMessage,
|
|
436
|
+
onConnected: () => void,
|
|
437
|
+
onError: (err: Error) => void,
|
|
438
|
+
timeout: ReturnType<typeof setTimeout>,
|
|
439
|
+
): void {
|
|
440
|
+
// Build ICE server strings for node-datachannel
|
|
441
|
+
const iceServers = this.options.iceServers ?? [{ urls: "stun:stun.l.google.com:19302" }];
|
|
442
|
+
const iceServerStrs = iceServers.map((s) => {
|
|
443
|
+
const urls = Array.isArray(s.urls) ? s.urls : [s.urls];
|
|
444
|
+
return urls[0]; // node-datachannel takes individual server strings
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
const rtcConfig: RtcConfig = { iceServers: iceServerStrs };
|
|
448
|
+
this.pc = new PeerConnection("agenticros-frontend", rtcConfig);
|
|
449
|
+
|
|
450
|
+
// Handle ICE candidates from our side → send to robot
|
|
451
|
+
this.pc.onLocalCandidate((candidate, mid) => {
|
|
452
|
+
this.signaling.sendIceCandidate(candidate, mid, null, this.robotPeerId ?? undefined);
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
// Handle state changes
|
|
456
|
+
this.pc.onStateChange((state) => {
|
|
457
|
+
if (state === "failed" || state === "closed") {
|
|
458
|
+
this.setStatus("disconnected");
|
|
459
|
+
this.rejectAllPending(new Error("Peer connection closed"));
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
// Handle incoming data channel
|
|
464
|
+
this.pc.onDataChannel((dc) => {
|
|
465
|
+
this.dataChannel = dc;
|
|
466
|
+
|
|
467
|
+
dc.onOpen(() => {
|
|
468
|
+
clearTimeout(timeout);
|
|
469
|
+
onConnected();
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
dc.onMessage((data: string | Buffer) => {
|
|
473
|
+
const str = typeof data === "string" ? data : data.toString("utf-8");
|
|
474
|
+
this.handleDataChannelMessage(str);
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
dc.onClosed(() => {
|
|
478
|
+
this.dataChannel = null;
|
|
479
|
+
this.setStatus("disconnected");
|
|
480
|
+
this.rejectAllPending(new Error("Data channel closed"));
|
|
481
|
+
});
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
// Set remote offer and create answer
|
|
485
|
+
this.pc.setRemoteDescription(offer.data.sdp, DescriptionType.Offer);
|
|
486
|
+
const answer = this.pc.localDescription();
|
|
487
|
+
if (answer) {
|
|
488
|
+
this.signaling.sendAnswer(answer.sdp, this.roomId!, this.peerId!, this.robotPeerId ?? undefined);
|
|
489
|
+
} else {
|
|
490
|
+
clearTimeout(timeout);
|
|
491
|
+
onError(new Error("Failed to create SDP answer"));
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
private cleanup(): void {
|
|
496
|
+
this.rejectAllPending(new Error("Transport disconnected"));
|
|
497
|
+
|
|
498
|
+
if (this.dataChannel) {
|
|
499
|
+
this.dataChannel.close();
|
|
500
|
+
this.dataChannel = null;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
if (this.pc) {
|
|
504
|
+
this.pc.close();
|
|
505
|
+
this.pc = null;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
private rejectAllPending(error: Error): void {
|
|
510
|
+
for (const [, pending] of this.pendingRequests) {
|
|
511
|
+
clearTimeout(pending.timer);
|
|
512
|
+
pending.reject(error);
|
|
513
|
+
}
|
|
514
|
+
this.pendingRequests.clear();
|
|
515
|
+
}
|
|
516
|
+
}
|