stitchkit 0.123.6 → 0.124.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 (56) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/dist/entrypoints/application/diagnostic-journal.js +1 -1
  3. package/dist/entrypoints/application/directory-inbox.js +3 -3
  4. package/dist/entrypoints/cli/publish.js +2 -2
  5. package/dist/entrypoints/cli.js +2 -1
  6. package/dist/entrypoints/files.js +2 -2
  7. package/dist/entrypoints/node.js +2 -2
  8. package/dist/entrypoints/server.js +5 -5
  9. package/dist/entrypoints/telegram.js +1 -1
  10. package/dist/entrypoints/tools/contract.d.ts +1 -1
  11. package/dist/entrypoints/tools/contract.d.ts.map +1 -1
  12. package/dist/entrypoints/tools/contract.js +6 -2
  13. package/dist/entrypoints/tools/toolkit.js +2 -1
  14. package/dist/entrypoints/tools.d.ts +1 -1
  15. package/dist/entrypoints/tools.d.ts.map +1 -1
  16. package/dist/entrypoints/tools.js +53 -52
  17. package/dist/{index-yfpt7sxr.js → index-6qrspvxp.js} +5 -3
  18. package/dist/index-81t0bf0f.js +18 -0
  19. package/dist/{index-d9cg0gen.js → index-8yky60kq.js} +1 -1
  20. package/dist/{index-bph35vpy.js → index-9cxxfkhb.js} +21 -1
  21. package/dist/{index-73dappvg.js → index-ezwvsqx9.js} +1 -1
  22. package/dist/index-gy9x38a2.js +40 -0
  23. package/dist/{index-chz7c830.js → index-mqttte96.js} +39 -6
  24. package/dist/{index-xjb131sc.js → index-q89kd1xc.js} +194 -51
  25. package/dist/{index-eabx6qjh.js → index-tnnmekgb.js} +1 -6
  26. package/dist/index-zs8cze4j.js +6 -0
  27. package/dist/internal/exclusive-lock.d.ts.map +1 -1
  28. package/dist/internal/media-extension.d.ts +3 -0
  29. package/dist/internal/media-extension.d.ts.map +1 -0
  30. package/dist/tools/cli/args.d.ts +1 -1
  31. package/dist/tools/cli/args.d.ts.map +1 -1
  32. package/dist/tools/cli/command.d.ts +7 -1
  33. package/dist/tools/cli/command.d.ts.map +1 -1
  34. package/dist/tools/cli/config.d.ts +5 -2
  35. package/dist/tools/cli/config.d.ts.map +1 -1
  36. package/dist/tools/cli/download.d.ts +25 -4
  37. package/dist/tools/cli/download.d.ts.map +1 -1
  38. package/dist/tools/cli/inline-files.d.ts +70 -0
  39. package/dist/tools/cli/inline-files.d.ts.map +1 -0
  40. package/dist/tools/cli/session.d.ts.map +1 -1
  41. package/dist/tools/transfer/download-core.d.ts +2 -0
  42. package/dist/tools/transfer/download-core.d.ts.map +1 -1
  43. package/dist/tools/transfer/view-file-contract.d.ts +45 -4
  44. package/dist/tools/transfer/view-file-contract.d.ts.map +1 -1
  45. package/dist/tools/transfer/view-file.d.ts +1 -1
  46. package/dist/tools/transfer/view-file.d.ts.map +1 -1
  47. package/llms/cli.txt +64 -3
  48. package/llms/stitchkit.txt +3 -3
  49. package/llms/tools.2.txt +11 -0
  50. package/llms/tools.3.txt +2 -1
  51. package/llms/{upgrading-0.106.0-0.123.0.txt → upgrading-0.106.0-0.124.0.txt} +39 -3
  52. package/llms/upgrading.txt +1 -1
  53. package/llms-full.txt +116 -7
  54. package/llms.txt +3 -3
  55. package/package.json +1 -1
  56. package/dist/index-sba3e6m4.js +0 -52
package/CHANGELOG.md CHANGED
@@ -15,6 +15,86 @@ additive**; the first breaking change landed in 0.10.0. Grep the file for
15
15
 
16
16
  ## [Unreleased]
17
17
 
