360 Secure SkillHub
360 安全技能中心

Pilot Stream Data

核心功能:通过Pilot Protocol持久连接,以NDJSON格式实现实时结构化数据流,支持双向传输与背压处理。典型场景:持续传感器读数、日志、系统指标的跨Agent实时传输。输入为NDJSON格式的结构化数据,输出为接收方获取的NDJSON数据流。需依赖pilot-protocol技能、pilotctl工具及运行的守护进程,不适用于文件传输、Pub/Sub广播等场景。

teoslayer
teoslayer
热度 45.09
最近更新 2026-05-11 17:41:37
分类:自动化依赖:代码执行 / 第三方 API应用场景:数据处理 / 自动化脚本

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add pilot-stream-data
Metadata
name
pilot-stream-data
description
Real-time NDJSON data streaming over persistent Pilot Protocol connections. Use this skill when: 1. You need to stream structured data in real-time between agents 2. You want to send continuous sensor readings, logs, or metrics 3. You need bidirectional streaming communication with backpressure Do NOT use this skill when: - You need to transfer files (use pilot-share or pilot-sync) - You need pub/sub broadcast (use pilot-pubsub instead) - You need request/response patterns (use pilot-rpc instead)
tags
["pilot-protocol","streaming","real-time","ndjson"]
license
AGPL-3.0
compatibility
Requires pilot-protocol skill and pilotctl binary on PATH. The daemon must be running (pilotctl daemon start).
metadata
{"author":"vulture-labs","version":"1.0","openclaw":{"requires":{"bins":["pilotctl"]},"homepage":"https://pilotprotocol.network"}}
allowed-tools
["Bash"]

pilot-stream-data

Real-time structured data streaming using NDJSON format over Pilot Protocol's persistent connections with backpressure handling.

Commands

Start stream server:

pilotctl --json listen 1002 > /tmp/pilot-stream.log &

Stream NDJSON data:

DEST="1:0001.AAAA.BBBB"
while true; do
  MSG="{\"timestamp\":$(date +%s),\"temp\":$(echo "scale=2; 20 + $RANDOM % 10" | bc),\"humidity\":50}"
  pilotctl --json send "$DEST" 1002 --data "$MSG"
  sleep 1
done

Receive and process stream:

pilotctl --json listen 1002 | while read -r line; do
  TIMESTAMP=$(echo "$line" | jq -r '.timestamp')
  VALUE=$(echo "$line" | jq -r '.value')
  echo "[$TIMESTAMP] Value: $VALUE"
done

Subscribe to stream topic:

pilotctl --json subscribe "$DEST" data-stream | while read -r line; do
  echo "Data: $(echo $line | jq -r '.value')"
done

Workflow Example

#!/bin/bash
# Real-time sensor data streaming

STREAM_PORT=1002
DEST="1:0001.AAAA.BBBB"

# Producer: stream sensor data
produce_stream() {
  echo "Starting stream producer"

  # Send metadata header
  pilotctl --json send "$DEST" "$STREAM_PORT" \
    --data "{\"type\":\"stream_start\",\"schema\":\"temp_humidity_v1\"}"

  # Stream data
  counter=0
  while true; do
    timestamp=$(date +%s)
    temp=$(echo "scale=2; 20 + ($counter % 10)" | bc)
    humidity=$(echo "scale=2; 50 + ($counter % 20)" | bc)

    pilotctl --json send "$DEST" "$STREAM_PORT" \
      --data "{\"type\":\"data\",\"timestamp\":$timestamp,\"temp\":$temp,\"humidity\":$humidity,\"seq\":$counter}"

    counter=$((counter + 1))
    sleep 1
  done
}

# Consumer: receive and process
consume_stream() {
  pilotctl --json listen "$STREAM_PORT" | while read -r line; do
    type=$(echo "$line" | jq -r '.type')

    if [ "$type" = "data" ]; then
      temp=$(echo "$line" | jq -r '.temp')
      echo "Temperature: ${temp}°C"
    fi
  done
}

produce_stream

Dependencies

Requires pilot-protocol skill, running daemon, jq, bc, and optional gzip for compression.