Skip to main content

Context and filesystem

Components for two things long-running agents need: a view of how full the context window is, and files that live in the browser.

Context window​

The context budget chip and usage panel, as a long run fills the window and compacts. Background in Context usage.

Loading the live demo…

ContextChip props​

PropTypeNotes
rationumberRequired. 0 to 1, how full the window is.
showLabelbooleanShow the percentage next to the ring.
isCompactingbooleanAnimate while a compaction is running.
sizenumberDiameter in px.
onClick() => voidTypically opens the usage panel.
title, classNamestring

ContextUsagePanel props​

PropTypeNotes
budgetContextBudgetToken counts by category, from the chat store.
compactionsCompactionLogItem[]History of compactions in this thread.
isCompactingboolean
onCompact() => voidCalled when the user asks to compact now.
classNamestring

File workspace​

A Monaco-backed file tree the agent reads and writes, stored in IndexedDB. From @distri/fs. See Using IndexedDB.

Loading the live demo…

FileWorkspace props​

PropTypeNotes
projectIdstringRequired. Namespaces the files in IndexedDB.
initialEntriesInitialEntry[]Files and folders to seed an empty project with.
defaultFilePathstringThe file to open first.
onSaveFileFileSaveHandlerCalled when the user saves a file.
filesystemProjectFilesystemYour own storage backend instead of IndexedDB.
previewRendererPreviewRendererCustom preview for a file type.
panels, activityBarItemsExtra side panels and activity-bar entries.
fileActionItems, fileActionRenderersPer-file actions in the tree.
classNamestring

Script testing panel​

A payload editor and a run button for a script tool. See Browser scripting.

Loading the live demo…

ScriptTestingPanel props​

PropTypeNotes
onRun(payload: string) => string | void | Promise<string | void>Run the script; the returned string is shown as the result.
onGenerate(currentPayload: string) => string | void | Promise<string | void>Fill the editor with a generated payload.
defaultPayloadstringInitial editor contents.
title, descriptionstring
resultPlaceholderstringShown before the first run.
languagestringEditor language for the payload.