跳转到内容

SSH Tunnel 示例包

本示例面向想看完整扩展包结构的开发者。读完后,你会知道 examples/extensions/ssh-tunnel-pack 每个文件的作用,以及 /ssh-tunnel 如何启动工作流。

examples/extensions/ssh-tunnel-pack/
jarvis-pack.yaml
README.md
LICENSE
CHANGELOG.md
profiles/
tunnel-operator.yaml
workflows/
open-tunnel.yaml
examples/
basic.md

jarvis-pack.yaml 定义 pack 身份、权限和贡献点:

schemaVersion: 1
id: example.ssh-tunnel
publisher: example
name: ssh-tunnel
displayName: SSH Tunnel Workflow Pack
version: 0.1.0
engines:
jarvis: ">=0.0.1"
permissions:
sessions:
launch: true
terminal:
requested: true
contributes:
profiles:
- id: tunnel-operator
path: profiles/tunnel-operator.yaml
workflows:
- id: open-tunnel
path: workflows/open-tunnel.yaml
title: Open reviewed SSH tunnel
commands:
- command: "/ssh-tunnel"
title: Open SSH tunnel
action:
type: startWorkflow
workflow: open-tunnel
taskTemplate: "Tunnel request: {{args}}"

terminal.requested 会在验证报告里显示为 high risk。它不是直接授权;worker 仍然走 Jarvis 的权限模型。

profiles/tunnel-operator.yaml 给 worker 一组专门指令:

version: 2
name: Tunnel Operator
runtime: claude-code
tools:
builtin:
- Read
- Bash
permissions:
mode: acceptEdits
ask:
- "Bash(ssh:*)"

这个 profile 是 pack-owned。安装后,它在 Agent Profiles 中显示为扩展提供,不能原地编辑。需要改动时,复制后编辑。

workflows/open-tunnel.yaml 有两个节点:

  • plan:检查输入并生成命令,不执行。
  • open:等待显式放行后再执行。

第二个节点设置 requires_approval: true,适合终端或外部副作用动作。

/ssh-tunnel 的 action 是 startWorkflow。执行流程是:

  1. 前端 slash menu 从 GET /api/v1/commands 读取命令。
  2. 用户提交 /ssh-tunnel ...
  3. Jarvis Core 找到 example.ssh-tunnel 的 enabled command contribution。
  4. Core 解析 taskTemplate,把参数传入 materialized workflow。
  5. Pipeline engine 启动 workflow run。

扩展包没有可执行入口,也不会接收命令回调。

终端窗口
.venv/bin/jarvis extensions validate examples/extensions/ssh-tunnel-pack
.venv/bin/jarvis extensions install examples/extensions/ssh-tunnel-pack --enable

在 Jarvis chat 输入:

/ssh-tunnel 15432:database.internal:5432 bastion