You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Agents.md
+56Lines changed: 56 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -107,6 +107,28 @@ aiagent:
107
107
108
108
This agent restricts tools to only the built-in read-only tools, preventing any page modifications.
109
109
110
+
### Sandboxed Agent with Path Restrictions
111
+
112
+
An agent that can only operate on pages within a specific folder:
113
+
114
+
```yaml
115
+
---
116
+
tags: meta/template/aiAgent
117
+
aiagent:
118
+
name: "Sandbox Agent"
119
+
description: "Can only access pages under Sandbox/"
120
+
systemPrompt: |
121
+
You help the user with notes in the Sandbox folder.
122
+
You cannot access or modify pages outside this area.
123
+
allowedReadPaths: ["Sandbox/"]
124
+
allowedWritePaths: ["Sandbox/"]
125
+
---
126
+
```
127
+
128
+
This agent can read and write pages under `Sandbox/` but will get an error if it tries to access other pages via tools that support path permissions.
129
+
130
+
> **Note:** Path permissions only apply to tools that declare `readPathParam` or `writePathParam`. Tools like `eval_lua` can bypass these restrictions. For a true sandbox, combine path permissions with a tool whitelist.
131
+
110
132
### Writing Assistant with Context
111
133
112
134
An agent with additional context embedded from wiki-links:
@@ -186,6 +208,8 @@ aiagent:
186
208
|`tools`| string[]| Whitelist - only these tools are available |
187
209
|`toolsExclude`| string[]| Blacklist - these tools are removed |
188
210
|`inheritBasePrompt`| boolean | Prepend base system prompt (default: true) |
211
+
|`allowedReadPaths`| string[]| Path prefixes tools can read from (e.g., `["Journal/", "Notes/"]`) |
212
+
|`allowedWritePaths`| string[]| Path prefixes tools can write to (e.g., `["Journal/"]`) |
189
213
190
214
### Base Prompt Inheritance
191
215
@@ -199,6 +223,38 @@ By default, agents inherit the base system prompt which includes SilverBullet ma
199
223
200
224
**Tip:** Use `tools` (whitelist) for restrictive agents that should only have specific capabilities. Use `toolsExclude` (blacklist) when you want most tools but need to block a few dangerous ones like `eval_lua`.
201
225
226
+
### Path Permissions
227
+
228
+
Restrict which pages an agent can read from or write to using path prefixes:
229
+
230
+
```yaml
231
+
---
232
+
tags: meta/template/aiAgent
233
+
aiagent:
234
+
name: "Journal Assistant"
235
+
description: "Helps with journal entries only"
236
+
allowedReadPaths: ["Journal/", "Daily/"]
237
+
allowedWritePaths: ["Journal/"]
238
+
---
239
+
```
240
+
241
+
Or in Lua:
242
+
243
+
```lua
244
+
ai.agents.journal= {
245
+
name="Journal Assistant",
246
+
allowedReadPaths= {"Journal/", "Daily/"},
247
+
allowedWritePaths= {"Journal/"}
248
+
}
249
+
```
250
+
251
+
**How it works:**
252
+
- If `allowedReadPaths` is set, tools with `readPathParam` can only read pages starting with those prefixes
253
+
- If `allowedWritePaths` is set, tools with `writePathParam` can only write to pages starting with those prefixes
254
+
- If not set, no path restrictions apply
255
+
256
+
This is useful for creating restricted agents that can only operate on specific areas of your space.
257
+
202
258
## Usage
203
259
204
260
1.**Select Agent**: Run `AI: Select Agent` command
-`handler` - Function that receives `args` and returns a string result
87
87
-`requiresApproval` - (optional) If `true`, user must confirm before the tool executes
88
+
-`readPathParam` - (optional) Parameter name(s) containing page paths for read operations. Can be a string or array of strings. (used with agent path permissions)
89
+
-`writePathParam` - (optional) Parameter name(s) containing page paths for write operations. Can be a string or array of strings. (used with agent path permissions)
88
90
89
91
## Requiring Approval
90
92
@@ -137,4 +139,53 @@ The `ai.writePage` function:
137
139
138
140
All built-in editing tools (`update_note`, `update_frontmatter`, `create_note`, etc.) use `ai.writePage` internally to provide diff previews.
139
141
140
-
There's nothing stopping you from bypassing this, so please be careful when making custom tools.
142
+
There's nothing stopping you from bypassing this, so please be careful when making custom tools.
143
+
144
+
## Path Permissions
145
+
146
+
Tools can declare which parameter contains a page path for permission validation. When an agent has `allowedReadPaths` or `allowedWritePaths` configured, tools will be blocked from accessing pages outside those paths.
147
+
148
+
### Declaring Path Parameters
149
+
150
+
```lua
151
+
ai.tools.my_reader= {
152
+
description="Read data from a page",
153
+
readPathParam="page", -- This param will be validated against allowedReadPaths
154
+
parameters= {
155
+
type="object",
156
+
properties= {
157
+
page= {type="string", description="The page to read"}
158
+
},
159
+
required= {"page"}
160
+
},
161
+
handler=function(args)
162
+
returnspace.readPage(args.page)
163
+
end
164
+
}
165
+
166
+
ai.tools.my_writer= {
167
+
description="Write data to a page",
168
+
writePathParam="page", -- This param will be validated against allowedWritePaths
169
+
requiresApproval=true,
170
+
parameters= {
171
+
type="object",
172
+
properties= {
173
+
page= {type="string", description="The page to write"}
174
+
},
175
+
required= {"page"}
176
+
},
177
+
handler=function(args)
178
+
ai.writePage(args.page, "content")
179
+
return"Written"
180
+
end
181
+
}
182
+
```
183
+
184
+
### How It Works
185
+
186
+
1. Agent defines `allowedReadPaths` and/or `allowedWritePaths` (see [[Agents]])
187
+
2. When a tool is called, the validation checks if the path parameter starts with any allowed prefix
188
+
3. If the path is not allowed, the tool returns an error instead of executing
189
+
4. Write operations require **both** read and write access (since tools typically read content before modifying it)
190
+
191
+
All built-in tools declare their path parameters, so they work with agent path permissions automatically.
0 commit comments