opencode-config/.opencode/tools/tunnel.ts
Sergey efc0827226
feat(tunnel): add cloudflare tunnel toggle tool (#34)
* feat(tunnel): add toggle tool and bash script

* feat(tunnel): add cloudflared to Dockerfile

* docs(tunnel): add ADR and handoff

* docs(handoff): set PR number

* docs: update project map + handoff + ADR

---------

Co-authored-by: opencode-agent <agent@slaid098.dev>
2026-07-24 02:11:29 +03:00

19 lines
597 B
TypeScript

import { spawnSync } from "child_process"
import path from "path"
import { tool } from "@opencode-ai/plugin"
export default tool({
description: "Toggle cloudflare tunnel. First call starts, second call stops. No arguments needed.",
args: {},
async execute(_args, context) {
const script = path.join(import.meta.dir, "..", "scripts", "tunnel.sh")
const r = spawnSync("bash", [script], {
encoding: "utf-8",
cwd: context.worktree,
})
if (r.status !== 0) {
return `⚠️ tunnel failed (exit ${r.status}): ${r.stderr}`
}
return r.stdout.trim()
},
})