18
+ ## [0.124.0] - 2026-11-17
19
+
20
+ ### ⚠️ Breaking changes
21
+
22
+ **Who must act:** code that builds or reads an `image` or `audio` block of `McpMediaContentSchema` with a `name` — a tool that returns such a block, or a reader of a `defineViewFileTool`, `mountViewFile` or `resolveMedia` result. See the migration: [media-block-file-name](docs/guide/upgrading.md#media-block-file-name).
23
+
24
+ - `stitchkit/tools`, `stitchkit/tools/contract` — **the file name of an image or audio block
25
+ lives in its `_meta`, and the block has no `name`.** MCP's `ImageContent` and `AudioContent`
26
+ declare no file name, and the MCP server SDK drops a field they do not declare from `content`
27
+ before a result is sent: the `name` added in 0.123.7 reached `structuredContent` and an Agent,
28
+ and never a host reading `content` or a caller of the raw `mountViewFile`. A block of
29
+ `McpMediaContentSchema` is now the protocol's block field for field — `type`, `data`,
30
+ `mimeType`, `annotations`, `_meta` — and the name is `_meta['stitchkit/fileName']`, exported
31
+ as `MCP_FILE_NAME_META_KEY`. `defineViewFileTool`, `mountViewFile` and `resolveMedia` set it;
32
+ the handler output, the Agent result, `structuredContent` and MCP `content` carry the same
33
+ block. A `name` on a block is not read any more: the schema drops it, and a TypeScript object
34
+ typed `McpMediaContent` does not compile with it.
35
+ Before: `{ type: 'image', data, mimeType, name: 'shot.png' }`. After: `{ type: 'image', data, mimeType, _meta: { [MCP_FILE_NAME_META_KEY]: 'shot.png' } }`.
36
+ [migration](docs/guide/upgrading.md#media-block-file-name). → ADR 0292
37
+ **Affects:** `stitchkit/tools` McpMediaContentSchema, McpMediaContent, ViewFileOutputSchema, ViewFileOutput, defineViewFileTool, mountViewFile, resolveMedia; `stitchkit/tools/contract` McpMediaContentSchema, McpMediaContent, ViewFileOutputSchema, ViewFileOutput
38
+
39
+ ### Fixed
40
+
41
+ - `stitchkit/cli` — **`--output-dir` saves the media of a raw `mountViewFile` under its source
42
+ name through an MCP connection.** That result has no `structuredContent`, so the name the
43
+ block lost on the wire left the file named `image-<sha256>.png`. The CLI reads the name where
44
+ the block now carries it, `_meta['stitchkit/fileName']`.
45
+ **Affects:** `stitchkit/cli` behaviour
46
+
47
+ ## [0.123.7] - 2026-11-17
48
+
49
+ ### Added
50
+
51
+ - `stitchkit/cli` — **`--output-dir` saves the files a result carries inline and prints links
52
+ to them.** The blocks of a successful result's top-level `content` that hold a file — `image`
53
+ and `audio` of `McpMediaContentSchema`, and an embedded `resource` of any type with `blob` or
54
+ `text` (a PDF, a spreadsheet, a CSV) — are saved without a `download` callback, in the same
55
+ batch, pinned directory and atomic contained writer as URL downloads. This covers a
56
+ `defineViewFileTool` result and a tool mounted through MCP. A part of any other shape is left
57
+ alone. A media block's `name`, or the last path segment of a resource's `uri`, supplies the
58
+ file's basename; a block that names no file is `<type>-<sha256 of its bytes><extension>`.
59
+ Canonical base64 is validated and `maxDownloadBytes` is checked before the bytes are
60
+ allocated, one file at a time. On stdout each saved block becomes
61
+ `{ type: 'resource_link', uri: 'file://…', name, mimeType, size }`, so the bytes are not
62
+ printed again; a block that could not be saved keeps its bytes and the exit is `1`. A result
63
+ policy still receives the operation's own result. A result with no media prints and exits as
64
+ it does without the flag, and stderr says that nothing was saved — so `--output-dir` on a CLI
65
+ without a `download` callback runs the command instead of refusing it with exit `2`.
66
+ [guide](docs/guide/cli.md#saving-result-media). → ADR 0291
67
+
68
+ - `stitchkit/tools`, `stitchkit/tools/contract` — **An image or audio block carries the file
69
+ name of its source.** `McpMediaContentSchema` gains an optional `name` on its `image` and
70
+ `audio` blocks. `defineViewFileTool`, `mountViewFile` and `resolveMedia` set it: a managed
71
+ file keeps its own name, a URL takes its download name — the path's base name with the body's
72
+ extension. The name travels inside the block, over MCP as well. A download whose body is
73
+ `audio/mp4` is named `.m4a`.
74
+
75
+ ### Fixed
76
+
77
+ - `stitchkit/cli` — **Two `--output-dir` files with one name do not replace each other.** A
78
+ `download` callback that named two different files alike left the last one on disk while both
79
+ printed `saved`. A name is written once per batch: the same bytes again are one file,
80
+ different bytes fail that file with `another file of this batch is already saved as "<name>"`
81
+ and exit `1`, and the first file stays.
82
+ **Affects:** `stitchkit/cli` behaviour
83
+
84
+ - `stitchkit/cli` — **A `maxDownloadBytes` that is not a positive safe integer is refused when
85
+ the CLI is created**, with the shared limit message that ends in the value received. A
86
+ fractional, zero, negative or non-finite cap used to reach the first download.
87
+ **Affects:** `stitchkit/cli` createCli(maxDownloadBytes)
88
+
89
+ - `stitchkit/files` — **Reclaiming a dead owner's lock never removes a live one.** A reclaimer
90
+ judged the lock's record, then removed the file by its inode number. If the judged owner
91
+ released in between and a new holder created the lock on the freed inode, the live lock was
92
+ removed and two processes held it at once — seen under load when several processes recovered
93
+ a lock and its reclaim guard together. The reclaimer now keeps a descriptor open on the judged
94
+ file, so its inode cannot be reused, and removes it only while the name still holds that file
95
+ with the judged record; a lock replaced meanwhile refuses the reclaim and is waited for.
96
+ **Affects:** `stitchkit/files` withExclusiveLock(behaviour)
97
+
18
98
  ## [0.123.6] - 2026-11-16
19
99
 
20
100
  ### Added
@@ -21,7 +21,7 @@ import"../../index-sqc6ezrb.js";
21
21
  import"../../index-bqzgaj57.js";
22
22
  import {
23
23
  attemptExclusiveLock
24
- } from "../../index-chz7c830.js";
24
+ } from "../../index-mqttte96.js";
25
25
  import {
26
26
  BoundedFileReadError,
27
27
  openRegularFile
@@ -15,14 +15,14 @@ import {
15
15
  } from "../../index-g6a3na27.js";
16
16
  import"../../index-sqc6ezrb.js";
17
17
  import"../../index-bqzgaj57.js";
18
- import"../../index-chz7c830.js";
18
+ import"../../index-mqttte96.js";
19
19
  import {
20
20
  defineManagedResource2
21
21
  } from "../../index-50ejfz75.js";
22
22
  import {
23
23
  createFileStateStore2
24
- } from "../../index-d9cg0gen.js";
25
- import"../../index-73dappvg.js";
24
+ } from "../../index-8yky60kq.js";
25
+ import"../../index-ezwvsqx9.js";
26
26
  import {
27
27
  isJsonData
28
28
  } from "../../index-m6w6jtda.js";
@@ -1,7 +1,7 @@
1
1
  import"../../index-xqhede6x.js";
2
2
  import"../../index-sqc6ezrb.js";
3
3
  import"../../index-bqzgaj57.js";
4
- import"../../index-chz7c830.js";
4
+ import"../../index-mqttte96.js";
5
5
  import {
6
6
  signCliManifest2,
7
7
  verifyCliManifest2,
@@ -18,7 +18,7 @@ import {
18
18
  } from "../../index-tt3ej8r3.js";
19
19
  import {
20
20
  withExclusiveLock2
21
- } from "../../index-73dappvg.js";
21
+ } from "../../index-ezwvsqx9.js";
22
22
  import {
23
23
  ManagedFileError2,
24
24
  createManagedFileBoundary2
@@ -17,7 +17,7 @@ import {
17
17
  renderCliView2,
18
18
  pollUntilDone2,
19
19
  createCli2
20
- } from "../index-xjb131sc.js";
20
+ } from "../index-q89kd1xc.js";
21
21
  import"../index-ndjzbt2v.js";
22
22
  import"../index-ct75c3at.js";
23
23
  import"../index-tynna0n4.js";
@@ -26,6 +26,7 @@ import"../index-yt1gg11x.js";
26
26
  import"../index-qc7tq0za.js";
27
27
  import"../index-332d0m9g.js";
28
28
  import"../index-sqc6ezrb.js";
29
+ import"../index-gy9x38a2.js";
29
30
  import"../index-0v9xb8pz.js";
30
31
  import {
31
32
  CliBuildSignatureSchema2,
@@ -4,14 +4,14 @@ import {
4
4
  } from "../index-xqhede6x.js";
5
5
  import"../index-sqc6ezrb.js";
6
6
  import"../index-bqzgaj57.js";
7
- import"../index-chz7c830.js";
7
+ import"../index-mqttte96.js";
8
8
  import {
9
9
  bindUnixSocket2
10
10
  } from "../index-drcjjhy1.js";
11
11
  import {
12
12
  ExclusiveLockError2,
13
13
  withExclusiveLock2
14
- } from "../index-73dappvg.js";
14
+ } from "../index-ezwvsqx9.js";
15
15
  import {
16
16
  ManagedFileError2,
17
17
  createManagedFileBoundary2
@@ -24,7 +24,7 @@ import {
24
24
  createSocketIOServer2,
25
25
  UnixClientTransportError2,
26
26
  createUnixClientTransport2
27
- } from "../index-yfpt7sxr.js";
27
+ } from "../index-6qrspvxp.js";
28
28
  import {
29
29
  bindRealtimeServer2
30
30
  } from "../index-sqkttz7z.js";
@@ -33,7 +33,7 @@ import {
33
33
  implement2,
34
34
  createImplement2,
35
35
  createScopedImplement2
36
- } from "../index-eabx6qjh.js";
36
+ } from "../index-tnnmekgb.js";
37
37
  import"../index-9ypczvpj.js";
38
38
  import {
39
39
  AppError2,
@@ -1,6 +1,6 @@
1
1
  import"../index-sqc6ezrb.js";
2
2
  import"../index-bqzgaj57.js";
3
- import"../index-chz7c830.js";
3
+ import"../index-mqttte96.js";
4
4
  import {
5
5
  errorCode2,
6
6
  normalizeError2
@@ -53,17 +53,17 @@ import {
53
53
  socketIoLane2,
54
54
  UnixClientTransportError2,
55
55
  createUnixClientTransport2
56
- } from "../index-yfpt7sxr.js";
56
+ } from "../index-6qrspvxp.js";
57
57
  import {
58
58
  createFileStateStore2
59
- } from "../index-d9cg0gen.js";
59
+ } from "../index-8yky60kq.js";
60
60
  import {
61
61
  bindRealtimeServer2
62
62
  } from "../index-sqkttz7z.js";
63
63
  import {
64
64
  bindUnixSocket2
65
65
  } from "../index-drcjjhy1.js";
66
- import"../index-73dappvg.js";
66
+ import"../index-ezwvsqx9.js";
67
67
  import {
68
68
  withDeadline
69
69
  } from "../index-9tqbxv5p.js";
@@ -84,7 +84,7 @@ import {
84
84
  implement2,
85
85
  createImplement2,
86
86
  createScopedImplement2
87
- } from "../index-eabx6qjh.js";
87
+ } from "../index-tnnmekgb.js";
88
88
  import"../index-9ypczvpj.js";
