Expose zot execution to child processes
- commit
- 1b0d3836c9a83260ff41a2426f0eca154c1cf268
- author
- Zeno Jiricek · · 2026-09-08 22:06 UTC
- committer
- Zeno Jiricek · · 2026-09-08 23:29 UTC
- parent
- 6abb410
- signature
- unsigned
3 files · +17 -0
M README.md +2 -0
| @@ -816,6 +816,8 @@ A model installed through Ollama is kept in Ollama's internal storage and is not | |||
| 816 | 816 | ||
| 817 | 817 | ## Inline images | |
| 818 | 818 | ||
| 819 | + | Scripts and shell commands launched by zot inherit `ZOT_AGENT=1`. Use this signal when a script needs to distinguish execution inside zot from a standalone invocation. | |
| 820 | + | ||
| 819 | 821 | When a tool returns an image (for example `read` on a PNG), zot renders it inline on terminals that support it: **Ghostty**, **Kitty**, **iTerm2**, **WezTerm**. On other terminals you see a text placeholder with MIME type, pixel dimensions, and byte size. Control with the `ZOT_INLINE_IMAGES` env var: | |
| 820 | 822 | ||
| 821 | 823 | | Value | Effect | | |
| @@ -816,6 +816,8 @@ A model installed through Ollama is kept in Ollama's internal storage and is not | |||||
| 816 | 816 | ||||
| 817 | ## Inline images | 817 | ## Inline images | ||
| 818 | 818 | ||||
| 819 | + | Scripts and shell commands launched by zot inherit `ZOT_AGENT=1`. Use this signal when a script needs to distinguish execution inside zot from a standalone invocation. | |||
| 820 | + | ||||
| 819 | When a tool returns an image (for example `read` on a PNG), zot renders it inline on terminals that support it: **Ghostty**, **Kitty**, **iTerm2**, **WezTerm**. On other terminals you see a text placeholder with MIME type, pixel dimensions, and byte size. Control with the `ZOT_INLINE_IMAGES` env var: | 821 | When a tool returns an image (for example `read` on a PNG), zot renders it inline on terminals that support it: **Ghostty**, **Kitty**, **iTerm2**, **WezTerm**. On other terminals you see a text placeholder with MIME type, pixel dimensions, and byte size. Control with the `ZOT_INLINE_IMAGES` env var: | ||
| 820 | 822 | ||||
| 821 | | Value | Effect | | 823 | | Value | Effect | | ||
M packages/agent/args_test.go +10 -0
| @@ -98,6 +98,16 @@ func TestRunHelpHelperProcess(t *testing.T) { | |||
| 98 | 98 | os.Exit(0) | |
| 99 | 99 | } | |
| 100 | 100 | ||
| 101 | + | func TestRunSetsAgentEnvironment(t *testing.T) { | |
| 102 | + | t.Setenv("ZOT_AGENT", "") | |
| 103 | + | if err := Run([]string{"--help"}, "test"); err != nil { | |
| 104 | + | t.Fatalf("Run returned %v", err) | |
| 105 | + | } | |
| 106 | + | if got := os.Getenv("ZOT_AGENT"); got != "1" { | |
| 107 | + | t.Fatalf("ZOT_AGENT = %q, want %q", got, "1") | |
| 108 | + | } | |
| 109 | + | } | |
| 110 | + | ||
| 101 | 111 | func TestHelpOutputStreams(t *testing.T) { | |
| 102 | 112 | run := func(args string) (stdout, stderr string, err error) { | |
| 103 | 113 | t.Helper() | |
| @@ -98,6 +98,16 @@ func TestRunHelpHelperProcess(t *testing.T) { | |||||
| 98 | os.Exit(0) | 98 | os.Exit(0) | ||
| 99 | } | 99 | } | ||
| 100 | 100 | ||||
| 101 | + | func TestRunSetsAgentEnvironment(t *testing.T) { | |||
| 102 | + | t.Setenv("ZOT_AGENT", "") | |||
| 103 | + | if err := Run([]string{"--help"}, "test"); err != nil { | |||
| 104 | + | t.Fatalf("Run returned %v", err) | |||
| 105 | + | } | |||
| 106 | + | if got := os.Getenv("ZOT_AGENT"); got != "1" { | |||
| 107 | + | t.Fatalf("ZOT_AGENT = %q, want %q", got, "1") | |||
| 108 | + | } | |||
| 109 | + | } | |||
| 110 | + | ||||
| 101 | func TestHelpOutputStreams(t *testing.T) { | 111 | func TestHelpOutputStreams(t *testing.T) { | ||
| 102 | run := func(args string) (stdout, stderr string, err error) { | 112 | run := func(args string) (stdout, stderr string, err error) { | ||
| 103 | t.Helper() | 113 | t.Helper() | ||
M packages/agent/cli.go +5 -0
| @@ -206,6 +206,11 @@ func fanoutAgentEvent(mgr *extensions.Manager, ev core.AgentEvent) { | |||
| 206 | 206 | ||
| 207 | 207 | // Run is the top-level entrypoint for the zot binary. | |
| 208 | 208 | func Run(rawArgs []string, version string) error { | |
| 209 | + | // Mark the process and all child processes as running under zot. This | |
| 210 | + | // lets shell tools, extensions, and scripts distinguish zot execution | |
| 211 | + | // from an ordinary invocation. | |
| 212 | + | _ = os.Setenv("ZOT_AGENT", "1") | |
| 213 | + | ||
| 209 | 214 | // Apply network configuration before any subcommand can make an HTTP | |
| 210 | 215 | // request. Standard proxy environment variables retain precedence. | |
| 211 | 216 | applyConfiguredHTTPProxy() | |
| @@ -206,6 +206,11 @@ func fanoutAgentEvent(mgr *extensions.Manager, ev core.AgentEvent) { | |||||
| 206 | 206 | ||||
| 207 | // Run is the top-level entrypoint for the zot binary. | 207 | // Run is the top-level entrypoint for the zot binary. | ||
| 208 | func Run(rawArgs []string, version string) error { | 208 | func Run(rawArgs []string, version string) error { | ||
| 209 | + | // Mark the process and all child processes as running under zot. This | |||
| 210 | + | // lets shell tools, extensions, and scripts distinguish zot execution | |||
| 211 | + | // from an ordinary invocation. | |||
| 212 | + | _ = os.Setenv("ZOT_AGENT", "1") | |||
| 213 | + | ||||
| 209 | // Apply network configuration before any subcommand can make an HTTP | 214 | // Apply network configuration before any subcommand can make an HTTP | ||
| 210 | // request. Standard proxy environment variables retain precedence. | 215 | // request. Standard proxy environment variables retain precedence. | ||
| 211 | applyConfiguredHTTPProxy() | 216 | applyConfiguredHTTPProxy() | ||