@softure-ai/files 0.1.1 → 0.2.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.
Files changed (90) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +113 -10
  3. package/dist/contract.d.ts +41 -1
  4. package/dist/contract.d.ts.map +1 -1
  5. package/dist/index.d.ts +35 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +17 -4
  8. package/dist/index.js.map +1 -1
  9. package/dist/mcp/index.d.ts +41 -0
  10. package/dist/mcp/index.d.ts.map +1 -0
  11. package/dist/mcp/index.js +114 -0
  12. package/dist/mcp/index.js.map +1 -0
  13. package/dist/messages/en.d.ts +15 -0
  14. package/dist/messages/en.d.ts.map +1 -1
  15. package/dist/messages/en.js +14 -0
  16. package/dist/messages/en.js.map +1 -1
  17. package/dist/messages/index.d.ts +15 -0
  18. package/dist/messages/index.d.ts.map +1 -1
  19. package/dist/next/index.d.ts +1 -0
  20. package/dist/next/index.d.ts.map +1 -1
  21. package/dist/next/index.js +2 -1
  22. package/dist/next/index.js.map +1 -1
  23. package/dist/next/upload-route.d.ts +3 -0
  24. package/dist/next/upload-route.d.ts.map +1 -0
  25. package/dist/next/upload-route.js +11 -0
  26. package/dist/next/upload-route.js.map +1 -0
  27. package/dist/options.d.ts +6 -0
  28. package/dist/options.d.ts.map +1 -1
  29. package/dist/options.js +27 -0
  30. package/dist/options.js.map +1 -1
  31. package/dist/schema.d.ts +255 -0
  32. package/dist/schema.d.ts.map +1 -1
  33. package/dist/schema.js +17 -2
  34. package/dist/schema.js.map +1 -1
  35. package/dist/server/index.d.ts +6 -2
  36. package/dist/server/index.d.ts.map +1 -1
  37. package/dist/server/index.js +6 -2
  38. package/dist/server/index.js.map +1 -1
  39. package/dist/server/options.d.ts +2 -0
  40. package/dist/server/options.d.ts.map +1 -1
  41. package/dist/server/options.js +8 -0
  42. package/dist/server/options.js.map +1 -1
  43. package/dist/server/privacy.d.ts +6 -1
  44. package/dist/server/privacy.d.ts.map +1 -1
  45. package/dist/server/privacy.js +6 -3
  46. package/dist/server/privacy.js.map +1 -1
  47. package/dist/server/prune.d.ts +4 -0
  48. package/dist/server/prune.d.ts.map +1 -1
  49. package/dist/server/prune.js +4 -2
  50. package/dist/server/prune.js.map +1 -1
  51. package/dist/server/save.d.ts +15 -0
  52. package/dist/server/save.d.ts.map +1 -1
  53. package/dist/server/save.js +11 -9
  54. package/dist/server/save.js.map +1 -1
  55. package/dist/server/serve-upload.d.ts +6 -0
  56. package/dist/server/serve-upload.d.ts.map +1 -0
  57. package/dist/server/serve-upload.js +110 -0
  58. package/dist/server/serve-upload.js.map +1 -0
  59. package/dist/server/upload-page.d.ts +5 -0
  60. package/dist/server/upload-page.d.ts.map +1 -0
  61. package/dist/server/upload-page.js +94 -0
  62. package/dist/server/upload-page.js.map +1 -0
  63. package/dist/server/upload-tokens.d.ts +9 -0
  64. package/dist/server/upload-tokens.d.ts.map +1 -0
  65. package/dist/server/upload-tokens.js +43 -0
  66. package/dist/server/upload-tokens.js.map +1 -0
  67. package/dist/server/uploads.d.ts +73 -0
  68. package/dist/server/uploads.d.ts.map +1 -0
  69. package/dist/server/uploads.js +403 -0
  70. package/dist/server/uploads.js.map +1 -0
  71. package/migrations/0002_create_uploads.sql +33 -0
  72. package/module.json +9 -4
  73. package/package.json +12 -2
  74. package/src/contract.ts +45 -1
  75. package/src/index.ts +32 -5
  76. package/src/mcp/index.ts +169 -0
  77. package/src/messages/en.ts +14 -0
  78. package/src/next/index.ts +2 -1
  79. package/src/next/upload-route.ts +11 -0
  80. package/src/options.ts +28 -0
  81. package/src/schema.ts +20 -2
  82. package/src/server/index.ts +20 -2
  83. package/src/server/options.ts +8 -0
  84. package/src/server/privacy.ts +12 -4
  85. package/src/server/prune.ts +8 -2
  86. package/src/server/save.ts +25 -11
  87. package/src/server/serve-upload.ts +116 -0
  88. package/src/server/upload-page.ts +103 -0
  89. package/src/server/upload-tokens.ts +43 -0
  90. package/src/server/uploads.ts +437 -0
