@valbuild/mcp 0.126.0 → 0.128.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +2 -2
- package/dist/valbuild-mcp.cjs.dev.js +21 -16
- package/dist/valbuild-mcp.cjs.prod.js +21 -16
- package/dist/valbuild-mcp.esm.js +22 -17
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @valbuild/mcp
|
|
2
2
|
|
|
3
|
+
## 0.128.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`8b52b33`](https://github.com/valbuild/val/commit/8b52b33e1f629f14f66cc71dcc7cf415d210c7d4), [`362fb49`](https://github.com/valbuild/val/commit/362fb49f30d2b04c4ff78d54dca2bf5ad978a05c), [`c595799`](https://github.com/valbuild/val/commit/c59579977a436ec530c6c69f2b340ab9829d97ab)]:
|
|
8
|
+
- @valbuild/core@0.128.0
|
|
9
|
+
- @valbuild/server@0.128.0
|
|
10
|
+
- @valbuild/shared@0.128.0
|
|
11
|
+
|
|
12
|
+
## 0.127.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [[`7fa8699`](https://github.com/valbuild/val/commit/7fa869974bc895af992a7d5c18b76253636d7d65), [`5b7fe05`](https://github.com/valbuild/val/commit/5b7fe05cec6365f9cd1de9ba31e65ed4a87edb63), [`88262ac`](https://github.com/valbuild/val/commit/88262ac8db068650a664981ef73556457d87741a), [`7072e07`](https://github.com/valbuild/val/commit/7072e07623c953a09ac14388ae22dada0b431ce3), [`29811c3`](https://github.com/valbuild/val/commit/29811c3f8c7e001a950e6f4833af6888e6a4efea)]:
|
|
17
|
+
- @valbuild/core@0.127.0
|
|
18
|
+
- @valbuild/shared@0.127.0
|
|
19
|
+
- @valbuild/server@0.127.0
|
|
20
|
+
|
|
3
21
|
## 0.126.0
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ Writing:
|
|
|
39
39
|
| `create_patch` | change a value at a path |
|
|
40
40
|
| `duplicate_source` | copy an array item or record entry |
|
|
41
41
|
| `empty_at_path` | build an empty value the schema accepts, to fill in |
|
|
42
|
-
| `remove_image_gallery_entry` | drop an image from an `s.
|
|
42
|
+
| `remove_image_gallery_entry` | drop an image from an `s.imageset()` gallery |
|
|
43
43
|
| `upload_image` | add one — see below |
|
|
44
44
|
|
|
45
45
|
Every write is validated against the schema before it is stored, and refused
|
|
@@ -70,7 +70,7 @@ const { valMcpAuthorize, valMcpTools } = initValMcp(valModules, config, {
|
|
|
70
70
|
Leave `extraTools` out and everything else still works — an agent can then read,
|
|
71
71
|
validate and edit content, but not add an image.
|
|
72
72
|
|
|
73
|
-
Remotely stored images (`s.
|
|
73
|
+
Remotely stored images (`s.imageset({...}).remote()`) work through the same tool.
|
|
74
74
|
Adding one uploads nothing to Val's content host — the bytes go into the patch
|
|
75
75
|
store, and the push happens at publish — so the only thing it needs is the
|
|
76
76
|
project's bucket list, read with your app's own credential (its API key, or the
|
|
@@ -1630,7 +1630,12 @@ function writeTools() {
|
|
|
1630
1630
|
case 1:
|
|
1631
1631
|
built = internal.buildEmptyAtPathPatch({
|
|
1632
1632
|
destinationPath: destinationPath
|
|
1633
|
-
}, schema, deps.state.sources[modulePath]
|
|
1633
|
+
}, schema, deps.state.sources[modulePath], {
|
|
1634
|
+
locales: internal.declaredLocales({
|
|
1635
|
+
schemas: deps.state.serializedSchemas,
|
|
1636
|
+
sources: deps.state.sources
|
|
1637
|
+
})
|
|
1638
|
+
});
|
|
1634
1639
|
if (!(built.kind !== "ok")) {
|
|
1635
1640
|
_context3.n = 2;
|
|
1636
1641
|
break;
|
|
@@ -1651,7 +1656,7 @@ function writeTools() {
|
|
|
1651
1656
|
title: "Remove an image gallery entry",
|
|
1652
1657
|
description: "Remove one image from an image gallery module by its file path. This deletes the entry and the file it refers to.",
|
|
1653
1658
|
inputSchema: zod.z.object({
|
|
1654
|
-
moduleFilePath: ModuleFilePathSchema$1.describe("The gallery module, i.e. one declared with s.
|
|
1659
|
+
moduleFilePath: ModuleFilePathSchema$1.describe("The gallery module, i.e. one declared with s.imageset() or s.fileset()."),
|
|
1655
1660
|
filePath: zod.z.string().describe('The gallery key to remove, e.g. "/public/val/photo_a1b2c.jpg".')
|
|
1656
1661
|
}),
|
|
1657
1662
|
// Destructive: it removes content and the underlying file, so a host
|
|
@@ -2312,7 +2317,7 @@ function _load() {
|
|
|
2312
2317
|
_context.n = 1;
|
|
2313
2318
|
break;
|
|
2314
2319
|
}
|
|
2315
|
-
return _context.a(2, err("unsupported", "This Val project is not connected to Val Build, so there is nowhere to upload a remote image to. Set `project` in val.config (or the VAL_PROJECT environment variable), or use a schema without
|
|
2320
|
+
return _context.a(2, err("unsupported", "This Val project is not connected to Val Build, so there is nowhere to upload a remote image to. Set `project` in val.config (or the VAL_PROJECT environment variable), or use a schema without `.remote()`."));
|
|
2316
2321
|
case 1:
|
|
2317
2322
|
_context.n = 2;
|
|
2318
2323
|
return server.resolveRemoteFileAuth(options);
|
|
@@ -2439,7 +2444,7 @@ function buildRemoteRef(input) {
|
|
|
2439
2444
|
* that installs Val. So the host builds this one and hands it in — see
|
|
2440
2445
|
* `createValTools`'s `extraTools`, and `@valbuild/mcp/sharp`.
|
|
2441
2446
|
*
|
|
2442
|
-
* What it deliberately does NOT do: remote files. `s.image(
|
|
2447
|
+
* What it deliberately does NOT do: remote files. `s.image().remote()`
|
|
2443
2448
|
* uploads straight to Val's content host through a presigned nonce, which is
|
|
2444
2449
|
* the one path in local mode that needs a personal access token
|
|
2445
2450
|
* (`docs/plans/mcp.md` D.1). Refused with a message that says so rather than
|
|
@@ -2484,7 +2489,7 @@ function createValImageTools(processor, options) {
|
|
|
2484
2489
|
return [defineTool({
|
|
2485
2490
|
name: "upload_image",
|
|
2486
2491
|
title: "Upload an image",
|
|
2487
|
-
description: "Upload an image file and put it in an image field, or add it to an image gallery module (one declared with s.
|
|
2492
|
+
description: "Upload an image file and put it in an image field, or add it to an image gallery module (one declared with s.imageset()). Give it either imageFilePath — a path to a file on the machine this app runs on — or imageBase64. The image is re-encoded first if the schema asks for that. Works for remotely stored images too (s.image().remote()), which need the project to be connected to Val Build.",
|
|
2488
2493
|
inputSchema: zod.z.object({
|
|
2489
2494
|
moduleFilePath: ModuleFilePathSchema,
|
|
2490
2495
|
path: zod.z.array(zod.z.string())["default"]([]).describe('Path of the image field within the module, e.g. ["hero","image"]. Leave empty when the module itself is an image gallery — the image is then added to it under a generated key.'),
|
|
@@ -2562,7 +2567,7 @@ function createValImageTools(processor, options) {
|
|
|
2562
2567
|
// Where the bytes live, always: a `/public/...` path in the patch
|
|
2563
2568
|
// store. For a remote image the CONTENT points somewhere else, but the
|
|
2564
2569
|
// bytes still land here and stay here until publish pushes them.
|
|
2565
|
-
storedPath = "".concat(target.
|
|
2570
|
+
storedPath = "".concat(target.dir, "/").concat(generated);
|
|
2566
2571
|
_context.n = 9;
|
|
2567
2572
|
return resolveRef(target, settingsFor(deps.config), {
|
|
2568
2573
|
bytes: prepared.bytes,
|
|
@@ -2690,7 +2695,7 @@ function _resolveRef() {
|
|
|
2690
2695
|
_context3.n = 2;
|
|
2691
2696
|
break;
|
|
2692
2697
|
}
|
|
2693
|
-
return _context3.a(2, err("invalid-args", "A remote image has to be stored under /public, and this schema's directory is ".concat(JSON.stringify(target.
|
|
2698
|
+
return _context3.a(2, err("invalid-args", "A remote image has to be stored under /public, and this schema's directory is ".concat(JSON.stringify(target.dir), ".")));
|
|
2694
2699
|
case 2:
|
|
2695
2700
|
_context3.n = 3;
|
|
2696
2701
|
return resolveRemoteUploadTarget(loadSettings);
|
|
@@ -2729,9 +2734,9 @@ function _resolveRef() {
|
|
|
2729
2734
|
/** The default in `createFilePatch`, and the same default here. */
|
|
2730
2735
|
var DEFAULT_DIRECTORY = "/public/val";
|
|
2731
2736
|
function resolveTarget(deps, moduleSchema, fieldPath) {
|
|
2732
|
-
var _ref2, _schema$options$
|
|
2737
|
+
var _ref2, _schema$options$dir, _schema$options, _schema$options$accep, _schema$options2, _schema$options3;
|
|
2733
2738
|
if (fieldPath.length === 0) {
|
|
2734
|
-
var _moduleSchema$
|
|
2739
|
+
var _moduleSchema$dir;
|
|
2735
2740
|
if (moduleSchema.type !== "record" || moduleSchema.mediaType !== "images") {
|
|
2736
2741
|
return {
|
|
2737
2742
|
status: "error",
|
|
@@ -2742,7 +2747,7 @@ function resolveTarget(deps, moduleSchema, fieldPath) {
|
|
|
2742
2747
|
status: "ok",
|
|
2743
2748
|
kind: "gallery",
|
|
2744
2749
|
gallerySchema: moduleSchema,
|
|
2745
|
-
|
|
2750
|
+
dir: (_moduleSchema$dir = moduleSchema.dir) !== null && _moduleSchema$dir !== void 0 ? _moduleSchema$dir : DEFAULT_DIRECTORY,
|
|
2746
2751
|
accept: moduleSchema.accept,
|
|
2747
2752
|
encode: internal.resolveEncodeSettings(undefined, moduleSchema.encode),
|
|
2748
2753
|
altRequired: altIsRequired(moduleSchema),
|
|
@@ -2795,7 +2800,7 @@ function resolveTarget(deps, moduleSchema, fieldPath) {
|
|
|
2795
2800
|
kind: "field",
|
|
2796
2801
|
referencedModule: referencedModule,
|
|
2797
2802
|
galleryBacked: referencedModule !== undefined,
|
|
2798
|
-
|
|
2803
|
+
dir: (_ref2 = (_schema$options$dir = (_schema$options = schema.options) === null || _schema$options === void 0 ? void 0 : _schema$options.dir) !== null && _schema$options$dir !== void 0 ? _schema$options$dir : galleryRecord === null || galleryRecord === void 0 ? void 0 : galleryRecord.dir) !== null && _ref2 !== void 0 ? _ref2 : DEFAULT_DIRECTORY,
|
|
2799
2804
|
accept: (_schema$options$accep = (_schema$options2 = schema.options) === null || _schema$options2 === void 0 ? void 0 : _schema$options2.accept) !== null && _schema$options$accep !== void 0 ? _schema$options$accep : galleryRecord === null || galleryRecord === void 0 ? void 0 : galleryRecord.accept,
|
|
2800
2805
|
encode: internal.resolveEncodeSettings((_schema$options3 = schema.options) === null || _schema$options3 === void 0 ? void 0 : _schema$options3.encode, galleryRecord === null || galleryRecord === void 0 ? void 0 : galleryRecord.encode),
|
|
2801
2806
|
// Only a gallery has an alt schema to satisfy. A plain `s.image()` field
|
|
@@ -2822,8 +2827,8 @@ function galleryEntryImageSchema(gallery) {
|
|
|
2822
2827
|
opt: false,
|
|
2823
2828
|
options: _objectSpread2(_objectSpread2({}, gallery.accept ? {
|
|
2824
2829
|
accept: gallery.accept
|
|
2825
|
-
} : {}), gallery.
|
|
2826
|
-
|
|
2830
|
+
} : {}), gallery.dir ? {
|
|
2831
|
+
dir: gallery.dir
|
|
2827
2832
|
} : {})
|
|
2828
2833
|
};
|
|
2829
2834
|
}
|
|
@@ -2831,8 +2836,8 @@ function galleryEntryImageSchema(gallery) {
|
|
|
2831
2836
|
/**
|
|
2832
2837
|
* Does this gallery insist on alt text?
|
|
2833
2838
|
*
|
|
2834
|
-
* `s.
|
|
2835
|
-
* without one stores `null`. A gallery that passed its own — `s.
|
|
2839
|
+
* `s.imageset()` gives `alt` a nullable string by default, and an entry written
|
|
2840
|
+
* without one stores `null`. A gallery that passed its own — `s.imageset({ alt:
|
|
2836
2841
|
* s.string().minLength(4) })`, which the example app does — has made it
|
|
2837
2842
|
* required, and an upload with no `alt` cannot satisfy it however it is
|
|
2838
2843
|
* written. Asked here so the caller is told what to pass, rather than shown a
|
|
@@ -3360,7 +3365,7 @@ var packageJson = {
|
|
|
3360
3365
|
"./package.json": "./package.json"
|
|
3361
3366
|
},
|
|
3362
3367
|
types: "dist/valbuild-mcp.cjs.d.ts",
|
|
3363
|
-
version: "0.
|
|
3368
|
+
version: "0.128.0",
|
|
3364
3369
|
scripts: {
|
|
3365
3370
|
typecheck: "tsc --noEmit",
|
|
3366
3371
|
test: "jest",
|
|
@@ -1630,7 +1630,12 @@ function writeTools() {
|
|
|
1630
1630
|
case 1:
|
|
1631
1631
|
built = internal.buildEmptyAtPathPatch({
|
|
1632
1632
|
destinationPath: destinationPath
|
|
1633
|
-
}, schema, deps.state.sources[modulePath]
|
|
1633
|
+
}, schema, deps.state.sources[modulePath], {
|
|
1634
|
+
locales: internal.declaredLocales({
|
|
1635
|
+
schemas: deps.state.serializedSchemas,
|
|
1636
|
+
sources: deps.state.sources
|
|
1637
|
+
})
|
|
1638
|
+
});
|
|
1634
1639
|
if (!(built.kind !== "ok")) {
|
|
1635
1640
|
_context3.n = 2;
|
|
1636
1641
|
break;
|
|
@@ -1651,7 +1656,7 @@ function writeTools() {
|
|
|
1651
1656
|
title: "Remove an image gallery entry",
|
|
1652
1657
|
description: "Remove one image from an image gallery module by its file path. This deletes the entry and the file it refers to.",
|
|
1653
1658
|
inputSchema: zod.z.object({
|
|
1654
|
-
moduleFilePath: ModuleFilePathSchema$1.describe("The gallery module, i.e. one declared with s.
|
|
1659
|
+
moduleFilePath: ModuleFilePathSchema$1.describe("The gallery module, i.e. one declared with s.imageset() or s.fileset()."),
|
|
1655
1660
|
filePath: zod.z.string().describe('The gallery key to remove, e.g. "/public/val/photo_a1b2c.jpg".')
|
|
1656
1661
|
}),
|
|
1657
1662
|
// Destructive: it removes content and the underlying file, so a host
|
|
@@ -2312,7 +2317,7 @@ function _load() {
|
|
|
2312
2317
|
_context.n = 1;
|
|
2313
2318
|
break;
|
|
2314
2319
|
}
|
|
2315
|
-
return _context.a(2, err("unsupported", "This Val project is not connected to Val Build, so there is nowhere to upload a remote image to. Set `project` in val.config (or the VAL_PROJECT environment variable), or use a schema without
|
|
2320
|
+
return _context.a(2, err("unsupported", "This Val project is not connected to Val Build, so there is nowhere to upload a remote image to. Set `project` in val.config (or the VAL_PROJECT environment variable), or use a schema without `.remote()`."));
|
|
2316
2321
|
case 1:
|
|
2317
2322
|
_context.n = 2;
|
|
2318
2323
|
return server.resolveRemoteFileAuth(options);
|
|
@@ -2439,7 +2444,7 @@ function buildRemoteRef(input) {
|
|
|
2439
2444
|
* that installs Val. So the host builds this one and hands it in — see
|
|
2440
2445
|
* `createValTools`'s `extraTools`, and `@valbuild/mcp/sharp`.
|
|
2441
2446
|
*
|
|
2442
|
-
* What it deliberately does NOT do: remote files. `s.image(
|
|
2447
|
+
* What it deliberately does NOT do: remote files. `s.image().remote()`
|
|
2443
2448
|
* uploads straight to Val's content host through a presigned nonce, which is
|
|
2444
2449
|
* the one path in local mode that needs a personal access token
|
|
2445
2450
|
* (`docs/plans/mcp.md` D.1). Refused with a message that says so rather than
|
|
@@ -2484,7 +2489,7 @@ function createValImageTools(processor, options) {
|
|
|
2484
2489
|
return [defineTool({
|
|
2485
2490
|
name: "upload_image",
|
|
2486
2491
|
title: "Upload an image",
|
|
2487
|
-
description: "Upload an image file and put it in an image field, or add it to an image gallery module (one declared with s.
|
|
2492
|
+
description: "Upload an image file and put it in an image field, or add it to an image gallery module (one declared with s.imageset()). Give it either imageFilePath — a path to a file on the machine this app runs on — or imageBase64. The image is re-encoded first if the schema asks for that. Works for remotely stored images too (s.image().remote()), which need the project to be connected to Val Build.",
|
|
2488
2493
|
inputSchema: zod.z.object({
|
|
2489
2494
|
moduleFilePath: ModuleFilePathSchema,
|
|
2490
2495
|
path: zod.z.array(zod.z.string())["default"]([]).describe('Path of the image field within the module, e.g. ["hero","image"]. Leave empty when the module itself is an image gallery — the image is then added to it under a generated key.'),
|
|
@@ -2562,7 +2567,7 @@ function createValImageTools(processor, options) {
|
|
|
2562
2567
|
// Where the bytes live, always: a `/public/...` path in the patch
|
|
2563
2568
|
// store. For a remote image the CONTENT points somewhere else, but the
|
|
2564
2569
|
// bytes still land here and stay here until publish pushes them.
|
|
2565
|
-
storedPath = "".concat(target.
|
|
2570
|
+
storedPath = "".concat(target.dir, "/").concat(generated);
|
|
2566
2571
|
_context.n = 9;
|
|
2567
2572
|
return resolveRef(target, settingsFor(deps.config), {
|
|
2568
2573
|
bytes: prepared.bytes,
|
|
@@ -2690,7 +2695,7 @@ function _resolveRef() {
|
|
|
2690
2695
|
_context3.n = 2;
|
|
2691
2696
|
break;
|
|
2692
2697
|
}
|
|
2693
|
-
return _context3.a(2, err("invalid-args", "A remote image has to be stored under /public, and this schema's directory is ".concat(JSON.stringify(target.
|
|
2698
|
+
return _context3.a(2, err("invalid-args", "A remote image has to be stored under /public, and this schema's directory is ".concat(JSON.stringify(target.dir), ".")));
|
|
2694
2699
|
case 2:
|
|
2695
2700
|
_context3.n = 3;
|
|
2696
2701
|
return resolveRemoteUploadTarget(loadSettings);
|
|
@@ -2729,9 +2734,9 @@ function _resolveRef() {
|
|
|
2729
2734
|
/** The default in `createFilePatch`, and the same default here. */
|
|
2730
2735
|
var DEFAULT_DIRECTORY = "/public/val";
|
|
2731
2736
|
function resolveTarget(deps, moduleSchema, fieldPath) {
|
|
2732
|
-
var _ref2, _schema$options$
|
|
2737
|
+
var _ref2, _schema$options$dir, _schema$options, _schema$options$accep, _schema$options2, _schema$options3;
|
|
2733
2738
|
if (fieldPath.length === 0) {
|
|
2734
|
-
var _moduleSchema$
|
|
2739
|
+
var _moduleSchema$dir;
|
|
2735
2740
|
if (moduleSchema.type !== "record" || moduleSchema.mediaType !== "images") {
|
|
2736
2741
|
return {
|
|
2737
2742
|
status: "error",
|
|
@@ -2742,7 +2747,7 @@ function resolveTarget(deps, moduleSchema, fieldPath) {
|
|
|
2742
2747
|
status: "ok",
|
|
2743
2748
|
kind: "gallery",
|
|
2744
2749
|
gallerySchema: moduleSchema,
|
|
2745
|
-
|
|
2750
|
+
dir: (_moduleSchema$dir = moduleSchema.dir) !== null && _moduleSchema$dir !== void 0 ? _moduleSchema$dir : DEFAULT_DIRECTORY,
|
|
2746
2751
|
accept: moduleSchema.accept,
|
|
2747
2752
|
encode: internal.resolveEncodeSettings(undefined, moduleSchema.encode),
|
|
2748
2753
|
altRequired: altIsRequired(moduleSchema),
|
|
@@ -2795,7 +2800,7 @@ function resolveTarget(deps, moduleSchema, fieldPath) {
|
|
|
2795
2800
|
kind: "field",
|
|
2796
2801
|
referencedModule: referencedModule,
|
|
2797
2802
|
galleryBacked: referencedModule !== undefined,
|
|
2798
|
-
|
|
2803
|
+
dir: (_ref2 = (_schema$options$dir = (_schema$options = schema.options) === null || _schema$options === void 0 ? void 0 : _schema$options.dir) !== null && _schema$options$dir !== void 0 ? _schema$options$dir : galleryRecord === null || galleryRecord === void 0 ? void 0 : galleryRecord.dir) !== null && _ref2 !== void 0 ? _ref2 : DEFAULT_DIRECTORY,
|
|
2799
2804
|
accept: (_schema$options$accep = (_schema$options2 = schema.options) === null || _schema$options2 === void 0 ? void 0 : _schema$options2.accept) !== null && _schema$options$accep !== void 0 ? _schema$options$accep : galleryRecord === null || galleryRecord === void 0 ? void 0 : galleryRecord.accept,
|
|
2800
2805
|
encode: internal.resolveEncodeSettings((_schema$options3 = schema.options) === null || _schema$options3 === void 0 ? void 0 : _schema$options3.encode, galleryRecord === null || galleryRecord === void 0 ? void 0 : galleryRecord.encode),
|
|
2801
2806
|
// Only a gallery has an alt schema to satisfy. A plain `s.image()` field
|
|
@@ -2822,8 +2827,8 @@ function galleryEntryImageSchema(gallery) {
|
|
|
2822
2827
|
opt: false,
|
|
2823
2828
|
options: _objectSpread2(_objectSpread2({}, gallery.accept ? {
|
|
2824
2829
|
accept: gallery.accept
|
|
2825
|
-
} : {}), gallery.
|
|
2826
|
-
|
|
2830
|
+
} : {}), gallery.dir ? {
|
|
2831
|
+
dir: gallery.dir
|
|
2827
2832
|
} : {})
|
|
2828
2833
|
};
|
|
2829
2834
|
}
|
|
@@ -2831,8 +2836,8 @@ function galleryEntryImageSchema(gallery) {
|
|
|
2831
2836
|
/**
|
|
2832
2837
|
* Does this gallery insist on alt text?
|
|
2833
2838
|
*
|
|
2834
|
-
* `s.
|
|
2835
|
-
* without one stores `null`. A gallery that passed its own — `s.
|
|
2839
|
+
* `s.imageset()` gives `alt` a nullable string by default, and an entry written
|
|
2840
|
+
* without one stores `null`. A gallery that passed its own — `s.imageset({ alt:
|
|
2836
2841
|
* s.string().minLength(4) })`, which the example app does — has made it
|
|
2837
2842
|
* required, and an upload with no `alt` cannot satisfy it however it is
|
|
2838
2843
|
* written. Asked here so the caller is told what to pass, rather than shown a
|
|
@@ -3360,7 +3365,7 @@ var packageJson = {
|
|
|
3360
3365
|
"./package.json": "./package.json"
|
|
3361
3366
|
},
|
|
3362
3367
|
types: "dist/valbuild-mcp.cjs.d.ts",
|
|
3363
|
-
version: "0.
|
|
3368
|
+
version: "0.128.0",
|
|
3364
3369
|
scripts: {
|
|
3365
3370
|
typecheck: "tsc --noEmit",
|
|
3366
3371
|
test: "jest",
|
package/dist/valbuild-mcp.esm.js
CHANGED
|
@@ -2,7 +2,7 @@ import { _ as _asyncToGenerator, a as _regenerator } from './asyncToGenerator-50
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { createValOps, getSettings, resolveRemoteFileAuth, getFileExt, initHandlerOptions } from '@valbuild/server';
|
|
4
4
|
import { Internal, getSourcePathFromRoute, DEFAULT_VAL_REMOTE_HOST } from '@valbuild/core';
|
|
5
|
-
import { performSearch, createSearchIndex, indexModule, filterBlockingValidationErrors, describeContainerAtPath, safeParsePatch, buildDuplicatePatch, buildEmptyAtPathPatch, buildRemoveImageGalleryEntryPatch, resolveEncodeSettings, resolveSerializedSchemaAtPath, withExtension, fitWithin, isSkippedSource, ENCODE_MIME_TYPE_OF, isMimeTypeAccepted, chooseEncoded, buildImageGalleryPatch } from '@valbuild/shared/internal';
|
|
5
|
+
import { performSearch, createSearchIndex, indexModule, filterBlockingValidationErrors, describeContainerAtPath, safeParsePatch, buildDuplicatePatch, buildEmptyAtPathPatch, declaredLocales, buildRemoveImageGalleryEntryPatch, resolveEncodeSettings, resolveSerializedSchemaAtPath, withExtension, fitWithin, isSkippedSource, ENCODE_MIME_TYPE_OF, isMimeTypeAccepted, chooseEncoded, buildImageGalleryPatch } from '@valbuild/shared/internal';
|
|
6
6
|
import { minimatch } from 'minimatch';
|
|
7
7
|
import { randomUUID, createPublicKey, verify } from 'node:crypto';
|
|
8
8
|
import { JSONOps, applyPatch, deepClone } from '@valbuild/core/patch';
|
|
@@ -1621,7 +1621,12 @@ function writeTools() {
|
|
|
1621
1621
|
case 1:
|
|
1622
1622
|
built = buildEmptyAtPathPatch({
|
|
1623
1623
|
destinationPath: destinationPath
|
|
1624
|
-
}, schema, deps.state.sources[modulePath]
|
|
1624
|
+
}, schema, deps.state.sources[modulePath], {
|
|
1625
|
+
locales: declaredLocales({
|
|
1626
|
+
schemas: deps.state.serializedSchemas,
|
|
1627
|
+
sources: deps.state.sources
|
|
1628
|
+
})
|
|
1629
|
+
});
|
|
1625
1630
|
if (!(built.kind !== "ok")) {
|
|
1626
1631
|
_context3.n = 2;
|
|
1627
1632
|
break;
|
|
@@ -1642,7 +1647,7 @@ function writeTools() {
|
|
|
1642
1647
|
title: "Remove an image gallery entry",
|
|
1643
1648
|
description: "Remove one image from an image gallery module by its file path. This deletes the entry and the file it refers to.",
|
|
1644
1649
|
inputSchema: z.object({
|
|
1645
|
-
moduleFilePath: ModuleFilePathSchema$1.describe("The gallery module, i.e. one declared with s.
|
|
1650
|
+
moduleFilePath: ModuleFilePathSchema$1.describe("The gallery module, i.e. one declared with s.imageset() or s.fileset()."),
|
|
1646
1651
|
filePath: z.string().describe('The gallery key to remove, e.g. "/public/val/photo_a1b2c.jpg".')
|
|
1647
1652
|
}),
|
|
1648
1653
|
// Destructive: it removes content and the underlying file, so a host
|
|
@@ -2303,7 +2308,7 @@ function _load() {
|
|
|
2303
2308
|
_context.n = 1;
|
|
2304
2309
|
break;
|
|
2305
2310
|
}
|
|
2306
|
-
return _context.a(2, err("unsupported", "This Val project is not connected to Val Build, so there is nowhere to upload a remote image to. Set `project` in val.config (or the VAL_PROJECT environment variable), or use a schema without
|
|
2311
|
+
return _context.a(2, err("unsupported", "This Val project is not connected to Val Build, so there is nowhere to upload a remote image to. Set `project` in val.config (or the VAL_PROJECT environment variable), or use a schema without `.remote()`."));
|
|
2307
2312
|
case 1:
|
|
2308
2313
|
_context.n = 2;
|
|
2309
2314
|
return resolveRemoteFileAuth(options);
|
|
@@ -2430,7 +2435,7 @@ function buildRemoteRef(input) {
|
|
|
2430
2435
|
* that installs Val. So the host builds this one and hands it in — see
|
|
2431
2436
|
* `createValTools`'s `extraTools`, and `@valbuild/mcp/sharp`.
|
|
2432
2437
|
*
|
|
2433
|
-
* What it deliberately does NOT do: remote files. `s.image(
|
|
2438
|
+
* What it deliberately does NOT do: remote files. `s.image().remote()`
|
|
2434
2439
|
* uploads straight to Val's content host through a presigned nonce, which is
|
|
2435
2440
|
* the one path in local mode that needs a personal access token
|
|
2436
2441
|
* (`docs/plans/mcp.md` D.1). Refused with a message that says so rather than
|
|
@@ -2475,7 +2480,7 @@ function createValImageTools(processor, options) {
|
|
|
2475
2480
|
return [defineTool({
|
|
2476
2481
|
name: "upload_image",
|
|
2477
2482
|
title: "Upload an image",
|
|
2478
|
-
description: "Upload an image file and put it in an image field, or add it to an image gallery module (one declared with s.
|
|
2483
|
+
description: "Upload an image file and put it in an image field, or add it to an image gallery module (one declared with s.imageset()). Give it either imageFilePath — a path to a file on the machine this app runs on — or imageBase64. The image is re-encoded first if the schema asks for that. Works for remotely stored images too (s.image().remote()), which need the project to be connected to Val Build.",
|
|
2479
2484
|
inputSchema: z.object({
|
|
2480
2485
|
moduleFilePath: ModuleFilePathSchema,
|
|
2481
2486
|
path: z.array(z.string())["default"]([]).describe('Path of the image field within the module, e.g. ["hero","image"]. Leave empty when the module itself is an image gallery — the image is then added to it under a generated key.'),
|
|
@@ -2553,7 +2558,7 @@ function createValImageTools(processor, options) {
|
|
|
2553
2558
|
// Where the bytes live, always: a `/public/...` path in the patch
|
|
2554
2559
|
// store. For a remote image the CONTENT points somewhere else, but the
|
|
2555
2560
|
// bytes still land here and stay here until publish pushes them.
|
|
2556
|
-
storedPath = "".concat(target.
|
|
2561
|
+
storedPath = "".concat(target.dir, "/").concat(generated);
|
|
2557
2562
|
_context.n = 9;
|
|
2558
2563
|
return resolveRef(target, settingsFor(deps.config), {
|
|
2559
2564
|
bytes: prepared.bytes,
|
|
@@ -2681,7 +2686,7 @@ function _resolveRef() {
|
|
|
2681
2686
|
_context3.n = 2;
|
|
2682
2687
|
break;
|
|
2683
2688
|
}
|
|
2684
|
-
return _context3.a(2, err("invalid-args", "A remote image has to be stored under /public, and this schema's directory is ".concat(JSON.stringify(target.
|
|
2689
|
+
return _context3.a(2, err("invalid-args", "A remote image has to be stored under /public, and this schema's directory is ".concat(JSON.stringify(target.dir), ".")));
|
|
2685
2690
|
case 2:
|
|
2686
2691
|
_context3.n = 3;
|
|
2687
2692
|
return resolveRemoteUploadTarget(loadSettings);
|
|
@@ -2720,9 +2725,9 @@ function _resolveRef() {
|
|
|
2720
2725
|
/** The default in `createFilePatch`, and the same default here. */
|
|
2721
2726
|
var DEFAULT_DIRECTORY = "/public/val";
|
|
2722
2727
|
function resolveTarget(deps, moduleSchema, fieldPath) {
|
|
2723
|
-
var _ref2, _schema$options$
|
|
2728
|
+
var _ref2, _schema$options$dir, _schema$options, _schema$options$accep, _schema$options2, _schema$options3;
|
|
2724
2729
|
if (fieldPath.length === 0) {
|
|
2725
|
-
var _moduleSchema$
|
|
2730
|
+
var _moduleSchema$dir;
|
|
2726
2731
|
if (moduleSchema.type !== "record" || moduleSchema.mediaType !== "images") {
|
|
2727
2732
|
return {
|
|
2728
2733
|
status: "error",
|
|
@@ -2733,7 +2738,7 @@ function resolveTarget(deps, moduleSchema, fieldPath) {
|
|
|
2733
2738
|
status: "ok",
|
|
2734
2739
|
kind: "gallery",
|
|
2735
2740
|
gallerySchema: moduleSchema,
|
|
2736
|
-
|
|
2741
|
+
dir: (_moduleSchema$dir = moduleSchema.dir) !== null && _moduleSchema$dir !== void 0 ? _moduleSchema$dir : DEFAULT_DIRECTORY,
|
|
2737
2742
|
accept: moduleSchema.accept,
|
|
2738
2743
|
encode: resolveEncodeSettings(undefined, moduleSchema.encode),
|
|
2739
2744
|
altRequired: altIsRequired(moduleSchema),
|
|
@@ -2786,7 +2791,7 @@ function resolveTarget(deps, moduleSchema, fieldPath) {
|
|
|
2786
2791
|
kind: "field",
|
|
2787
2792
|
referencedModule: referencedModule,
|
|
2788
2793
|
galleryBacked: referencedModule !== undefined,
|
|
2789
|
-
|
|
2794
|
+
dir: (_ref2 = (_schema$options$dir = (_schema$options = schema.options) === null || _schema$options === void 0 ? void 0 : _schema$options.dir) !== null && _schema$options$dir !== void 0 ? _schema$options$dir : galleryRecord === null || galleryRecord === void 0 ? void 0 : galleryRecord.dir) !== null && _ref2 !== void 0 ? _ref2 : DEFAULT_DIRECTORY,
|
|
2790
2795
|
accept: (_schema$options$accep = (_schema$options2 = schema.options) === null || _schema$options2 === void 0 ? void 0 : _schema$options2.accept) !== null && _schema$options$accep !== void 0 ? _schema$options$accep : galleryRecord === null || galleryRecord === void 0 ? void 0 : galleryRecord.accept,
|
|
2791
2796
|
encode: resolveEncodeSettings((_schema$options3 = schema.options) === null || _schema$options3 === void 0 ? void 0 : _schema$options3.encode, galleryRecord === null || galleryRecord === void 0 ? void 0 : galleryRecord.encode),
|
|
2792
2797
|
// Only a gallery has an alt schema to satisfy. A plain `s.image()` field
|
|
@@ -2813,8 +2818,8 @@ function galleryEntryImageSchema(gallery) {
|
|
|
2813
2818
|
opt: false,
|
|
2814
2819
|
options: _objectSpread2(_objectSpread2({}, gallery.accept ? {
|
|
2815
2820
|
accept: gallery.accept
|
|
2816
|
-
} : {}), gallery.
|
|
2817
|
-
|
|
2821
|
+
} : {}), gallery.dir ? {
|
|
2822
|
+
dir: gallery.dir
|
|
2818
2823
|
} : {})
|
|
2819
2824
|
};
|
|
2820
2825
|
}
|
|
@@ -2822,8 +2827,8 @@ function galleryEntryImageSchema(gallery) {
|
|
|
2822
2827
|
/**
|
|
2823
2828
|
* Does this gallery insist on alt text?
|
|
2824
2829
|
*
|
|
2825
|
-
* `s.
|
|
2826
|
-
* without one stores `null`. A gallery that passed its own — `s.
|
|
2830
|
+
* `s.imageset()` gives `alt` a nullable string by default, and an entry written
|
|
2831
|
+
* without one stores `null`. A gallery that passed its own — `s.imageset({ alt:
|
|
2827
2832
|
* s.string().minLength(4) })`, which the example app does — has made it
|
|
2828
2833
|
* required, and an upload with no `alt` cannot satisfy it however it is
|
|
2829
2834
|
* written. Asked here so the caller is told what to pass, rather than shown a
|
|
@@ -3351,7 +3356,7 @@ var packageJson = {
|
|
|
3351
3356
|
"./package.json": "./package.json"
|
|
3352
3357
|
},
|
|
3353
3358
|
types: "dist/valbuild-mcp.cjs.d.ts",
|
|
3354
|
-
version: "0.
|
|
3359
|
+
version: "0.128.0",
|
|
3355
3360
|
scripts: {
|
|
3356
3361
|
typecheck: "tsc --noEmit",
|
|
3357
3362
|
test: "jest",
|
package/package.json
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"./package.json": "./package.json"
|
|
21
21
|
},
|
|
22
22
|
"types": "dist/valbuild-mcp.cjs.d.ts",
|
|
23
|
-
"version": "0.
|
|
23
|
+
"version": "0.128.0",
|
|
24
24
|
"preconstruct": {
|
|
25
25
|
"entrypoints": [
|
|
26
26
|
"./index.ts",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"minimatch": "^10.2.6",
|
|
33
33
|
"zod": "^4.4.3",
|
|
34
|
-
"@valbuild/core": "0.
|
|
35
|
-
"@valbuild/shared": "0.
|
|
36
|
-
"@valbuild/server": "0.
|
|
34
|
+
"@valbuild/core": "0.128.0",
|
|
35
|
+
"@valbuild/shared": "0.128.0",
|
|
36
|
+
"@valbuild/server": "0.128.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@prettier/sync": "^0.6.1",
|