@alwith/module-drive

中文文档
0.6.2发布于 2026/11/05SEE LICENSE IN LICENSETypeScriptES Module零依赖构建来源已验证近 30 天下载 2880

Pre-release shared Drive module. This package ships the frontend and the private native Drive library (native/); the Tauri plugin alwith-drive (crates.io) carries the public types, typed commands and the transactional Rust API. Frontend and library ve

原始使用文档
文档目录5 节
  1. Entry points
  2. Host contract
  3. Current boundaries
  4. Development
  5. Desktop capabilities

@alwith/module-drive

Pre-release shared Drive module. This package ships the frontend and the private native Drive library (native/); the Tauri plugin alwith-drive (crates.io) carries the public types, typed commands and the transactional Rust API. Frontend and library versions always match. The engine was extracted from ALwith Desktop; desktop-provenance.json (kept in the repository, not published) records the source revision.

Entry points

  • @alwith/module-drive: generated protocol types, transport interface and controller.
  • @alwith/module-drive/react: controller subscriptions, launcher/settings/status panels, permissions, badges, mass-delete confirmation, localization and pinned-entry helpers. Inject host shadcn controls and navigation.
  • @alwith/module-drive/content: comments, Markdown/HTML integration, collaboration, frontmatter, versions, knowledge jobs, chat suggestions, cross-project move and file-link helpers.
  • @alwith/module-drive/tauri: createTauriDriveTransport() over the plugin's commands and drive:event.
  • @alwith/module-drive/commands: generated typed plugin commands and events.
  • @alwith/module-drive/styles.css: scoped semantic-token styles.

Host contract

Register .plugin(alwith_drive::init(Config::new(|app| ...).event_windows(["main"]).development_directory(development_directory))); the closure opens the one DriveService from application data, a shared ownership registry, default local directory, reserved legacy application directories, device identity and a system browser opener. A start failure is kept and returned by every command. The plugin delivers drive:event to the configured windows and replaces a lagging subscriber's skipped events with a fresh snapshot (generation/sequence contract); a failed transport stream (queue overflow) is reported as an error, never as a resynchronization. Grant alwith-drive:default (allow-request) to windows that use Drive. alwith-drive:allow-session-request (MCP and collaboration credentials: mcpSessionConfig, collabSession) and alwith-drive:allow-collaborative-write (writeCollaborativeDocument) are separate permissions; grant them to every window the application trusts with the user's Drive session, such as Desktop's chat windows. The plugin does not restrict them to a window label. Keep credentials out of snapshots, logs and persisted frontend state.

Subscribe before fetching the initial snapshot. createDriveController buffers this interval and reconciles generation/sequence gaps. A window's disposal stops its listener, not the application service. Before exit call app.state::<Drive>(): begin_shutdown() once, then await shutdown() (cancels transactions, drains and stops synchronization, ends event delivery), then exit; is_stopped() tells the exit hook to let the exit through.

All native filesystem mutations that can intersect the Drive root must run through DriveService::with_filesystem (or with_collaborative_filesystem, with_move_to_filesystem) after host path authorization; dropping the future cancels the transaction. Pass exact write destinations and removed source paths. It serializes native changes with complete sync rounds, checks indexed read-only/collaboration state, and records successful removal intent. This coarse coordinator can delay operations during a transfer. It is not an OS sandbox: external editors and agents use ordinary filesystem permissions.

New roots must be empty by default. Hosts may opt into DriveService::with_existing_default_root() to adopt existing files only at their configured default root. This does not move or delete files and does not relax ownership checks for registered roots or custom directories. Ownership is persisted by canonical root, account/server and host data directory; overlapping roots and reuse by another profile are rejected. Legacy clients do not participate in the registry: sharing a default directory requires the same server/account and strictly sequential operation, with the previous sync process fully stopped. Hosts upgrading from ALwith Desktop pass OpenOptions::new().legacy_desktop(LegacyDesktopProfile { store, settings, index }) to DriveService::open: store is Desktop's drive.json named store (baseUrl, token, deviceId, localRoot, userName), settings its settings.json (drive.* keys) and index its drive/index.sqlite3. When the plugin has no profile.json yet, Drive reports the Desktop profile as configured; the first operation that needs it (normally start) identifies the account, adopts Desktop's directory, moves the index (with WAL files) into the profile and writes the profile with Desktop's preferences, download threshold, server configuration and local server overrides. Without network that operation fails and the import stays pending; logout declines it. Desktop's files other than the index are never changed, and a written profile file, signed in or not, ends the import for good.

Credentials are stored in a native atomic profile file (owner-only permissions on Unix); protect the containing app data directory on the host OS. Logout preserves local files. Revocation retains the extracted engine's cleanup/residual behavior. Use dedicated accounts and temporary directories when testing revocation.

Current boundaries

This remains an integration candidate pending real service and multi-client acceptance. The panel provides separate launcher, settings and status modes; the host supplies native directory selection, navigation, settings routing and external opening. It uses the existing workspace rather than rendering a second tree. Download preference changes reload the engine while preserving pause state.

