* refactor(sandbox): move workspace layout and path rules into a leaf package
internal/sandbox/workspace owns the remote layout (root, input, output,
GitDir, skills root) and the lexical path rules. The sandbox root package
re-exports them through aliases, so callers keep their imports. No
behaviour change.
* feat(sandbox): add the allocation domain model
Pure types for placing a session: session/user mode, the user-mode
admission whitelist (web account or API external user only, with a fixed
fallback reason otherwise), the shared-machine identity and its digest,
the empty-retention bounds and the deployment gate.
* feat(sandbox): add machine and session admission leases
Registry of in-flight operations per shared machine and per session, with
Redis and in-memory implementations. Leases renew only while still live,
report loss at a local deadline measured from the request send time, and
Bind cancels a context when any held lease or barrier is lost. Holding or
renewing only ever extends the scope key's lifetime.
* feat(sandbox): add allocation_mode and empty retention to sandbox configs
Configs gain allocation_mode (session|user, default session) and
user_sandbox_empty_retention_days (0 = default 7, up to 90). Updates that
omit them keep the stored values. Switching a config to user requires the
deployment gate (WEKNORA_SANDBOX_USER_ALLOCATION plus Redis), exposed as
the settings.sandbox.user_allocation capability.
The gate stays closed in this build regardless of the env var: the session
manager does not place sessions by their assignment yet, so a user-mode
placement would be recorded for a session that still runs on its own
machine.
* feat(session): record the server-verified owner auth source
sessions.owner_auth_source records how user_id was authenticated when the
session was created or its owner first bound: web, API direct header or
signed token, API key, MCP endpoint, embed, IM, internal. The auth
middleware puts the source on the context, CreateSession stamps it and
ignores client input, owner binding (MCP ask, embed backfill) records the
entry's own source, and a fork inherits it. Rows from before the column
stay empty, which means unknown.
Per-user sandbox allocation reads it to tell a verified person from a
shared entry; the owner's kind follows from the source and user_id, so it
is not stored separately.
* feat(sandbox): persist session placements and shared-machine registry
session_sandbox_assignments records each session's placement once: its
config pair, the shared machine digest ('' for a machine of its own),
when it was released and when its directory cleanup is due. Mode and
layout follow from the digest. sandbox_user_machines holds the identity
behind each digest and the empty-retention clock.
ClaimPlacement writes the assignment and projects the session pin in one
transaction that locks the session row, then the machine row, before
inserting. RetireSessions releases assignments under the same locks and
writes a tombstone for a session that was never placed, so no placement
lands after a deletion began. The repository is also exercised on the
schema the shipped SQLite migrations create.
* feat(sandbox): place sessions through the allocation service
sandboxalloc decides a session's placement on first remote use and records
it with the pin: sessions that already used a per-session sandbox stay on
it, maintenance sessions are always dedicated, and only an eligible owner
on a user-mode config with the gate open shares a machine. A placed
session resolves straight from its assignment; a released one is refused.
Skill maintenance sessions record a maintenance placement and are removed
if that fails.
* fix(sandbox): retry placement when the sandbox config cannot be read
A failed config load was stored as session mode, so the session could never join a shared machine after the error cleared.
* fix(sandbox): satisfy golangci-lint on the allocation foundations
Wrap lines past 120 characters, comment exported names, and clear the two staticcheck findings so the pull request lint job can pass.
---------
Co-authored-by: hailongzhao <hailongzhao@tencent.com>
* feat(automation): scheduled agent runs with in-app notifications
Automations let a user have an agent run a task on a schedule as them.
The scheduler is database driven: every instance claims due rows with a
version CAS, so Lite and multi-instance deployments share one path.
Runs execute in deferred mode, suspend on approvals and notify the
owner; an answered prompt resumes the run from its snapshot. Standing
grants are promoted from approvals past runs asked for, bound to the
agent configuration and the owner's role.
Adds the automation, run and notification APIs, the automation.*
assistant operations, and regenerates the Swagger document.
* feat(frontend): automations page and notification bell
Adds an Automations page to the sidebar: a list with schedule, agent,
next run and last status; an editor with schedule presets, a custom
cron field, timezone and a live preview of the next runs; and a detail
drawer with run history, links into each run's conversation and the
standing approvals the owner can grant from past approval requests.
The top-right bell now merges pending invitations with in-app
notifications and polls for new ones.
* fix(automation): let the assistant schedule tasks and match the settings UI
The assistant never searched for automation operations, one-time times failed unless they were RFC3339, and the create, detail, and notification surfaces did not match the rest of the app.
* feat(chat): fold long streaming timelines and steady their height
Keep recent steps visible while a run streams, attach finished reasoning to the following tool, and absorb sudden height drops so the followed viewport does not jump.
* style(chat): use the motion token for the reasoning toggle
* refactor(agent): route approval decisions through a single policy
Operations, assistant write tools, MCP tool approval, delegated-child
approval and the child tool guard each compared access levels on their
own. They now ask policy.Decide, which maps an action's risk and the
run's rules to allow or ask. Behaviour is unchanged: MCP tools still
follow only the workspace per-tool flag and delegation, and a write that
reaches a read-only run still asks.
Add design docs for the agent permission model and scheduled automation.
* refactor(agent): replace interactive flags with a run mode
Runs are attended, deferred or unattended. Unattended runs refuse every
approval, including MCP approvals that used to wait out the timeout;
deferred runs suspend at once.
* feat(agent): apply access levels to MCP tools and every agent
MCP tools get a risk: the workspace's explicit setting, else the service's
readOnlyHint, never lower than a risk the service declared before. The
run's access level now decides MCP calls as it does operations; read-only
runs neither see nor run tools that change data. Ordinary agents get a
configurable ceiling that defaults to auto_write, and delegated children
take the lower of their parent's level and their own ceiling instead of
asking for every MCP call.
* feat(agent): persist approval grants with session/automation scopes
Remembered "allow for this conversation" approvals move from prompt history
into an agent_grants table keyed by root session (or automation binding), so
delegated children share the root grant and unattended runs honour it.
MCP write tools now offer the grant, keyed by service, tool and input schema.
Users can list and revoke their grants from the chat header.
* feat(agent): acting-via identity, decision logs and grant lapse reasons
Principal gains ActingVia so work done on a user's behalf (automations) is
told apart in audit details and policy decision logs. Every non-read policy
decision is logged with its action, risk, level, mode and verdict.
Automation grants bind to a hash of the agent setup, owner role and access
ceiling; a grant that no longer applies asks again and the card says why.
* docs(agent): record permission model implementation status
* chore(handler): check c.Error in agent grant handlers
* chore(handler): check c.Error in MCP tool policy handler
* fix(agent): raise MCP observed risk atomically and scope worker access
- Compare observed_risk inside the upsert so a stale lower observation
cannot overwrite a higher one recorded concurrently.
- Delegated workers use the same conditional level as attach: the
assistant ceiling applies only under an assistant parent.
- Mock @/api/assistant in useModalShell tests; gofmt internal/mcp/client.go.
* docs(agent): allow destructive pre-grants only in automation scope
Decide against a level that skips every prompt: Always stays
unwaivable and destructive actions may only be pre-approved per resource
when an automation is set up. Note that automation runs must look up
both automation and session grants.
* feat(agent): standing grant scope and risk-bounded grants
Grants record the risk they were approved for and never cover a riskier
call. Destructive calls are now named for matching, so an automation's
standing grant can cover one, but the card still offers to remember only
writes. The gate looks up the run's own scope and then its standing
scope; approvals during a run are written only to the run's scope.
* fix(agent): let open_page finish the turn with the answer above it
Split page navigation into a separate view_page tool, keep the answer
written before an open_page button as the final reply, and tidy the
grouped progress updates in the timeline.
* style(assistant): align child agent rows, tabs and task brief with the timeline
Child task rows become single-line timeline steps with a light sweep while
running, tabs pulse and shimmer for running children, collaboration tools
share the agent mark, and the task brief card is lighter and renamed.
* fix(agent): deliver child agent messages as tagged user input
Child results were injected as assistant turns, so the parent read the
envelope as its own words and imitated it in visible replies. Deliver them
in <agent_message> blocks in the user position, escape spoofed closing tags,
and tell the parent never to reproduce the envelope.
* fix(ci): wrap the page button test fixture within the line limit
* feat(assistant): add persistent multi-agent collaboration and live task views
* fix(ci): wrap runtime notice message append
* fix(agent): preserve collaboration results and prevent duplicate execution
* fix(agent): fence panic followups and preserve approval timelines
* test(frontend): stub connector labels in assistant refresh fixture
* fix(migrations): avoid collaboration migration collision with main
* fix(assistant): preserve child continuations and artifact access
* fix(frontend): align artifact and icon checks with updated UI
* fix: enforce child approvals and finalize interrupted collaboration runs
* feat: support inherited temporary agent workers
* docs: clarify inherited worker scope and lifecycle
* fix: harden assistant retrieval and final delivery
* fix(agent): keep closed child prompts continuable and renew active deadlines
Expired child approvals were looked up by the child session, so the parent group stayed open and the run became needs_attention. Active collaborations also expired one hour after creation.
* fix(lint): clear golangci-lint findings on the collaboration PR
The previous CI run failed on line length, gofumpt, unchecked closes, and an unused dial parameter.
* fix(ci): use the public npm registry for frontend dependencies
* fix(agent): address collaboration review findings
- keep ordinary fallbacks when a turn delegated no work
- throttle lease/deadline heartbeats and drop duplicated child answers
- force-close or compact aggregates that exceed the size limit
- clamp completion budget to the model output limit
- honor prompt_suspend for non-collaboration tools
- clean up collaborations and child sessions on session delete, prune old rows
- bound concurrent child executions globally
- retry prompt classification and tolerate transient heartbeat errors
- scope prompt history to listed messages, reject nil tenants
* fix(knowledge): show recursive folder counts in the folder tree
Connector-synced knowledge bases now come with multi-level folders, so a
parent folder often holds no documents of its own while its subtree holds
several. The folder tree, the breadcrumb and the empty state all read
document_count (documents directly in the folder), so those parents rendered
0 and the document list stated "this folder has no documents yet" even though
the documents were one level down. The API was already correct: total_count
carries the recursive number.
- KbFolderTree renders the row's totalCount; the existing tooltip still spells
out the direct/recursive split.
- KnowledgeBase reports the selected folder's recursive total in the
breadcrumb. Filtering keeps the flat result count, and a tree that is
missing or stale falls back to the loaded list total.
- The empty state gains a third branch for folders whose documents all live in
sub-folders, with a new emptyFolderWithSubfolders message in all six locales.
- folderTree.ts exposes folderDocumentCounts() and shares the node lookup with
childFolders().
Tests render the tree through Vite SSR (a 0/5 parent and the root row) and
cover the breadcrumb/empty-state computed values plus the template wiring.
* fix(knowledge): count sub-folders beside the breadcrumb document count
The breadcrumb reported the selected folder's recursive document total while
the document list only renders that folder's own documents. A folder holding 2
documents and 1 sub-folder therefore claimed "3 documents" next to a list of 2.
Report the two numbers the page can actually account for, the way the DingTalk
original does: "{documents} documents / {folders} folders".
- The breadcrumb renders a new two-part folderContentsCount message in all six
locales. Browsing counts the loaded list total (the documents on screen) and
the folder's direct sub-folders; filtering keeps the flat result count and
adds no folder number, since it searches documents rather than folders.
- The sub-folder number is childFolders().length: the tree's top-level folders
at the root, the selected node's children in a folder, and 0 when the tree is
unavailable or the path is stale.
- The recursive total stays where it is useful: the tree row (totalCount) and
the empty state, whose folderSubfolderDocumentCount is a different quantity
(documents below the folder) and is left untouched.
* fix(knowledge): list sub-folders in the document views
Render the current folder's direct sub-folders as rows in the list and as
cards in the grid, ahead of the documents, so browsing matches a file manager
and the DingTalk folder view. Folder entries are navigation only: they carry
no batch checkbox and never enter document selection or sorting.
Filtering still searches the subtree and shows documents only. When the folder
tree is unavailable the views receive an empty list instead of crashing.
Also hide the breadcrumb's folder segment when the folder has no sub-folders
(falling back to the document-only message) and pluralize the folder count in
English and Russian.
* fix(knowledge): use t-icon sizes so the style guard stays at its baseline
The folder row/card icons were sized with literal CSS font-size values,
which the style guard counts against a fixed baseline. Use the t-icon size
attribute instead, as the guard's own guidance asks.
* fix(knowledge): preserve folder list icon size after style guard cleanup
---------
Co-authored-by: linus-liu-web <linus-liu-web@users.noreply.github.com>
Co-authored-by: wizardchen <wizardchen@tencent.com>
jsonToMarkdown decoded the upload with json.Unmarshal, which turns every
number into a float64. An id above 2^53 therefore changed digits:
12345678901234567890 came out as 12345678901234567000, and
9007199254740993 as 9007199254740992. 1.50 became 1.5 and 1e5 became
100000. The decoder now uses UseNumber, and each number is written back
exactly as it was in the file.
The chunks were encoded with json.Marshal, which escapes <, > and & for
embedding in HTML, so "a < b && c > d" was indexed as
"a \u003c b \u0026\u0026 c \u003e d". They are now encoded with HTML
escaping off, in the size measurement as well, so a chunk is measured as
it is written.
web_fetch stopped at 60s inside the page fetch. The tool wrapper, storePage,
and the HTTP and chromedp fetcher each had their own cap, so a page that
needed about 150s never finished.
WEKNORA_WEB_FETCH_TIMEOUT is the single page budget (default 3m). HTTP and
chromedp share it, and the agent wrapper waits 5 seconds longer so the tool
can return its own result. Other tools and the 15s pipeline fetcher keep
their current timeouts.
Fixes#2298
Co-authored-by: Frank-zhu2000 <332350688+Frank-zhu2000@users.noreply.github.com>
HTML and MHTML uploads turn tables into GFM through markdownify, which
writes a pipe in a cell's text as is. That pipe ends the cell, so
<td>a|b</td> became two cells and every later cell in the row moved one
column right. Pipes in table cell text are now escaped before the
conversion, as `\|`.
The escape then has to survive MarkdownTableUtil, which normalizes the
converted tables and split rows on every pipe: `| a \| b | c |` came out
as a three-column row with the escape turned into `\ |`. It now splits
on unescaped pipes only; a pipe after an odd run of backslashes is cell
text, as in the Go chunker since #3979.
* feat(assistant): let the assistant find skills and MCP services on the web
Enable web_search/web_fetch for the WeKnora assistant so it can locate a
skill source or MCP endpoint from a description, with prompt guidance on
sources, injected page text, console-only credentials and a missing search
provider. mcp_service.create now always asks the user.
Agent trials no longer stall on prompts nobody can answer: tool approvals
are refused at once and OAuth falls back to the non-interactive notice.
* fix(ci): wrap the unattended approval test constructor
golangci-lint rejects the NewGate call at 127 characters.
* fix(assistant): polish interaction cards and stabilize composer context
Localize operation labels across all six UI languages and expose answer copying in the assistant panel. Refine question and page-link cards with a single open/return action, and keep the current-page context row at a stable height.
* feat(assistant): add common data source, chunk and knowledge base operations
* feat(assistant): support parsing configuration and batch FAQ updates
* feat(assistant): add MCP tool directory query and sync operations
* feat(assistant): manage web search providers and data source sync settings
* feat(assistant): add model configuration copy operation
* feat(assistant): add workspace profile members and system information operations
* feat(assistant): add system administrator queries and runtime diagnostics
* fix(frontend): polish assistant and resource card UI
Refine assistant composer layout, context controls and reply actions, including narrow-window alignment. Unify knowledge base, agent and shared-space cards with consistent icons, hover feedback, favorites, menus and compact localized statistics.
* fix(assistant): preserve concurrent settings and exclude upstream error secrets
* fix(knowledge): leave the root span open while a retry is left
FailSpan closed the attempt root as failed on any main-stage failure, but
asynq retries reuse the payload and record onto the same attempt. Once the
root is terminal FinalizeAttempt returns on its guard, so a retry that
succeeds leaves the root failed while every child span and the document
itself report completed.
Defer the root's terminal status until the runner has no retry left, using
the same counters ProcessDocument already computes isLastRetry from.
* fix(knowledge): distinguish terminal span failures from retryable errors
---------
Co-authored-by: wizardchen <wizardchen@tencent.com>
pickDefaultEngineName guessed the default from engine availability order,
so it badges anydoc as the PDF default while preferAnydocWhenAvailable
deliberately excludes PDF, and it labels builtin as the default for the
simple formats the Go reader actually handles.
Mirror the three backend routing tables instead of guessing, and pin the
mirror with a per-group assertion table.
The upload panel split every file still parsing into chunks of 40 and
sent all chunks at once on each poll. With a few thousand files in
flight that is 100+ parallel /api/v1/knowledge/batch requests every
few seconds, each holding a Postgres connection, which exhausts the
default max_connections=100 (FATAL: sorry, too many clients already).
Keep at most 4 status requests in flight per poll; the remaining chunks
are queried as earlier ones finish.
Claude-Session: https://claude.ai/code/session_014ENAekfB7Um4VUnzUWWAv1
* feat(assistant): let the assistant check MCP services and retrieval
Add a probe risk for operations that change nothing but do real work
(connecting to a service, running a retrieval). Probes use POST, run
without approval at every access level, and are capped per run.
Open three operations on top of it:
- mcp_service.test: connect with the saved settings and report why not
- mcp_service.list_tools: list what a service offers before binding it
- knowledge_base.search: raw hybrid recall with thresholds, to explain
why a document is or is not found
x-agent can now name one method when a handler documents several, and
catalog parameters accept numbers.
* feat(assistant): let the assistant try an agent it set up
Add try_agent: the assistant asks an agent one question the way a user
would and gets back its answer, the tools it called and the documents it
cited, so it can check a setup before calling it done.
- The trial runs as the signed-in user in a new agent_trial session kind,
which ordinary listings already exclude and the API cannot create, and
the session is removed afterwards. Runs are non-interactive, so tools
that would ask the user are refused. Long-term memory is untouched: it
is written only by the HTTP handler.
- The assistant itself, the Wiki fixer and the skill installer cannot be
tried, nor any agent granted the operation catalog.
- A trial spends model calls and runs the agent's own tools, so it is a
write for the access level: confirm asks, auto_write runs, read_only
does not offer it. The confirmation card names the agent and question;
ConfirmedTool now lets a wrapped tool supply that text.
- At most 3 trials per turn, 4 minutes each; the tool timeout is raised
above that. Answers, tool errors and references are capped.
- The runner is bound to the session service after the container builds
it, since the session service depends on the agent service.
* feat(assistant): let the user allow similar changes for the conversation
The confirmation card for a recoverable change now offers "allow this for
the rest of the conversation". Once chosen, later calls of the same kind
in the same session run without asking, so a batch tidy-up no longer
needs a click per item.
- What a grant covers is derived on the server, never taken from the
model: the same catalog operation on the same knowledge bases (a
document's knowledge base comes from the target read) or the same
agent; the same Wiki tool on the run's Wiki knowledge bases; trials of
the same agent. Deletions and operations without such a scope, such as
creating a knowledge base, always ask.
- No new storage: the gate looks for an earlier approved prompt in the
session with the same grant and allow_in_session set, for the same
tenant and user. Grants therefore survive suspend/resume and replicas,
and end with the conversation. A failed lookup asks again.
- The response validator accepts allow_in_session only on approval and
only when the prompt offered a grant, so a client cannot widen it.
- The card shows the scope in the user's language. The model is told
such calls may run without a card and that deletions always ask.
- describeTarget now returns its target read so the grant reuses it
instead of reading again.
* feat(assistant): tell the assistant about settings pages and chat answers
Pages now report which page is open and, for the agent editor, which
section. The model and MCP settings name the model or service open for
editing, and chat answers gain an "ask the assistant" button that
attaches that answer. The backend resolves these for the assistant only:
models and MCP services in the caller's tenant without endpoints or
credentials, and messages through the caller's session read access, with
the question, an answer excerpt and cited sources quoted as data.
* feat(assistant): link the user to pages and filled-in forms
The assistant gains open_page, which shows a button to a knowledge base
or document, a Wiki page, an agent's editor at a tab, a model or MCP
service to edit, or a new model or MCP service with its form filled in.
Targets are read through the operation catalog as the user, so a link
never points at something they cannot open. Drafts take no credentials
and only http(s) endpoints without user info; the card shows the
endpoint, and the user enters keys and saves the form themselves.
* feat(assistant): manage MCP services, model names and skills
* fix(assistant): prefill model drafts on initial navigation
* feat(assistant): document tags, model catalog reads, clearer cards, live page refresh
- Operations project lists of objects; knowledge.get/list report tags.
- model.get shows provider, endpoint and capabilities; new
model.list_providers and model.get_provider read the model catalog,
including vendors an admin added.
- open_page and ask_user guidance: offer page buttons whenever the next
step is the user's, word choices for the user.
- Chat cards: redesigned open-page card pinned under the final answer,
ask-user inputs in the dock style, approval card with aligned fields,
translated labels and a question built from the operation summary.
- Open pages reload after assistant changes: deletes and moves wait for
the background task, Wiki edits now report their changes, KB list
counts, tags and chat model selectors refresh.
- The assistant panel stays open across reloads within the tab.
* fix(ci): format assistant operation code and wrap long lines
* feat(assistant): let the assistant see, fill and open the page beside it
- read_page / fill_page tools answered by the browser over a page_action prompt,
with refs, redaction, in-place text edits, undo card and a page-access switch
- composer shows the open page, dialog and selection; a selection bubble and an
editor toolbar entry ask the assistant about the selected text
- edits scroll into view with a highlight and an inline undo bar
- open_page reaches any settings section, toolbox tool and list page, and can
navigate there itself to read it, keeping the button when edits are unsaved
* feat(assistant): let the assistant open the tab it needs
A visible tab can be selected and re-read, and system settings can open straight to user management, so the next step is no longer blocked on the wrong tab.
* feat(assistant): expose read-only conversation operations
Add session.list, message.list, message.search and
message.chat_history_stats to the operation catalog, restrict the
sessions and messages areas to non-mutating operations, and search
messages with the raw query instead of the log-sanitized one.
* style(chat): restyle open-page and page-edit cards
* fix(ci): comply with assistant card styles and Go line limits
The compile step sits after `COPY . .`, so every source change invalidates
it. Without a build-cache mount each rebuild regenerates the whole Go
compile cache inside that layer (~2.7 GB): it accumulates in the local
builder cache, and since CI exports intermediate layers
(cache-to: type=gha, mode=max) it is uploaded to the GitHub Actions cache
whose per-repository storage limit is a hard 10 GB.
Mounting /root/.cache/go-build keeps the cache outside the layer: repeated
local builds reuse compiled objects instead of recompiling everything, and
the cached/transferred layer shrinks from ~3 GB to ~265 MB (the compiled
binary). Multi-stage output is unchanged - the final stage still copies
only the binaries and assets it names.
Co-authored-by: tayadwx <tayadwx@users.noreply.github.com>
* fix(tools): reject legacy binary .xls with an actionable error
DuckDB's excel extension only reads the ZIP-based OOXML container
(.xlsx/.xlsm). A genuine binary BIFF .xls therefore fails deep inside
read_xlsx with "No xl/workbook.xml found in xlsx file", which neither
names the real cause nor says what to do; the multi-sheet .xls in #4239
surfaced exactly this way and left the agent with an empty table.
Sniff the OLE2/CFB signature by content (not by extension, so a renamed
.xlsx keeps working) and fail up front with a message that names the
conversion to perform. The tool description is updated so the model is
told the same thing before it calls the tool.
Refs #4239
* fix(tools): wrap the legacy-xls warning under the line limit
---------
Co-authored-by: Jay0130-a <Jay0130-a@users.noreply.github.com>
Endpoint.Do bounds the error body at 1 MiB. Thirty lines below it, roundTrip
read the success body whole, and the four chat protocols each did the same in
their own read: a reply was buffered without limit before anything inspected it.
The older models/chat layer already caps the same replies at 20 MiB.
Cap them through one helper, and return an over-cap body without the
TransportError wrapper. withRetry retries only TransportError, and repeating an
oversized reply would bill the request again for the same bytes - the same
reason its own doc gives for not retrying a reply that arrives whole but does
not decode.
64 MiB clears every payload the catalog can legitimately return: an embeddings
batch is bounded by BATCH_EMBED_SIZE (default 5) times the model dimensions, and
a chat reply by the model's output-token ceiling. Streaming replies are
assembled incrementally and are unaffected.
An embedding row with spec.input image and no image_format or image_field
was treated as text-only on every vendor except generic and Jina. Default
that case to the vLLM messages format. An explicit object format without a
field stays refused.
Fixes#4343
A MinerU result package arrives over the network from a third-party parse API and
was buffered whole before anything about it was validated. The Cloud converter
downloaded it with an unbounded io.ReadAll, even though the V1 client already caps
the same artifact at mineruV1MaxZipBytes - the two implementations of one feature
disagreed about the limit.
Decompression was unbounded on every path. readZipEntry and readZipEntryBytes
called io.ReadAll on a decompressed archive entry, and extractMarkdownZip keeps
every extracted image in memory until the caller hands the slice on, so a package
of many small entries expanded without ever tripping a per-entry check. The
declared UncompressedSize64 is attacker or vendor controlled and may understate
the expansion, so the header is checked and the read is capped as well.
Cap the download at the V1 ceiling, each entry at maxZipEntryBytes, and the
accumulated images at maxZipImagesTotalBytes. The image budget is a parameter on
extractMarkdownZipBounded so a test can exercise it without materialising the
production figure, mirroring the jsonLimit field added in #3985.