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
@@ -0,0 +1,70 @@
1
+ import { z } from 'zod';
2
+ declare const InlineFileSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
3
+ data: z.ZodString;
4
+ mimeType: z.ZodString;
5
+ annotations: z.ZodOptional<z.ZodObject<{
6
+ audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
7
+ assistant: "assistant";
8
+ user: "user";
9
+ }>>>;
10
+ priority: z.ZodOptional<z.ZodNumber>;
11
+ }, z.core.$strip>>;
12
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
13
+ type: z.ZodLiteral<"image">;
14
+ }, z.core.$strip>, z.ZodObject<{
15
+ data: z.ZodString;
16
+ mimeType: z.ZodString;
17
+ annotations: z.ZodOptional<z.ZodObject<{
18
+ audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
19
+ assistant: "assistant";
20
+ user: "user";
21
+ }>>>;
22
+ priority: z.ZodOptional<z.ZodNumber>;
23
+ }, z.core.$strip>>;
24
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
25
+ type: z.ZodLiteral<"audio">;
26
+ }, z.core.$strip>, z.ZodObject<{
27
+ type: z.ZodLiteral<"resource">;
28
+ resource: z.ZodUnion<readonly [z.ZodObject<{
29
+ uri: z.ZodString;
30
+ mimeType: z.ZodOptional<z.ZodString>;
31
+ blob: z.ZodString;
32
+ }, z.core.$strip>, z.ZodObject<{
33
+ uri: z.ZodString;
34
+ mimeType: z.ZodOptional<z.ZodString>;
35
+ text: z.ZodString;
36
+ }, z.core.$strip>]>;
37
+ }, z.core.$strip>], "type">;
38
+ type InlineFile = z.infer<typeof InlineFileSchema>;
39
+ /** One block of a result that carries a file, and its position in the result's `content`. */
40
+ export interface InlineFileBlock {
41
+ index: number;
42
+ file: InlineFile;
43
+ }
44
+ /**
45
+ * The blocks in a result's top-level `content` that carry a file: an `image` or `audio`
46
+ * block of the media schema, or an embedded `resource` of any type. A part of any other
47
+ * shape — a rich-text node that also calls itself `image` — is the result's own data and
48
+ * is left alone.
49
+ */
50
+ export declare function inlineFileBlocks(data: unknown): InlineFileBlock[];
51
+ /** The bytes of one block, bounded before they are allocated. */
52
+ export declare function inlineFileBytes(file: InlineFile, maxBytes: number): Buffer;
53
+ export declare function inlineFileMimeType(file: InlineFile): string | undefined;
54
+ /**
55
+ * The file name of a block: a media block's `_meta` file name or the file name in a
56
+ * resource's URI. A block that names no file is `<type>-<sha256 of its bytes><extension>`;
57
+ * a media block that names an empty one is refused by the writer like any other unusable name.
58
+ */
59
+ export declare function inlineFileName(file: InlineFile, digest: string): string;
60
+ /**
61
+ * The result as stdout prints it once its files are saved: each saved block gives up its
62
+ * bytes for an MCP resource link to the file. A block that was not saved keeps its bytes.
63
+ */
64
+ export declare function linkSavedFiles(data: unknown, blocks: readonly InlineFileBlock[], saved: (block: InlineFileBlock) => {
65
+ path: string;
66
+ name: string;
67
+ size: number;
68
+ } | undefined): unknown;
69
+ export {};
70
+ //# sourceMappingURL=inline-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inline-files.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/inline-files.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAkBxB,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAIpB,CAAC;AAEH,KAAK,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEnD,6FAA6F;AAC7F,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe,EAAE,CAMjE;AAgCD,iEAAiE;AACjE,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAK1E;AAWD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAEvE;AASD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAKvE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,SAAS,eAAe,EAAE,EAClC,KAAK,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,GAC1F,OAAO,CAiBT"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CAAC,CAAC;IACjC,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,aAAa,EAAE,OAAO,CAAC;IACvB,iFAAiF;IACjF,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EACL,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACxC,QAAQ,SAAS,SAAS,EAE1B,OAAO,EAAE,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAC9C,IAAI,EAAE,MAAM,EAAE,GACb,QAAQ,CAAC,QAAQ,CAAC,GAAG,SAAS,CAgEhC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,sBAAsB,GACjC,MAAM,CAcR;AAED,qFAAqF;AACrF,wBAAgB,cAAc,CAC5B,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,WAAW,GAAG,WAAW,CAAC,EAClD,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,MAAM,GACf,WAAW,CAOb"}
@@ -6,6 +6,8 @@ export declare class DownloadOperationError extends Error {
6
6
  readonly status: number;
7
7
  constructor(code: 'DOWNLOAD_HTTP_ERROR' | 'DOWNLOAD_TOO_LARGE', message: string, status: number);
8
8
  }