89
89
  import {
90
90
  DEFAULT_CORS_ALLOW_HEADERS2,
@@ -5,7 +5,7 @@ import"../index-sqc6ezrb.js";
5
5
  import"../index-bqzgaj57.js";
6
6
  import {
7
7
  attemptExclusiveLock
8
- } from "../index-chz7c830.js";
8
+ } from "../index-mqttte96.js";
9
9
  import {
10
10
  TELEGRAM_WIDGET_LIMITS2,
11
11
  TelegramWidgetHtmlSchema2,
@@ -25,5 +25,5 @@
25
25
  */
26
26
  export { type AsyncOperationCancelResult, AsyncOperationCancelResultSchema, type AsyncOperationCapability, type AsyncOperationSnapshotSchema, type AsyncOperationSnapshotSchemaWithProgress, createAsyncOperationSnapshotSchema, } from '../../tools/operations/async-operation-contract.js';
27
27
  export { coerceJsonArgs } from '../../tools/schema/coerce.js';
28
- export { type McpAnnotations, McpAnnotationsSchema, type McpMediaContent, McpMediaContentSchema, ViewFileErrorSchema, ViewFileInputSchema, type ViewFileOutput, ViewFileOutputSchema, } from '../../tools/transfer/view-file-contract.js';
28
+ export { MCP_FILE_NAME_META_KEY, type McpAnnotations, McpAnnotationsSchema, type McpMediaContent, McpMediaContentSchema, ViewFileErrorSchema, ViewFileInputSchema, type ViewFileOutput, ViewFileOutputSchema, } from '../../tools/transfer/view-file-contract.js';
29
29
  //# sourceMappingURL=contract.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../../src/entrypoints/tools/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EACL,KAAK,0BAA0B,EAC/B,gCAAgC,EAChC,KAAK,wBAAwB,EAC7B,KAAK,4BAA4B,EACjC,KAAK,wCAAwC,EAC7C,kCAAkC,GACnC,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EACL,KAAK,cAAc,EACnB,oBAAoB,EACpB,KAAK,eAAe,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,KAAK,cAAc,EACnB,oBAAoB,GACrB,MAAM,yCAAyC,CAAC"}
1
+ {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../../src/entrypoints/tools/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EACL,KAAK,0BAA0B,EAC/B,gCAAgC,EAChC,KAAK,wBAAwB,EAC7B,KAAK,4BAA4B,EACjC,KAAK,wCAAwC,EAC7C,kCAAkC,GACnC,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EACL,sBAAsB,EACtB,KAAK,cAAc,EACnB,oBAAoB,EACpB,KAAK,eAAe,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,KAAK,cAAc,EACnB,oBAAoB,GACrB,MAAM,yCAAyC,CAAC"}
@@ -1,18 +1,22 @@
1
1
  import {
2
2
  AsyncOperationCancelResultSchema2,
3
- createAsyncOperationSnapshotSchema2,
3
+ createAsyncOperationSnapshotSchema2
4
+ } from "../../index-81t0bf0f.js";
5
+ import {
4
6
  McpAnnotationsSchema2,
7
+ MCP_FILE_NAME_META_KEY2,
5
8
  McpMediaContentSchema2,
6
9
  ViewFileErrorSchema2,
7
10
  ViewFileOutputSchema2,
8
11
  ViewFileInputSchema2
9
- } from "../../index-sba3e6m4.js";
12
+ } from "../../index-gy9x38a2.js";
10
13
  import {
11
14
  coerceJsonArgs2
12
15
  } from "../../index-t8jz0e20.js";
13
16
  import"../../index-dsa676h8.js";
14
17
  export {
15
18
  AsyncOperationCancelResultSchema2 as AsyncOperationCancelResultSchema,
19
+ MCP_FILE_NAME_META_KEY2 as MCP_FILE_NAME_META_KEY,
16
20
  McpAnnotationsSchema2 as McpAnnotationsSchema,
17
21
  McpMediaContentSchema2 as McpMediaContentSchema,
18
22
  ViewFileErrorSchema2 as ViewFileErrorSchema,
@@ -11,9 +11,10 @@ import {
11
11
  } from "../../index-yebkpytc.js";
12
12
  import {
13
13
  createCli2
14
- } from "../../index-xjb131sc.js";
14
+ } from "../../index-q89kd1xc.js";
15
15
  import"../../index-332d0m9g.js";
16
16
  import"../../index-sqc6ezrb.js";
17
+ import"../../index-gy9x38a2.js";
17
18
  import"../../index-0v9xb8pz.js";
18
19
  import {
19
20
  mountMcp2,
@@ -38,7 +38,7 @@ export { type DefineUploadToolConfig, defineUploadTool, UploadToolInputSchema, }
38
38
  export { type DefineViewFileToolConfig, defineViewFileTool, } from '../tools/transfer/define-view-file-tool.js';
39
39
  export { type DownloadToolConfig, mountDownload } from '../tools/transfer/mount-download.js';
40
40
  export { mountUpload, type UploadToolConfig } from '../tools/transfer/mount-upload.js';
41
- export { mountViewFile, resolveMedia, type ViewFileOptions, } from '../tools/transfer/view-file.js';
41
+ export { MCP_FILE_NAME_META_KEY, mountViewFile, resolveMedia, type ViewFileOptions, } from '../tools/transfer/view-file.js';
42
42
  export { summarizeTransports, type TransportCounts, type TransportSummary, } from '../tools/transports.js';
43
43
  export * from './tools/contract.js';
44
44
  //# sourceMappingURL=tools.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.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27 @@ import {
37
37
  } from "../index-99nnsz39.js";
38
38
  import {
39
39
  AsyncOperationCancelResultSchema2,
40
- createAsyncOperationSnapshotSchema2,
40
+ createAsyncOperationSnapshotSchema2
41
+ } from "../index-81t0bf0f.js";
42
+ import {
43
+ ManagedFilePathSchema2,
44
+ ManagedFileRefSchema2
45
+ } from "../index-xqhede6x.js";
46
+ import {
41
47
  McpAnnotationsSchema2,
48
+ MCP_FILE_NAME_META_KEY2,
42
49
  McpMediaContentSchema2,
43
50
  ViewFileErrorSchema2,
44
51
  ViewFileOutputSchema2,
45
52
  ViewFileInputSchema2
46
- } from "../index-sba3e6m4.js";
47
- import {
48
- ManagedFilePathSchema2,
49
- ManagedFileRefSchema2
50
- } from "../index-xqhede6x.js";
53
+ } from "../index-gy9x38a2.js";
51
54
  import {
52
55
  signJwt2,
53
56
  verifyPkce2
54
57
  } from "../index-hkw233vx.js";
