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
{{ message }}
Repository navigation
Commit 0a5736f
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/coder-agents/architecture.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,7 @@ When the agent executes a tool call (reading a file, running a command, writing
42
42
43
43
The underlying tunnel is identical.
44
44
IDE connections use SSH, web terminals use a WebSocket protocol, and the agent uses the workspace daemon's HTTP API, but all three traverse the same Tailnet connection and rely on the same security boundary.
45
-
No additional ports or network paths are introduced.
45
+
You don't need to expose additional inbound ports or configure new network paths.
46
46
47
47
### No inbound ports
48
48
@@ -130,6 +130,9 @@ They traverse the same Tailnet tunnel used by web terminals and IDE connections.
130
130
|`process_signal`| Sends a signal (SIGTERM or SIGKILL) to a tracked process. |
131
131
|`attach_file`| Attach a workspace file to the current chat so the user can download it directly from the conversation. Use this when the user should receive an artifact such as a screenshot, log, patch, or document. Pass an absolute file path. The file must already exist in the workspace. |
132
132
133
+
`open_preview` is also a workspace tool, but only root chats outside plan mode can use it.
134
+
For details, refer to [Embedded previews](./index.md#embedded-previews).
135
+
133
136
#### Windows workspace shell requirement
134
137
135
138
Coder Agents run workspace commands through a Portable Operating System Interface (POSIX)-compatible shell (`sh`).
Copy file name to clipboardExpand all lines: docs/coder-agents/index.md
+56-1Lines changed: 56 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -243,6 +243,7 @@ The agent has access to a set of workspace tools that it uses to accomplish task
243
243
|`process_list`| List all tracked processes in the workspace |
244
244
|`process_signal`| Send a signal (terminate/kill) to a tracked process |
245
245
|`attach_file`| Attach a workspace file to the chat as a durable downloadable attachment |
246
+
|`open_preview`| Open an embedded preview of a running HTTP app, an `.html` file, or a directory containing `index.html`|
246
247
|`spawn_agent` (`type=general` or `explore`) | Delegate a task to a sub-agent running in parallel, optionally on a specific model |
247
248
|`list_subagent_models`| List the models available for `spawn_agent`'s `model_config_id` argument |
248
249
|`wait_agent`| Wait for a sub-agent to complete and collect its result |
@@ -256,7 +257,7 @@ The agent has access to a set of workspace tools that it uses to accomplish task
256
257
|`find_tools`| Search the deferred MCP tool catalog and activate matching tools. Only available when the turn has MCP tools to defer |
257
258
258
259
These tools connect to the workspace over the same secure connection used for web terminals and IDE access.
259
-
No additional ports or services are required in the workspace.
260
+
You don't need to expose additional inbound ports.
260
261
261
262
Platform tools (`list_templates`, `read_template`, `create_workspace`, `start_workspace`, `stop_workspace`, `propose_plan`, `ask_user_question`) and orchestration tools (`spawn_agent`, `list_subagent_models`, `wait_agent`, `message_agent`, `interrupt_agent`, `list_agents`) are only available to root chats.
262
263
Sub-agents do not have access to these tools and cannot create workspaces or spawn further sub-agents.
@@ -268,6 +269,60 @@ Sub-agents do not have access to these tools and cannot create workspaces or spa
268
269
In plan mode, the agent can still inspect the workspace and template metadata, execute shell commands for exploration, and read process output.
269
270
`write_file` and `edit_files` remain available only for the chat-specific plan file under `.coder/plans/`.
270
271
Workspace MCP tools are unavailable in plan mode, and plan-mode sub-agents receive no MCP tools.
272
+
`open_preview` is only available to root chats outside plan mode.
273
+
274
+
### Embedded previews
275
+
276
+
The agent can call `open_preview` to show a running app or HyperText Markup Language (HTML) files in the chat's **Preview** tab.
277
+
It gives each preview a short title and supplies exactly one of `port` or `path`:
278
+
279
+
-`port` opens an HTTP app that is already running on a workspace port between 1000 and 65535.
280
+
An optional `url_path` opens the app at a path and query, such as `/?folder=/home/coder/project`.
281
+
-`path` publishes an absolute workspace path to an `.html` file, or a directory containing `index.html`.
282
+
283
+
`open_preview` is only available when the deployment has a [wildcard access URL](../admin/networking/wildcard-access-url.md).
284
+
Previews also need the selected workspace proxy, including one the dashboard selects automatically, to have a wildcard access URL and run the deployment's Coder version.
285
+
If the **Preview** tab is missing or a preview doesn't load, [select](../admin/networking/workspace-proxies.md#select-a-proxy) the primary proxy, named **Default** unless an administrator renamed it, or a proxy that meets both requirements.
286
+
Preview hostnames must fit the 63-character DNS label limit, so previews can fail to load when the agent, workspace, and user names total more than 40 characters, minus any suffix in the wildcard access URL, such as `-apps` in `*-apps.example.com`.
287
+
288
+
A file preview publishes only the selected file, so for HTML that uses local Cascading Style Sheets (CSS), JavaScript, or images, the agent must publish their directory.
289
+
A directory preview serves every regular file in the directory except files and subdirectories whose names start with a dot or contain `~`, `:`, or `\`, which Windows can use to refer to another file.
290
+
It doesn't provide directory listings or serve symbolic links inside the directory, and no preview serves a file with more than one hard link.
291
+
Links to a subdirectory must end in `/`, such as `/about/`.
292
+
293
+
> [!WARNING]
294
+
> Do not publish a directory containing secrets.
295
+
> A directory preview exposes every eligible file, including files added after publishing, not only HTML and assets.
296
+
297
+
Preview pages contain content the agent wrote, and a prompt injection can change what the agent writes, so Coder restricts what they can do:
298
+
299
+
- Only users who can connect to the workspace's apps can view its previews, such as the workspace owner and users the workspace is shared with.
300
+
Deployment owners can too, unless the deployment sets `--disable-owner-workspace-access`.
301
+
[Port sharing levels](../workspaces/workspace-access/port-forwarding.md#share-ports) don't apply to previews.
302
+
- Preview pages run in a sandbox that keeps them from navigating the dashboard or opening pop-ups.
303
+
- Preview pages can load scripts, styles, images, and other files, and send `fetch` calls, WebSocket connections, and form posts, only from their own origin.
304
+
They can't load files from a content delivery network (CDN), embed pages from other origins, such as videos or maps, or call external APIs from the browser.
305
+
- Preview pages can't register service workers.
306
+
- In the **Preview** tab, and when you open a preview in a new browser tab from it, a preview page can't navigate itself to another origin.
307
+
A preview in a new browser tab shows its title and host above the page, because the address bar shows the dashboard's URL.
308
+
If you go to a preview's URL directly, the page can navigate to any URL, such as the workspace's other ports and apps, and pages there don't have these restrictions.
309
+
- Coder removes `Clear-Site-Data` headers and cookies with a `Domain` attribute from preview responses.
310
+
Scripts on a preview page can still set cookies that other apps on the wildcard domain receive, so enable [`--host-prefix-cookie`](../reference/cli/server/index.md#--host-prefix-cookie) to keep them from replacing your session cookie.
311
+
312
+
Treat a preview like any app that runs code the agent controls.
313
+
314
+
The **Preview** tab has a menu that lists every preview the chat opened in its current workspace.
315
+
When the chat has a workspace, you can add the tab from the right panel's add menu, even before the agent opens a preview.
316
+
When the agent opens a preview while you view your chat, the right panel shows the **Preview** tab with that preview selected.
317
+
When the window is narrower than 1024 pixels, such as on a phone, a preview opens only when you select **Open preview** on the tool result.
318
+
Unless the chat is archived, reloading the page keeps the tab and preview you last selected.
319
+
To see edited static files, use the refresh button.
320
+
If a build deletes and recreates the published directory, or the directory that contains a published file, ask the agent to call `open_preview` again.
321
+
322
+
Published files stay available until the workspace agent restarts, even if you close the tab, and can't be unpublished.
323
+
The workspace agent serves up to 64 published paths until it restarts.
324
+
After a restart, ask the agent to call `open_preview` again.
325
+
Preview links from before the restart stop working.
0 commit comments