9
+ /** The file name a fetched URL is saved under: its path's base name and the body's extension. */
10
+ export declare function downloadFileName(url: string, mime: string): string;
9
11
  export interface DownloadOperationConfig {
10
12
  url: string;
11
13
  files: ManagedFileBoundary;
@@ -1 +1 @@
1
- {"version":3,"file":"download-core.d.ts","sourceRoot":"","sources":["../../../src/tools/transfer/download-core.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,E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ACZ,KAAK,EAAE,mBAAmB,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,kFAAkF;AAClF,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,cAAc,CAAC,CA2BzB"}
@@ -27,12 +27,48 @@ export declare const McpAnnotationsSchema: z.ZodObject<{
27
27
  priority: z.ZodOptional<z.ZodNumber>;
28
28
  }, z.core.$strip>;
29
29
  export type McpAnnotations = z.infer<typeof McpAnnotationsSchema>;
30
+ /**
31
+ * The `_meta` key under which an image or audio block carries the file name of its
32
+ * source. A consumer that saves the bytes saves them under it, as a CLI's
33
+ * `--output-dir` does.
34
+ *
35
+ * MCP's `ImageContent` and `AudioContent` have no field for a file name, and the
36
+ * official SDK drops a field the protocol does not declare from `content` before it
37
+ * is sent. `_meta` is the protocol's place for what a block carries beyond it, and
38
+ * the key is namespaced because that place is shared.
39
+ */
40
+ export declare const MCP_FILE_NAME_META_KEY = "stitchkit/fileName";
41
+ export declare const McpImageContentSchema: z.ZodObject<{
42
+ data: z.ZodString;
43
+ mimeType: z.ZodString;
44
+ annotations: z.ZodOptional<z.ZodObject<{
45
+ audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
46
+ assistant: "assistant";
47
+ user: "user";
48
+ }>>>;
49
+ priority: z.ZodOptional<z.ZodNumber>;
50
+ }, z.core.$strip>>;
51
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
52
+ type: z.ZodLiteral<"image">;
53
+ }, z.core.$strip>;
54
+ export declare const McpAudioContentSchema: z.ZodObject<{
55
+ data: z.ZodString;
56
+ mimeType: z.ZodString;
57
+ annotations: z.ZodOptional<z.ZodObject<{
58
+ audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
59
+ assistant: "assistant";
60
+ user: "user";
61
+ }>>>;
62
+ priority: z.ZodOptional<z.ZodNumber>;
63
+ }, z.core.$strip>>;
64
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
65
+ type: z.ZodLiteral<"audio">;
66
+ }, z.core.$strip>;
30
67
  /** An MCP content block — text / image / audio (video cannot be inlined). */
31
68
  export declare const McpMediaContentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
32
69
  type: z.ZodLiteral<"text">;
33
70
  text: z.ZodString;
34
71
  }, z.core.$strip>, z.ZodObject<{
35
- type: z.ZodLiteral<"image">;
36
72
  data: z.ZodString;
37
73
  mimeType: z.ZodString;
38
74
  annotations: z.ZodOptional<z.ZodObject<{
@@ -42,8 +78,9 @@ export declare const McpMediaContentSchema: z.ZodDiscriminatedUnion<[z.ZodObject
42
78
  }>>>;
43
79
  priority: z.ZodOptional<z.ZodNumber>;
44
80
  }, z.core.$strip>>;
81
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
82
+ type: z.ZodLiteral<"image">;
45
83
  }, z.core.$strip>, z.ZodObject<{
46
- type: z.ZodLiteral<"audio">;
47
84
  data: z.ZodString;
48
85
  mimeType: z.ZodString;
49
86
  annotations: z.ZodOptional<z.ZodObject<{
@@ -53,6 +90,8 @@ export declare const McpMediaContentSchema: z.ZodDiscriminatedUnion<[z.ZodObject
53
90
  }>>>;
54
91
  priority: z.ZodOptional<z.ZodNumber>;
55
92
  }, z.core.$strip>>;
93
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
94
+ type: z.ZodLiteral<"audio">;
56
95
  }, z.core.$strip>], "type">;
57
96
  export type McpMediaContent = z.infer<typeof McpMediaContentSchema>;
58
97
  export declare const ViewFileErrorSchema: z.ZodObject<{
@@ -64,7 +103,6 @@ export declare const ViewFileOutputSchema: z.ZodObject<{
64
103
  type: z.ZodLiteral<"text">;
65
104
  text: z.ZodString;
66
105
  }, z.core.$strip>, z.ZodObject<{
67
- type: z.ZodLiteral<"image">;
68
106
  data: z.ZodString;
69
107
  mimeType: z.ZodString;
70
108
  annotations: z.ZodOptional<z.ZodObject<{
@@ -74,8 +112,9 @@ export declare const ViewFileOutputSchema: z.ZodObject<{
74
112
  }>>>;
75
113
  priority: z.ZodOptional<z.ZodNumber>;
76
114
  }, z.core.$strip>>;
115
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
116
+ type: z.ZodLiteral<"image">;
77
117
  }, z.core.$strip>, z.ZodObject<{
78
- type: z.ZodLiteral<"audio">;
79
118
  data: z.ZodString;
80
119
  mimeType: z.ZodString;
81
120
  annotations: z.ZodOptional<z.ZodObject<{
@@ -85,6 +124,8 @@ export declare const ViewFileOutputSchema: z.ZodObject<{
85
124
  }>>>;
86
125
  priority: z.ZodOptional<z.ZodNumber>;
87
126
  }, z.core.$strip>>;
127
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
128
+ type: z.ZodLiteral<"audio">;
88
129
  }, z.core.$strip>], "type">>;
