v0.2.8 ec5eb20

README.md RawHistoryFolder

guard — example zot extension (Go, phase 3)

Demonstrates the event subscription and tool-call interception half of the extension protocol (phase 3).

What it does:

  • Subscribes to session_start, turn_start, tool_call, turn_end and appends a line to /tmp/zot-guard-audit.log for each.
  • Intercepts every bash tool call. If the command matches a danger regex (rm -rf, sudo, dd of=/, mkfs, the fork bomb, chmod -R 777), the call is refused. The model sees the refusal as the tool error and (typically) proposes something safer or asks for confirmation.

Build

cd examples/extensions/guard
go build -o guard .

Install

zot ext install .

Try it

In zot, ask:

Run rm -rf /tmp/foo

The model's bash call is intercepted and refused; the model explains the refusal in its reply. No file is touched.

Run ls /tmp

Allowed; the audit log records the call.

Tail the audit log:

tail -f /tmp/zot-guard-audit.log

Extending the danger list

Edit dangerPatterns in main.go. Each entry is a Go regexp; the match is case-insensitive. Rebuild and reinstall.

See also

  • examples/extensions/hello — slash command (phase 1)
  • examples/extensions/clock — slash command in plain Node (phase 1)
  • examples/extensions/weather — LLM-callable tool (phase 2)
  • docs/extensions.md — full protocol reference
source
1# guard — example zot extension (Go, phase 3)
2
3Demonstrates the **event subscription** and **tool-call interception**
4half of the extension protocol (phase 3).
5
6What it does:
7
8- Subscribes to `session_start`, `turn_start`, `tool_call`, `turn_end`
9  and appends a line to `/tmp/zot-guard-audit.log` for each.
10- Intercepts every `bash` tool call. If the command matches a danger
11  regex (`rm -rf`, `sudo`, `dd of=/`, `mkfs`, the fork bomb, `chmod -R
12  777`), the call is **refused**. The model sees the refusal as the
13  tool error and (typically) proposes something safer or asks for
14  confirmation.
15
16## Build
17
18```bash
19cd examples/extensions/guard
20go build -o guard .
21```
22
23## Install
24
25```bash
26zot ext install .
27```
28
29## Try it
30
31In zot, ask:
32
33> Run `rm -rf /tmp/foo`
34
35The model's `bash` call is intercepted and refused; the model
36explains the refusal in its reply. No file is touched.
37
38> Run `ls /tmp`
39
40Allowed; the audit log records the call.
41
42Tail the audit log:
43
44```bash
45tail -f /tmp/zot-guard-audit.log
46```
47
48## Extending the danger list
49
50Edit `dangerPatterns` in `main.go`. Each entry is a Go regexp; the
51match is case-insensitive. Rebuild and reinstall.
52
53## See also
54
55- `examples/extensions/hello` — slash command (phase 1)
56- `examples/extensions/clock` — slash command in plain Node (phase 1)
57- `examples/extensions/weather` — LLM-callable tool (phase 2)
58- `docs/extensions.md` — full protocol reference

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 476

↑↓ moveenter openesc close