Opt into content integration by mounting DriveContentProvider, wrapping managed documents in CommentSurface, and merging drivePreviewIntegrations into the shared editor host. Supply saveDocument and track collaboration ownership. Route authorized collaborative atomic writes through with_collaborative_filesystem; ordinary writes remain subject to with_filesystem. Lock source editing separately from collaborative preview permissions. The content entry requires its documented optional Milkdown, Yjs and editor peer dependencies.

Mount DriveMassDeleteDialog in the primary window independently of panel visibility. ChatCondenseEntry takes host preference storage for its 30-day snooze; pass approved jobs to DriveCondense.initialJob. Keep dialog ownership outside transient context menus. Hosts choose their OS link scheme; avoid claiming another application's registered protocol.

Archive is disabled by default. Hosts obtain explicit consent, export dialogue through their existing conversation owner, and provide expectedGeneration with each upload. Native code rechecks consent, private-session exclusion, workspace markers and generation before filtering and uploading. Archive metadata contains hashes and status, not a second conversation store. Knowledge and MCP configuration are resolved for each explicit session workspace. Configure a skills directory before starting the native engine.

Removal intent is inherited in-memory engine state; crash-safe delete/move recovery is not provided. The shared service adds no database schema migration. The editor host must preserve dirty buffers and check expected file versions. Native workspace size limits still apply after downloads. Cloud-only files cannot be edited locally; collaborative files require the explicit owner adapter rather than ordinary source writes.

Generated JSON numeric fields use JavaScript numbers, matching the existing transport. Values outside JavaScript's safe integer range are not supported; remote identifiers preserve string variants.

Development

bun install
bun run bindings   # regenerates src/generated/commands.ts and src/contract.ts from the plugin
bun test src
cargo test --manifest-path rust/Cargo.toml
bun run build

Use the repository's scripts/build-npm.ts builder. With the native library built, ALWITH_NATIVE_DIRECTORY=<target/debug> cargo test --manifest-path rust/Cargo.toml -- --ignored exercises the client against it. Publish only after an explicit release decision and real native, multi-process and supported-platform validation.

Desktop capabilities

  • DriveService::open(options, OpenOptions) adds host choices: session_archive_directory (native session archive), default_preferences (preferences of a profile that has not chosen any; Desktop used knowledgeInject: true) and legacy_desktop (above). DriveService::new(options) keeps the previous behavior.
  • Session archive: with session_archive_directory, Drive archives that conversation directory when it starts, every five minutes and on archiveSyncNow, only while sessionArchive is on, skipping sessions marked private. Each round emits archive events (syncing true, then false with the counts) and archiveStatus reports the native archive. Without the directory, hosts keep exporting conversations themselves with archiveSession, and archiveSyncNow is an error.
  • Server overrides: serverOverrides / setServerOverrides { overrides } read and change webBaseUrl, collabRelayUrl, transferConcurrency (1 to 64) and maxUploadMb (0 unlimited). They persist beside the profile across sign-out. Addresses apply only while the server has not published its client configuration; maxUploadMb yields to a server limit. A running engine restarts with its pause state preserved.
  • moveToCloudDirectory { sources, directory } moves Drive items into a cloud folder that has not landed locally and answers cloudMove { moved, error }.
  • recheckCloudOnly answers cloudOnlyRecheck with its counts, and engine rechecks emit cloudOnly events (contract generation 2).
  • searchUsers { query, limit? }: 1 to 50 users, 20 when absent.
  • knowledgeContext is cached for ten minutes per workspace and cleared by any profile, preference or engine change.

版本与发布记录

@alwith/module-drive 共发布 15 个版本,首次发布于 2026/10/22;过去 12 个月发布了 15 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.6.2latest2026/11/052 天前
0.6.12026/11/043 天前
0.6.02026/11/034 天前
0.5.32026/11/035 天前
0.5.12026/10/308 天前
0.5.02026/10/308 天前

其他发布通道:next → 0.1.0-rc.24。

关于 @alwith/module-drive 的常见问题

@alwith/module-drive 是什么?

Pre-release shared Drive module. This package ships the frontend and the private native Drive library (native/); the Tauri plugin alwith-drive (crates.io) carries the public types, typed commands and the transactional Rust API. Frontend and library ve

如何安装 @alwith/module-drive?

在项目目录运行 npm install @alwith/module-drive,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^19.3.1)、react-dom(^19.3.1)、@tauri-apps/api(^3.0.0-alpha.3)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@alwith/module-drive 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@alwith/module-drive 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@alwith/module-drive 可以商用吗?

@alwith/module-drive 使用 SEE LICENSE IN LICENSE 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@alwith/module-drive 的下载量有多少?

根据 npm 官方下载统计,@alwith/module-drive 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,880 次,日均约 96 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@alwith/module-drive 还在维护吗?

最新版本 0.6.2 发布于 2026/11/05(2 天前);至今共发布 15 个版本,其中过去 12 个月发布了 15 个;首次发布于 2026/10/22。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。