dream-num / dsh-univer-workspace-plugin
Univer capability plugin for DSH: agent tools that operate remote Univer Workspace Units (documents) through the harness workspaceAuth service.
About this plugin
Written by the registry from verified metadata, not from the README.
dsh-univer-workspace-plugin is a DSH plugin published from the packages/dsh-univer-workspace-plugin package in the dream-num/univer-workspace repository.
Capabilities and topics
dsh-univer-workspace-plugin
The Node host defers loading the document runtime pool, Office conversion and API
reference until their first operation. The build ships these lazy chunks beside
the worker bootstrap in lib/; closing an unused runtime manager does not load
document engines. Account switching also joins pending pool initialization before
closing it. These are internal packaging and lifecycle choices, not new exports.
The Univer capability plugin for DSH. It gives an agent the ability to operate remote Univer Workspace Units (documents) in the Spaces the authorizing User can access. Documents are Units managed and persisted by the Univer Workspace backend; local paths are used only for task assets and import/export, not as document identities.
The distributed host, worker and browser entries bundle their JavaScript SDK
dependencies without source maps. Desktop packaging stages a reduced installation
manifest containing external native bindings and ws; binding versions come from
the installed SDK wrappers. The source manifest retains its SDK dependencies.
DSH peers remain host-provided. Moving a dependency across this boundary requires
checking the emitted bundle and running the isolated desktop runtime checks.
Screenshot and layout-lint tools receive the same resolved Univer license as the headless document runtime, including the bundled development default. Local rendering still requires a built render page and Chrome/Chromium; see the Agent render setup.
Why run in a dedicated DSH profile?
This plugin is part of the Workspace Agent application composition. The supported
setup installs it into the dedicated univer-workspace-harness profile alongside
the Agent core, skin, and version-matched DSH web bundle. Follow the
Agent installation guide
instead of adding this capability bundle alone to an existing general-purpose
web profile.
A DSH profile selects an installed bundle set and its composition patches. A separate profile matters here for four reasons:
- Required services and lifecycle. The plugin consumes the Agent core's
workspaceAuthandworkspaceRuntimeservices. They supply the authorized Workspace connection and account-owned runtime directory. Installing the tools alone does not establish OAuth, Space bindings, or account switching. - Application-wide UI composition. Agent replaces the native sidebar and reference discovery, and configures the webserver, connection handling, settings, and credentials. The native and replacement sidebar cannot both declare the same child slots. Applying these patches to a user's ordinary profile would also change that profile's interface and behavior.
- Tool and document semantics. Other Univer plugins may use overlapping tool
names for local
.univerfiles. Here documents are remote, database-backed Workspace Units with Resource identities and Worktree review. Mixing both toolsets in one composition can introduce name collisions and contradictory instructions about where content lives. - Reproducible dependencies. The profile is a separate pnpm project under
$DSH_HOME/profiles/<profile>. The profile builder installs the pinned DSH web bundle first, then the three repository bundles, reusing its peer versions. This keeps Agent's supported bundle set separate from another profile's plugin choices. The DSH CLI is also installed outside the repository workspace to keep its React 18 graph separate from Workspace Browser's React 19 graph; choosing a profile alone does not provide that dependency isolation.
Profile isolation is not account isolation
| Boundary | What owns it |
|---|---|
| Installed plugins and composition patches | The dedicated DSH profile, assembled by build-profile.sh |
| Workspace connection, login, and account switching | Agent core; one active connection per running instance |
| Account-specific Sessions, indexes, attachments, and local Space directories | Runtime directories selected by Workspace origin and user ID under UWH_DSH_DATA_HOME |
| Shared local model settings and browser-session signing state | Agent's shared settings and credentials paths |
| Remote document access and mutation permissions | Workspace server |
Use the same profile when switching Workspace accounts; the application switches account-owned services and data directories without reinstalling plugins or restarting the HTTP listener. All tabs connected to that Agent instance share its current Workspace identity. A profile is not an OS sandbox and does not restrict the agent's local filesystem permissions.
The default profile name remains univer-workspace-harness after the application
rename. Keep the builder and launcher on the same DSH_PROFILE if choosing a
custom name. See the Agent storage guide
for installation paths, shared state, and account data; do not use a profile name
as a substitute for those explicit storage boundaries.
Persisted comment anchors
The headless worker (through the pinned SDK headless factory) and the browser
Viewer (in its own pipeline, src/client/viewer/rendering.ts) register the
Thread Comment models for Sheet, Doc, Slide, Base and Board so existing comment
anchors survive replay, export and Viewer saves. Neither installs comment UI or
a body datasource; comment bodies stay in the Workspace Comment service.
Markdown file preview
Remote .md/.markdown Blobs use the private
Markdown viewer, shared with Workspace
Browser. Preview/Source switching supports CommonMark/GFM, tables, read-only
tasks and footnotes. Content is fetched through the existing authenticated
proxy. Preview and Source both show the complete file without a preview size
cutoff. Raw HTML stays text, relative paths are not resolved, and external images
require a click. This does not replace DSH chat or local-file rendering.
Delivered so far
-
Workspace sign-in onboarding: a first-run step before model setup offers the Workspace service URL and a primary sign-in action. Connected accounts skip the step; users who defer it retain a sign-in button in the sidebar. Expanding or collapsing the sidebar preserves the settings owner and its deferred onboarding state. Workspace authorization and model credentials remain separate.
-
Explicit Space registration: listing remote Spaces is read-only. A new device/account starts with an empty session list; a Space is bound to a local dsh workspace directory only when the user selects it in the add/picker flow. Removing its local registration does not cause browsing to add it back. A durable shadow table (
space-linksstorage domain) maps a dsh workspace id back to{ userId, spaceId }. Selecting a Space in DSH selects one of the User's accessible Spaces; the directory is never surfaced to the User. -
Discovery tool:
univer_spaceslists the User's Spaces through the harnessworkspaceAuthservice, resolving the calling agent from its session working directory. -
Document tools:
univer_documents,univer_open, anduniver_createlist, open, and create Univer documents through the Workspace product API. -
Editing:
univer_editexecutes Facade API code in a headless collaboration runtime (read against trunk/draft, write only in Worktree scope with a committed changeset), managed by a forked worker pool. -
Review:
univer_worktreedrives the Worktree lifecycle (create/ready/merge/discard) with merge and discard forced through thetools/pre-executeapproval waterfall. -
Issues:
univer_issuereads and operates Team Space Issues (list/get/create/update/comment/close/reopen) through the Workspace product API as the authenticated user.getreturns the discussion and linked files with theresourceIds the other tools take. Nothing needs approval because every Issue action can be reversed by another; theuniverskill tells the agent to comment its result and leave closing to the user. -
Worktree-local Unit:
univer_unitimplements the Workspace product'ssource=worktreecreate contract with the calling Space as its enforced scope, stable idempotency, pending-Operation polling, and complete Unit response validation.action=removemarks a Unit for deletion at merge;action=restoreundoes that draft intent. Existing documents enter Trash only after merge, while canceled new Units never become published documents. -
Execution sources and path safety:
univer_executeaccepts exactly one inlinecodeor session-relativecodeFile; both import/export paths use canonical realpath containment checks, including symlink escapes. -
Import/export:
univer_importanduniver_exportuse the pinned@univerjs-pro/exchange-nodeSDK locally. Import converts the session file into JSON-safe UnitData and creates a Worktree-local Unit (so it can be reviewed, discarded, or merged); export synchronizes a trunk or Worktree Unit and writes.xlsx/.csv/.tsv/.docx/.pptxbytes back to the session workspace. The product trunk exchange task is intentionally not used because it would bypass Worktree review semantics. -
Structured inspection:
univer_inspectuses the pinned@univer-cli/content-inspectioncontract for workbook/document/ presentation overviews and Sheet ranges; it never executes caller-provided write code. -
SDK reference and assets:
univer_apiuses the pinned@univer-cli/api-reference;univer_resourcesuses the pinned resource library and a build-time copied@univerjs-pro/cli-assetsmanifest. The latter is a static visual-asset catalog, not the Workspace product's Resource/ACL model. -
Skill references: the native DSH
skillloader returns the main instructions and lists reference-reading calls. Useuniver_skill_resourcewith the listedskillandpathto read one document. Reading is limited to references and templates bundled with the selected Skill. -
Worktree parity:
univer_worktreeexposes the review lifecycle used by the browser (create→ready→merge/discard). The underlying transition adapter may retain compatibility with older server actions, but the plugin exposesreopenfor returning a ready Worktree to draft. -
Browser Space picker: this plugin owns the Workspace Space picker and injects it into the stock DSH hero/sidebar slots. DSH still owns its native mechanical workspace list and session persistence; selecting a Space registers that Space and hands its directory to the native DSH picker/adoption flow.
-
Browser file workspace: the sidebar replaces the shell root with native DSH session and Workspace file tabs. The file tab browses the authenticated Space/Node/Resource tree, creates items in permitted folders, renames and trashes nodes, and exposes a capability-gated trash view with restore and permanent removal. Univer Resources open in the embedded Viewer; Blob Resources use the native DSH Sidecar for read-only image, video, audio, PDF, and text previews, while unsupported media remains download-only.
.univer.htmlfiles use the private shared HTML viewer with live Sheet subscriptions and permission-checked trunk writes. Other Blob previews are read-only. HTML source access is independently authorized through the current account; publishing its template does not edit Sheets. Native tab close retains the HTML runtime until save confirms; failed saves keep a recovery surface with a save-and-close action. See the HTML integration guide. -
Blob tools:
univer_blobexposes get/download/upload/replace through the existing Workspace service/provider and authenticated HTTP client. Get reads metadata only. Upload creates a new Blob from a session file in the current Space by default, with optionalspaceId,parentNodeId, andname. Download into the session workspace, edit locally, then replace with the exact downloaded ETag. Uploads and replacements publish immediately, without Worktree review. Both writes require anidempotencyKey; retry with the same key and unchanged input to resume the same operation instead of creating a duplicate. Stale ETags require downloading and reconciling current content; file paths use the same session containment checks as import/export. -
Native Sidecar preview: file and Worktree opens update one Workspace preview tab in the current session's native right sidebar. DSH owns tab closing, resizing, splitting and fullscreen; Workspace renders the content inside it. With no selected session, the native flow reuses or creates a blank session in an already-added Space. If none has been added, the UI asks the user to add one first. Other native tab types remain available.
-
Capability HTTP routes:
/api/uwh/me,/api/uwh/template-fork, Space rename, the same-origin Space/Node tree, and trash actions are registered by this plugin. The Workspace Agent only supplies the authenticatedworkspaceAuthservice they consume. -
Bundled skill:
univerteaches the model the Space/document model and the Worktree review rules. -
Conversation change summaries: turn cards list the documents touched by that Turn. Clicking a row opens its Worktree in Sidecar and locates the document; conversation cards do not mount document runtimes or offer preview accordions.
-
Floating task list: one compact session list shows each Worktree's status and counts of added, modified and deleted documents. Rows open Sidecar. The list is portaled to the document and can be dragged across the entire viewport, independently of conversation and Sidecar layout.
Not yet delivered (tracked as follow-up stages)
- The remaining Office-only gateway/file capabilities that do not have a Workspace product equivalent yet.
Document creation and review
For agent tasks, create an empty draft with univer_worktree (action: "create",
no resourceId), then create a document with univer_unit (action: "create")
or import one with univer_import. New Units stay in the Worktree until merge
activates their reserved Resource and Node identities in the target Space.
Existing documents enter a new Worktree by passing their resourceId to
univer_worktree. Verify the content, mark the draft ready, and let the user
review it before merge.
Each conversation writes only in the Worktrees it created. The tools read that
list from the conversation's own DSH log: successful univer_worktree
create results, including those inside run_code. A forked or template
conversation does not inherit its parent's Worktrees. Content writes
(univer_execute, univer_edit mode=write, univer_compile_markdown,
univer_compile_svg, univer_import, univer_unit) and ready/reopen on
any other Worktree fail with WORKTREE_NOT_IN_CONVERSATION, even when the same
user created it in another conversation or client. Reads stay open to every
Worktree the user can access. merge and discard stay open as well, because
each one waits for the user's approval. univer_status marks each listed
Worktree with createdInThisConversation, and the univer skill continues
only those.
univer_new and univer_create create documents directly in trunk and are for
explicit requests to publish immediately. Worktree changes support new, modified, and deleted documents. Use
univer_unit with action: "remove" to mark a document for deletion and
action: "restore" to undo that intent while the Worktree is a draft.
Merging moves existing documents to Trash and cancels unpublished new Units.
Discarding a Worktree leaves existing documents unchanged.
dsh-univer-office tool audit
The office plugin operates local .univer files, while this plugin operates
remote Workspace Resources. The shared operations are deliberately mapped to
the remote contract rather than accepting a local file path that the server
cannot authorize:
| dsh-univer-office | Workspace plugin | Boundary |
|---|---|---|
univer_new | univer_new / univer_create | Resource creation is a Workspace API operation; the result is opened to resolve unitId. |
univer_unit | univer_unit (create, remove, restore) | Create draft Units or update their deletion intent through the Workspace product API; merge approval remains a separate Worktree action. |
univer_status | univer_status + univer_spaces, univer_documents, univer_open | Status returns the selected trunk Resource or Worktree Unit/file-state; Space, Node and Unit identity remain separate remote resources. |
univer_execute | univer_execute (or univer_edit mode=write) | Writes are Worktree-scoped and commit a collaboration changeset; exactly one inline code/safe session codeFile is accepted. |
univer_inspect | univer_inspect | Uses the public content-inspection SDK over the same headless collaboration runtime; range selectors are validated before execution. |
univer_worktree | univer_worktree | Lifecycle and approval semantics are aligned. |
univer_import / univer_export | same names | Local exchange SDK conversion; import creates a Worktree-local Unit and export reads trunk/draft UnitData into a session-relative output. |
univer_api | univer_api (find/show) | Pinned local CLI SDK reference; read-only and independent of Workspace ACL. |
univer_resources | univer_resources (registries/find/read/export/clear-cache) | Pinned local visual-resource library; cache/export are session-relative. This is not a product Resource listing. |
univer_compile_markdown | univer_compile_markdown | Shared Markdown compiler, SDK default styling, and stable-ID block updates in a draft Worktree. |
univer_export_markdown | univer_export_markdown | Read selected current native Doc blocks to session Markdown/resources with their authoritative revision and refreshed mapping. |
univer_screenshot / univer_lint / univer_compile_svg | same names | Uses the CLI SDK over the synchronized Unit. Rendered checks require a version-matched render page and browser. Board model lint runs headless. Screenshots require the host attachment service. |
Architecture boundary
Board rendered/both includePortPlan: true returns native automatic port-order plans in analyses[].portPlan.
It preserves node frames, authored ports/routes and editing ownership. Missing or incomplete requested planning
keeps coverage incomplete, and original findings remain visible. Apply one ready plan through the editing Board
Facade, then lint a fresh snapshot before using another plan.
Board rendered/both lint also accepts explicit generated textPlanElementIds and optional textPlanMaximumWidthGrowth from 1 to 2. The width limit requires a non-empty unique selection. Plans remain read-only; missing/incomplete native planning remains incomplete coverage. Apply only a ready current plan through the editing Facade, then replan and lint.
univer_lint accepts Slide and Board Units. Board mode: "model" runs without a browser;
"rendered" checks final geometry and "both" (the default) preserves both raw analyses.
Reports retain status, incomplete coverage and the inspected snapshot hash. An empty findings list with
incomplete coverage is not a clean pass. Configure UWH_RENDER_PAGE_ROOT (or UNIVER_RENDER_PAGE_ROOT)
for rendered checks and screenshots; rendering errors remain explicit failures.
Board rendered/both lint accepts optional maximumAutomaticLabelDistance, a finite non-negative number
of Board units including zero. It forwards the caller policy to the CLI SDK; missing native support or
unresolved requested distance leaves coverage incomplete, and exceeded limits remain native errors.
Fixed/authored and endpoint-role labels are excluded. The native sampled, marker-trimmed stroke-centerline
metric is not raster ink, and inspection never moves labels. The tool's operation-success envelope does
not override the report's findings or incomplete status.
- No separate gateway process: the browser-facing API is registered on the
DSH web server (
/univer-workspace/api/**), and the host side calls the Workspace service directly with the User's workspace session credential obtained from the harnessworkspaceAuthservice.
Non-responsibilities
- Authentication and credential storage (
workspaceAuthbelongs to@univerjs/workspace-agent). - Workspace product APIs, Unit data model, or collaboration contracts (owned by the Workspace application and the Univer SDKs).
- Publication: this is a private workspace package consumed by the harness profile build, never published to npm.
Build
pnpm build emits lib/index.js (node host bundle), lib/client.js (browser
bundle), and the linked lib/client.css stylesheet; bundled skills ship under
skills/. The WebServer plugin serves the stylesheet and contributes its
<link> to the DSH boot page, so client code does not create runtime style
tags.
After changing bundled Skills or their reader, run pnpm build followed by
pnpm test:skills-package. This checks reference discovery and reading through
DSH tools using the extracted package artifact.
Native/binary addons are deliberately not bundled into either the host or the worker. The plugin depends on the wrapper packages that own them, so each binding arrives as a transitive production dependency:
@univerjs-pro/engine-formula-rustowns@univerjs-pro/engine-formula-rust-binding, the headless formula engine;@univerjs-pro/exchange-nodeowns@univerjs-pro/exchange-node-bindingfor Office import/export.
Depending on the wrappers keeps every binding at the version its owner
publishes instead of pinning a second copy here that drifts from the SDK
baseline. DSH initializes every profile with pnpm's nodeLinker: hoisted, so
the profile installs those transitive bindings into one flat node_modules;
the bundles load a binding through the wrapper's createRequire, which
resolves from the plugin directory up to that flat profile root.
supportedArchitectures: current keeps the install to the container's platform
binary.
Account-level Workspace Agent sessions use the connected account's personal Space as the default destination. Sessions opened in a selected Space keep that Space as their default. Explicit targets still require Workspace server permission; unrelated local DSH directories are not automatically linked.
Worktree list loading
The Worktree sidebar loads one page of summaries per request, defaults to pending
Worktrees, and loads further pages with Load more. Search and lifecycle filters
run on the Workspace server; selecting a row loads that Worktree's Unit details.
The Team and personal groups describe the loaded rows, not global totals.
Conversation cards continue resolving their known Worktree IDs independently.
This sidebar requires a Workspace server supporting scope=all, search, and
order=createdAtDesc on GET /api/worktrees; update the server before the plugin.
Historical Worktree review
Merged Worktrees open the Base-to-draft comparison by default. Draft, ready, and discarded Worktrees open the read-only resulting draft document; choose Changes to inspect the comparison. New Worktree-local Units have an empty Base, including those in discarded Worktrees. Switch between structured changes and the resulting full version. Ready Worktrees also offer the evaluated merge preview; merged Units can show their recorded merge revision. A Unit without a recorded merge revision reports that limitation instead of showing the current trunk as a historical result. Canceled creations are omitted and deleted Units remain individual review records.
Fixed-Base and recorded-result modes require the matching Workspace Server comparison endpoint. Older servers can still display the equivalent empty-Base comparison for new Worktree-local Units. Their merge previews also work when the server evaluator confirms a Worktree-created Unit and its returned snapshot matches the exact ready revision. Other unsupported historical modes report that the server needs updating; they never silently fall back to current trunk or draft.
Optional Desktop diagnostics
When hosted by Workspace Agent Desktop, the browser registers a dedicated About section in DSH settings, containing update controls and diagnostics. These use the optional sandbox-preload capability; ordinary web deployments omit them. The components display environment, update progress, startup timings and failure codes, and request directory opening or report export. The Desktop application owns all collection, filtering, filesystem access and update behavior; this plugin does not read local files or own installation.
Sign-in guidance
Disconnected Files, Worktree, and Space-picker views offer a direct Workspace
sign-in button. A successful status request with connected: false remains a
sign-in state, while permission and network failures retain their own errors.
Desktop delegates sign-in to its default-browser bridge; browser deployments
keep the local OAuth navigation. Settings also offers Switch account.
The original headless implementation now lives in the private @univerjs/univer-workspace-agent-runtime package. Build it first; the existing runtime paths re-export that shared implementation. This extraction supplies no external product UI or DSH service to the Space app.
Modern Doc generation uses univer_compile_markdown: session Markdown and bounded local resources are compiled
through the same Univer AI SDK capability as both CLIs. It creates a staged native Doc with SDK default styling;
explicit source IDs and execution source maps support stable-ID block replacement. Native edits remain authoritative.
Callouts inherit native SDK theme colors by default. Author :::callout{#notice} without tone
or color overrides; supply an explicit tone only when the user requests a custom semantic color.
Use univer_export_markdown before changing a block that may have been edited natively. Provide its
Worktree, Unit, previous sourceMapFile, selected blockIds, and session out Markdown path. The
tool reads current native content, writes resource sidecars beside the Markdown, and saves a refreshed
map with the same-read revision to sourceMapOut (default <out>.map.json). Current Workspace image
resources are resolved through the authenticated Worktree Asset API. Edit the exported file,
then call univer_compile_markdown with that map and the same selected IDs. The exported revision
remains read metadata. Export performs no document write. Unsupported selected content
fails rather than silently losing native structure.
Badge
Listed here? Link back with this badge — paste the snippet into your repository README.
[](https://dsh-plugin.com/plugins/dream-num/univer-workspace/packages/dsh-univer-workspace-plugin)