gavinguo521/paseo-mesh / skills/paseo-peer-zh
paseo-peer-zh
Verified和其他 Paseo 会话协作(本机或另一台机器):查哪个会话在做某件事、看进度、发消息、回复、在那边新开会话。用户问「哪个会话在做 X / 谁在部署 / 隔壁在干什么」(本机也算),或提到另一台机器、跨机器、让那边的会话做什么,或收到以【跨机器消息】/【跨项目消息】/[Cross-machine message]/[Cross-project message] 开头的消息时使用。
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 20.1 KB |
| scripts/paseo-peerexecutable | script | 27.7 KB |
| scripts/paseo-peer-admin.mjs | script | 26.7 KB |
| scripts/paseo-peer-wait.mjs | script | 12.1 KB |
scripts/paseo-peer
View on GitHub#!/usr/bin/env bash
# paseo-peer — let Paseo sessions in different projects and on different machines find and message each other.
# https://github.com/gavinguo521/paseo-mesh
#
# Machine list: ~/.paseo/peers.json (private to this machine, chmod 600, holds pairing links — never commit it).
# See peers.example.json in the repo for the format.
#
# Usage:
# paseo-peer init [--name N] [--label L] Register this machine in peers.json (its own pairing link is read locally)
# paseo-peer invite [--print] Put this machine's join code on the clipboard (not shown)
# paseo-peer join [--stdin] [--name N] Add another machine from its join code (clipboard, or hidden prompt);
# connects once to verify before saving
# paseo-peer password <machine> [--clear] Save that machine's daemon password (hidden prompt; checked before saving).
# Needed since Paseo 0.13 when the daemon there has a password set
# paseo-peer link [machine…] Register the other machines as connected hosts of this daemon (Paseo 0.13+),
# so sessions here can use MCP tools with serverId and get finish notifications
# paseo-peer doctor Check Paseo version, peers.json, and that every machine is reachable
# paseo-peer ls List machines in peers.json (no links), marking this one
# paseo-peer <machine> <paseo args…> Run any paseo command against that machine (<machine> = name, serverId,
# or `local` for this machine)
# paseo-peer <machine> who [project-dir] Sessions on that machine working in this project: status, last activity,
# title, latest exchange (project-dir defaults to the current dir name)
# paseo-peer <machine> find <pattern> [-a] [--days N] Which sessions there are doing X: search every live session's
# recent messages and commands (case-insensitive regex; -a also searches
# closed/archived ones; --days N skips sessions idle longer; on another
# machine -a only adds archived sessions created in the last --days days,
# default 7, at most 50, since each one is fetched over the relay)
# paseo-peer whoami This session's sender line: project + session name + short id
# paseo-peer whoami --header [--remote] First line for messages sent with MCP tools (same wording as tell;
# --remote for another machine)
# paseo-peer whoami --labels Labels to put on a helper session you start:
# --label collab.by=<this machine>:<short id> --label collab.from=<project>
# paseo-peer <machine> mine Helper sessions this session started on that machine (by label, incl. archived)
# paseo-peer <machine> tell <agentId> "message" Message a session there (preferred). Adds a sender line on top and a reply
# paseo-peer <machine> tell <agentId> --file <p> command at the bottom; steers into a running turn instead of interrupting.
# Marked "cross-project" when the target is this machine, else "cross-machine".
# On success prints "Sent: <machine> (serverId …)" so Paseo clients can open the target.
# paseo-peer <machine> wait <agentId> [--timeout M] [--interval S] [--start-grace S]
# Wait for that session's current/next turn to finish, then print the
# final status and its last reply in full (run it in the background
# after sending; defaults 60 min / 30 s / 300 s, timeout max 120 min).
# Exit 0 finished, 2 never started, 3 still running at the timeout,
# 4 stopped at a permission request (printed, not answered), 5 status unreadable
# paseo-peer <machine> send --no-wait <agentId> "message" Raw send, no sender line
#
# Language of the sender/reply lines: PASEO_PEER_LANG=zh|en; by default zh when installed as a "-zh" skill, else en.
set -euo pipefail
# Resolve symlinks (e.g. ~/.local/bin/paseo-peer -> …/skills/paseo-peer-zh/scripts/paseo-peer) to find the real skill dir
src="$0"
while [ -L "$src" ]; do
dir="$(cd "$(dirname "$src")" && pwd)"; src="$(readlink "$src")"
case "$src" in /*) ;; *) src="$dir/$src" ;; esac
done
SCRIPT_DIR="$(cd "$(dirname "$src")" && pwd -P)"
SKILL_NAME="$(basename "$(dirname "$SCRIPT_DIR")")"
case "${PASEO_PEER_LANG:-}" in
zh|en) LANG_UI="$PASEO_PEER_LANG" ;;
*) case "$SKILL_NAME" in *-zh) LANG_UI=zh ;; *) LANG_UI=en ;; esac ;;
esac
# t "<中文>" "<English>"
t() { if [ "$LANG_UI" = zh ]; then printf '%s' "$1"; else printf '%s' "$2"; fi; }
# Usage = the comment block at the top: from line 2 up to the first line that isn't a comment
usage() { awk 'NR > 1 && !/^#/ { exit } NR > 1 { sub(/^# ?/, ""); print }' "$0"; }
PEERS="${PASEO_PEERS:-$HOME/.paseo/peers.json}"
# Paseo CLI: `paseo` on PATH first, then the CLI bundled with the macOS desktop app
PASEO="$(command -v paseo || true)"
[ -n "$PASEO" ] || [ ! -x /Applications/Paseo.app/Contents/Resources/bin/paseo ] || PASEO=/Applications/Paseo.app/Contents/Resources/bin/paseo
[ -n "$PASEO" ] || { t "找不到 Paseo CLI(paseo),请先安装 Paseo 或把 paseo 加进 PATH" "Paseo CLI (paseo) not found; install Paseo or put paseo on PATH" >&2; echo >&2; exit 1; }
# How the reply line tells the other side to call this script: PASEO_PEER_CMD, else `paseo-peer` if on PATH,
# else this script's own path (with $HOME shown as ~)
if [ -n "${PASEO_PEER_CMD:-}" ]; then SELF_CMD="$PASEO_PEER_CMD"
elif command -v paseo-peer >/dev/null 2>&1; then SELF_CMD=paseo-peer
else SELF_CMD="$SCRIPT_DIR/$(basename "$src")"; SELF_CMD="${SELF_CMD/#"$HOME"/\~}"
fi
SELF_ID="$(cat "$HOME/.paseo/server-id" 2>/dev/null || true)"
# Setup commands live in paseo-peer-admin.mjs (they handle pairing links, so they never put them in argv)
case "${1:-}" in
init|invite|join|password|link|doctor)
PASEO="$PASEO" PEERS="$PEERS" LANG_UI="$LANG_UI" SELF_CMD="$SELF_CMD" exec node "$SCRIPT_DIR/paseo-peer-admin.mjs" "$@" ;;
esac
# peers.json is optional: without it only this machine (`local`) is reachable, which is enough for cross-project work
HAVE_PEERS=0
if [ -f "$PEERS" ]; then
HAVE_PEERS=1
# peers.json holds pairing links (keys to the other machines): refuse to run if group/others can read it
perm="$(stat -c %a "$PEERS" 2>/dev/null || stat -f %Lp "$PEERS")"
case "$perm" in
*00) ;;
*) t "$PEERS 的权限是 ${perm},其他用户可读;里面的配对链接是钥匙,请先 chmod 600 $PEERS" \
"$PEERS has mode $perm and is readable by others; it holds pairing links (keys) — run: chmod 600 $PEERS" >&2
echo >&2; exit 1 ;;
esac
fi
[ $# -ge 1 ] || { usage; exit 1; }
# Codex shells may omit PASEO_AGENT_ID. Match the native thread against the local
# daemon's persisted agents, never cwd/title/activity. Ambiguous or unreadable
# records fail closed; a remote daemon cannot be identified from local records.
resolve_self_id() {
[ -z "${PASEO_AGENT_ID:-}" ] || return 0
[ -n "${CODEX_THREAD_ID:-${CODEX_SESSION_ID:-}}" ] || return 0
[ -z "${PASEO_HOST:-}" ] || return 0
PASEO_AGENT_ID="$(node -e '
const fs = require("fs")
const path = require("path")
const { CODEX_THREAD_ID: thread, CODEX_SESSION_ID: session, PASEO_HOME: home } = process.env
if (thread && session && thread !== session) process.exit(0)
const nativeId = thread || session
const root = path.join(home || path.join(require("os").homedir(), ".paseo"), "agents")
try {
const matches = []
for (const dir of fs.readdirSync(root, { withFileTypes: true })) {
if (!dir.isDirectory()) continue
const folder = path.join(root, dir.name)
for (const file of fs.readdirSync(folder)) {
if (!file.endsWith(".json")) continue
const agent = JSON.parse(fs.readFileSync(path.join(folder, file), "utf8"))
if (agent.provider === "codex" && agent.persistence?.provider === "codex" &&
agent.persistence.sessionId === nativeId) matches.push(agent.id)
}
}
if (matches.length === 1 && typeof matches[0] === "string" && matches[0]) console.log(matches[0])
} catch { /* Cannot prove uniqueness: keep the existing non-session behavior. */ }
')" || PASEO_AGENT_ID=""
[ -z "$PASEO_AGENT_ID" ] || export PASEO_AGENT_ID
return 0
}
# This session's sender line. Project name = the Paseo project (as shown in the sidebar) whose path contains the
# session's cwd; falls back to the directory name. Mode "project" prints just the project name.
self_desc() {
[ -n "${PASEO_AGENT_ID:-}" ] || { t "不是 Paseo 会话" "not a Paseo session"; echo; return; }
node -e '
const { execFileSync } = require("child_process")
const [paseo, id, mode, lang] = process.argv.slice(1)
const run = (args) => { try { return JSON.parse(execFileSync(paseo, args, { encoding: "utf8" })) } catch { return null } }
const agent = run(["inspect", id, "--json"]) ?? {}
const cwd = agent.Cwd ?? process.cwd()
const list = run(["project", "ls", "--json"])
const projects = Array.isArray(list) ? list : (list?.projects ?? [])
const hit = projects.filter((p) => cwd === p.path || cwd.startsWith(p.path + "/")).sort((a, b) => b.path.length - a.path.length)[0]
const project = hit?.name ?? cwd.split("/").pop()
const name = agent.Name ?? (lang === "zh" ? "未命名" : "untitled")
const short = id.slice(0, 7)
if (mode === "project") console.log(project)
else console.log(lang === "zh" ? `「${project}」项目的会话「${name}」(id ${short})` : `session "${name}" in project "${project}" (id ${short})`)
' "$PASEO" "$PASEO_AGENT_ID" "${1:-desc}" "$LANG_UI"
}
# This machine's `name` (e.g. office) or `label` (e.g. "Office iMac") from peers.json
self_machine() {
if [ "$HAVE_PEERS" = 0 ]; then [ "$1" = name ] && echo local || hostname -s; return; fi
node -e '
const d = JSON.parse(require("fs").readFileSync(process.argv[1], "utf8"))
console.log(d.machines.find((x) => x.serverId === process.argv[2])?.[process.argv[3]] ?? "")
' "$PEERS" "$SELF_ID" "$1"
}
if [ "$1" = whoami ]; then
resolve_self_id
if [ "${2:-}" = --labels ]; then
[ -n "${PASEO_AGENT_ID:-}" ] || { t "不是 Paseo 会话,没有可打的标签" "Not a Paseo session; no labels to print" >&2; echo >&2; exit 1; }
printf -- '--label collab.by=%s:%s --label collab.from=%s\n' "$(self_machine name)" "${PASEO_AGENT_ID:0:7}" "$(self_desc project)"
elif [ "${2:-}" = --header ]; then
# First line for messages sent with MCP tools (which add no sender line): same wording as tell
if [ "${3:-}" = --remote ]; then
machine="$(self_machine label)"; machine="${machine:-$(self_machine name)}"
t "【跨机器消息】来自 ${machine:-未知机器} 上$(self_desc)" "[Cross-machine message] From $(self_desc) on ${machine:-unknown machine}"
else
t "【跨项目消息】来自$(self_desc)" "[Cross-project message] From $(self_desc)"
fi
echo
else
self_desc
fi
exit 0
fi
if [ "$1" = ls ]; then
if [ "$HAVE_PEERS" = 0 ]; then t "还没有机器清单;只有本机(local)。要跨机器,运行 paseo-peer init" "No machine list yet; only this machine (local). For cross-machine, run paseo-peer init"; echo; exit 0; fi
node -e '
const d = JSON.parse(require("fs").readFileSync(process.argv[1], "utf8"))
const mark = process.argv[3] === "zh" ? " ← 本机" : " ← this machine"
for (const m of d.machines) console.log(`${m.name.padEnd(10)} ${m.serverId} ${m.label}${m.serverId === process.argv[2] ? mark : ""}`)
' "$PEERS" "$SELF_ID" "$LANG_UI"
exit 0
fi
target="$1"; shift
# A bare `paseo` (no subcommand) is not help: it can print this machine's pairing link. Show our usage instead.
[ $# -ge 1 ] || { usage; exit 1; }
if [ "$target" = local ] || { [ "$HAVE_PEERS" = 0 ] && [ "$target" = "$(self_machine name)" ]; }; then
info="$SELF_ID
"
elif [ "$HAVE_PEERS" = 0 ]; then
t "没有机器清单 ${PEERS},只能用 local(本机)。要跨机器,先运行 paseo-peer init 并 invite / join" \
"No machine list at $PEERS; only \"local\" works. For cross-machine, run paseo-peer init, then invite / join" >&2
echo >&2; exit 1
else
# Prints three lines: serverId, pairing link, daemon password (empty when none)
info="$(node -e '
const d = JSON.parse(require("fs").readFileSync(process.argv[1], "utf8"))
const m = d.machines.find((x) => x.name === process.argv[2] || x.serverId === process.argv[2])
if (!m) {
const names = d.machines.map((x) => x.name).join(", ")
console.error(process.argv[3] === "zh" ? `清单里没有「${process.argv[2]}」,可选:${names}` : `No machine "${process.argv[2]}" in peers.json; known: ${names}`)
process.exit(1)
}
console.log(m.serverId); console.log(m.pairing); console.log(m.password || "")
' "$PEERS" "$target" "$LANG_UI")"
fi
server_id="$(printf '%s\n' "$info" | sed -n 1p)"
pairing="$(printf '%s\n' "$info" | sed -n 2p)"
peer_password="$(printf '%s\n' "$info" | sed -n 3p)"
if [ "${1:-}" = mine ]; then
resolve_self_id
[ -n "${PASEO_AGENT_ID:-}" ] || { t "不是 Paseo 会话" "Not a Paseo session" >&2; echo >&2; exit 1; }
set -- ls -g -a --label "collab.by=$(self_machine name):${PASEO_AGENT_ID:0:7}"
fi
if [ "${1:-}" = who ]; then
project="${2:-$(basename "$PWD")}"
host=""
[ "$server_id" = "$SELF_ID" ] || host="$pairing"
PEER_HOST="$host" PEER_PASSWORD="${host:+$peer_password}" exec node -e '
const { execFileSync } = require("child_process")
const [paseo, project, lang] = process.argv.slice(1)
const zh = lang === "zh"
// The pairing link arrives via PEER_HOST and goes to paseo as PASEO_HOST — never in argv, where other users could see it
const env = { ...process.env }
if (env.PEER_HOST) { env.PASEO_HOST = env.PEER_HOST; delete env.PASEO_HOME }
if (env.PEER_PASSWORD) env.PASEO_PASSWORD = env.PEER_PASSWORD
delete env.PEER_HOST; delete env.PEER_PASSWORD
const run = (args) => execFileSync(paseo, args, { encoding: "utf8", maxBuffer: 64 << 20, env })
const agents = JSON.parse(run(["ls", "-g", "--json"])).filter((a) => a.cwd.split("/").pop() === project)
if (!agents.length) { console.log(zh ? `那台机器上没有在 ${project} 目录下的会话` : `No sessions in a "${project}" directory on that machine`); process.exit(0) }
const ago = (t) => {
const m = Math.round((Date.now() - Date.parse(t)) / 60000)
if (m < 60) return zh ? `${m} 分钟前` : `${m}m ago`
if (m < 1440) return zh ? `${Math.round(m / 60)} 小时前` : `${Math.round(m / 60)}h ago`
return zh ? `${Math.round(m / 1440)} 天前` : `${Math.round(m / 1440)}d ago`
}
const rows = agents.map((a) => {
let updated = a.created, last = ""
try { updated = JSON.parse(run(["inspect", a.id, "--json"])).UpdatedAt ?? updated } catch {}
// Latest few text entries minus internal reasoning ([Thought], may span lines until the next [Tag] entry):
// what the user last asked and what the session last answered
try {
let skip = false
last = run(["logs", a.id, "--tail", "6", "--filter", "text"]).split("\n").filter((l) => {
const tag = /^\[[A-Za-z][A-Za-z ]*\]/.exec(l)
if (tag) skip = tag[0] === "[Thought]"
return !skip
}).join(" ").replace(/\s+/g, " ").trim().slice(-300)
} catch {}
return { ...a, updated, last }
}).sort((x, y) => Date.parse(y.updated) - Date.parse(x.updated))
for (const r of rows) {
console.log(`${r.shortId} ${r.status.padEnd(8)} ${ago(r.updated)} ${r.name}`)
if (r.last) console.log(` ${zh ? "最近" : "latest"}: …${r.last}`)
}
' "$PASEO" "$project" "$LANG_UI"
fi
if [ "${1:-}" = find ]; then
shift
all=0; days=""; pattern=""
while [ $# -gt 0 ]; do
case "$1" in
-a|--all) all=1 ;;
--days) days="${2:-}"; shift ;;
*) pattern="${pattern:+$pattern|}$1" ;;
esac
shift
done
case "$days" in *[!0-9]*) pattern="" ;; esac
[ -n "$pattern" ] || { t '用法:paseo-peer <机器> find <关键词> [-a] [--days 天数] 多个关键词任一命中即可,支持正则' \
'Usage: paseo-peer <machine> find <pattern> [-a] [--days N] any of several patterns matches; regex allowed' >&2; echo >&2; exit 1; }
resolve_self_id
host=""
[ "$server_id" = "$SELF_ID" ] || host="$pairing"
PEER_HOST="$host" PEER_PASSWORD="${host:+$peer_password}" exec node -e '
const { execFile } = require("child_process")
const fs = require("fs"), os = require("os"), path = require("path")
const [paseo, pattern, all, self, lang, days] = process.argv.slice(1)
const zh = lang === "zh"
const remote = !!process.env.PEER_HOST
const env = { ...process.env }
if (env.PEER_HOST) { env.PASEO_HOST = env.PEER_HOST; delete env.PASEO_HOME }
if (env.PEER_PASSWORD) env.PASEO_PASSWORD = env.PEER_PASSWORD
delete env.PEER_HOST; delete env.PEER_PASSWORD
const run = (args) => new Promise((ok, fail) =>
execFile(paseo, args, { encoding: "utf8", maxBuffer: 64 << 20, env }, (e, out) => (e ? fail(e) : ok(out))))
let re
try { re = new RegExp(pattern, "i") } catch { re = new RegExp(pattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "i") }
const ago = (t) => {
const m = Math.round((Date.now() - Date.parse(t)) / 60000)
if (!(m >= 0)) return ""
if (m < 60) return zh ? `${m} 分钟前` : `${m}m ago`
if (m < 1440) return zh ? `${Math.round(m / 60)} 小时前` : `${Math.round(m / 60)}h ago`
return zh ? `${Math.round(m / 1440)} 天前` : `${Math.round(m / 1440)}d ago`
}
;(async () => {
// This machine: the daemon agent records give last activity and archive time for free, so sessions can be
// sorted and filtered by age without one inspect call each. Another machine: no such shortcut.
const rec = new Map()
if (!remote) {
const root = path.join(process.env.PASEO_HOME || path.join(os.homedir(), ".paseo"), "agents")
try {
for (const dir of fs.readdirSync(root, { withFileTypes: true })) {
if (!dir.isDirectory()) continue
for (const file of fs.readdirSync(path.join(root, dir.name))) {
if (!file.endsWith(".json")) continue
try {
const r = JSON.parse(fs.readFileSync(path.join(root, dir.name, file), "utf8"))
rec.set(r.id, { updated: r.lastActivityAt || r.updatedAt || "", archived: !!r.archivedAt })
} catch {}
}
}
} catch {}
} else if (days && all !== "1") {
console.error(zh ? "(跨机器时 --days 只配合 -a 筛已归档会话,活跃会话照常全搜)" : "(on another machine --days only narrows archived sessions with -a; live sessions are always searched)")
}
const cutoff = days && !remote ? Date.now() - Number(days) * 86400000 : 0
// -a only when asked: on another machine archived sessions come back as "idle" with no archive time, so
// without this every archived session would be scanned (hundreds of extra paseo logs calls over the relay)
let agents = JSON.parse(await run(["ls", "-g", ...(all === "1" ? ["-a"] : []), "--json"]))
.map((a) => ({ ...a, updated: rec.get(a.id)?.updated ?? "", status: rec.get(a.id)?.archived ? "archived" : a.status }))
.filter((a) => a.id !== self && (all === "1" || !["closed", "archived"].includes(a.status)))
.filter((a) => !cutoff || !a.updated || Date.parse(a.updated) >= cutoff)
.sort((x, y) => (Date.parse(y.updated) || 0) - (Date.parse(x.updated) || 0))
// Another machine with -a: archived sessions there come back as "idle" with no archive or activity time, and each
// one scanned is a separate paseo logs call over the relay (~0.6 MB). An unbounded -a once pulled 600+ archived
// sessions (~400 MB) through the relay in five minutes. So: tell archived ones apart by listing without -a too,
// keep every live session, and only take archived ones created in the last --days days (default 7), at most 50
if (remote && all === "1") {
const REMOTE_DAYS = 7, REMOTE_MAX = 50
const live = new Set(JSON.parse(await run(["ls", "-g", "--json"])).map((a) => a.id))
const unit = { second: 1e3, minute: 6e4, hour: 36e5, day: 864e5, week: 6048e5, month: 2592e6, year: 31536e6 }
const age = (c) => {
const s = String(c || "").trim().toLowerCase()
if (s === "just now") return 0
const m = /^(\d+|an?)\s+(second|minute|hour|day|week|month|year)s?\s+ago$/.exec(s)
return m ? (/^\d/.test(m[1]) ? Number(m[1]) : 1) * unit[m[2]] : Infinity // unknown format: treat as old
}
const span = Number(days) || REMOTE_DAYS
const archived = agents.filter((a) => !live.has(a.id)).map((a) => ({ ...a, status: "archived", age: age(a.created) }))
const recent = archived.filter((a) => a.age <= span * 864e5).sort((x, y) => x.age - y.age)
const kept = recent.slice(0, REMOTE_MAX)
agents = [...agents.filter((a) => live.has(a.id)), ...kept]
if (kept.length < archived.length)
console.error(zh
? `(跨机器 -a:那边共 ${archived.length} 个已归档会话,只搜了最近 ${span} 天内创建的 ${kept.length} 个${recent.length > REMOTE_MAX ? `(每次最多 ${REMOTE_MAX} 个)` : ""},避免经中继逐个拉取占满带宽;更早的用 --days 放宽,或先 ls -a -g 按标题/目录找到会话再 logs <id>)`
: `(on another machine with -a: of ${archived.length} archived sessions there, searched only the ${kept.length} created in the last ${span} days${recent.length > REMOTE_MAX ? ` (at most ${REMOTE_MAX} per run)` : ""}, so the relay is not flooded with one fetch each; widen with --days, or find the session with ls -a -g by title/dir and then logs <id>)`)
}
// Line by line over recent messages and tool calls (commands carry the real signal: deploy, migrate, push…).
// Skipped: internal reasoning ([Thought], may span lines until the next [Tag]) and whatever follows the first
// line of a [User] entry (hook / system context injected into the prompt, not what the user said)
const scan = async (a) => {
let out = ""
try { out = await run(["logs", a.id, "--tail", "200"]) } catch { return null }
const hits = []
let tag = ""
for (const l of out.split("\n")) {
const m = /^\[[A-Za-z][A-Za-z ]*\]/.exec(l)
if (m) tag = m[0]
else if (tag === "[User]") continue
if (tag !== "[Thought]" && re.test(l)) hits.push(l.trim())
}
if (!hits.length) return null
let updated = a.updated
if (!updated) try { updated = JSON.parse(await run(["inspect", a.id, "--json"])).UpdatedAt ?? "" } catch {}
return { ...a, updated, hits: hits.slice(-3) }
}
// Each scan spawns the paseo CLI, so its startup is the cost: keep one per core busy
const rows = []
let next = 0
const worker = async () => { while (next < agents.length) { const i = next++; rows[i] = await scan(agents[i]) } }
await Promise.all(Array.from({ length: Math.min(16, os.cpus().length || 4) }, worker))
const found = rows.filter(Boolean).sort((x, y) => (Date.parse(y.updated) || 0) - (Date.parse(x.updated) || 0))
if (!found.length) {
console.log(zh ? `${agents.length} 个会话最近的记录里都没有「${pattern}」${all === "1" ? "" : "(加 -a 连已关闭的一起搜)"}${cutoff ? `(只搜了最近 ${days} 天有活动的,去掉 --days 搜更早的)` : ""}`
: `No match for "${pattern}" in the recent activity of ${agents.length} sessions${all === "1" ? "" : " (add -a to include closed ones)"}${cutoff ? ` (only sessions active in the last ${days} days; drop --days to search older ones)` : ""}`)
return
}
for (const r of found) {
console.log(`${r.shortId} ${r.status.padEnd(8)} ${ago(r.updated)} ${r.cwd} ${r.name}`)
for (const h of r.hits) {
const i = Math.max(0, h.search(re) - 60)
console.log(` ${i ? "…" : ""}${h.slice(i, i + 200)}`)
}
}
})()
' "$PASEO" "$pattern" "$all" "${PASEO_AGENT_ID:-}" "$LANG_UI" "$days"
fi
if [ "${1:-}" = wait ]; then
shift
host=""
[ "$server_id" = "$SELF_ID" ] || host="$pairing"
PEER_HOST="$host" PEER_PASSWORD="${host:+$peer_password}" PASEO="$PASEO" LANG_UI="$LANG_UI" PEER_TARGET="$target" \
SELF_CMD="$SELF_CMD" exec node "$SCRIPT_DIR/paseo-peer-wait.mjs" "$@"
fi
if [ "${1:-}" = tell ]; then
if [ $# -eq 4 ] && [ "$3" = --file ]; then
[ -f "$4" ] || { t "找不到消息文件 $4" "Message file not found: $4" >&2; echo >&2; exit 1; }
to="$2"; msg="$(cat "$4")"
elif [ $# -eq 3 ]; then
to="$2"; msg="$3"
else
t '用法:paseo-peer <机器> tell <agentId> "消息" 或 paseo-peer <机器> tell <agentId> --file <路径>' \
'Usage: paseo-peer <machine> tell <agentId> "message" or paseo-peer <machine> tell <agentId> --file <path>' >&2
echo >&2; exit 1
fi
resolve_self_id
self_name="$(self_machine name)"; self_label="$(self_machine label)"
machine="${self_label:-${self_name:-$(t 未知机器 "unknown machine")}}"
me="${PASEO_AGENT_ID:-}"
if [ "$server_id" = "$SELF_ID" ]; then
header="$(t "【跨项目消息】来自$(self_desc)" "[Cross-project message] From $(self_desc)")"
else
header="$(t "【跨机器消息】来自 ${machine} 上$(self_desc)" "[Cross-machine message] From $(self_desc) on ${machine}")"
fi
if [ -n "$me" ] && [ -n "$self_name" ]; then
reply="$(t "(回复请运行:${SELF_CMD} ${self_name} tell ${me:0:7} \"回复内容\",长回复用 --file;用法见 skill ${SKILL_NAME})" \
"(To reply, run: ${SELF_CMD} ${self_name} tell ${me:0:7} \"your reply\" — use --file for long replies; see skill ${SKILL_NAME})")"
else
reply="$(t "(发送方不是 Paseo 会话,无法直接回复;结果写在你自己的会话里即可)" \
"(The sender is not a Paseo session and cannot receive replies; just write the result in your own session.)")"
fi
# Write the whole message to a temp file and send it with --prompt-file: no argv length or quoting issues
tmp="$(mktemp -t paseo-peer-tell.XXXXXX)"
trap 'rm -f "$tmp"' EXIT
printf '%s\n---\n%s\n---\n%s\n' "$header" "$msg" "$reply" > "$tmp"
set -- send --no-wait --behavior steer --prompt-file "$tmp" "$to"
told=1
fi
if [ "$server_id" = "$SELF_ID" ]; then
"$PASEO" "$@"
sent=$?
else
# Pass the pairing link and password through the environment, not argv (argv is visible to other users via ps).
# Shell assignments before exec, not env(1): `env VAR=value` would put the secrets in env's own argv.
# PASEO_HOME must be unset or the CLI refuses PASEO_HOST.
(
unset PASEO_HOME
if [ -n "$peer_password" ]; then
PASEO_HOST="$pairing" PASEO_PASSWORD="$peer_password" exec "$PASEO" "$@"
else
PASEO_HOST="$pairing" exec "$PASEO" "$@"
fi
)
sent=$?
fi
# After a successful tell, one line naming the target machine's serverId: Paseo clients show the message as a card
# and need the serverId to open the target session (machine names here need not match host names in the app).
if [ "${told:-0}" = 1 ] && [ "$sent" = 0 ] && [ -n "$server_id" ]; then
t "已发送:${target}(serverId ${server_id})" "Sent: ${target} (serverId ${server_id})"; echo
fi
exit "$sent"
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |