v0.3.93 0192a2e

openrouter_server.go RawHistoryFolder

1package tools
2
3import (
4	"context"
5	"encoding/json"
6	"fmt"
7
8	"github.com/patriceckhart/zot/packages/core"
9	"github.com/patriceckhart/zot/packages/provider"
10)
11
12// OpenRouterServerToolCallLimit bounds the remote agent loop when zot
13// advertises OpenRouter server tools.
14const OpenRouterServerToolCallLimit = 4
15
16// ResolveToolCallLimit returns n when it is a positive int, otherwise the
17// built-in default. This lets callers resolve a config.json *int without
18// importing the agent config package.
19func ResolveToolCallLimit(n *int) int {
20	if n != nil && *n > 0 {
21		return *n
22	}
23	return OpenRouterServerToolCallLimit
24}
25
26// OpenRouterServerToolNames lists every OpenRouter server tool that zot
27// can advertise on Chat Completions. Shell, bash, apply_patch, and
28// tool_search require Responses/Messages and are omitted here.
29func OpenRouterServerToolNames() []string {
30	return []string{
31		"openrouter:web_search",
32		"openrouter:web_fetch",
33		"openrouter:advisor",
34		"openrouter:subagent",
35		"openrouter:fusion",
36		"openrouter:image_generation",
37		"openrouter:datetime",
38		"openrouter:experimental__search_models",
39	}
40}
41
42// IsOpenRouterServerTool reports whether name is an OpenRouter server tool
43// that zot may inject into the live registry.
44func IsOpenRouterServerTool(name string) bool {
45	for _, n := range OpenRouterServerToolNames() {
46		if n == name {
47			return true
48		}
49	}
50	return false
51}
52
53// OpenRouterServerTool is a stub advertised to the model so OpenRouter
54// can execute the matching server tool. The agent never runs it locally.
55type OpenRouterServerTool struct {
56	name        string
57	description string
58	schema      json.RawMessage
59}
60
61func (t *OpenRouterServerTool) Name() string            { return t.name }
62func (t *OpenRouterServerTool) Description() string     { return t.description }
63func (t *OpenRouterServerTool) Schema() json.RawMessage { return t.schema }
64
65func (t *OpenRouterServerTool) Execute(context.Context, json.RawMessage, func(string)) (core.ToolResult, error) {
66	return core.ToolResult{
67		Content: []provider.Content{provider.TextBlock{Text: fmt.Sprintf("%s is executed by OpenRouter, not locally", t.name)}},
68		IsError: true,
69	}, nil
70}
71
72// OpenRouterServerTools returns stubs for every Chat Completions-capable
73// OpenRouter server tool.
74func OpenRouterServerTools() []core.Tool {
75	return []core.Tool{
76		&OpenRouterServerTool{
77			name:        "openrouter:web_search",
78			description: "Search the web for current information. Executed by OpenRouter.",
79		},
80		&OpenRouterServerTool{
81			name:        "openrouter:web_fetch",
82			description: "Fetch and extract content from a URL. Executed by OpenRouter.",
83		},
84		&OpenRouterServerTool{
85			name:        "openrouter:advisor",
86			description: "Consult a stronger model for guidance mid-generation. Executed by OpenRouter.",
87			schema:      json.RawMessage(`{"model":"openai/gpt-4.1-mini"}`),
88		},
89		&OpenRouterServerTool{
90			name:        "openrouter:subagent",
91			description: "Delegate a self-contained task to a smaller worker model. Executed by OpenRouter.",
92			schema:      json.RawMessage(`{"model":"openai/gpt-4.1-mini"}`),
93		},
94		&OpenRouterServerTool{
95			name:        "openrouter:fusion",
96			description: "Run a panel of models and an analyst for multi-model analysis. Executed by OpenRouter.",
97		},
98		&OpenRouterServerTool{
99			name:        "openrouter:image_generation",
100			description: "Generate an image from a text prompt. Executed by OpenRouter.",
101		},
102		&OpenRouterServerTool{
103			name:        "openrouter:datetime",
104			description: "Get the current date and time. Executed by OpenRouter.",
105		},
106		&OpenRouterServerTool{
107			name:        "openrouter:experimental__search_models",
108			description: "Search and filter the OpenRouter model catalog. Executed by OpenRouter.",
109			schema:      json.RawMessage(`{"max_results":5}`),
110		},
111	}
112}

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 477

↑↓ moveenter openesc close