package/CHANGELOG.md CHANGED
@@ -4,6 +4,29 @@ Newest first. Each version lists what changed for an app that uses `@softure-ai/
4
4
  in production, the version gets a line `verified in: <app>@<commit>` ([docs/05](../../docs/05-adoption-playbook.md),
5
5
  "Definition of done").
6
6
 
7
+ ## 0.2.0
8
+
9
+ - Resumable uploads from clients (#949): table `files.uploads` (migration 0002), `createUpload` (a signed upload URL
10
+ under the link keyring, limits `uploads.chunkBytes` 64 MiB, `uploads.ttlSeconds`, `uploads.maxOpenPerOwner`,
11
+ `uploads.contentTypes`, `maxFileBytes` and the quota checked up front), `getUpload`, `writeUploadChunk` and
12
+ `finalizeUpload` (every chunk, size and optional SHA-256 checked, saved like `saveFile`, idempotent).
13
+ - The upload route `serveUploadRoute` (`app/u/[...upload]/route.ts`, `GET`, `HEAD`, `PUT`): chunked with
14
+ `Content-Range`, resumable through `HEAD` and the JSON status, streamed with a cap, a browser upload page, and the
15
+ `files-upload` rate limit bucket (`FILES_RATE_LIMIT_BUCKETS`) when the security module is on. Keep `/u` outside the
16
+ sign-in guard and add an edge bypass for it, as for `/f`.
17
+ - `@softure-ai/files/mcp`: `registerFileUploadTools` (`create_upload` with a ready `curl` loop, `finalize_upload`),
18
+ `FILE_UPLOAD_MCP_TOOLS` for the catalog, `buildCurlUploadScript`. `@modelcontextprotocol/server` is a new optional
19
+ peer.
20
+ - `pruneFiles` also removes expired upload sessions with their chunks (`deletedUploads`, `failedUploads` in its
21
+ report); the privacy export lists open sessions (`uploads`), the deletion removes them (`deletedUploads`,
22
+ `pendingUploads`).
23
+ - New dependency `@softure-ai/security` (the rate limit), new error codes `files.content_type_not_allowed`,
24
+ `files.too_many_uploads`, `files.upload_incomplete`, `files.checksum_mismatch` with their messages.
25
+
26
+ ## 0.1.2
27
+
28
+ - No code change: the first release through the package's npm trusted publisher (OIDC), without `NPM_TOKEN`.
29
+
7
30
  ## 0.1.1
8
31
 
9
32
  - The content of 0.1.0, which was never published: its release stopped at the gates (ESLint ran out of memory in
package/README.md CHANGED
@@ -4,7 +4,8 @@ Stored files for a Next.js app that takes uploads or produces media (rendered vi
4
4
  links that hand one of them to a third party: a social media scheduler that fetches media from a URL, a mail with a
5
5
  large download, a webhook consumer. The module keeps one table, puts the bytes on a storage driver (a folder on a
6
6
  volume, or an S3-compatible bucket), and serves links that work without the app's session, serve byte ranges for
7
- video and stop working after their time.
7
+ video and stop working after their time. A client that cannot hand the server a stream (an assistant in its own
8
+ sandbox, a phone behind a proxy with a body limit) uploads through a signed URL in resumable chunks.
8
9
 
9
10
  ## 1. What it provides
10
11
 
@@ -27,8 +28,16 @@ video and stop working after their time.
27
28
  `Content-Length`, `Accept-Ranges`, `206` for a range, `416` past the end, `Content-Disposition`, and
28
29
  `Cache-Control: private, no-store` (no CDN keeps a copy), and the same `404` for an expired, revoked, deleted or
29
30
  forged link. `revokeFileLinks(ctx, fileId)` stops every link made so far.
30
- - **Retention**: `pruneFiles(ctx)` removes expired and deleted files from storage and the table; the `files.prune`
31
- job (`@softure-ai/files/jobs`) runs it hourly.
31
+ - **Resumable uploads** (`files.uploads`): `createUpload(ctx, { ownerId, name, contentType?, size, sha256?, kind?,
32
+ ttlSeconds? })` opens a session and answers `{ uploadId, uploadUrl, chunkSize, chunkCount, expiresAt }`. The client
33
+ sends the file to `uploadUrl` in chunks under the edge's body limit (64 MiB by default), resumes after a dropped
34
+ connection, and `finalizeUpload(ctx, uploadId)` checks every byte and the optional SHA-256 and saves the file like
35
+ `saveFile` (quota, dedupe). See §4.1.
36
+ - **MCP upload tools** (`@softure-ai/files/mcp`): `registerFileUploadTools(server, { identity, getContext })` adds
37
+ `create_upload` (a signed URL, a ready `curl` loop and the browser page) and `finalize_upload`, so an assistant hands
38
+ over a video without its bytes going through a tool call. See §4.2.
39
+ - **Retention**: `pruneFiles(ctx)` removes expired and deleted files from storage and the table, and expired upload
40
+ sessions with their chunks; the `files.prune` job (`@softure-ai/files/jobs`) runs it hourly.
32
41
  - **A privacy contributor** (the export lists the owner's files, the deletion removes them) and **a health check**
33
42
  (the table answers, storage takes a write, free space above `health.minFreeBytes`).
34
43
  - **`/testing`**: an in-memory driver, a fixed link keyring, `fetchFileLink` (status, headers and bytes of a link,
@@ -40,7 +49,8 @@ video and stop working after their time.
40
49
  npm install @softure-ai/files
41
50
  ```
42
51
 
43
- `@softure-ai/jobs` is an optional peer, needed only for the prune schedule.
52
+ `@softure-ai/jobs` is an optional peer, needed only for the prune schedule; `@modelcontextprotocol/server` is an
53
+ optional peer, needed only for `@softure-ai/files/mcp`.
44
54
 
45
55
  ## 3. Configuration
46
56
 