89
130
  errors: z.ZodArray<z.ZodObject<{
90
131
  path: z.ZodString;
@@ -1 +1 @@
1
- {"version":3,"file":"view-file-contract.d.ts","sourceRoot":"","sources":["../../../src/tools/transfer/view-file-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,qFAAqF;AACrF,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB;;;;;;iBAG/B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,6EAA6E;AAC7E,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;2BAchC,CAAC;AAEH,MAAM,MAAM,eA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AM9B,CAAC"}
@@ -16,7 +16,7 @@ import type { McpServer } from '@modelcontextprotocol/server';
16
16
  import { z } from 'zod';
17
17
  import type { McpMediaContent, ViewFileOutput } from './view-file-contract.js';
18
18
  import { ViewFileInputSchema } from './view-file-contract.js';
19
- export { type McpAnnotations, McpAnnotationsSchema, type McpMediaContent, McpMediaContentSchema, ViewFileErrorSchema, ViewFileInputSchema, type ViewFileOutput, ViewFileOutputSchema, } from './view-file-contract.js';
19
+ export { MCP_FILE_NAME_META_KEY, type McpAnnotations, McpAnnotationsSchema, type McpMediaContent, McpMediaContentSchema, ViewFileErrorSchema, ViewFileInputSchema, type ViewFileOutput, ViewFileOutputSchema, } from './view-file-contract.js';
20
20
  import { type ManagedFileBoundary } from '../../files/boundary.js';
21
21
  export interface ViewFileOptions {
22
22
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"view-file.d.ts","sourceRoot":"","sources":["../../../src/tools/transfer/view-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAwB,MAAM,sBAAsB,CAAC;AAEjF,OAAO,EACL,KAAK,cAAc,EACnB,oBAAoB,EACpB,KAAK,eAAe,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,KAAK,cAAc,EACnB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,KAAK,mBAAmB,EAAoB,MAAM,sBAAsB,CAAC;AA0BlF,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;OAGG;I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AAC,EAAE,MAAM,CAAC;CACpB;AA+KD;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,eAAe,EAAE,CAAC,CAE5B;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC,OAAO,CAAC,EACpD,OAAO,GAAE,eAAoB,EAC7B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,cAAc,CAAC,CAuBzB;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,GAAE,eAAoB,GAAG,IAAI,CAyBpF"}
package/llms/cli.txt CHANGED
@@ -457,7 +457,7 @@ same Zod schema an HTTP or MCP call does.
457
457
  | `--json` | Compact success/error JSON records for scripts |
458
458
  | `--wait` | Block-poll an async result to a terminal state |
459
459
  | `--wait-timeout <s>` | Override the `--wait` timeout |
460
- | `--output-dir <dir>` | Download result media into a directory |
460
+ | `--output-dir <dir>` | Save the files a result names or carries into a directory |
461
461
  | `--quiet` | Suppress non-essential stderr output |
462
462
  | `--dry-run` | Print the resolved call without executing |
463
463
  | `--schema` | One JSON line: the JSON Schema of a command's input and output |
@@ -679,15 +679,76 @@ myapp generate "a fox" --wait --output-dir ./out
679
679
  myapp generate "a fox" --wait --json > result.json &
680
680
  ```
681
681
 
682
+ ### Saving result media
683
+
684
+ `--output-dir <dir>` saves the files a successful result carries, as one batch in one
685
+ directory: the blocks of the result's top-level `content` array that hold a file inline, and
686
+ the `{ url, name }` files the optional `download(result)` callback names. Inline files need
687
+ no callback — a `defineViewFileTool` result, or a file returned through an MCP client
688
+ connection, is saved as it arrives. URL files keep their SSRF checks, redirect checks and
689
+ fetch deadlines.
690
+
691
+ Three kinds of block hold a file, and the file may be of any type:
692
+
693
+ | Block | Bytes | File name |
694
+ | --- | --- | --- |
695
+ | `image`, `audio` (`McpMediaContentSchema`) | standard base64 in `data` | `_meta['stitchkit/fileName']` |
696
+ | `resource` with `blob` — a PDF, a spreadsheet, an archive | standard base64 in `resource.blob` | last path segment of `resource.uri` |
697
+ | `resource` with `text` — CSV, Markdown, JSON | `resource.text` as UTF-8 | last path segment of `resource.uri` |
698
+
699
+ A part of `content` is saved only when it matches one of these shapes. Any other part — a
700
+ rich-text node that also calls itself `image`, a `resource` without content — is the result's
701
+ own data and is left alone.
702
+
703
+ **Names.** A name is reduced to its basename, like a URL download name;
704
+ `defineViewFileTool` and `mountViewFile` set a media block's `_meta['stitchkit/fileName']`
705
+ (`MCP_FILE_NAME_META_KEY`) to the file name of the source. A block that names no file
706
+ is `<type>-<sha256-of-its-bytes><extension>`: known media types supply the extension and
707
+ the rest use `.bin`. A name is written once per batch. The same bytes under the same name
708
+ are one file; different bytes under a name the batch already wrote fail that file, and the
709
+ first one stays.
710
+
711
+ **Bytes.** Padded and unpadded canonical base64 are accepted; anything else fails that file
712
+ alone. `maxDownloadBytes` — a positive safe integer, checked when the CLI is created —
713
+ limits each URL file and each inline file by its decoded or UTF-8 size (default 100 MB). The
714
+ size is checked before the bytes are allocated, and inline files are decoded and written one
715
+ at a time.
716
+
717
+ **Output.** `saved <path> (<size>KB)` goes to stderr; `--quiet` suppresses those lines and
718
+ keeps errors. On stdout each saved inline block is replaced by a link to its file, so the
719
+ bytes are not printed a second time:
720
+
721
+ ```json
722
+ {
723
+ "type": "resource_link",
724
+ "uri": "file:///work/out/shot.png",
725
+ "name": "shot.png",
726
+ "mimeType": "image/png",
727
+ "size": 48213
728
+ }
729
+ ```
730
+
731
+ The link carries `mimeType` when the block declared one. A block that could not be saved
732
+ keeps its bytes, so nothing the operation returned is lost;
733
+ the other files of the batch are still saved and the exit is `1`. A result policy
734
+ (`results`) receives the operation's own result, not the linked one. Without `--output-dir`,
735
+ an inline result is ordinary JSON.
736
+
737
+ **Nothing to save.** A result that carries no files is not an error. The command prints and
738
+ exits exactly as it does without the flag — views and result policies included — and stderr
739
+ says `--output-dir: the result carries no files to save` unless `--quiet` is given. A failed
740
+ operation keeps its own error and exit code. Help, schema inspection and dry-run do not
741
+ execute the operation.
742
+
682
743
  ### Download filesystem boundary
683
744
 
684
- `--output-dir` resolves the explicitly configured root once before fetching and pins that
745
+ `--output-dir` resolves the explicitly configured root once before fetching or decoding and pins that
685
746
  one directory for the whole batch. An initial root alias (including a symbolic link) selects
686
747
  its canonical directory; missing components are created through pinned parents. The root
687
748
  capability continues to name the same directory if another actor renames it or replaces its
688
749
  pathname. The original spelling printed in `saved` is a display path, not a re-open of the root.
689
750
 
690
- Each media name becomes a direct child. Downloads atomically replace an existing file,
751
+ Each media name becomes a direct child. URL and inline files atomically replace an existing file,
691
752
  symbolic link (including a dangling link), or hard link without changing the inode a link
692
753
  points to. An existing directory refuses replacement. Ordinary files retain their permission
693
754
  bits; new files use `0666 & ~umask`. Replacing writes a new file beside the old one, so it needs
@@ -94,13 +94,13 @@ own, recorded as an ADR.
94
94
  | `stitchkit/xlsx` | browser **and** server | evolving | a workbook from rows and typed columns, with no dependency; text never runs as a formula |
95
95
  | `stitchkit/oauth` | browser **and** server | evolving | provider-neutral Authorization Code + PKCE request and one-shot callback transaction mechanics |
96
96
  | `stitchkit/google` | server (Bun or Node) | evolving | optional Google code exchange and verified OIDC identity adapter |
97
- | `stitchkit/observability` | server | stable<br>_redefined in 2 of the 68 minors since 0.56.2, most recently 0.92.0_ | request/tool event projections — `createObservability`, trace context, sanitisation |
97
+ | `stitchkit/observability` | server | stable<br>_redefined in 2 of the 69 minors since 0.56.2, most recently 0.92.0_ | request/tool event projections — `createObservability`, trace context, sanitisation |
98
98
  | `stitchkit/testing` | tests on Bun or Node | stable | in-process generated clients over a real Fetch handler, the managed-resource conformance kit and manual time for schedules and retries |
99
99
  | `stitchkit/declaration` | browser + build and deployment tooling (Bun or Node) | evolving | `ProjectDeclarationSchema` — the one machine-readable statement a repository makes about itself |
100
100
  | `stitchkit/react` | browser + server rendering | stable | `createCursorQuery`, `createCacheBridge`, QueryClient and `ApiError` retry policy |
101
101
  | `stitchkit/react/keyboard` | browser | evolving | which part of a screen gets a key — ordered layers, one Escape per level, list zones with real focus; see [keyboard guide](keyboard.md) |
102
102
  | `stitchkit/react/keyboard/testing` | server (Bun or Node) | evolving | the keyboard layers and zones without a DOM — fakes for the window, elements and key events beside the two engines, to test the order of layers, `scope`/`inert` and the edges of a zone in milliseconds |
103
- | `stitchkit/agent-runtime` | server | evolving<br>_redefined in 26 of the 68 minors since 0.56.2, most recently 0.121.0_ | optional durable conversation/run loop, history, models, prompts, fencing and events |
103
+ | `stitchkit/agent-runtime` | server | evolving<br>_redefined in 26 of the 69 minors since 0.56.2, most recently 0.121.0_ | optional durable conversation/run loop, history, models, prompts, fencing and events |
104
104
  | `stitchkit/agent-runtime/sandbox` | server | evolving | optional Linux Bubblewrap sessions, durable workspaces and a host HTTP credential gateway; see [sandbox guide](sandbox.md) |
105
105
  | `stitchkit/agent-runtime/testing` | tests on Bun or Node | evolving | credential-free replay, scripted provider faults, deterministic race controls and the agent-store conformance kit |
106
106
  | `stitchkit/agent-runtime/harness` | server | evolving | resource-aware process-local facade over the canonical Agent runtime; supervision stays outside |
@@ -112,7 +112,7 @@ own, recorded as an ADR.
112
112
  | `stitchkit/agent-runtime/sqlite/bun` | server (Bun) | evolving | durable built-in SQLite store for the agent runtime |
113
113
  | `stitchkit/agent-runtime/sqlite/node` | server (Node ≥ 22.5) | evolving | durable built-in SQLite store for the agent runtime |
114
114
  | `stitchkit-tui` | terminal (Bun) | evolving | optional official OpenTUI host over a caller-composed headless runtime |
115
- | `stitchkit/application` | browser + server | evolving<br>_redefined in 14 of the 68 minors since 0.56.2, most recently 0.110.0_ | managed resource graph, readiness, admission, schedules, subtree restart and bounded shutdown |
115
+ | `stitchkit/application` | browser + server | evolving<br>_redefined in 14 of the 69 minors since 0.56.2, most recently 0.110.0_ | managed resource graph, readiness, admission, schedules, subtree restart and bounded shutdown |
116
116
  | `stitchkit/application/grammy` | server | evolving | a grammY bot as application resources — configuration, then polling with updates admitted by batch — and the webhook adapter |
117
117
  | `stitchkit/application/opentelemetry` | server | evolving | maps application snapshots onto an injected OpenTelemetry `Meter` |
118
118
  | `stitchkit/application/schemas` | browser + server | evolving | the application's snapshot, health and shutdown schemas alone, without the kernel |
package/llms/tools.2.txt CHANGED
@@ -556,6 +556,17 @@ Ordinary file names containing brackets, such as `[preview].png`, remain valid.
556
556
  A local file with an unsupported extension is refused before reading; its
557
557
  per-item error identifies the caller's path and the extension it saw.
558
558
 
559
+ Each inline `image` and `audio` block carries the file name of its source in
560
+ `_meta['stitchkit/fileName']` (`MCP_FILE_NAME_META_KEY`): a managed file keeps
561
+ its own name, a URL takes its download name — the path's base name with the
562
+ body's extension. MCP declares no file name on `ImageContent` or `AudioContent`,
563
+ and the MCP server SDK drops an undeclared field from `content`, so the name is
564
+ in `_meta`, the protocol's place for what a block carries beyond it. The block
565
+ is therefore the same in the handler's output, an Agent's result,
566
+ `structuredContent` and MCP `content`, and a host reads the name from the block
567
+ it renders. A CLI saves the block under that name with
568
+ [`--output-dir`](cli.md#saving-result-media).
569
+
559
570
  The older `mountWait`, `mountDownload`, `mountUpload` and `mountViewFile`
560
571
  functions remain
561
572
  intentional raw MCP adapters with their text-envelope behavior. Use them under
package/llms/tools.3.txt CHANGED
@@ -83,7 +83,8 @@ server SDK), [`stitchkit/tools/agent`](#stitchkittoolsagent) (the `ai` peer) and
83
83
  | `ViewFileErrorSchema` | constant | Zod schema for one structured per-item view failure |
84
84
  | `McpAnnotations` | _type_ | MCP annotations on a media result |
85
85
  | `McpAnnotationsSchema` | constant | Zod schema for MCP media annotations |
86
- | `McpMediaContentSchema` | constant | Zod schema for text/image/audio media content |
86
+ | `McpMediaContentSchema` | constant | Zod schema for text/image/audio media content — the blocks MCP declares, field for field |
87
+ | `MCP_FILE_NAME_META_KEY` | constant | the namespaced `_meta` key (`stitchkit/fileName`) under which an `image` or `audio` block carries the file name of its source |
87
88
  | `CollectToolsConfig` | _type_ | options for `collectTools` |
88
89
  | `findUntypedProperties` | function | every property in a JSON Schema with no `type`/`enum`/`$ref` — what a model is shown and cannot obey ([guide](../guide/mcp-and-agents.md)) |
89
90
  | `UntypedProperty` | _type_ | one such property — `{ path, description? }` |
@@ -1,14 +1,50 @@
1
- # Upgrading 0.106.0 → 0.123.0 — stitchkit docs slice
1
+ # Upgrading 0.106.0 → 0.124.0 — stitchkit docs slice
2
2
 
3
3
  > Generated from the `docs/` tree by `bun run gen:llms`. The index of all slices is
4
4
  > `llms.txt` in this package.
5
5
 
6
- Contains: Guide: Upgrading, 0.106.0 → 0.123.0 (docs/guide/upgrading.md)
6
+ Contains: Guide: Upgrading, 0.106.0 → 0.124.0 (docs/guide/upgrading.md)
7
7
 
8
8
  ==============================================================================
9
- # Guide: Upgrading, 0.106.0 → 0.123.0 (docs/guide/upgrading.md)
9
+ # Guide: Upgrading, 0.106.0 → 0.124.0 (docs/guide/upgrading.md)
10
10
  ==============================================================================
11
11
 
12
+ ## Released migration: 0.124.0
13
+
14
+ ### media-block-file-name
15
+
16
+ **Who must act:** code that builds or reads an `image` or `audio` block of
17
+ `McpMediaContentSchema` with a `name` — a tool that returns such a block, or a reader of a
18
+ `defineViewFileTool`, `mountViewFile` or `resolveMedia` result. The field exists only in 0.123.7.
19
+
20
+ The file name of a media block lives in the block's `_meta`, under the key
21
+ `MCP_FILE_NAME_META_KEY` (`stitchkit/fileName`), and the block has no `name`. The block is now
22
+ exactly what MCP declares, so the same block reaches a handler's caller, an Agent,
23
+ `structuredContent` and MCP `content`; the `name` field never reached `content`.
24
+
25
+ ```ts
26
+ import { MCP_FILE_NAME_META_KEY } from 'stitchkit/tools/contract'
27
+
28
+ // before
29
+ const block = { type: 'image', data, mimeType: 'image/png', name: 'shot.png' }
30
+ const fileName = block.name
31
+
32
+ // after
33
+ const block = {
34
+ type: 'image',
35
+ data,
36
+ mimeType: 'image/png',
37
+ _meta: { [MCP_FILE_NAME_META_KEY]: 'shot.png' },
38
+ }
39
+ const fileName = block._meta?.[MCP_FILE_NAME_META_KEY] // unknown: check it is a string
40
+ ```
41
+
42
+ A block that still carries `name` is not refused: the schema drops the field, and a CLI's
43
+ `--output-dir` then names the file `<type>-<sha256><extension>`. An object typed
44
+ `McpMediaContent` does not compile with `name`, which is where TypeScript code finds every
45
+ site; search untyped code for `name:` beside `type: 'image'` or `type: 'audio'`. A test that
46
+ compared MCP `content` with `structuredContent` minus `name` compares them whole.
47
+
12
48
  ## Released migration: 0.123.0
13
49
 
14
50
  ### unknown-operation
@@ -11,7 +11,7 @@ Contains: Guide: Upgrading, general (docs/guide/upgrading.md)
11
11
 
12
12
  Load this slice, then every range slice between your installed version and the target:
13
13
 
14
- - 0.106.0 → 0.123.0: `llms/upgrading-0.106.0-0.123.0.txt`
14
+ - 0.106.0 → 0.124.0: `llms/upgrading-0.106.0-0.124.0.txt`
15
15
  - 0.96.0 → 0.105.0: `llms/upgrading-0.96.0-0.105.0.txt`
16
16
  - 0.69.0 → 0.95.0: `llms/upgrading-0.69.0-0.95.0.txt`
17
17
  - 0.55.0 → 0.68.0: `llms/upgrading-0.55.0-0.68.0.txt`
package/llms-full.txt CHANGED
@@ -85,13 +85,13 @@ own, recorded as an ADR.
85
85
  | `stitchkit/xlsx` | browser **and** server | evolving | a workbook from rows and typed columns, with no dependency; text never runs as a formula |
86
86
  | `stitchkit/oauth` | browser **and** server | evolving | provider-neutral Authorization Code + PKCE request and one-shot callback transaction mechanics |
87
87
  | `stitchkit/google` | server (Bun or Node) | evolving | optional Google code exchange and verified OIDC identity adapter |
88
- | `stitchkit/observability` | server | stable<br>_redefined in 2 of the 68 minors since 0.56.2, most recently 0.92.0_ | request/tool event projections — `createObservability`, trace context, sanitisation |
88
+ | `stitchkit/observability` | server | stable<br>_redefined in 2 of the 69 minors since 0.56.2, most recently 0.92.0_ | request/tool event projections — `createObservability`, trace context, sanitisation |
89
89
  | `stitchkit/testing` | tests on Bun or Node | stable | in-process generated clients over a real Fetch handler, the managed-resource conformance kit and manual time for schedules and retries |
90
90
  | `stitchkit/declaration` | browser + build and deployment tooling (Bun or Node) | evolving | `ProjectDeclarationSchema` — the one machine-readable statement a repository makes about itself |
91
91
  | `stitchkit/react` | browser + server rendering | stable | `createCursorQuery`, `createCacheBridge`, QueryClient and `ApiError` retry policy |
92
92
  | `stitchkit/react/keyboard` | browser | evolving | which part of a screen gets a key — ordered layers, one Escape per level, list zones with real focus; see [keyboard guide](keyboard.md) |
93
93
  | `stitchkit/react/keyboard/testing` | server (Bun or Node) | evolving | the keyboard layers and zones without a DOM — fakes for the window, elements and key events beside the two engines, to test the order of layers, `scope`/`inert` and the edges of a zone in milliseconds |
94
- | `stitchkit/agent-runtime` | server | evolving<br>_redefined in 26 of the 68 minors since 0.56.2, most recently 0.121.0_ | optional durable conversation/run loop, history, models, prompts, fencing and events |
94
+ | `stitchkit/agent-runtime` | server | evolving<br>_redefined in 26 of the 69 minors since 0.56.2, most recently 0.121.0_ | optional durable conversation/run loop, history, models, prompts, fencing and events |
95
95
  | `stitchkit/agent-runtime/sandbox` | server | evolving | optional Linux Bubblewrap sessions, durable workspaces and a host HTTP credential gateway; see [sandbox guide](sandbox.md) |
96
96
  | `stitchkit/agent-runtime/testing` | tests on Bun or Node | evolving | credential-free replay, scripted provider faults, deterministic race controls and the agent-store conformance kit |
97
97
  | `stitchkit/agent-runtime/harness` | server | evolving | resource-aware process-local facade over the canonical Agent runtime; supervision stays outside |
@@ -103,7 +103,7 @@ own, recorded as an ADR.
103
103
  | `stitchkit/agent-runtime/sqlite/bun` | server (Bun) | evolving | durable built-in SQLite store for the agent runtime |
104
104
  | `stitchkit/agent-runtime/sqlite/node` | server (Node ≥ 22.5) | evolving | durable built-in SQLite store for the agent runtime |
105
105
  | `stitchkit-tui` | terminal (Bun) | evolving | optional official OpenTUI host over a caller-composed headless runtime |
106
- | `stitchkit/application` | browser + server | evolving<br>_redefined in 14 of the 68 minors since 0.56.2, most recently 0.110.0_ | managed resource graph, readiness, admission, schedules, subtree restart and bounded shutdown |
106
+ | `stitchkit/application` | browser + server | evolving<br>_redefined in 14 of the 69 minors since 0.56.2, most recently 0.110.0_ | managed resource graph, readiness, admission, schedules, subtree restart and bounded shutdown |
107
107
  | `stitchkit/application/grammy` | server | evolving | a grammY bot as application resources — configuration, then polling with updates admitted by batch — and the webhook adapter |
108
108
  | `stitchkit/application/opentelemetry` | server | evolving | maps application snapshots onto an injected OpenTelemetry `Meter` |
109
109
  | `stitchkit/application/schemas` | browser + server | evolving | the application's snapshot, health and shutdown schemas alone, without the kernel |
@@ -5413,6 +5413,17 @@ Ordinary file names containing brackets, such as `[preview].png`, remain valid.
5413
5413
  A local file with an unsupported extension is refused before reading; its
5414
5414
  per-item error identifies the caller's path and the extension it saw.
5415
5415
 
5416
+ Each inline `image` and `audio` block carries the file name of its source in
5417
+ `_meta['stitchkit/fileName']` (`MCP_FILE_NAME_META_KEY`): a managed file keeps
5418
+ its own name, a URL takes its download name — the path's base name with the
5419
+ body's extension. MCP declares no file name on `ImageContent` or `AudioContent`,
5420
+ and the MCP server SDK drops an undeclared field from `content`, so the name is
5421
+ in `_meta`, the protocol's place for what a block carries beyond it. The block
5422
+ is therefore the same in the handler's output, an Agent's result,
5423
+ `structuredContent` and MCP `content`, and a host reads the name from the block
5424
+ it renders. A CLI saves the block under that name with
5425
+ [`--output-dir`](cli.md#saving-result-media).
5426
+
5416
5427
  The older `mountWait`, `mountDownload`, `mountUpload` and `mountViewFile`
5417
5428
  functions remain
5418
5429
  intentional raw MCP adapters with their text-envelope behavior. Use them under
@@ -10864,7 +10875,7 @@ same Zod schema an HTTP or MCP call does.
10864
10875
  | `--json` | Compact success/error JSON records for scripts |
10865
10876
  | `--wait` | Block-poll an async result to a terminal state |
10866
10877
  | `--wait-timeout <s>` | Override the `--wait` timeout |
10867
- | `--output-dir <dir>` | Download result media into a directory |
10878
+ | `--output-dir <dir>` | Save the files a result names or carries into a directory |
10868
10879
  | `--quiet` | Suppress non-essential stderr output |
10869
10880
  | `--dry-run` | Print the resolved call without executing |
10870
10881
  | `--schema` | One JSON line: the JSON Schema of a command's input and output |
@@ -11086,15 +11097,76 @@ myapp generate "a fox" --wait --output-dir ./out
11086
11097
  myapp generate "a fox" --wait --json > result.json &
11087
11098
  ```
11088
11099
 
11100
+ ### Saving result media
11101
+
11102
+ `--output-dir <dir>` saves the files a successful result carries, as one batch in one
11103
+ directory: the blocks of the result's top-level `content` array that hold a file inline, and
11104
+ the `{ url, name }` files the optional `download(result)` callback names. Inline files need
11105
+ no callback — a `defineViewFileTool` result, or a file returned through an MCP client
11106
+ connection, is saved as it arrives. URL files keep their SSRF checks, redirect checks and
11107
+ fetch deadlines.
11108
+
11109
+ Three kinds of block hold a file, and the file may be of any type:
11110
+
11111
+ | Block | Bytes | File name |
11112
+ | --- | --- | --- |
11113
+ | `image`, `audio` (`McpMediaContentSchema`) | standard base64 in `data` | `_meta['stitchkit/fileName']` |
11114
+ | `resource` with `blob` — a PDF, a spreadsheet, an archive | standard base64 in `resource.blob` | last path segment of `resource.uri` |
11115
+ | `resource` with `text` — CSV, Markdown, JSON | `resource.text` as UTF-8 | last path segment of `resource.uri` |
11116
+
11117
+ A part of `content` is saved only when it matches one of these shapes. Any other part — a
11118
+ rich-text node that also calls itself `image`, a `resource` without content — is the result's
11119
+ own data and is left alone.
11120
+
11121
+ **Names.** A name is reduced to its basename, like a URL download name;
11122
+ `defineViewFileTool` and `mountViewFile` set a media block's `_meta['stitchkit/fileName']`
11123
+ (`MCP_FILE_NAME_META_KEY`) to the file name of the source. A block that names no file
11124
+ is `<type>-<sha256-of-its-bytes><extension>`: known media types supply the extension and
11125
+ the rest use `.bin`. A name is written once per batch. The same bytes under the same name
11126
+ are one file; different bytes under a name the batch already wrote fail that file, and the
11127
+ first one stays.
11128
+
11129
+ **Bytes.** Padded and unpadded canonical base64 are accepted; anything else fails that file
11130
+ alone. `maxDownloadBytes` — a positive safe integer, checked when the CLI is created —
11131
+ limits each URL file and each inline file by its decoded or UTF-8 size (default 100 MB). The
11132
+ size is checked before the bytes are allocated, and inline files are decoded and written one
11133
+ at a time.
11134
+
11135
+ **Output.** `saved <path> (<size>KB)` goes to stderr; `--quiet` suppresses those lines and
11136
+ keeps errors. On stdout each saved inline block is replaced by a link to its file, so the
11137
+ bytes are not printed a second time:
11138
+
11139
+ ```json
11140
+ {
11141
+ "type": "resource_link",
11142
+ "uri": "file:///work/out/shot.png",
11143
+ "name": "shot.png",
11144
+ "mimeType": "image/png",
11145
+ "size": 48213
11146
+ }
11147
+ ```
11148
+
11149
+ The link carries `mimeType` when the block declared one. A block that could not be saved
11150
+ keeps its bytes, so nothing the operation returned is lost;
11151
+ the other files of the batch are still saved and the exit is `1`. A result policy
11152
+ (`results`) receives the operation's own result, not the linked one. Without `--output-dir`,
11153
+ an inline result is ordinary JSON.
11154
+
11155
+ **Nothing to save.** A result that carries no files is not an error. The command prints and
11156
+ exits exactly as it does without the flag — views and result policies included — and stderr
11157
+ says `--output-dir: the result carries no files to save` unless `--quiet` is given. A failed
11158
+ operation keeps its own error and exit code. Help, schema inspection and dry-run do not
11159
+ execute the operation.
11160
+
11089
11161
  ### Download filesystem boundary
11090
11162
 
11091
- `--output-dir` resolves the explicitly configured root once before fetching and pins that
11163
+ `--output-dir` resolves the explicitly configured root once before fetching or decoding and pins that
11092
11164
  one directory for the whole batch. An initial root alias (including a symbolic link) selects
11093
11165
  its canonical directory; missing components are created through pinned parents. The root
11094
11166
  capability continues to name the same directory if another actor renames it or replaces its
11095
11167
  pathname. The original spelling printed in `saved` is a display path, not a re-open of the root.
11096
11168
 
11097
- Each media name becomes a direct child. Downloads atomically replace an existing file,
11169
+ Each media name becomes a direct child. URL and inline files atomically replace an existing file,
11098
11170
  symbolic link (including a dangling link), or hard link without changing the inode a link
11099
11171
  points to. An existing directory refuses replacement. Ordinary files retain their permission
11100
11172
  bits; new files use `0666 & ~umask`. Replacing writes a new file beside the old one, so it needs
@@ -17813,6 +17885,42 @@ charts, no merged cells and no streaming: an application that needs them takes a
17813
17885
 
17814
17886
  # Upgrading stitchkit
17815
17887
 
17888
+ ## Released migration: 0.124.0
17889
+
17890
+ ### media-block-file-name
17891
+
17892
+ **Who must act:** code that builds or reads an `image` or `audio` block of
17893
+ `McpMediaContentSchema` with a `name` — a tool that returns such a block, or a reader of a
17894
+ `defineViewFileTool`, `mountViewFile` or `resolveMedia` result. The field exists only in 0.123.7.
17895
+
17896
+ The file name of a media block lives in the block's `_meta`, under the key
17897
+ `MCP_FILE_NAME_META_KEY` (`stitchkit/fileName`), and the block has no `name`. The block is now
17898
+ exactly what MCP declares, so the same block reaches a handler's caller, an Agent,
17899
+ `structuredContent` and MCP `content`; the `name` field never reached `content`.
17900
+
17901
+ ```ts
17902
+ import { MCP_FILE_NAME_META_KEY } from 'stitchkit/tools/contract'
17903
+
17904
+ // before
17905
+ const block = { type: 'image', data, mimeType: 'image/png', name: 'shot.png' }
17906
+ const fileName = block.name
17907
+
17908
+ // after
17909
+ const block = {
17910
+ type: 'image',
17911
+ data,
17912
+ mimeType: 'image/png',
17913
+ _meta: { [MCP_FILE_NAME_META_KEY]: 'shot.png' },
17914
+ }
17915
+ const fileName = block._meta?.[MCP_FILE_NAME_META_KEY] // unknown: check it is a string
17916
+ ```
17917
+
17918
+ A block that still carries `name` is not refused: the schema drops the field, and a CLI's
17919
+ `--output-dir` then names the file `<type>-<sha256><extension>`. An object typed
17920
+ `McpMediaContent` does not compile with `name`, which is where TypeScript code finds every
17921
+ site; search untyped code for `name:` beside `type: 'image'` or `type: 'audio'`. A test that
17922
+ compared MCP `content` with `structuredContent` minus `name` compares them whole.
17923
+
17816
17924
  ## Released migration: 0.123.0
17817
17925
 
17818
17926
  ### unknown-operation
@@ -24926,7 +25034,8 @@ server SDK), [`stitchkit/tools/agent`](#stitchkittoolsagent) (the `ai` peer) and
24926
25034
  | `ViewFileErrorSchema` | constant | Zod schema for one structured per-item view failure |
24927
25035
  | `McpAnnotations` | _type_ | MCP annotations on a media result |
24928
25036
  | `McpAnnotationsSchema` | constant | Zod schema for MCP media annotations |
24929
- | `McpMediaContentSchema` | constant | Zod schema for text/image/audio media content |
25037
+ | `McpMediaContentSchema` | constant | Zod schema for text/image/audio media content — the blocks MCP declares, field for field |
25038
+ | `MCP_FILE_NAME_META_KEY` | constant | the namespaced `_meta` key (`stitchkit/fileName`) under which an `image` or `audio` block carries the file name of its source |
24930
25039
  | `CollectToolsConfig` | _type_ | options for `collectTools` |
24931
25040
  | `findUntypedProperties` | function | every property in a JSON Schema with no `type`/`enum`/`$ref` — what a model is shown and cannot obey ([guide](../guide/mcp-and-agents.md)) |
24932
25041
  | `UntypedProperty` | _type_ | one such property — `{ path, description? }` |