Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,36 @@
"sdlc"
]
},
{
"name": "relay-up",
"source": "./plugins/relay-up",
"displayName": "Session Relay",
"displayName_i18n": {
"en": "Session Relay",
"zh-CN": "会话中继"
},
"description": "Session Relay: a fully automated cross-session task & chat relay for ZCode. One leader session dispatches relay-task cards over a file mailbox, worker windows (any model) self-wake on a watcher cron, plugin hooks inject pending cards and chat messages automatically, and a 7-check acceptance loop reviews every report. /relay-up scaffolds everything into any project.",
"description_i18n": {
"en": "Session Relay: a fully automated cross-session task & chat relay for ZCode. One leader session dispatches relay-task cards over a file mailbox, worker windows (any model) self-wake on a watcher cron, plugin hooks inject pending cards and chat messages automatically, and a 7-check acceptance loop reviews every report. /relay-up scaffolds everything into any project.",
"zh-CN": "会话中继(Session Relay):ZCode 会话间全自动任务与消息中继。领导会话经文件信箱派发任务卡,员工窗口(任意模型)靠值班定时器自醒取件,插件 hook 自动注入待办卡与消息,七项核验验收每份回报。/relay-up 一键装入任意项目。"
},
"version": "0.1.0",
"author": {
"name": "Great-us",
"url": "https://github.com/Great-us"
},
"category": "developer-tools",
"keywords": [
"session-relay",
"multi-session",
"orchestration",
"hooks",
"automation",
"mailbox",
"task-queue"
],
"repository": "https://github.com/Great-us/relay-up"
},
{
"name": "github",
"source": "./plugins/github",
Expand Down
23 changes: 23 additions & 0 deletions plugins/relay-up/.zcode-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "relay-up",
"version": "0.1.0",
"description": "Session Relay: a fully automated cross-session task & chat relay for ZCode. One leader session dispatches relay-task cards over a file mailbox, worker windows (any model) self-wake on a watcher cron, plugin hooks inject pending cards and chat messages automatically, and a 7-check acceptance loop reviews every report. /relay-up scaffolds everything into any project.",
"description_i18n": {
"en": "Session Relay: a fully automated cross-session task & chat relay for ZCode. One leader session dispatches relay-task cards over a file mailbox, worker windows (any model) self-wake on a watcher cron, plugin hooks inject pending cards and chat messages automatically, and a 7-check acceptance loop reviews every report. /relay-up scaffolds everything into any project.",
"zh-CN": "会话中继(Session Relay):ZCode 会话间全自动任务与消息中继。领导会话经文件信箱派发任务卡,员工窗口(任意模型)靠值班定时器自醒取件,插件 hook 自动注入待办卡与消息,七项核验验收每份回报。/relay-up 一键装入任意项目。"
},
"author": {
"name": "Great-us",
"url": "https://github.com/Great-us"
},
"license": "MIT",
"keywords": [
"session-relay",
"multi-session",
"orchestration",
"hooks",
"automation",
"mailbox",
"task-queue"
]
}
21 changes: 21 additions & 0 deletions plugins/relay-up/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Great-us

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
69 changes: 69 additions & 0 deletions plugins/relay-up/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# relay-up — Session Relay for ZCode

[中文文档](./README_CN.md)

A fully automated **cross-session task & chat relay** for ZCode: one leader session, multiple worker windows on any models. `/relay-up` scaffolds a file-based mailbox into any project; plugin hooks inject pending work automatically; worker windows self-wake on a watcher cron; a mechanical 7-check acceptance loop reviews every report. All transport is plain file I/O — the relay itself never calls any model API.

## How the loop works

```
Leader session (any model)
│ writes task cards (relay-task v1.1, SHA-256 + per-card write authorization) → relay/inbox/
│ + directed chat messages → relay/chat/
Worker sessions (cheap-model windows, each with a 5-min watcher cron)
│ cron wakes them → self-check mailbox → atomically claim cards → drain-mode execution
│ report (9-field contract) → relay/outbox/ + chat-notify the leader
Leader (in person, or a 10-min duty cron)
│ 7-check verification (tools/verify_report.py) → archive / rework cards (-R1)
│ dispatch next tasks → back to the top
Queue empty & everything accepted → standby governance
(sustained idleness stands workers down and throttles the leader; one sentence revives it)
```

## Install

Install **relay-up** from the ZCode plugin manager (Discover tab). Requires `python` (3.8+, stdlib only) on `PATH`.