@@ -67,7 +77,12 @@ files({
67
77
  | `links.maxTtlSeconds` | 7 days | the longest lifetime `createFileLink` grants |
68
78
  | `links.disposition` | `attachment` | `attachment` (a download) or `inline` (shown by the browser) |
69
79
  | `health.minFreeBytes` | 1 GiB | the health check fails below this many free bytes (local disk only) |
80
+ | `uploads.chunkBytes` | 64 MiB | the bytes of one upload request; keep it under the edge's body limit (Cloudflare: 100 MB on Free and Pro, 200 MB on Business) |
81
+ | `uploads.ttlSeconds` | 1 day | how long an upload session and its URL work (at most 7 days); `createUpload` may ask for less |
82
+ | `uploads.maxOpenPerOwner` | 5 | sessions one owner may have open at once (`files.too_many_uploads`) |
83
+ | `uploads.contentTypes` | `null` (any) | the media types an upload may declare, `video/mp4` or `video/*` (`files.content_type_not_allowed`) |
70
84
  | `routes.links` | `/f` | the link route's prefix; mount the route under the same folder |
85
+ | `routes.uploads` | `/u` | the upload route's prefix; mount the route under the same folder |
71
86
 
72
87
  Building a driver touches neither the disk nor the network, so `next build` runs without the folder or the bucket's
73
88
  keys.
@@ -127,6 +142,85 @@ const link = await createFileLink(ctx, saved.value.id, { ttlSeconds: 86_400 });
127
142
  A request body streams in directly: `saveFile(ctx, { ownerId, body: request.body, name, contentType })` (a web
128
143
  `ReadableStream` is an async iterable in Node 22).
129
144
 
145
+ ### 4.1 Uploads from clients
146
+
147
+ A second route handler takes uploads:
148
+
149
+ ```ts
150
+ // app/u/[...upload]/route.ts
151
+ export { serveUploadRoute as GET, serveUploadRoute as HEAD, serveUploadRoute as PUT } from "@softure-ai/files/next";
152
+ ```
153
+
154
+ Like `/f`, **the route has no session**: the URL carries an HMAC signature (under `SOFTURE_FILES_LINK_KEYS`, with its
155
+ own context, so an upload URL never passes as a link) and stops working once the session expires or is finalized. Keep
156
+ `/u` out of the app's sign-in guard, add an edge bypass for it as for `/f` (`apps[].access.bypassPaths: [/f, /u]` with
157
+ `@softure-ai/host`), and never cache it. Raise the edge's body limit only if you raise `uploads.chunkBytes`.
158
+
159
+ The app opens a session for a signed-in user and hands the URL to the client; the client sends the bytes; the app
160
+ finalizes:
161
+
162
+ ```ts
163
+ import { createUpload, finalizeUpload } from "@softure-ai/files/server";
164
+
165
+ const created = await createUpload(ctx, { ownerId: user.id, name: "promo.mp4", contentType: "video/mp4", size, kind: "input" });
166
+ if (!created.ok) return created; // files.too_large, files.quota_exceeded, files.content_type_not_allowed, files.too_many_uploads, files.invalid_input
167
+ // ...the client uploads to created.value.uploadUrl...
168
+ const saved = await finalizeUpload(ctx, created.value.uploadId, { ownerId: user.id });
169
+ // saved.value is the StoredFile; files.upload_incomplete, files.checksum_mismatch, files.quota_exceeded otherwise
170
+ ```
171
+
172
+ The wire protocol on `uploadUrl`:
173
+
174
+ | Request | Answer |
175
+ | --- | --- |
176
+ | `PUT` with `Content-Range: bytes <start>-<end>/<size>` | stores one chunk: `start` a multiple of `chunkSize`, `end` the chunk's last byte (the last chunk is shorter). `200` with the JSON status; a chunk that already arrived is answered without being rewritten, so a resend is safe. `416` for a range that is not one chunk, `400` for a body of another length, `404` once finalized or expired. |
177
+ | `PUT` without `Content-Range` | the whole file, when it fits one chunk |
178
+ | `HEAD` | `upload-state` (`open`, `complete`, `finalized`), `upload-size`, `upload-chunk-size`, `upload-received` (byte ranges, `0-67108863,134217728-201326591`), `upload-expires` |
179
+ | `GET` | the JSON status (`received`, `receivedBytes`, `missingChunks`, `state`, ...); a browser (`Accept: text/html`) gets the upload page instead |
180
+
181
+ The **upload page** is a small phone-friendly page on the same URL: the person picks the file and it is sent in chunks
182
+ with `fetch`, from the missing ones, so pressing Upload again resumes. Its copy is `filesMessages.en.uploadPage`; it
183
+ loads nothing external and runs one inline script under a per-response CSP nonce.
184
+
185
+ **Rate limit**: when the app enables `@softure-ai/security`, every request to the upload route counts in the
186
+ `files-upload` bucket, keyed by the session; spread `FILES_RATE_LIMIT_BUCKETS` (from `@softure-ai/files`) into
187
+ `security({ buckets })`, or the route throws a setup error naming it. Without the security module the route relies on
188
+ the signature alone.
189
+
190
+ Every chunk is its own object in storage (`uploads/<id>/<index>`); `finalizeUpload` streams them in order into
191
+ `saveFile`, which writes the one final object (a multipart upload on S3) and the parts are removed. Storage briefly
192
+ holds the file twice while a finalize runs. Two parallel finalizes keep one file; a second call answers the same file.
193
+
194
+ ### 4.2 MCP upload tools
195
+
196
+ An MCP tool cannot take a video as an argument. With `@softure-ai/mcp-access`, register the two upload tools in the
197
+ app's server factory and list them in the catalog:
198
+
199
+ ```ts
200
+ import { getFilesContext } from "@softure-ai/files/next";
201
+ import { FILE_UPLOAD_MCP_TOOLS, registerFileUploadTools } from "@softure-ai/files/mcp";
202
+
203
+ mcpAccess({ serverName: "acme", tools: [...appTools, ...FILE_UPLOAD_MCP_TOOLS] });
204
+
205
+ export const createServer = createMcpServerFactory({
206
+ name: "acme",
207
+ strictToolInput: true,
208
+ registerTools: (server, identity) => {
209
+ registerAppTools(server, identity);
210
+ registerFileUploadTools(server, { identity, getContext: () => getFilesContext(), kind: "input" });
211
+ },
212
+ });
213
+ ```
214
+
215
+ - `create_upload({ name, size, content_type?, sha256? })` answers `upload_id`, `upload_url`, `chunk_size`,
216
+ `chunk_count`, `expires_at`, `curl` (a bash loop with `dd` and `curl` that sends every chunk; `CHUNKS="3 4"` resends
217
+ only those) and `browser_page`. The assistant runs the loop in its own sandbox; the bytes never pass through the tool
218
+ call.
219
+ - `finalize_upload({ upload_id })` answers `file_id`, `name`, `size`, `content_type`, `sha256`, or the error's
220
+ sentence with its code.
221
+ - Both are write tools: registered only when `identity.canWrite` (mcp-access's write switch). The uploads belong to the
222
+ token's user (`getOwnerId` changes that). The app's tools then take the `file_id`.
223
+
130
224
  ## 5. Migrations and tables
131
225
 
132
226
  Schema `files`, migration `0001_create_files.sql`, table `files`:
@@ -146,11 +240,17 @@ Schema `files`, migration `0001_create_files.sql`, table `files`:
146
240
  A deleted or expired file keeps its row until `pruneFiles` has removed its bytes. Rollback: drop the table and its
147
241
  `softure.migrations` row (the migration's header has the statements); the objects in storage stay.
148
242
 
243
+ Migration `0002_create_uploads.sql`, table `uploads`: one row per upload session (owner, sanitised name, content type,
244
+ kind, declared size and optional SHA-256, chunk size, `received_chunks` (the indices that arrived), `file_id` once
245
+ finalized, `expires_at`). The state is derived from those columns. A finalized session keeps its row until it expires,
246
+ so a repeated finalize answers the same file; `pruneFiles` then removes it. Rollback: drop `files.uploads` and the
247
+ version 2 row; chunk objects under `uploads/` stay in storage.
248
+
149
249
  ## 6. Environment variables
150
250
 
151
251
  | Variable | Required | Meaning |
152
252
  | --- | --- | --- |
153
- | `SOFTURE_FILES_LINK_KEYS` | for links | the signing keyring, `<id>:<base64 of 32 bytes>[,<id>:<key>…]`: the first key signs, every key verifies. `generateFilesLinkKey()` (from `/server`) prints a new entry. Rotate by putting a new key first and dropping the old one after `links.maxTtlSeconds`. Without it, `createFileLink` answers `files.link_key_missing` and the route answers `404` (and logs the code). |
253
+ | `SOFTURE_FILES_LINK_KEYS` | for links and uploads | the signing keyring, `<id>:<base64 of 32 bytes>[,<id>:<key>…]`: the first key signs, every key verifies. `generateFilesLinkKey()` (from `/server`) prints a new entry. Rotate by putting a new key first and dropping the old one after `links.maxTtlSeconds`. Without it, `createFileLink` answers `files.link_key_missing` and the route answers `404` (and logs the code). |
154
254
  | `SOFTURE_FILES_S3_ACCESS_KEY_ID`, `SOFTURE_FILES_S3_SECRET_ACCESS_KEY` | with `createS3Storage` | the bucket's access keys, read on each request (renamed with `accessKeyIdEnv` / `secretAccessKeyEnv`) |
155
255
 
156
256
  ## 7. Switches
@@ -159,13 +259,15 @@ None.
159
259
 
160
260
  ## 8. Appearance
161
261
 
162
- None: the module has no UI. A file browser is out of scope.
262
+ The upload page (§4.1) is plain HTML with a minimal inline style, so it works before any theme loads; an app that
263
+ wants its own look builds a page on `createUpload` and the same wire protocol. A file browser is out of scope.
163
264
 
164
265
  ## 9. Copy
165
266
 
166
267
  `filesMessages.en.errors.files.*` has a sentence per error code (`too_large`, `quota_exceeded`, `not_found`, ...);
167
268
  `getFilesErrorMessage(messages, code)` picks one, falling back to the generic failure. The link route's `404` body
168
- is a fixed `Not found` for machines, not copy.
269
+ is a fixed `Not found` for machines, not copy. `uploadPage.*` is the upload page's copy (`{name}`, `{size}`, `{done}`
270
+ and `{total}` are filled in).
169
271
 
170
272
  ## 10. Hooks
171
273
 
@@ -178,12 +280,13 @@ None. A driver is the extension point: any object with `kind`, `put(body, key)`,
178
280
  times), never the bytes or the storage key; an app that wants the bytes in the export adds links itself.
179
281
  `deleteUserData` marks every file of the user deleted (nothing of theirs is served from that moment), removes the
180
282
  bytes from storage and then the rows; a file whose storage delete fails keeps its marked row until `pruneFiles`
181
- removes it.
283
+ removes it. Upload sessions too: the export lists the open ones (name, size, what arrived), the deletion removes all
284
+ of the user's sessions with their chunks.
182
285
 
183
286
  ## 12. Limitations
184
287
 
185
- - No uploads from clients: no signed upload URLs, no chunked or resumable transfer. The app streams the request body
186
- into `saveFile` itself. No image transforms, no virus scanning, no file browser UI.
288
+ - Uploads from clients go through upload sessions (§4.1): chunks must align to the session's chunk size, and a
289
+ finalize briefly needs twice the file's size in storage. No image transforms, no virus scanning, no file browser UI.
187
290
  - A link serves one range per request; a request for several ranges gets the whole file (`200`), as RFC 9110 allows.
188
291
  No `If-Range` or `ETag`.
189
292
  - Links are `attachment` with `nosniff` and a sandboxing `Content-Security-Policy` by default, so an uploaded HTML or
@@ -18,7 +18,17 @@ export type FilesLookupErrorCode =
18
18
  "files.not_found"
19
19
  /** The asked range starts at or after the end of the file. */
20
20
  | "files.range_not_satisfiable";
21
- export type FilesErrorCode = FilesKeyErrorCode | FilesSaveErrorCode | FilesLookupErrorCode;
21
+ /** Why an upload session could not be created or finalized. */
22
+ export type FilesUploadErrorCode =
23
+ /** The declared media type is not in `uploads.contentTypes`. */
24
+ "files.content_type_not_allowed"
25
+ /** The owner already has `uploads.maxOpenPerOwner` open sessions. */
26
+ | "files.too_many_uploads"
27
+ /** Not every chunk has arrived yet. */
28
+ | "files.upload_incomplete"
29
+ /** The bytes that arrived do not match the declared SHA-256. */
30
+ | "files.checksum_mismatch";
31
+ export type FilesErrorCode = FilesKeyErrorCode | FilesSaveErrorCode | FilesLookupErrorCode | FilesUploadErrorCode;
22
32
  /** A stored file as the app sees it. Never carries the storage key. */
23
33
  export interface StoredFile {
24
34
  readonly id: string;
@@ -48,4 +58,34 @@ export interface FileLink {
48
58
  readonly path: string;
49
59
  readonly expiresAt: Date;
50
60
  }
61
+ /** Where an upload session stands: `open` (chunks missing), `complete` (every chunk arrived), `finalized`, `expired`. */
62
+ export type UploadState = "open" | "complete" | "finalized" | "expired";
63
+ /** A new upload session, as `createUpload` answers it. */
64
+ export interface CreatedUpload {
65
+ readonly uploadId: string;
66
+ /** The absolute URL the client sends the chunks to; it is the only secret the client needs. */
67
+ readonly uploadUrl: string;
68
+ /** The bytes of every chunk but the last. */
69
+ readonly chunkSize: number;
70
+ readonly chunkCount: number;
71
+ readonly expiresAt: Date;
72
+ }
73
+ /** An upload session as its owner and the upload route see it. */
74
+ export interface UploadStatus {
75
+ readonly uploadId: string;
76
+ readonly name: string;
77
+ readonly contentType: string;
78
+ readonly size: number;
79
+ readonly chunkSize: number;
80
+ readonly chunkCount: number;
81
+ /** The byte ranges that arrived, merged and in order. */
82
+ readonly received: readonly ByteRange[];
83
+ readonly receivedBytes: number;
84
+ /** The indices of the chunks still to send, in order. */
85
+ readonly missingChunks: readonly number[];
86
+ readonly state: UploadState;
87
+ /** The stored file, once finalized. */
88
+ readonly fileId: string | null;
89
+ readonly expiresAt: Date;
90
+ }
51
91
  //# sourceMappingURL=contract.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAGA,sFAAsF;AACtF,MAAM,MAAM,iBAAiB;AAC3B,4CAA4C;AAC1C,wBAAwB;AAC1B,sFAAsF;GACpF,wBAAwB,CAAC;AAE7B,qCAAqC;AACrC,MAAM,MAAM,kBAAkB;AAC5B,wGAAwG;AACtG,qBAAqB;AACvB,8CAA8C;GAC5C,iBAAiB;AACnB,iEAAiE;GAC/D,sBAAsB,CAAC;AAE3B,uDAAuD;AACvD,MAAM,MAAM,oBAAoB;AAC9B,+EAA+E;AAC7E,iBAAiB;AACnB,8DAA8D;GAC5D,6BAA6B,CAAC;AAElC,MAAM,MAAM,cAAc,GAAG,iBAAiB,GAAG,kBAAkB,GAAG,oBAAoB,CAAC;AAE3F,uEAAuE;AACvE,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,kFAAkF;IAClF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,4CAA4C;IAC5C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,yGAAyG;IACzG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;CAC1B;AAED,0DAA0D;AAC1D,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;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AAU,EAAE,MAAM,CAAC;IAC5B,yDAAyD;IACzD,QAAQ,CAAC,QAAQ,EAAE,SAAS,SAAS,EAAE,CAAC;IACxC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,yDAAyD;IACzD,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,uCAAuC;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;CAC1B"}
package/dist/index.d.ts CHANGED
@@ -1,10 +1,23 @@
1
1
  export declare const MODULE_ID = "files";
2
+ /**
3
+ * The rate limit bucket of the upload route, to spread into `security({ buckets })` when the app enables the
4
+ * security module: requests per upload session. 64 MiB chunks of a 2 GiB file are 32 requests; the rest is room for
5
+ * resumes and status checks.
6
+ */
7
+ export declare const FILES_RATE_LIMIT_BUCKETS: {
8
+ readonly "files-upload": {
9
+ readonly limit: 600;
10
+ readonly windowMinutes: 15;
11
+ readonly key: "subject";
12
+ };
13
+ };
2
14
  /**
3
15
  * Enables stored files in `softure.config.ts`:
4
16
  * `files({ storage: createLocalStorage({ dir: "/data/files" }), quotaBytesPerOwner: 2 * 1024 ** 3 })`.
5
17
  */
6
18
  export declare const files: import("@softure-ai/core").ModuleFactory<{
7
19
  links: string;
20
+ uploads: string;
8
21
  }, {
9
22
  errors: {
10
23
  files: {
@@ -15,11 +28,26 @@ export declare const files: import("@softure-ai/core").ModuleFactory<{
15
28
  quota_exceeded: string;
16
29
  not_found: string;
17
30
  range_not_satisfiable: string;
31
+ content_type_not_allowed: string;
32
+ too_many_uploads: string;
33
+ upload_incomplete: string;
34
+ checksum_mismatch: string;
18
35
  };
19
36
  core: {
20
37
  unexpected: string;
21
38
  };
22
39
  };
40
+ uploadPage: {
41
+ title: string;
42
+ intro: string;
43
+ expected: string;
44
+ choose: string;
45
+ start: string;
46
+ progress: string;
47
+ done: string;
48
+ wrongSize: string;
49
+ failed: string;
50
+ };
23
51
  }, import("zod").ZodObject<{
24
52
  storage: import("zod").ZodCustom<import("./storage.js").FileStorage, import("./storage.js").FileStorage>;
25
53
  maxFileBytes: import("zod").ZodDefault<import("zod").ZodNumber>;
@@ -33,11 +61,17 @@ export declare const files: import("@softure-ai/core").ModuleFactory<{
33
61
  inline: "inline";
34
62
  }>>;
35
63
  }, import("zod/v4/core").$strict>>;
64
+ uploads: import("zod").ZodDefault<import("zod").ZodObject<{
65
+ chunkBytes: import("zod").ZodDefault<import("zod").ZodNumber>;
66
+ ttlSeconds: import("zod").ZodDefault<import("zod").ZodNumber>;
67
+ maxOpenPerOwner: import("zod").ZodDefault<import("zod").ZodNumber>;
68
+ contentTypes: import("zod").ZodDefault<import("zod").ZodNullable<import("zod").ZodArray<import("zod").ZodString>>>;
69
+ }, import("zod/v4/core").$strict>>;
36
70
  health: import("zod").ZodDefault<import("zod").ZodObject<{
37
71
  minFreeBytes: import("zod").ZodDefault<import("zod").ZodNumber>;
38
72
  }, import("zod/v4/core").$strict>>;
39
73
  }, import("zod/v4/core").$strict>>;
40
- export type { ByteRange, FileLink, FilesErrorCode, FilesKeyErrorCode, FilesLookupErrorCode, FilesSaveErrorCode, StoredFile } from "./contract.js";
74
+ export type { ByteRange, CreatedUpload, FileLink, FilesErrorCode, FilesKeyErrorCode, FilesLookupErrorCode, FilesSaveErrorCode, FilesUploadErrorCode, StoredFile, UploadState, UploadStatus, } from "./contract.js";
41
75
  export { filesMessages, getFilesErrorMessage, type FilesMessages } from "./messages/index.js";
42
76
  export { DEFAULT_FILE_KIND, FILE_KIND_PATTERN, type FilesOptions, type FilesOptionsInput } from "./options.js";
43
77
  export { files as filesTable } from "./schema.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,SAAS,UAAU,CAAC;AAEjC;;;GAGG;AACH,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EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,KAAK,QAAQ,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -7,6 +7,14 @@ import { filesOptionsSchema } from "./options.js";
7
7
  import { checkFilesHealth } from "./server/health.js";
8
8
  import { filesPrivacyContributor } from "./server/privacy.js";
9
9
  export const MODULE_ID = "files";
10
+ /**
11
+ * The rate limit bucket of the upload route, to spread into `security({ buckets })` when the app enables the
12
+ * security module: requests per upload session. 64 MiB chunks of a 2 GiB file are 32 requests; the rest is room for
13
+ * resumes and status checks.
14
+ */
15
+ export const FILES_RATE_LIMIT_BUCKETS = {
16
+ "files-upload": { limit: 600, windowMinutes: 15, key: "subject" },
17
+ };
10
18
  /**
11
19
  * Enables stored files in `softure.config.ts`:
12
20
  * `files({ storage: createLocalStorage({ dir: "/data/files" }), quotaBytesPerOwner: 2 * 1024 ** 3 })`.
@@ -14,10 +22,10 @@ export const MODULE_ID = "files";
14
22
  export const files = defineModule({
15
23
  manifest: {
16
24
  id: MODULE_ID,
17
- version: "0.1.1",
18
- dependsOn: { jobs: "^0.1.6?" },
25
+ version: "0.2.0",
26
+ dependsOn: { jobs: "^0.1.6?", security: "^0.2.5?" },
19
27
  dbSchema: "files",
20
- tables: ["files"],
28
+ tables: ["files", "uploads"],
21
29
  env: [
22
30
  {
23
31
  name: "SOFTURE_FILES_LINK_KEYS",
@@ -26,13 +34,18 @@ export const files = defineModule({
26
34
  },
27
35
  ],
28
36
  switches: [],
29
- routes: { links: "/f" },
37
+ routes: { links: "/f", uploads: "/u" },
30
38
  mount: [
31
39
  {
32
40
  kind: "route-handler",
33
41
  path: "app/f/[...link]/route.ts",
34
42
  export: "serveFileLinkRoute",
35
43
  },
44
+ {
45
+ kind: "route-handler",
46
+ path: "app/u/[...upload]/route.ts",
47
+ export: "serveUploadRoute",
48
+ },
36
49
  ],
37
50
  privacy: { exports: true, deletes: true },
38
51
  },
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,gHAAgH;AAChH,8FAA8F;AAC9F,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAC;AAEjC;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,YAAY,CAAC;IAChC,QAAQ,EAAE;QACR,EAAE,EAAE,SAAS;QACb,OAAO,EAAE,OAAO;QAChB,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;QAC9B,QAAQ,EAAE,OAAO;QACjB,MAAM,EAAE,CAAC,OAAO,CAAC;QACjB,GAAG,EAAE;YACH;gBACE,IAAI,EAAE,yBAAyB;gBAC/B,QAAQ,EAAE,KAAK;gBACf,WAAW,EACT,sJAAsJ;aACzJ;SACF;QACD,QAAQ,EAAE,EAAE;QACZ,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;QACvB,KAAK,EAAE;YACL;gBACE,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE,0BAA0B;gBAChC,MAAM,EAAE,oBAAoB;aAC7B;SACF;QACD,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;KAC1C;IACD,QAAQ,EAAE,aAAa;IACvB,OAAO,EAAE,kBAAkB;IAC3B,UAAU,EAAE,EAAE,GAAG,EAAE,oBAAoB,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,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,IAAI,EAAE,yBAAyB;gBAC/B,QAAQ,EAAE,KAAK;gBACf,WAAW,EACT,sJAAsJ;aACzJ;SACF;QACD,QAAQ,EAAE,EAAE;QACZ,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;QACtC,KAAK,EAAE;YACL;gBACE,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE,0BAA0B;gBAChC,MAAM,EAAE,oBAAoB;aAC7B;YACD;gBACE,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE,4BAA4B;gBAClC,MAAM,EAAE,kBAAkB;aAC3B;SACF;QACD,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;KAC1C;IACD,QAAQ,EAAE,aAAa;IACvB,OAAO,EAAE,kBAAkB;IAC3B,UAAU,EAAE,EAAE,GAAG,EAAE,oBAAoB,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,gBAAgB,CAAC,EAAE;IAC5E,OAAO,EAAE,uBAAuB;IAChC,MAAM,EAAE,gBAAgB;CACzB,CAAC,CAAC;AAeH,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAsB,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAA6C,MAAM,cAAc,CAAC;AAC/G,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,aAAa,EAAsD,MAAM,cAAc,CAAC"}
@@ -0,0 +1,41 @@
1
+ import type { McpServer } from "@modelcontextprotocol/server";
2
+ import type { CreatedUpload } from "../contract.js";
3
+ import type { FilesContext } from "../server/context.js";
4
+ export declare const CREATE_UPLOAD_TOOL_NAME = "create_upload";
5
+ export declare const FINALIZE_UPLOAD_TOOL_NAME = "finalize_upload";
6
+ /** The catalog entries for `mcpAccess({ tools })`, so the token page and the catalog check know both tools. */
7
+ export declare const FILE_UPLOAD_MCP_TOOLS: readonly [{
8
+ readonly name: "create_upload";
9
+ readonly access: "write";
10
+ readonly description: {
11
+ readonly en: "Starts an upload of a large file to a one-time URL.";
12
+ };
13
+ }, {
14
+ readonly name: "finalize_upload";
15
+ readonly access: "write";
16
+ readonly description: {
17
+ readonly en: "Stores a file once its upload is complete.";
18
+ };
19
+ }];
20
+ /** What the tools need of the MCP request's identity (`McpServerIdentity` of `@softure-ai/mcp-access`). */
21
+ export interface FileUploadToolIdentity {
22
+ readonly userId: string;
23
+ readonly canWrite: boolean;
24
+ }
25
+ export interface FileUploadToolsOptions {
26
+ readonly identity: FileUploadToolIdentity;
27
+ /** The files context, e.g. `() => getFilesContext()` from `@softure-ai/files/next`. */
28
+ readonly getContext: () => FilesContext | Promise<FilesContext>;
29
+ /** Whose files the uploads become; the token's user by default. */
30
+ readonly getOwnerId?: (identity: FileUploadToolIdentity) => string;
31
+ /** The kind of the stored files; `file` by default. */
32
+ readonly kind?: string;
33
+ }
34
+ /** Registers `create_upload` and `finalize_upload` for an identity that can write; does nothing for a read-only one. */
35
+ export declare function registerFileUploadTools(server: Pick<McpServer, "registerTool">, options: FileUploadToolsOptions): void;
36
+ /**
37
+ * A bash loop that sends `$FILE` to an upload URL in chunks with `dd` and `curl` (GNU and BSD alike). It stops at the
38
+ * first failed chunk; `CHUNKS="3 4"` before the loop resends only those (the URL answers `missingChunks` to a GET).
39
+ */
40
+ export declare function buildCurlUploadScript(upload: Pick<CreatedUpload, "uploadUrl" | "chunkSize" | "chunkCount">, size: number): string;
41
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAkB,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAG9E,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,gBAAgB,CAAC;AAEhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGzD,eAAO,MAAM,uBAAuB,kBAAkB,CAAC;AACvD,eAAO,MAAM,yBAAyB,oBAAoB,CAAC;AAW3D,+GAA+G;AAC/G,eAAO,MAAM,qBAAqB;;;;;;;;;;;;EAGxB,CAAC;AAEX,2GAA2G;AAC3G,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,CAAC;IAC1C,uFAAuF;IACvF,QAAQ,CAAC,UAAU,EAAE,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAChE,mEAAmE;IACnE,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,sBAAsB,KAAK,MAAM,CAAC;IACnE,uDAAuD;IACvD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAiBD,wHAAwH;AACxH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,EAAE,OAAO,EAAE,sBAAsB,GAAG,IAAI,CAwCtH;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,WAAW,GAAG,WAAW,GAAG,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAYjI"}
@@ -0,0 +1,114 @@
1
+ import { errorLogLabel } from "@softure-ai/core";
2
+ import { z } from "zod";
3
+ import { filesMessages, getFilesErrorMessage } from "../messages/index.js";
4
+ import { createUpload, finalizeUpload } from "../server/uploads.js";
5
+ export const CREATE_UPLOAD_TOOL_NAME = "create_upload";
6
+ export const FINALIZE_UPLOAD_TOOL_NAME = "finalize_upload";
7
+ const CREATE_UPLOAD_DESCRIPTION = "Starts an upload of a file from your own environment (for a file too large for a tool call, such as a video). " +
8
+ "The file's bytes never go through this tool: it answers a one-time upload URL and a ready curl loop that sends the " +
9
+ "file in chunks; run it where the file is, then call finalize_upload with the upload_id. A person can open the " +
10
+ "same URL in a browser to upload the file there instead.";
11
+ const FINALIZE_UPLOAD_DESCRIPTION = "Finishes an upload started with create_upload once every chunk is sent: checks the bytes and stores the file. " +
12
+ "Answers the stored file's id. Calling it again answers the same file.";
13
+ /** The catalog entries for `mcpAccess({ tools })`, so the token page and the catalog check know both tools. */
14
+ export const FILE_UPLOAD_MCP_TOOLS = [
15
+ { name: CREATE_UPLOAD_TOOL_NAME, access: "write", description: { en: "Starts an upload of a large file to a one-time URL." } },
16
+ { name: FINALIZE_UPLOAD_TOOL_NAME, access: "write", description: { en: "Stores a file once its upload is complete." } },
17
+ ];
18
+ const createUploadInput = z.object({
19
+ name: z.string().min(1).max(255).describe("The file's name, e.g. promo.mp4."),
20
+ size: z.number().int().min(1).describe("The file's exact size in bytes (e.g. from `wc -c < file`)."),
21
+ content_type: z.string().min(3).max(255).optional().describe("The media type, e.g. video/mp4."),
22
+ sha256: z
23
+ .string()
24
+ .regex(/^[0-9a-fA-F]{64}$/)
25
+ .optional()
26
+ .describe("The file's SHA-256 in hex; when given, the upload is refused unless the bytes match."),
27
+ });
28
+ const finalizeUploadInput = z.object({
29
+ upload_id: z.string().uuid().describe("The upload_id create_upload answered."),
30
+ });
31
+ /** Registers `create_upload` and `finalize_upload` for an identity that can write; does nothing for a read-only one. */
32
+ export function registerFileUploadTools(server, options) {
33
+ if (!options.identity.canWrite)
34
+ return;
35
+ const ownerId = (options.getOwnerId ?? ((identity) => identity.userId))(options.identity);
36
+ server.registerTool(CREATE_UPLOAD_TOOL_NAME, {
37
+ description: CREATE_UPLOAD_DESCRIPTION,
38
+ inputSchema: createUploadInput,
39
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
40
+ }, (args) => answer(CREATE_UPLOAD_TOOL_NAME, async () => {
41
+ const ctx = await options.getContext();
42
+ const created = await createUpload(ctx, {
43
+ ownerId,
44
+ name: args.name,
45
+ size: args.size,
46
+ ...(args.content_type === undefined ? {} : { contentType: args.content_type }),
47
+ ...(args.sha256 === undefined ? {} : { sha256: args.sha256 }),
48
+ ...(options.kind === undefined ? {} : { kind: options.kind }),
49
+ });
50
+ return created.ok ? describeCreatedUpload(created.value, args.size) : created;
51
+ }));
52
+ server.registerTool(FINALIZE_UPLOAD_TOOL_NAME, {
53
+ description: FINALIZE_UPLOAD_DESCRIPTION,
54
+ inputSchema: finalizeUploadInput,
55
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
56
+ }, (args) => answer(FINALIZE_UPLOAD_TOOL_NAME, async () => {
57
+ const ctx = await options.getContext();
58
+ const finalized = await finalizeUpload(ctx, args.upload_id, { ownerId });
59
+ return finalized.ok ? describeStoredFile(finalized.value) : finalized;
60
+ }));
61
+ }
62
+ /**
63
+ * A bash loop that sends `$FILE` to an upload URL in chunks with `dd` and `curl` (GNU and BSD alike). It stops at the
64
+ * first failed chunk; `CHUNKS="3 4"` before the loop resends only those (the URL answers `missingChunks` to a GET).
65
+ */
66
+ export function buildCurlUploadScript(upload, size) {
67
+ const chunk = String(upload.chunkSize);
68
+ const total = String(size);
69
+ return [
70
+ `FILE='path/to/the/file'`,
71
+ `URL='${upload.uploadUrl}'`,
72
+ `for i in \${CHUNKS:-$(seq 0 ${String(upload.chunkCount - 1)})}; do`,
73
+ ` start=$((i * ${chunk})); end=$((start + ${chunk} - 1)); [ "$end" -ge ${total} ] && end=$((${total} - 1))`,
74
+ ` dd if="$FILE" bs=${chunk} skip="$i" count=1 2>/dev/null | curl -sS --fail -X PUT -H "Content-Range: bytes $start-$end/${total}" --data-binary @- "$URL" >/dev/null || { echo "chunk $i failed: run the loop again with CHUNKS=\\"$i ...\\""; break; }`,
75
+ `done`,
76
+ `curl -sS "$URL"`,
77
+ ].join("\n");
78
+ }
79
+ function describeCreatedUpload(upload, size) {
80
+ return {
81
+ upload_id: upload.uploadId,
82
+ upload_url: upload.uploadUrl,
83
+ chunk_size: upload.chunkSize,
84
+ chunk_count: upload.chunkCount,
85
+ expires_at: upload.expiresAt.toISOString(),
86
+ curl: buildCurlUploadScript(upload, size),
87
+ browser_page: upload.uploadUrl,
88
+ next_step: "Set FILE in the curl loop to the file's path and run it; the last line prints the upload's state. When missingChunks is " +
89
+ "empty, call finalize_upload with this upload_id. A person without a shell can open browser_page instead.",
90
+ };
91
+ }
92
+ function describeStoredFile(file) {
93
+ return { file_id: file.id, name: file.name, size: file.size, content_type: file.contentType, sha256: file.sha256 };
94
+ }
95
+ /** The tool's answer: a value as JSON text, an error code as its English sentence, a thrown error as a fixed text. */
96
+ async function answer(tool, work) {
97
+ try {
98
+ const value = await work();
99
+ if (isFailure(value))
100
+ return failure(`${getFilesErrorMessage(filesMessages.en, value.error)} (${value.error})`);
101
+ return { content: [{ type: "text", text: JSON.stringify(value) }] };
102
+ }
103
+ catch (error) {
104
+ console.error(`@softure-ai/files: tool ${tool} failed: ${errorLogLabel(error)}`);
105
+ return failure(filesMessages.en.errors.core.unexpected);
106
+ }
107
+ }
108
+ function failure(text) {
109
+ return { content: [{ type: "text", text }], isError: true };
110
+ }
111
+ function isFailure(value) {
112
+ return typeof value === "object" && value !== null && "ok" in value && value.ok === false && "error" in value && typeof value.error === "string";
113
+ }
114
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE3E,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEpE,MAAM,CAAC,MAAM,uBAAuB,GAAG,eAAe,CAAC;AACvD,MAAM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,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,2BAA2B,IAAI,YAAY,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjF,OAAO,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC1D,CAAC;AACH,CAAC;AAED,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC9D,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,IAAI,IAAI,KAAK,IAAI,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,OAAO,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,CAAC;AACnJ,CAAC"}
@@ -8,10 +8,25 @@ export declare const en: {
8
8
  quota_exceeded: string;
9
9
  not_found: string;
10
10
  range_not_satisfiable: string;
11
+ content_type_not_allowed: string;
12
+ too_many_uploads: string;
13
+ upload_incomplete: string;
14
+ checksum_mismatch: string;
11
15
  };
12
16
  core: {
13
17
  unexpected: string;
14
18
  };
15
19
  };
20
+ uploadPage: {
21
+ title: string;
22
+ intro: string;
23
+ expected: string;
24
+ choose: string;
25
+ start: string;
26
+ progress: string;
27
+ done: string;
28
+ wrongSize: string;
29
+ failed: string;
30
+ };
16
31
  };
17
32
  //# sourceMappingURL=en.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/messages/en.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;CAed,CAAC"}
1
+ {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/messages/en.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Bd,CAAC"}