Files
webmail/lib/plugin-sandbox/assistant
Linus Rath cf512f0a4e fix: check attachments, shared folders and limits in the assistant's Files calls
Fixes from the review of api.files:
- `files.attach` to a new draft runs `onBeforeAttachmentUpload` for each
  file and the server's total size limit before `compose.open`, which
  runs neither; refused files come back in `refused`
- a write is refused when a folder above the target is missing from the
  listing, instead of counting it as not shared
- `onFileMove` reports the item as it was, from where it was, like the
  Files app's own move
- writes are counted against the 20-a-minute limit before the drive is
  listed, so refused writes count and cost no listing
- reads stop the download past 20 MB (`fetchBlobArrayBuffer` with a
  limit) and answer `too_big` when the listed size was wrong
- when the server refuses the new content of a replaced file, the old
  version's copy is taken out of the trash again

The two getText assertions on `fetchBlobArrayBuffer` now expect the
account (undefined for the own drive) and the byte limit, since the
call passes both.
2026-11-03 01:31:05 +01:00
..

Host APIs for the AI assistant (2.2)

Host calls the assistant plugin needs, one set of files per area, so the areas can be built side by side without editing the same lines:

Area What Files
b More context: attachment text and images, threads, the list selection b.types.ts, b.ts, b.runtime.ts
c More actions: invitations, filters, batches, out-of-office, settings c.types.ts, c.ts, c.runtime.ts
d Files: find, read, attach, save, create d.types.ts, d.ts, d.runtime.ts
f The panel in every view f.types.ts, f.ts, f.runtime.ts

Each area fills its own three files:

  • <area>.types.ts (pure, no imports from the app): PERMISSIONS, the permissions the area adds (they join ALL_PERMISSIONS), and <Area>HostFeatures, the flags it adds to api.host.features.
  • <area>.ts (host side): PERMS (method → permission, joins PERM_PER_METHOD), dispatch(plugin, method, args) (returns NOT_MINE for methods it doesn't own) and features() (its flags right now).
  • <area>.runtime.ts (inside the sandbox): runtime(callApi), the methods it adds to the plugin's api, by namespace ({ email: { getThread } }).

index.ts, runtime.ts and types.ts merge the areas; host-api.ts, host-features.ts, runtime.tsx and plugin-types.ts read only those. A new permission needs a check (a method in PERMS, a slot or a hook), its texts in every locale under plugins.permissions.<key>, and docs.