55
58
  import {
56
- contractOnlyService,
57
- mediaTypeEssence
58
- } from "../index-eabx6qjh.js";
59
+ contractOnlyService
60
+ } from "../index-tnnmekgb.js";
59
61
  import"../index-9ypczvpj.js";
60
62
  import {
61
63
  describeToolCatalog2,
@@ -80,8 +82,12 @@ import {
80
82
  } from "../index-96yjwwgf.js";
81
83
  import {
82
84
  WaitTimeoutError,
83
- runWaitOperation
84
- } from "../index-bph35vpy.js";
85
+ runWaitOperation,
86
+ mediaExtension
87
+ } from "../index-9cxxfkhb.js";
88
+ import {
89
+ mediaTypeEssence
90
+ } from "../index-zs8cze4j.js";
85
91
  import {
86
92
  collectToolSurface
87
93
  } from "../index-993vtv1w.js";
@@ -1410,17 +1416,6 @@ function createToolLogger(config = {}) {
1410
1416
  // src/tools/transfer/download-core.ts
1411
1417
  import { basename, extname } from "node:path";
1412
1418
  var DEFAULT_MAX_BYTES = 100 * 1024 * 1024;
1413
- var MIME_EXT = {
1414
- "image/png": ".png",
1415
- "image/jpeg": ".jpg",
1416
- "image/webp": ".webp",
1417
- "image/gif": ".gif",
1418
- "video/mp4": ".mp4",
1419
- "video/webm": ".webm",
1420
- "audio/mpeg": ".mp3",
1421
- "audio/wav": ".wav",
1422
- "audio/ogg": ".ogg"
1423
- };
1424
1419
 
1425
1420
  class DownloadOperationError extends Error {
1426
1421
  code;
@@ -1433,8 +1428,9 @@ class DownloadOperationError extends Error {
1433
1428
  }
1434
1429
  }
1435
1430
  function extensionFor(url, mime) {
1436
- if (MIME_EXT[mime])
1437
- return MIME_EXT[mime];
1431
+ const known = mediaExtension(mime);
1432
+ if (known)
1433
+ return known;
1438
1434
  try {
1439
1435
  const ext = extname(new URL(url).pathname).toLowerCase();
1440
1436
  if (ext)
@@ -1450,6 +1446,9 @@ function baseNameFor(url) {
1450
1446
  return "download";
1451
1447
  }
1452
1448
  }
1449
+ function downloadFileName(url, mime) {
1450
+ return `${baseNameFor(url)}${extensionFor(url, mime)}`;
1451
+ }
1453
1452
  async function runDownloadOperation(config) {
1454
1453
  const res = await fetchGuarded(new URL(config.url), config.allowPrivateHosts ?? false, {
1455
1454
  timeoutMs: config.timeoutMs,
@@ -1465,7 +1464,7 @@ async function runDownloadOperation(config) {
1465
1464
  await res.body?.cancel();
1466
1465
  throw new DownloadOperationError("DOWNLOAD_TOO_LARGE", `file exceeds the ${max}-byte cap`, 413);
1467
1466
  }
1468
- const path = config.path ?? `${baseNameFor(config.url)}${extensionFor(config.url, mimeType)}`;
1467
+ const path = config.path ?? downloadFileName(config.url, mimeType);
1469
1468
  return config.files.write(path, res.body ?? new Uint8Array, {
1470
1469
  maxBytes: max,
1471
1470
  mediaType: mimeType,
@@ -1604,7 +1603,7 @@ function defineUploadTool(config) {
1604
1603
  });
1605
1604
  }
1606
1605
  // src/tools/transfer/view-file.ts
1607
- import { extname as extname2 } from "node:path";
1606
+ import { basename as basename2, extname as extname2 } from "node:path";
1608
1607
  import { z as z5 } from "zod";
1609
1608
  var MAX_INLINE_BYTES = 20 * 1024 * 1024;
1610
1609
  var EXT_MIME = {
@@ -1621,10 +1620,23 @@ var EXT_MIME = {
1621
1620
  ".webm": "video/webm",
1622
1621
  ".mov": "video/quicktime"
1623
1622
  };
1623
+ function isHttpUrl(pathOrUrl) {
1624
+ return pathOrUrl.startsWith("http://") || pathOrUrl.startsWith("https://");
1625
+ }
1626
+ function sourceName(pathOrUrl, mimeType) {
1627
+ return isHttpUrl(pathOrUrl) ? downloadFileName(pathOrUrl, mimeType) : basename2(pathOrUrl);
1628
+ }
1629
+ function inlineBlockType(mimeType) {
1630
+ if (mimeType.startsWith("image/"))
1631
+ return "image";
1632
+ if (mimeType.startsWith("audio/"))
1633
+ return "audio";
1634
+ return;
1635
+ }
1624
1636
  async function fetchSource(pathOrUrl, options, maxBytes) {
1625
1637
  const extension = extname2(pathOrUrl);
1626
1638
  const extMime = EXT_MIME[extension.toLowerCase()];
1627
- if (pathOrUrl.startsWith("http://") || pathOrUrl.startsWith("https://")) {
1639
+ if (isHttpUrl(pathOrUrl)) {
1628
1640
  const url = new URL(pathOrUrl);
1629
1641
  const res = await fetchGuarded(url, options.allowPrivateHosts ?? false, {
1630
1642
  timeoutMs: options.timeoutMs,
@@ -1710,36 +1722,24 @@ async function resolveMediaWithinBudget(pathOrUrl, options, maxBytes) {
1710
1722
  }
1711
1723
  const { buffer, mimeType } = result;
1712
1724
  const sizeKb = (buffer.length / 1024).toFixed(0);
1713
- if (mimeType.startsWith("image/")) {
1725
+ const type = inlineBlockType(mimeType);
1726
+ if (type === undefined) {
1714
1727
  return {
1715
- content: [
1716
- {
1717
- type: "image",
1718
- data: buffer.toString("base64"),
1719
- mimeType,
1720
- annotations: { audience: ["user", "assistant"], priority: 0.9 }
1721
- },
1722
- { type: "text", text: `[image] ${mimeType}, ${sizeKb}KB` }
1723
- ],
1724
- bytes: buffer.length
1725
- };
1726
- }
1727
- if (mimeType.startsWith("audio/")) {
1728
- return {
1729
- content: [
1730
- {
1731
- type: "audio",
1732
- data: buffer.toString("base64"),
1733
- mimeType,
1734
- annotations: { audience: ["user", "assistant"], priority: 0.9 }
1735
- },
1736
- { type: "text", text: `[audio] ${mimeType}, ${sizeKb}KB` }
1737
- ],
1728
+ content: [{ type: "text", text: `[${mimeType}] ${sizeKb}KB — ${pathOrUrl}` }],
1738
1729
  bytes: buffer.length
1739
1730
  };
1740
1731
  }
1741
1732
  return {
1742
- content: [{ type: "text", text: `[${mimeType}] ${sizeKb}KB — ${pathOrUrl}` }],
1733
+ content: [
1734
+ {
1735
+ type,
1736
+ data: buffer.toString("base64"),
1737
+ mimeType,
1738
+ annotations: { audience: ["user", "assistant"], priority: 0.9 },
1739
+ _meta: { [MCP_FILE_NAME_META_KEY2]: sourceName(pathOrUrl, mimeType) }
1740
+ },
1741
+ { type: "text", text: `[${type}] ${mimeType}, ${sizeKb}KB` }
1742
+ ],
1743
1743
  bytes: buffer.length
1744
1744
  };
1745
1745
  }
@@ -1944,6 +1944,7 @@ export {
1944
1944
  AgentToolError2 as AgentToolError,
1945
1945
  AsyncOperationCancelResultSchema2 as AsyncOperationCancelResultSchema,
1946
1946
  EffectUnresolvedError2 as EffectUnresolvedError,
1947
+ MCP_FILE_NAME_META_KEY2 as MCP_FILE_NAME_META_KEY,
1947
1948
  McpAnnotationsSchema2 as McpAnnotationsSchema,
1948
1949
  McpMediaContentSchema2 as McpMediaContentSchema,
1949
1950
  PORTABLE_JSON_SCHEMA_FORMATS2 as PORTABLE_JSON_SCHEMA_FORMATS,
@@ -32,9 +32,8 @@ import {
32
32
  isModuleNotFound
33
33
  } from "./index-srs8hj9c.js";
34
34
  import {
35
- bindContract,
36
- mediaTypeEssence
37
- } from "./index-eabx6qjh.js";
35
+ bindContract
36
+ } from "./index-tnnmekgb.js";
38
37
  import {
39
38
  assertCorsConfig,
40
39
  isOriginAllowed,
@@ -42,6 +41,9 @@ import {
42
41
  requestCorsHeaders,
43
42
  applyCors
44
43
  } from "./index-pq7rkwkk.js";
44
+ import {
45
+ mediaTypeEssence
46
+ } from "./index-zs8cze4j.js";
45
47
  import {
46
48
  runWithRequestContext2,
47
49
  getRequestContext2,
@@ -0,0 +1,18 @@
1
+ // src/tools/operations/async-operation-contract.ts
2
+ import { z } from "zod";
3
+ var AsyncOperationCancelResultSchema2 = z.discriminatedUnion("outcome", [
4
+ z.object({ outcome: z.literal("accepted") }),
5
+ z.object({ outcome: z.literal("already_terminal") }),
6
+ z.object({ outcome: z.literal("rejected"), reason: z.string().min(1) })
7
+ ]);
8
+ function createAsyncOperationSnapshotSchema2(config) {
9
+ const progress = config.progress ? { progress: config.progress.optional() } : {};
10
+ return z.discriminatedUnion("phase", [
11
+ z.object({ phase: z.literal("pending"), ...progress }),
12
+ z.object({ phase: z.literal("running"), ...progress }),
13
+ z.object({ phase: z.literal("succeeded"), ...progress }),
14
+ z.object({ phase: z.literal("failed"), failure: config.failure, ...progress }),
15
+ z.object({ phase: z.literal("cancelled"), ...progress })
16
+ ]);
17
+ }
18
+ export { AsyncOperationCancelResultSchema2, createAsyncOperationSnapshotSchema2 };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  withExclusiveLock2
3
- } from "./index-73dappvg.js";
3
+ } from "./index-ezwvsqx9.js";
4
4
  import {
5
5
  readBoundedFile
6
6
  } from "./index-m616f0yz.js";
@@ -1,3 +1,6 @@
1
+ import {
2
+ mediaTypeEssence
3
+ } from "./index-zs8cze4j.js";
1
4
  import {
2
5
  sleep
3
6
  } from "./index-eemvahkc.js";
@@ -74,4 +77,21 @@ function runWaitOperation(params) {
74
77
  });
75
78
  }
76
79
 
77
- export { WaitTimeoutError, pollUntil, runWaitOperation };
80
+ // src/internal/media-extension.ts
81
+ var MIME_EXT = new Map([
82
+ ["image/png", ".png"],
83
+ ["image/jpeg", ".jpg"],
84
+ ["image/webp", ".webp"],
85
+ ["image/gif", ".gif"],
86
+ ["video/mp4", ".mp4"],
87
+ ["video/webm", ".webm"],
88
+ ["audio/mpeg", ".mp3"],
89
+ ["audio/wav", ".wav"],
90
+ ["audio/ogg", ".ogg"],
91
+ ["audio/mp4", ".m4a"]
92
+ ]);
93
+ function mediaExtension(contentType) {
94
+ return MIME_EXT.get(mediaTypeEssence(contentType));
95
+ }
96
+
97
+ export { WaitTimeoutError, pollUntil, runWaitOperation, mediaExtension };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  attemptExclusiveLock
3
- } from "./index-chz7c830.js";
3
+ } from "./index-mqttte96.js";
4
4
  import {
5
5
  sleep
6
6
  } from "./index-eemvahkc.js";
@@ -0,0 +1,40 @@
1
+ // src/tools/transfer/view-file-contract.ts
2
+ import { z } from "zod";
3
+ var MAX_VIEW_FILES = 20;
4
+ var McpAnnotationsSchema2 = z.object({
5
+ audience: z.array(z.enum(["user", "assistant"])).optional(),
6
+ priority: z.number().optional()
7
+ });
8
+ var MCP_FILE_NAME_META_KEY2 = "stitchkit/fileName";
9
+ var inlineMediaShape = {
10
+ data: z.string(),
11
+ mimeType: z.string(),
12
+ annotations: McpAnnotationsSchema2.optional(),
13
+ _meta: z.record(z.string(), z.unknown()).optional()
14
+ };
15
+ var McpImageContentSchema = z.object({
16
+ type: z.literal("image"),
17
+ ...inlineMediaShape
18
+ });
19
+ var McpAudioContentSchema = z.object({
20
+ type: z.literal("audio"),
21
+ ...inlineMediaShape
22
+ });
23
+ var McpMediaContentSchema2 = z.discriminatedUnion("type", [
24
+ z.object({ type: z.literal("text"), text: z.string() }),
25
+ McpImageContentSchema,
26
+ McpAudioContentSchema
27
+ ]);
28
+ var ViewFileErrorSchema2 = z.object({
29
+ path: z.string(),
30
+ message: z.string()
31
+ });
32
+ var ViewFileOutputSchema2 = z.object({
33
+ content: z.array(McpMediaContentSchema2),
34
+ errors: z.array(ViewFileErrorSchema2)
35
+ });
36
+ var ViewFileInputSchema2 = z.object({
37
+ paths: z.union([z.string(), z.array(z.string()).max(MAX_VIEW_FILES)]).describe("One media URL or file path, or an array of them. Pass the array itself, not JSON written as text.")
38
+ });
39
+
40
+ export { McpAnnotationsSchema2, MCP_FILE_NAME_META_KEY2, McpImageContentSchema, McpAudioContentSchema, McpMediaContentSchema2, ViewFileErrorSchema2, ViewFileOutputSchema2, ViewFileInputSchema2 };