Files Plugin
Makes files the agent generates or modifies downloadable and previewable in the web UI, lets you browse the configured repositories, and runs static web apps the agent builds.
Formerly
file_links. Old configs (codumentor.plugins.file_links/FileLinksPlugin,disabled_plugins: [file_links]) still load, with a deprecation warning;/ui/plugins/file_links/…URLs still answer (GET: 308 to/ui/plugins/workspace_files/…). Transcript events keep theplugin.file_links.*types.
What you see
- Transcript cards after a tracked write: filename, size, kind, Download and Open in browser — plus ▶ Preview app when the file is an HTML entry
- In focus mode, a turn that wrote or shared several files shows one card under the answer instead: one row per file (a rewritten file appears once, at its latest size), two rows of a longer list, opened by clicking the header or Show N more, and Download all, which saves them as a single zip (same access rules and 100 MB cap as a single download; files deleted since are left out and reported)
- A Files control in the chat header (labelled Browse files in the overflow menu)
- A ▶ Preview control in the chat header, once a conversation has a pinned app
- A repo browser at
/plugins/workspace_files/reposwith a Changed here / All files toggle
The agent is told when a Download card appears, its own or an editor's save card: the tool result it reads says "The user now sees a Download card for <name> in the chat." The user keeps a card for every write, but the agent is told about a given file at most once per conversation — a repeated write of the same file is not re-announced. A scheduled or other unattended run is told instead that the card waits in the conversation until someone opens it in the web UI. The terminal UI, Telegram and Slack show no cards, so the agent is told nothing there.
A file a shell command wrote gets a card too, found after the command finished. In an isolated session that is every file the command wrote — a script's rewrite of an existing HTML file, a rendered PNG, mv tmp out — read off the session's overlay layer. Under direct execution or the light sandbox the workspace is shared with other conversations, so only the paths the command text names as written count (> out, tee, sed -i, cp/mv targets, -o options); a script's own writes get no card there. Caches and dependency folders (node_modules, __pycache__, .venv, …) never get one, and a command that wrote more than 10 files gets none: the agent is told the count and pointed at share_file instead.
For anything without a card the agent uses share_file(path), which only checks the file exists; the card is drawn by the same tracker, which consumes its shared-file result metadata. Any such file is also downloadable from Files → All files, which lists the conversation's whole workspace, including gitignored folders such as tmp/.
On the web UI and in unattended runs the main agent (when it holds write_file) gets a short [File delivery] note stating this: which writes draw a card, share_file for the rest, no attached folder needed, and the Files browser.
Changed here lists files this conversation actually wrote or saved. Uncommitted files the agent never touched stay out of that view. All files lists the directory and annotates entries with git status.
On a wide enough screen the file list can be resized and put away, with the same controls as the conversation list: drag the strip between the two panels (or focus it and use the arrow keys; Shift takes bigger steps, Home and End jump to the bounds), and click the chevron tab on the strip to fold the list away or bring it back. The width and the folded state are remembered per device, and the preview keeps a minimum width when the window is narrow. Phones and the pane-beside-chat layout keep the fixed layout.
The browser shows one folder breadcrumb: click its repository name (or Workspace) to go directly to that location's root. Switch location separately offers repositories and the conversation workspace. Up opens the parent folder (disabled at the location root); Refresh reloads the current folder and any active search without replacing an open editor's buffer.
Search this folder and subfolders searches filenames and paths recursively in the selected folder and scope, including binary filenames and conversation-workspace files. Results show paths relative to the searched folder so same-named files can be distinguished. Search is case-insensitive and matches literal text, not file contents. Clear search restores the folder listing without moving elsewhere. Loading, failed searches, no matches and incomplete results are shown explicitly; if a search reaches its result or scan limit, narrow the text or search inside a subfolder. Use Refresh to retry a failed search.
With Workspace Isolation, files that exist only in the conversation sandbox still appear and can be downloaded while that conversation's sandbox is alive.
Once the sandbox expires, a file the agent committed and pushed keeps working: the browser reads it back from the pushed commit, so it stays in Changed here and stays downloadable — as long as that commit has reached the repository Codumentor has on disk (it does once the push has been ingested, or when it went to a branch this checkout already tracks). A sandbox-only file that was never committed has no copy left after expiry and will 404 — commit and push anything you want to keep.
Download is capped at 100 MB (?force=1 overrides). Inline preview is capped at 5 MB.
Old Document Editor download links in existing transcripts still work: they redirect to this plugin. If you disable the Files plugin, those links 404.
Running an app the agent built
When the agent writes a static web app — index.html plus its scripts,
stylesheets and assets — the preview runs it instead of showing its source.
Clicking the entry file in the repo browser shows the working app in the right
pane with a Full screen button; Source and Diff stay one click away.
Files is for browsing and inspecting. Open in Preview tab opens a separate
workspace tab when you want to keep the app running while you browse other
files or need its app controls. In either view, Full screen expands the
current running page without restarting it; choose Exit full screen or press
Esc to return. The browser must support fullscreen.
Ways to open a workspace Preview tab:
| Open in Preview tab in Files | move from inspecting a file to working with the app |
| ▶ Preview app on a transcript card | right where the file was written |
/preview [path] | the named path. Works while a turn is running, which is the point: you poke the app while the agent keeps building. With no argument it reopens the conversation's pinned app. Also available as /app. |
the agent calling preview_app | the agent hands over a running app rather than a file path — it knows whether the entry is webapp/index.html or webapp/dist/index.html, and which directory to serve. When you ask to see the app, the agent can also open the preview for you (open: true), exactly as if you had clicked the button — in every tab showing this conversation. The agent cannot see the rendered page, so ask it to fix what you see. |
the agent calling preview_app with a process id | a dev server instead of files: the agent starts it in the conversation's sandbox with shell(run_in_background: true, preview_port: 5173, …), and the preview shows the running server, hot reload included. The server gets PORT and CODUMENTOR_PREVIEW_BASE (its base path, e.g. for vite --base); one that ignores the base still loads. If the server is not answering, or has exited, the preview says so and names its log. Needs api.app_preview.sandbox_origin and workspace isolation. |
Preview → Start dev server in the chat header, or the agent calling dev_server_start | the repository's configured dev_server block (user guide), started in the conversation's sandbox the same way, with a health check before the preview opens. Stop dev server (or dev_server_stop, or ■ Stop in the preview's toolbar) ends it. A pinned preview whose server is gone says so and offers to start it again. Offered where a repository has a dev_server.command, the preview has its sandbox origin and the conversation runs isolated. |
In the Preview tab, a small floating bar — drag it by the handle, double-click to
reset, collapse it to a pill — carries Reload (with a count of files the agent
has changed since you opened it), viewport presets for checking a responsive
layout, a console badge that opens the app's console.* output and errors,
Pin to chat, Full screen and, where available, Open in new tab.
Without a configured preview origin (the degraded tier), an app whose HTML or
CSS links assets root-absolute (/_astro/…, /assets/… — the default of
most bundlers) loads without them: the browser asks the main site instead. The
console badge counts those assets, and the panel names them and the fix —
build with relative asset URLs (Vite: base: './'), or have an operator set
api.app_preview.sandbox_origin.
The agent is told the same when it calls preview_app.
Open in new tab is the one control that steps outside the sandbox: the app
opens as an ordinary page rather than inside the framed preview, so it can
navigate itself anywhere — including off-origin with data in the URL, which
nothing in a browser prevents. It is still cookie-free and still read-only, but
prefer the framed preview for an app you have not read.
Pin to chat pins that entry as the conversation's app. The chat header
then grows a ▶ Preview action that reopens it, and the pin is remembered for
that conversation — not for you, and not globally — so it is still there
tomorrow.
Console output from the previewed app is shown to you, never fed back to the
agent on its own. Ask the agent to fix this puts the text in the chat input and
shows you exactly what it will send; you press Send.
The file browser's Preview tab (for multi-file apps; Rendered for a
single page) and the workspace Preview tab share the last validated in-app URL.
When they open a new frame (for example, after switching to source and back),
they can restore the pathname, query and hash — including hash-routed slideshow
positions, but not JavaScript memory, unsaved form state, or scroll position.
Fullscreen is different: it keeps the existing frame live.
The resume cache is held only in this page's memory, isolated by
conversation, repository, entry and serve root; refreshing Codumentor clears it.
The cache keeps at most 100 targets and accepts complete locations up to 16,384
characters; longer locations are ignored, never truncated into a different route.
Routing limits: the preview serves actual files, with no history-router
fallback to index.html. A remembered path must name a file inside the session's
serve root; a pushState route to a missing file can work until reload, then 404.
Routes outside the session prefix are not resumed. Prefer hash routing (for
example index.html?mode=present#/slide/8) or real HTML file paths, and build
assets with relative URLs. URL resume does not add history routing support or
loosen the preview's sandbox or network restrictions.
What the preview can and cannot do
A previewed app runs in a sandboxed frame on a second origin, so it holds no
session cookie, cannot touch the Codumentor page around it, and cannot make
network calls anywhere except back to its own files. It is served read-only from
one directory, and every request is re-checked against your access to that
repository — so a preview stops working the moment that access does.
A previewed app therefore cannot load anything from a CDN — no off-origin
script, stylesheet, font or image, and no fetch to a third-party API. That is
deliberate, not a bug: it is what stops repo bytes leaving through the app. The
console badge shows the blocked requests, so an app built against a CDN reads as
"these things were refused" rather than as a mystery blank page. Vendor the
assets, or point the app at files it serves itself.
Full fidelity — localStorage, history.pushState(), workers, root-absolute
asset paths like <script src="/assets/index.js"> — needs that second origin
configured: see api.app_preview.
Without it the preview still runs, and relative assets still load, but
localStorage and the app's own fetch() do not; the overlay says so in one
line. Building with a relative base (Vite's base: './') is the one-line fix on
the app side.
Web Workers work; service workers do not. Every preview shares the one
preview origin, so a service worker one app registered would sit in front of
every later preview in your browser, including other repositories'. The preview
server therefore refuses to serve a service-worker script, and the app's
navigator.serviceWorker.register() call rejects (a PWA still runs, just
without its offline worker). Each newly opened preview also starts with the
preview origin's storage cleared, so localStorage/IndexedDB survive reloads
of one preview but not reopening it, and opening a preview resets the storage
of any other preview open in the same browser.
Shared and exported transcripts show no preview — a share viewer is not the
conversation's owner.
Configuration
plugins:
- module: codumentor.plugins.workspace_files
class: WorkspaceFilesPlugin
args:
enabled: true
# preview_tool: true
# editing:
# enabled: true
# max_bytes: 2097152
# vim_mode: false
Parameters
| Key | Type | Default | Description |
|---|---|---|---|
enabled | bool | true | Master switch. |
tracked_tools | list of strings | none | Deprecated compatibility fallback for explicitly named tools without file-effect metadata. New providers declare Tool.file_effects; no built-in tool-name list is used. |
preview_tool | bool | true | Offer the preview_app tool to the agent. Its definition sits in every request, so set this to false on a deployment that wants the preview only from the UI and the /preview command. Withheld anyway when api.app_preview.enabled is false, and never offered to subagents. |
editing.enabled | bool | true | Accept saves from the file browser's editor (PUT /files/content). false makes the route answer 404 and the capability report enabled: false. |
editing.max_bytes | int | 2097152 | Largest file, in bytes, the editor opens or saves. |
editing.vim_mode | bool | false | Reserved for the editor's Vim keymap toggle (not built yet). |
The preview itself is configured under
api.app_preview, not here:
api.app_preview.enabled: false removes the preview, the /preview command and
the preview_app tool entirely, leaving the download / view / browse surface
untouched.
Editing files
The owner of a conversation can save a text file in its workspace
(design: workspace-files-editor.md §4.4).
Who may. The access feature workspace_files.write is paired with the
write_file and replace_in_file tools: a profile whose agent may hold both
may edit, and anything that withholds either write tool withholds the editor.
The repository must be in the profile's scope. The operator's Write(...) /
Edit(...) deny rules apply as a floor (e.g. Write(.env)); Save itself is
the approval, so allow and ask rules are not consulted.
Request. PUT /ui/plugins/workspace_files/files/content (the old
file_links prefix also works) with
{conversation_id, repo, path, base_sha256, content}. base_sha256 is the
X-Content-Sha256 header /view returned with the bytes the editor loaded;
null (create) is refused in v1. The file keeps its BOM, line endings and
final-newline state.
Response. 200 {sha256, size} of the bytes written. Errors carry
{"detail": {"code", "message", ...}}:
| Status | code | Extra fields |
|---|---|---|
| 404 | editing_disabled, not_found (conversation) | |
| 403 | forbidden (another user's conversation, profile, path, read-only workspace) | |
| 403 | denied_by_rule | rule |
| 409 | turn_running | |
| 409 | write_busy | holder |
| 409 | not_live | |
| 409 | conflict | current_sha256 (null if the file is gone) |
| 413 | too_large | max_bytes |
| 415 | not_utf8 | |
| 422 | create_unsupported |
A save emits the usual plugin.file_links.file_written card (tool
workspace_files.editor) and, at the next turn, one note tells the agent which
files the user edited, with line counts. The UI reads
capabilities.workspace_files.editing = {enabled, max_bytes}.
In the browser (design §4.1, §4.3, §4.5). The file browser shows an
Edit segment beside Diff / Rendered / Raw. Edit is offered only when
GET /files/editing?conversation_id=&repo= says the caller may save here
({enabled, max_bytes, can_write, reason, turn_running}, the save route's
own checks) and the file is text, strict UTF-8, within max_bytes and the
live version (/view sent X-Content-Sha256). It is absent for binary
files and images, and when no conversation is open (the standalone repo
browser page without conversation_id). Where a reason is worth giving (no
conversation, no permission, not UTF-8, too large) the Raw view shows a
Read-only badge with it as the tooltip.
- Saving. Save or Ctrl/Cmd+S writes the buffer against the hash it was opened at, then against each new hash. Line endings are LF in the editor; the server keeps the file's own.
- Agent working. Edit and Save are disabled with "The agent is working; save when it finishes." The browser learns this from the host's
codumentor:turn-statusevent (in the chat) and from the probe'sturn_running, re-read every 5 s while editing (the standalone page gets no events). The server re-checks on every save. - Unsaved changes. Choosing another file, folder, repository, scope or view mode, closing the preview, back/forward and closing the tab all ask before discarding them. Leaving through the app itself (its Back button, the sidebar) cannot be asked about, so the buffer is kept as a draft in
sessionStorage(per conversation, repository and path; up toediting.max_bytes). Reopening the file offers Restore unsaved changes or Discard. A restored draft saves against the version it was based on, so a file changed meanwhile opens the conflict view. Saving, Cancel and Take theirs drop the draft. - Conflict. If the file changed since it was opened, the editor turns into a unified merge view (
@codemirror/merge) against the server version: accept or reject each chunk, then Keep mine (save the merged buffer over it) or Take theirs (load the server version). - Loading. The editor is a lazy chunk (
pluginBuild.splitting): CodeMirror is fetched on the first Edit, each language's parser when a file of that kind is opened, and the merge view only on a conflict. Code:ui/plugins/workspace_files/src/edit-mode.ts,editor-gate.ts,editor/.
Provider contract
File tracking is automatic and tool-name independent. It is separate from
Tool.is_write, which describes authorization-sensitive mutations, including
remote resources that produce no workspace file.
For a simple tool, declare the output argument names:
from codumentor.agent.file_effects import FileEffects
class ExportTool(Tool):
file_effects = FileEffects(path_args=("destination",))
Tool.call() attaches structured file_effects result metadata after a
successful invocation. Missing optional output arguments mean no output. Failed
calls do not generate inferred effects. An explicit result report always wins.
Stateful tools declare file_effects = FileEffects() and return actual outputs:
from codumentor.agent.file_effects import FileEffect, file_effects_metadata
metadata = file_effects_metadata(
FileEffect(workspace_output, download_card=False),
)
Merge this metadata with any other result metadata. Use
config.repo_context.workspace_rel_path(host_output) for resolved host outputs;
never report a display path or an overlay worker's private path. Multiple files
are supported. Return file_effects_metadata() for a successful no-op; a dynamic
writer that omits the report produces a development warning.
The tracker resolves and stats every output through the conversation's execution
strategy. It records written files in plugin.file_links.file_written events,
which drive Changed here. download_card=False makes the tracking event
hidden: Office editors use this to retain their own detailed save cards without
duplicating them. Tracking does not require that a card was drawn.
Use kind="shared" for an existing file offered for download without modifying
it. These effects produce plugin.file_links.file_shared cards and remain
available to shared-conversation downloads, but do not enter Changed here.
share_file and client_fs_copy_from_repo use this distinction.
Office saves report their actual session or save-as output automatically; no
Files plugin configuration is required. Shell writes are reported by the shell
tool itself (see above); what it cannot see is offered with share_file, or
browsed under All files.
Explicit legacy tracked_tools accepts only file_path, path, or filename
and logs a deprecation warning. It neither disables nor overrides provider
metadata, including an explicit empty result report.
Disabling
plugins:
- module: codumentor.plugins.workspace_files
class: WorkspaceFilesPlugin
args:
enabled: false
Or disabled_plugins: [workspace_files].
Keep the plugin enabled if you retain old transcripts with Document Editor download links.
See also
- Document Editor, XLSX Editor, PPTX Editor
- Client Filesystem
- Workspace Isolation
- Configuration →
api.app_preview— the second origin the full-fidelity preview needs