* chore: Replace tunnel-agent with https-proxy-agent
* fix: Keep the target host in proxied HTTP request URLs
* test: Move test proxy into test support
* chore: Prune redundant comments and normalize lint directives
Removes comments that restate the following line and stale TODOs, drops
the passive event listener feature check now that all supported browsers
support it, and renames eslint directives to oxlint.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BehTjuZwKbN5csMCp3H4QH
* fix: Evaluate restricted team domains at validation time
The restricted email provider list was captured when the model loaded, so
it could not follow the hosting environment and the tests that covered it
never reached the model.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BehTjuZwKbN5csMCp3H4QH
* chore: Replace type suppressions with accurate types
Adds a Concrete helper type for registries of abstract classes, declares
missing Sequelize and refractor typings, uses public ProseMirror APIs, a
typed mock context helper in middleware tests, and a StaticLink component
for sidebar rows being edited.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BehTjuZwKbN5csMCp3H4QH
---------
Co-authored-by: Claude <noreply@anthropic.com>
* feat: Personal collections backend
Adds an owner to collections. A personal collection is private, one per user
per team, created lazily through collections.personal, and only its owner can
see or manage it. Admin bypasses in policies, lists, exports, events, webhooks
and file operations exclude the personal collections of other users. Turning
off the PersonalDocs preference makes the collection read-only.
* test: Access matrix for personal collections
Checks that collection and document endpoints, list and search results, MCP
tools, collaboration and websocket rooms agree with the read policy for the
owner, collaborators, members, admins, guests and other teams.
* feat: Personal collection in the sidebar
Adds a Personal sidebar section that renders the personal collection with the
collection document tree, creates the collection on the first new document,
and keeps it out of the Collections section. Adds the workspace setting, the
personal sidebar context, and hides collection sharing and membership UI for
personal collections.
* fix: Drag and drop in shared with me trees
Anchors the reorder drop cursor inside the row, and prefetches documents on
hover so that nested rows that were never opened can be dragged.
* feat: Personal collection owner for collaborators, no collection page
Presents the owner of the personal collection on documents, so that
collaborators see the owner in the share popover. Root rows in the Personal
section show the default document icon. A personal collection has no page:
the scene shows not found, and the breadcrumb, command bar and delete redirect
no longer link to it.
* fix: Personal sidebar indent and breadcrumb items without a link
Children of rows at depth 0 skip a level so that they start beyond the row
icon. Breadcrumb items without a destination, such as the personal and deleted
collection, are shown as plain text.
* test: Reduce personal collection tests to list paths
Endpoints that authorize a single model are already covered by the policy
tests. Keeps the lists and searches, which filter in queries, and the
presenter.
* test: Move personal collection list tests into collections tests
* feat: Create documents in the personal collection by alias
documents.create, documents.import and the MCP create_document tool accept
the collectionId "personal", which refers to the personal collection of the
user and creates it when it does not exist yet.
* refactor: Remove collections.personal route
The sidebar creates its first personal document with the personal
collectionId alias, so documents.create is the only path that creates the
personal collection.
* feat: Personal collection name, starring, templates and default
Personal collections cannot be starred, renamed or hold templates, and the
PersonalDocs preference is on by default. The app shows collections through a
displayName getter, which is the translated "Personal" for a personal
collection.
* fix: Use the same policy for starring and unstarring collections
* fix: No pins or viewer insights for personal documents
* revert: Show personal collection events in the audit log
Admins with audit access should see events in personal collections, even when
they cannot open the documents.
* fix: Load collection owner in share scopes
* fix: Keep personal collections out of workspace exports and webhooks
Workspace exports skip all personal collections, while an explicit export of
a personal collection stays available to its owner. Events in personal
collections, including attachments and documents moved after queueing, are
never delivered to workspace webhooks. Personal collections cannot be
renamed or made public through any path, cannot hold pins, and are not
offered as mentions.
* Change icon to avatar
* fix: Personal documents cannot be unpublished
* feat: Personal collection context for MCP
Collections are presented with an isPersonal flag, the server instructions
explain the personal collection, and move_document and update_document accept
the personal collectionId alias.
* fix: Keep moved personal exports private and remove pins on move
Document exports record the owner of the personal collection they came from,
so they stay private after the document moves. Moving documents into a
personal collection removes their pins, including pins to home.
* fix: Only create the personal collection in MCP when it is used
* feat: Support OAuth Client ID Metadata Documents for MCP clients
MCP clients can send an https URL as their client_id. The server fetches
the metadata document at that URL and caches one team-less client row per
URL, so MCP works on the root domain without dynamic registration.
Closes#14010
* fix: Address review findings for client ID metadata documents
- Only count unexpired tokens when cleaning up metadata document clients
- Reject backslashes, whitespace and trailing host dots in client_id URLs
- Strip trailing dots before installation host comparisons
- Type clientSecret as nullable
* fix: Keep OAuth clients with pending authorization codes during cleanup
* refactor: Simplify client ID metadata document handling
- Gate metadata document fetches on the MCP preference inside the helper
- Add isMCPClient getter and a shared client ID prefix constant
- Enforce the team/metadata document CHECK in both directions
- Index oauthClientId on OAuth token and code tables
- Reuse parseDomain, clamp and time helpers
* revert: Remove pending authorization code check from OAuth client cleanup
* fix: Block all special-use addresses when fetching client metadata documents
ALLOWED_PRIVATE_IP_ADDRESSES no longer applies to client ID metadata
document requests (draft -02 section 8.6). The fetch wrapper takes an
allowIPAddressList option to override the environment list.
* fix: Reject empty userinfo in client metadata document URLs
https://@host and https://:@host have a userinfo component that the URL
parser drops, so check the raw authority (draft -02 section 3).
* fix: Accept a root path in client metadata document URLs
Draft -02 section 3 marks a root path as NOT RECOMMENDED, not invalid, so
https://example.com/ is a valid client_id. A URL with no path is still
rejected.
* fix: Reject client metadata documents with private key material
A jwks key with private or symmetric members (d, p, q, dp, dq, qi, oth,
k) makes the document invalid, so it is not cached (draft -02 section 4.1).
Public keys are still ignored.
* fix: Respect no-cache, no-store and Age for client metadata documents
no-store and no-cache now expire the cached document at once, so it is
fetched again before the next authorization. Freshness from max-age or
Expires (measured from Date) is reduced by Age before clamping (draft -02
section 5.2).
* feat: Copy DCR and CIMD client logos to file storage in the background
logo_uri was rendered directly on the consent screen, which lets the logo
host track users and change the image at any time (draft -02 sections 8.8
and 9.2). A background task now fetches the logo with the strict fetch
rules, accepts only PNG, JPEG, GIF and WebP by their leading bytes, and
stores it content addressed in the public bucket. Requests never wait for
the upload.
* fix: Match loopback redirect URIs on any port
Native apps such as Claude Code register http://localhost/callback and
then listen on a free port, so an exact match rejected them. Loopback
redirect URIs now match on any port (RFC 8252 section 7.3); the scheme,
host and path must still match, and other URIs still match exactly.
* fix: Only break the redirect URL mid-word on the consent screen
break-all on the whole notice split words such as "continue" in the
loopback warning. It now applies only to the redirect URL.
* chore: Shorten the loopback warning on the consent screen
* fix: Show the punycode host of client metadata documents on the consent screen
A lookalike Unicode host was shown as written. Hostnames now come from a
shared getHostname helper that returns the punycode form.
* refactor: Move image type detection to ImageHelper and use it for avatars
Avatars and integration logos copied from a URL are now stored only if
they are PNG, JPEG, GIF or WebP, with the content type detected from the
file data rather than the remote host.
* fix: Address review findings for OAuth client logos and metadata caching
- Count the time since the Date header as age when caching metadata
documents, so a document is not cached past its Expires time
- Log logo scheduling failures instead of failing registration requests
- Run dynamic client registration in a transaction
- Delete copied logos from storage when no client uses them
* fix: Store one logo per OAuth client and return a distinct metadata document error
- Logos are stored per client, so a file is only deleted when its own
client stops using it. This removes the reference count and its race.
- A metadata document that cannot be fetched or is invalid now returns
invalid_client_metadata with the reason, not a 404. Network errors
are only logged.
- Move scheduleOptional to BaseTask so that any task can use it.
Adds a server-shared Vitest project with isolate disabled and moves every
server test into it by default. Files that mock or reset modules opt out
with a header marker and stay in the isolated project.
Restores env values that leaked between files: the test URL is reset after
each file, and tests that mutate env restore the previous value. The test
server no longer closes the shared sequelize pool.
* fix: Warn before discarding unsaved template changes
Template content is only persisted when the form is explicitly submitted,
so navigating away or closing the tab silently lost everything typed.
Adds a navigation Prompt and a beforeunload handler to both template
scenes, and reverts the model on unmount so abandoned edits no longer
leak into other views rendering the same record.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix: Persist templates from the first keystroke
New templates were held only in browser memory until Save was pressed, so
a refresh, crash, or stray navigation lost everything written.
Templates are now created up front as an unpublished draft and autosaved,
mirroring how documents behave. Drafts are visible only to their author
until published, and are cleaned up if abandoned while empty.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix: Preserve icon edits made during an in-flight template save
applyEdits only restored title and content, so an icon or color changed
while a save was in flight was overwritten by the response and never
re-saved.
Pending edits are now tracked as a single record covering every field the
form can change, rather than one ref per field.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* feedback
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix: Friendly error and retry for duplicate team subdomains
Picking a subdomain already in use in settings surfaced the raw unique
constraint violation as a 500, and concurrent signups could race between
the availability check and the insert.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* test: Use setCloudHosted helper rather than spying on env
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* refactor: Move retryOnUniqueConstraintError to storage/database
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
* feat: Import PDF documents
Adds a PdfConverter that parses PDF files to markdown with pdf-inspector,
recovering headings, lists and tables from the layout of the text on the
page. A PDF with no embedded text is rejected, as reading it would need OCR.
Markdown has no syntax for underline, so the parser writes underlined text
as an HTML <u> element. Inline HTML is not enabled when the markdown is read
back, so the tags are rewritten to the underline syntax the editor knows.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* Accept PDF files in the import dialog, and give it a two column layout
The supported formats move alongside the drop target rather than below it,
so the dialog reads in one glance. Their badge icons are dropped with the
grid they were laid out in, leaving FileFormatIcon unused.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* feedback
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
* feat: Add TextPack (.textpack) import support
Adds a single-document importer for TextPack, the zipped variant of
TextBundle used by Bear, Ulysses, iA Writer and others. Bare .textbundle
directories are not supported, as a directory cannot be delivered through
a browser file input.
The bundle's text entry may use any extension, per the spec, with
info.json's type deciding whether it can be read as markdown. Assets are
inlined as data URIs for the existing attachment pipeline to pick up,
bounded by the attachment size limit and a memory ceiling, and only for
media types markdown-it accepts as a link destination.
Also fixes an existing bug where a file embedded in an HTML or email
import as a data URI was stored in the document as base64 rather than
being uploaded as an attachment.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* Refactor to individual converters
* refactor
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
* feat: Add support for web page and email import
* fix: Type mailparser result explicitly
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* Combine HTML and Web Page
* fix: Validate mime type before inlining MIME archive parts
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
* Reduce server memory usage and add container memory best practices
Profiling a full-service boot showed ~300MB RSS per service process, much
of it client-only dependencies pulled into the server module graph, and no
heap limits applied in containers:
- Import date-fns locales individually rather than via the locale index,
which loaded all ~90 locales into every process
- Load @sentry/react dynamically in insertFiles so the browser Sentry SDK
stays out of the server-side editor graph
- Replace class-validator isHexColor with the existing validateColorHex
in the Highlight mark
- Extract icon names into a standalone IconNames module so server-side
schema validation no longer imports Font Awesome icon packs, with a
test to keep it in sync with IconLibrary
- Require S3Storage lazily so the AWS SDK and native CRT binding are only
loaded when S3 file storage is configured
- Default each forked service process to a V8 heap limit derived from the
cgroup memory constraint, preventing several processes from together
committing more memory than the container allows
- Cap glibc malloc arenas in the Docker image to reduce resident memory
fragmentation in multi-threaded processes
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016YMX5ReGHyxrR4ZE5ZbaXa
* Require both file storage backends lazily for consistency
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016YMX5ReGHyxrR4ZE5ZbaXa
* Load AWS SDK via dynamic imports compatible with test environment
Requiring the storage TypeScript modules lazily broke under Vitest, which
cannot resolve require() of source files and does not apply vi.mock to
bare requires. Move the laziness into S3Storage instead: the module is
imported statically, and the AWS SDK packages are loaded with dynamic
imports on first use, including deferred creation of the S3 client.
Also address review feedback: handle rejection of the dynamic Sentry
import, and warn when the minimum per-process heap limit exceeds the
memory budget of the container.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016YMX5ReGHyxrR4ZE5ZbaXa
* Consolidate S3 SDK loading into a single lazy accessor
The commands are loaded together with the client in getS3() rather than
as separate dynamic imports per method. The global S3Client test mock is
now a class, as a mock function is not constructable when reached through
a dynamic import.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016YMX5ReGHyxrR4ZE5ZbaXa
---------
Co-authored-by: Claude <noreply@anthropic.com>
* fix(mcp): return text content for empty list tool results
When MCP list tools return zero items, success([]) previously produced
an empty content array. Anthropic's MCP connector rejects that format.
Return a single JSON text block for empty arrays so clients can
distinguish no results from a broken tool response.
Fixes#12858
* test(mcp): handle empty list sentinel in integration tests
Add parseMcpListContent helper for the [] sentinel block and update
list tool tests that can receive zero results.
* test(mcp): fix list_collections type assertion in integration test
---------
Co-authored-by: syf2211 <syf2211@users.noreply.github.com>
* fix(test): restore plugin loading under Vite 8
Vite 8 dropped support for extglob negation (`!(...)`) in glob patterns,
so the test setup's plugin glob matched zero files and no plugin routes
were registered, causing every plugin API test to 404. Use Vite's
array-with-negative-patterns syntax to exclude test and schema files.
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* chore: Update JSON importer to use zip streaming, new importer flow
* chore: Drop teamId from import urlId collision check and remove unused internal-id scaffolding
urlId is globally unique on Document/Collection so the team scope was wrong.
Also removes leftover internal-id generation in JSONAPIImportTask that was
never used in task input/output.
* Restore classes used upstream
* Auto-subscribe mentioned users to documnet
* Add tests for mention auto-subscribe and a buildMention factory
* Add tests that prior unsubscribes are respected when mentioned
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* Batch mention subscriptions into a single transaction
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
* wip
* Remove obsolete snapshots
* simplify
* chore(test): Convert mocks to TypeScript and tighten fetch mock types
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* Remove unneccessary patches
* Migrate to msw instead of custom fetch mock
* Address PR review comments
- Split chained vi.useFakeTimers().setSystemTime() into separate calls.
- Switch test setup to dynamic imports so EventEmitter.defaultMaxListeners
assignment runs before module init (static imports were hoisted above it).
- Drop redundant NODE_ENV guard in monkeyPatchSequelizeErrorsForJest; its
sole caller already gates on env.isTest.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
* chore: Replace lodash with es-toolkit
Migrate all direct lodash imports to es-toolkit/compat for a smaller,
faster, lodash-compatible utility library. Transitive lodash usage from
other packages remains unchanged.
* fix: Restore isPlainObject semantics in CanCan policy
The lodash migration aliased `isObject` to `lodash/isPlainObject` and
the codemod incorrectly mapped the local name to es-toolkit's `isObject`,
which also returns true for arrays and functions. This caused condition
objects in policy definitions to be skipped, breaking authorization
checks across the codebase.
* fix: Restore unicode-aware length counting in validators
es-toolkit/compat's size() returns string.length, while lodash's _.size()
counts unicode code points. Switch to [...value].length to preserve the
previous behavior so multi-byte characters like emoji count as one.
* chore(test): drop no-op per-test Redis flushall
The afterEach created a fresh ioredis-mock client and flushed it, which
doesn't clear state held by clients elsewhere in the test. Removing the
hook saves a few ms across thousands of test cases.
* Cache Jest transform cache
* fix: Suspended users should not be included in cached member count for groups
* fix: Defer CounterCache hook registration until model is initialized
The previous test-only no-op hid a timing bug where setImmediate could
fire before the Sequelize instance had registered the related model,
causing "Model not initialized" failures. Poll until the model is
ready, and unref the pending immediate so it does not keep the event
loop alive in environments where the database is never initialized.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* perf: Reduce overhead of group member count invalidation
Select only the groupId column with raw queries and de-duplicate before
issuing Redis deletes, avoiding loading full GroupUser rows into memory
when a user belongs to many groups.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* chore: unref Redis healthcheck interval
Don't keep the Node event loop alive solely for the periodic ping; the
event loop should drain on its own when the application is shutting
down or a Jest worker is finishing.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor: Centralize counter cache key in RedisPrefixHelper
Avoid duplicating the "count:<Model>:<relation>:<id>" string between
the CounterCache decorator and the User suspension hook by routing
both through a single getCounterCacheKey helper.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix: Walk to parent transaction when scheduling cache invalidation
Nested savepoints commit independently of their outer transaction, so
afterCommit callbacks attached to the inner transaction may run after
the outer rolls back, or never run at all. Match the pattern used in
Collection, Event, and base/Model and walk to the parent transaction
so the cache invalidation fires after the real outer commit.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
* chore: Reduce no-explicit-any warnings in server directory
Tightens types across test response bodies, decorator signatures, the
TestServer wrapper, base class generics, and presenter Record types.
Where any is genuinely load-bearing (Sequelize model generics,
PropertyDescriptor decorator returns, plugin-registered template
classes, Fix mixin), keeps any with a targeted eslint-disable plus
reason rather than masking the constraint. Cuts server-only
no-explicit-any warnings from 162 to 70.
* fix: groups test asserts on first response instead of second
Caught by Copilot review on the no-explicit-any cleanup. Also fixes
the pre-existing getChangsetSkipped → getChangesetSkipped typo
surfaced while reviewing nearby decorator code.
* First pass
* Remove popularity changes
* Address review feedback
- Compute retention cutoff in UTC from the database rather than worker-local TZ
- Push partition predicate into rollup source CTEs to avoid full-table scans per partition
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* Anchor insight rollups to UTC and include today
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
* fix: Correctly validate uploaded file size using local storage option
* fix: Normalize attachment size from BIGINT before comparison
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
* chore: Update modelcontextprotocol
* fix: Restore native Web API classes after jest-fetch-mock setup
jest-fetch-mock replaces globalThis.Response with a cross-fetch polyfill
that doesn't support Web Streams (ReadableStream bodies become Buffers).
The MCP SDK's @hono/node-server adapter calls response.body.getReader()
which fails with the polyfilled Response. Since dontMock() is already
called, preserving the native classes is the correct behavior.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* fix: Data always included in list_documents response
* Remove resources, add fetch tool
Fix pagination arguments do not accept string
* type -> resource
* Add URL resolving