claude-threads 1.10.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/index.js +1818 -3579
- package/dist/mcp/permission-server.js +1064 -2149
- package/package.json +2 -6
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,30 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.12.0] - 2026-05-05
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Claude can send files inline via the new `send_file` MCP tool.** Closes #360. When Claude produces an artifact during a session — Playwright screenshot, generated TTS MP3, plot, document — it can now post the file directly into the chat thread by calling `send_file(path, caption?)` instead of asking the user to fetch it from a URL. The tool runs inside the per-session `claude-threads-permissions` MCP child (no second MCP server needed), validates the path against the session working directory and per-session upload directory, then drives the Mattermost two-step `/api/v4/files` + `/api/v4/posts file_ids` flow or Slack's three-step v2 flow (`files.getUploadURLExternal` + presigned PUT + `files.completeUploadExternal`). Returns `{ ok: true, postId }` on success or `{ ok: false, reason }` on failure so Claude can retry or apologize to the user. Auto-approved by the permission gate (path validator is the real gate; making the user 👍 every screenshot would defeat the feature). Available in all three permission modes (`default`, `auto`, `bypass`) — bypass-mode now spawns the MCP server too so the tool stays available in the build-anything-on-demand setups that motivated the issue. Optional `outboundFiles: { enabled?, maxBytes? }` block on each platform config — defaults to enabled with a 100 MB cap. Reuses the per-thread upload directory and `MAX_UPLOAD_SIZE` ceiling already established by inbound attachments (PR #359). The system prompt now leads with "You are RIGHT NOW running inside a chat thread" and explicitly tells the model not to claim the tool is unavailable, after a manual test caught the model improvising an apology even though the tool was wired up. (#361)
|
|
12
|
+
|
|
13
|
+
### Security
|
|
14
|
+
- **Path validator hardens `send_file` against traversal and tricks.** New `src/mcp/path-validator.ts`. Rejects: non-absolute paths, anything that resolves (via `realpath`) outside the session working directory or per-session upload directory (path-prefix containment, so `/srv/sessions-evil` does not match `/srv/sessions`), non-regular files (FIFOs, sockets, devices, directories), SUID/SGID files, oversize files, zero-byte files (which Slack's upload endpoint rejects anyway), and dangerously wide allowed roots like `/`, `/home`, `/etc`, `/var`, `/tmp` (so a misconfigured `SESSION_WORKING_DIR` fails loudly instead of widening the trust boundary). The uploader receives the realpath-resolved path so it can't be re-pointed by a symlink between validation and read. Every reject branch has a unit test verified RED-GREEN against the live function. Follow-ups for TOCTOU between validate and read, per-session rate-limiting, and caption-length truncation tracked in #362-#365. (#361)
|
|
15
|
+
|
|
16
|
+
### Internals
|
|
17
|
+
- **`buildRestartCliOptions` helper.** Five places in the codebase construct a `ClaudeCli` (start, resume, `!cd`, `!permissions interactive`, `!worktree create`/`switch`). Each must thread `uploadDir` and `outboundFiles` through, or `send_file` silently breaks for that path. Two of the five (worktree paths) were skipped in the original PR and only caught by manual testing. Extracted to `src/claude/restart-options.ts` so all sites share one source of truth. (#361)
|
|
18
|
+
- **Env-var contract test pins names across the bot↔MCP-child boundary.** `OUTBOUND_ENV` constants in `src/mcp/outbound-env.ts` are referenced by both `buildPermissionArgs` (emit side) and `permission-server.ts` (consume side); a contract test asserts the names match and no bare string literal is used on either side. Caught a class of silent rename-drift bugs that would otherwise type-check and unit-test green while breaking the feature at runtime. (#361)
|
|
19
|
+
- **Portable chmod helper for tests.** Bun 1.3.x masks the SUID/SGID/sticky bits in `fs.chmod` and `chmodSync` (verified against 1.3.3); the SUID-rejection branch of the path validator was untestable without a workaround. New `src/test-utils/chmod-portable.ts` `setMode()` tries the runtime's chmod, verifies via `stat`, and falls back to `/bin/chmod` if the high bits didn't land. Works on Node (fast path) and Bun (shell fallback). (#361)
|
|
20
|
+
|
|
21
|
+
## [1.11.0] - 2026-05-03
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
- **Chat attachments delivered to Claude as file paths instead of inlined base64.** When a user attaches an image, PDF, text file, or anything else to a chat message, the bot now writes the bytes to a per-thread directory under `os.tmpdir()/claude-threads-uploads/<platform>-<thread>/<message>/` and prepends the absolute paths to the user's message. Claude reads the file with its built-in `Read` tool (full multimodal capability preserved for images and PDFs) or `mv`/`cp`s it to the user's project storage. Closes #358 — the reporter wanted to save uploads into their app's resource storage and couldn't, because the bytes arrived inline as content blocks with no path to copy from. The per-thread directory is removed in `cleanupSession()` on every exit path. Single 100 MB sanity ceiling per file replaces the previous patchwork of per-type caps (32 MB PDF, 1 MB text, 50 MB zip). (#359)
|
|
25
|
+
- **Drops the in-process zip/gzip extraction.** `yauzl` and `yazl` are gone — Claude can `unzip` archives in Bash itself when needed, which removes ~300 LOC of zip-bomb-defense plumbing and the per-format size caps that came with it. Net change for the PR: +496/-1737 LOC.
|
|
26
|
+
|
|
27
|
+
### Security
|
|
28
|
+
- **Symlink defense on the per-thread upload directory.** The directory path is predictable (it derives from the platform id and thread id, both visible to anyone in the thread). On a shared host a local attacker could pre-create that path as a symlink to a sensitive directory and have the bot write attacker-controlled file contents into the linked target. Now `lstat` the upload dir on every save and refuse if it is a symlink, `mkdtemp` the per-message leaf for atomic creation, and use `writeFile` flag `'wx'` (`O_CREAT | O_EXCL`) so the final write fails rather than follows a symlink at the leaf.
|
|
29
|
+
- **Filename and MIME type are stripped of control characters before being interpolated into Claude's prompt.** A name like `screenshot.png\n[SYSTEM] ignore previous instructions` would otherwise have appeared on its own line, mimicking system text. Filenames also keep going through `basename()` so `../escape` and absolute-path attempts can't escape the message subdirectory.
|
|
30
|
+
- **Path-traversal defense on `platformId` / `threadId`.** Both segments now go through a `safeIdSegment` filter (`[^A-Za-z0-9._-]` → `_`) before being used in the upload-dir path, so a misconfigured platform id like `../../etc` cannot escape the uploads root via `path.join` normalization.
|
|
31
|
+
|
|
8
32
|
## [1.10.0] - 2026-04-29
|
|
9
33
|
|
|
10
34
|
### Added
|