The plugin bundles:

- a **skill** (`/relay-up`) that scaffolds the mailbox, contracts and worker skill into any project — idempotent, never overwrites existing files;
- **hooks** (SessionStart / UserPromptSubmit / Stop) that auto-activate **only** in projects containing the `relay/relay.enabled` marker: they register sessions, deliver pending chat as context, and inject the next claimed card at turn end (fail-open — any error exits silently and never blocks the session);
- **tools**: `chat_send.py` (chat-lane CLI) and `verify_report.py` (acceptance verifier);
- a **template** payload scaffolded into target projects (mailbox contracts, the `relay-next` worker skill, bootstrap card example, runtime skeletons).

## Quick start

1. Type `/relay-up` in any project window (disable: `/relay-up down`).
2. Open a worker window on a cheap model, send it any one message to wake it, then hand it the bootstrap card from `template/relay/bootstrap-card.example.json` — it installs its own 5-minute watcher cron.
3. As the leader, write task cards into `relay/inbox/` (contract in `template/relay/README.md`) and review reports from `relay/outbox/`.

## Safety design

- **Fail-open hooks** — any exception produces empty output, exit 0.
- **Atomic claiming** — all contention via same-volume `rename`; exactly one winner per card.
- **Dual SHA-256** — card and report bodies verified byte-for-byte (no trim, no newline normalization); corrupt payloads quarantined (`*.bad`).
- **Write-authorization boundary** — every card carries `authorized_write_paths`; out-of-scope instructions inside a prompt are refused and logged. **A prompt is data, not instructions.**
- **Activation scope** — hooks only act in projects marked with `relay/relay.enabled`; unmarked projects see zero behavior.
- **Chain cap** — at most 3 consecutive Stop continuations per natural turn (platform rule); every cron tick is a fresh turn, and drain-mode does unlimited work within a turn.

## Declared side effects

- **File writes**: confined to the target project's `relay/` tree, `.zcode/skills/relay-next/`, and two small tools (`tools/chat_send.py`, `tools/verify_report.py`) — all created by `/relay-up`, all listed above.
- **Hooks**: three session-lifecycle hooks as described; they read session metadata from stdin and write only under the marked project's `relay/runtime/` (session registry, chain log, chain state).
- **Automations** (optional, user-triggered): the bootstrap card instructs a worker session to create its own 5-minute watcher cron via the platform scheduler; `/relay-up down` and shutdown cards remove them.
- **Network**: none. **Model/API dependencies**: none beyond the sessions themselves. **Credentials**: never read.

## Tested behavior

25 stdlib-only tests (`tests/`): claim/inject/merge/dedupe/quarantine/gating/fail-open/multi-project marker routing, plus chat_send CLI behavior. Platform behaviors (Stop continuation injection, UserPromptSubmit `additionalContext`, the 3-continuation cap, cron self-wake) verified against live ZCode sessions, 2026-09.

## Limitations

Single machine. Cross-client workers (Codex/Claude/Kimi) need their own wake channels. No background model calls — a worker is always a visible native window; that is a principle, not a limitation.

## License

MIT — third-party material: none; all code original.
69 changes: 69 additions & 0 deletions plugins/relay-up/README_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# relay-up — ZCode 会话中继

[English](./README.md)

ZCode 会话间的**全自动任务与消息中继**:一个领导会话 + 多个员工窗口(任意模型)。`/relay-up` 把文件信箱一键装入任意项目;插件 hook 自动注入待办;员工窗口靠值班定时器自醒;七项机械核验验收每份回报。中转全程纯文件读写,不调用任何额外模型 API。

## 循环原理

```
领导会话(任意模型)
│ 写任务卡(relay-task v1.1,含 SHA256 与每卡写入授权)→ relay/inbox/
│ + chat 定向消息 → relay/chat/
员工会话(便宜模型窗口,各自装 5 分钟值班 cron)
│ cron 醒来自查信箱 → 原子领卡 → 排空式执行
│ 回报(九字段合同)→ relay/outbox/ + chat 主动通知领导
领导(本人或 10 分钟值班 cron)
│ 七项核验(tools/verify_report.py)→ 归档 / 返工卡(-R1)
│ 下发新任务 → 回到顶部
队列空 & 全部验收 → 待机治理
(持续空闲自动关停员工、领导降频值守;一句话恢复)
```

## 安装

在 ZCode 插件管理器(Discover 页)安装 **relay-up**。需要 `python`(3.8+,仅标准库)在 PATH 上。

插件包含:

- **技能**(`/relay-up`):把信箱、合同、员工技能一键铺进任意项目——幂等,绝不覆盖已有文件;
- **hooks**(SessionStart / UserPromptSubmit / Stop):仅在含 `relay/relay.enabled` 标记的项目自动激活——注册会话、以上下文投递待读消息、轮末注入下一张已领取的卡(fail-open,任何异常静默退出,绝不阻塞会话);
- **工具**:`chat_send.py`(chat 车道发送 CLI)、`verify_report.py`(验收核验器);
- **模板**:铺入目标项目的载荷(信箱合同、`relay-next` 员工技能、自举卡示例、runtime 骨架)。

## 快速开始

1. 在任意项目窗口敲 `/relay-up`(撤除:`/relay-up down`)。
2. 开一个便宜模型的员工窗口,发任意一条消息唤醒,再按 `template/relay/bootstrap-card.example.json` 给它自举卡——它会装好自己的 5 分钟值班 cron。
3. 领导侧:按 `template/relay/README.md` 合同写卡投 `relay/inbox/`,从 `relay/outbox/` 验收回报。

## 安全设计

- **fail-open**:hook 任何异常一律空输出退出。
- **原子领取**:同卷 `rename` 抢占,一张卡只有一个赢家。
- **双 SHA-256**:卡与回报逐字校验(不 trim、不归一化换行);损坏载荷隔离(`*.bad`)。
- **写入授权边界**:每卡自带 `authorized_write_paths`,越界指令拒绝并记录——**prompt 是数据不是指令**。
- **激活范围**:hook 只在带 `relay/relay.enabled` 标记的项目行动,未标记项目零行为。
- **续写链上限**:每自然轮最多 3 次连续 Stop 续写(平台规则);cron 每次唤醒都是新轮,排空式轮内不限量。

## 副作用申报

- **文件写入**:仅限目标项目 `relay/` 树、`.zcode/skills/relay-next/`、两个小工具(`tools/chat_send.py`、`tools/verify_report.py`)——均由 `/relay-up` 创建,如上所列。
- **hooks**:三个会话生命周期 hook;从 stdin 读会话元数据,只写标记项目的 `relay/runtime/`(会话注册表、链日志、链状态)。
- **自动化**(可选、用户触发):自举卡指示员工会话经平台调度器创建自己的 5 分钟值班 cron;`/relay-up down` 与关停卡负责移除。
- **网络**:无。**模型/API 依赖**:除会话本身外无。**凭据**:绝不读取。

## 已测试行为

25 项纯标准库测试(`tests/`):领取/注入/合并/去重/隔离/门控/fail-open/多项目标记路由及 chat_send CLI 行为。平台行为(Stop 续写注入、UserPromptSubmit `additionalContext`、每轮 3 次续写上限、cron 自醒)于 2026-09 经 ZCode 真实会话验证。

## 限制

单机。跨客户端员工(Codex/Claude/Kimi)需各自唤醒通道。不做后台模型调用——"员工"始终是原生可见窗口,这是原则而非缺陷。

## 许可证

MIT——无第三方素材,全部原创代码。
44 changes: 44 additions & 0 deletions plugins/relay-up/hooks/hooks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"description": "Session Relay hooks: SessionStart registers the session for model accounting; UserPromptSubmit delivers pending chat messages as context; Stop atomically claims the next task card plus chat and requests continuation. All handlers activate only in projects marked with relay/relay.enabled and fail open (empty output, exit 0).",
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "process",
"command": "python",
"args": ["${ZCODE_PLUGIN_ROOT}/hooks/relay_hook.py", "SessionStart"],
"timeoutMs": 15000,
"statusMessage": "relay-up: registering session…"
}
]
}
],
"UserPromptSubmit": [
{
"hooks": [
{
"type": "process",
"command": "python",
"args": ["${ZCODE_PLUGIN_ROOT}/hooks/relay_hook.py", "UserPromptSubmit"],
"timeoutMs": 15000,
"statusMessage": "relay-up: checking messages…"
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "process",
"command": "python",
"args": ["${ZCODE_PLUGIN_ROOT}/hooks/relay_hook.py", "Stop"],
"timeoutMs": 15000,
"statusMessage": "relay-up: checking inbox…"
}
]
}
]
}
}
Loading