@valbuild/mcp 0.123.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 (31) hide show
  1. package/CHANGELOG.md +109 -0
  2. package/README.md +79 -0
  3. package/dist/asyncToGenerator-500f022f.esm.js +137 -0
  4. package/dist/asyncToGenerator-8e5c36c8.cjs.prod.js +140 -0
  5. package/dist/asyncToGenerator-c3823d62.cjs.dev.js +140 -0
  6. package/dist/declarations/src/images/imageTools.d.ts +14 -0
  7. package/dist/declarations/src/images/index.d.ts +2 -0
  8. package/dist/declarations/src/images/remoteUploadTarget.d.ts +70 -0
  9. package/dist/declarations/src/images/types.d.ts +60 -0
  10. package/dist/declarations/src/index.d.ts +24 -0
  11. package/dist/declarations/src/initValMcp.d.ts +95 -0
  12. package/dist/declarations/src/sharp/index.d.ts +46 -0
  13. package/dist/declarations/src/tools/createValTools.d.ts +47 -0
  14. package/dist/declarations/src/tools/defineTool.d.ts +79 -0
  15. package/dist/declarations/src/tools/index.d.ts +7 -0
  16. package/dist/declarations/src/tools/types.d.ts +172 -0
  17. package/dist/declarations/src/tools/writePath.d.ts +160 -0
  18. package/dist/declarations/src/valAccessToken.d.ts +93 -0
  19. package/dist/declarations/src/valMcpMetadata.d.ts +47 -0
  20. package/dist/valbuild-mcp.cjs.d.ts +2 -0
  21. package/dist/valbuild-mcp.cjs.dev.js +4399 -0
  22. package/dist/valbuild-mcp.cjs.js +7 -0
  23. package/dist/valbuild-mcp.cjs.prod.js +4399 -0
  24. package/dist/valbuild-mcp.esm.js +4381 -0
  25. package/package.json +66 -0
  26. package/sharp/dist/valbuild-mcp-sharp.cjs.d.ts +2 -0
  27. package/sharp/dist/valbuild-mcp-sharp.cjs.dev.js +157 -0
  28. package/sharp/dist/valbuild-mcp-sharp.cjs.js +7 -0
  29. package/sharp/dist/valbuild-mcp-sharp.cjs.prod.js +157 -0
  30. package/sharp/dist/valbuild-mcp-sharp.esm.js +153 -0
  31. package/sharp/package.json +4 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,109 @@
1
+ # @valbuild/mcp
2
+
3
+ ## 0.123.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#613](https://github.com/valbuild/val/pull/613) [`c5e7dfd`](https://github.com/valbuild/val/commit/c5e7dfd12aa1371195be642e1c2fb72b6f3e3ce2) Thanks [@freekh](https://github.com/freekh)! - Val's MCP endpoint moves to its own package, and can now upload images
8
+
9
+ Everything that serves Val's content tools over MCP — the tool registry, the
10
+ write path behind it, the request guards and the access-token verification —
11
+ now lives in **`@valbuild/mcp`** instead of being split between
12
+ `@valbuild/server` and `@valbuild/next`.
13
+
14
+ **Nothing changes for an app that already mounts it.** `initValMcp` is still
15
+ exported from `@valbuild/next/server` and behaves exactly as before; it is now a
16
+ ten-line binding over `@valbuild/mcp`, supplying the Next version that
17
+ `initHandlerOptions` asks for. A host that is not Next can call
18
+ `initValMcp` from `@valbuild/mcp` directly.
19
+
20
+ If you built your own host on `createValTools`, import it from `@valbuild/mcp`
21
+ rather than `@valbuild/server`; the tool types moved with it.
22
+
23
+ ## Image uploads
24
+
25
+ An agent can now add an image, with a new `upload_image` tool. It takes a path
26
+ to a file on the machine your app runs on, or the image inline as base64, and
27
+ puts it in an `s.image()` field or an `s.images()` gallery.
28
+
29
+ Uploads are converted **only where the Studio would convert them**: `encode` is
30
+ off unless the schema asks for it (`s.image({ encode: { type: "webp" } })`), and
31
+ when it does, which images are converted, how far they are scaled and when the
32
+ original wins are the same decisions the browser makes — the same code, now
33
+ shared. An upload to a schema without `encode` is stored exactly as it arrived,
34
+ whatever its size.
35
+
36
+ One thing the tool does that the Studio does not: it refuses an image the
37
+ schema's `accept` does not cover, checked on the bytes that would actually be
38
+ stored. The Studio does not need to — its file picker carries `accept` — and
39
+ validation reports a mismatch as server-repairable, so nothing downstream would
40
+ stop it. An agent has no picker. Note the ordering:
41
+ `s.image({ accept: "image/webp", encode: { type: "webp" } })` still takes a PNG,
42
+ because the conversion happens first and it is the result that is checked.
43
+
44
+ It is the one tool you construct yourself, because it needs an image library
45
+ and `sharp` ships a compiled binary per platform. Val does not put one in every
46
+ project that installs it, so you decide:
47
+
48
+ ```sh
49
+ npm install sharp
50
+ ```
51
+
52
+ ```ts
53
+ import sharp from "sharp";
54
+ import { createValImageTools } from "@valbuild/mcp";
55
+ import { sharpImageProcessor } from "@valbuild/mcp/sharp";
56
+
57
+ const { valMcpAuthorize, valMcpTools } = initValMcp(valModules, config, {
58
+ extraTools: createValImageTools(sharpImageProcessor(sharp)),
59
+ });
60
+ ```
61
+
62
+ Leave `extraTools` out and everything else works as before — the agent can read,
63
+ validate and edit content, it just cannot add an image. `sharp` is passed in
64
+ rather than imported, so you can supply another encoder: `ValImageProcessor` is
65
+ two functions, `read` and `encode`.
66
+
67
+ Remotely stored images work too — `s.image().remote()` and
68
+ `s.images({ remote: true })` — and they need nothing extra from the MCP client.
69
+ Adding one does not upload anything to Val's content host: the bytes go into the
70
+ patch store like any other unpublished change, and the push to
71
+ `remote.val.build` happens when you publish, exactly as it does for an image
72
+ added through the Studio. All the tool has to do first is ask the project which
73
+ bucket to name in the ref, and the credential for that is the one your app
74
+ already has — its API key when it has one, and in local development the
75
+ `val login` token in your project, the same one `val validate --fix` uses. If
76
+ you have not logged in, it says so and writes nothing.
77
+
78
+ ## `npm create @valbuild` asks
79
+
80
+ The starter template now ships the MCP endpoint, and `npm create @valbuild`
81
+ asks whether you want it — and, if you do, whether agents should be able to
82
+ upload images, saying that this adds `sharp`. Both default to yes, and both can
83
+ be answered up front for a scripted setup:
84
+
85
+ ```sh
86
+ pnpm create @valbuild my-app --mcp --no-image-uploads
87
+ ```
88
+
89
+ - [#620](https://github.com/valbuild/val/pull/620) [`53f670c`](https://github.com/valbuild/val/commit/53f670c0cf2d7a03a6d068c78b7874ce77652c2a) Thanks [@freekh](https://github.com/freekh)! - MCP: `search_content` — full-text search across the project's content, unpublished changes included.
90
+
91
+ The same index the Studio's search box uses, moved into `@valbuild/shared` so both run it, and built fresh on every call. That was the part that looked expensive and is not: indexing `valbuild/web`, a real production site of 20 modules and 206 KB of source, takes 162 ms, and it scales linearly from there — the 10 s default deadline is not reached until roughly 13 MB of content. Loading the modules costs more than indexing them, and every tool call already pays that.
92
+
93
+ That ratio between building the index and querying it — 162 ms against 0.2 ms — is why `queries` is a list. Everything expensive happens before the first query runs, so up to 20 of them are answered from a single pass, separately, so a caller can tell which of its guesses found the thing. A bare string still works as one query.
94
+
95
+ It returns source paths, so `get_source` reads what it finds. The rest of the arguments narrow or bound the work:
96
+
97
+ - `include` / `exclude` — module file path globs, e.g. `["/content/blogs/**"]`. `exclude` is applied after `include`.
98
+ - `limit` — per query, defaulting to 100. A model filters a long list more cheaply than it asks again.
99
+ - `timeoutMs` — stop indexing and answer with what has been indexed so far. The result then carries `timedOut`, the paths of the modules that were not reached, and a hint pointing at `include`.
100
+
101
+ Every answer says what it actually searched (`searched: { modules, of }`), so each query's `total` can be read as a count over those modules rather than over the project. Modules you excluded are not reported as omissions — an omission always means the deadline, never your filter.
102
+
103
+ `performSearch` now counts all the matches rather than the page it returns, which the Studio's result count gets too: FlexSearch stops as soon as it has the ids it was asked for, so a total taken from a page-sized search was only ever the page size again.
104
+
105
+ ### Patch Changes
106
+
107
+ - Updated dependencies [[`c5e7dfd`](https://github.com/valbuild/val/commit/c5e7dfd12aa1371195be642e1c2fb72b6f3e3ce2), [`53f670c`](https://github.com/valbuild/val/commit/53f670c0cf2d7a03a6d068c78b7874ce77652c2a)]:
108
+ - @valbuild/server@0.123.0
109
+ - @valbuild/shared@0.123.0
package/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # Val MCP
2
+
3
+ Val's content tools, and the checks that decide whether a request may reach
4
+ them, for hosts that speak the Model Context Protocol.
5
+
6
+ Nothing in this package imports an MCP SDK. The app owns the transport — which
7
+ SDK, which route, which framework — and this owns the parts that must not be
8
+ re-decided per app: the tools themselves, whether a request is allowed to reach
9
+ them at all, and whose credential it carries.
10
+
11
+ ```ts
12
+ import { initValMcp } from "@valbuild/mcp";
13
+
14
+ const { valMcpAuthorize, valMcpTools, valMcpMetadata } = initValMcp(
15
+ valModules,
16
+ config,
17
+ );
18
+ ```
19
+
20
+ ## The tools
21
+
22
+ Reading:
23
+
24
+ | Tool | |
25
+ | ---------------------------- | --------------------------------------------------------- |
26
+ | `get_all_schema` | every module's path and schema — where to start |
27
+ | `search_content` | find content by text, several queries at once |
28
+ | `get_source` | the content at a source path, unpublished changes applied |
29
+ | `get_record_keys` | a record's keys without its values |
30
+ | `count_entries` | how big something is before asking for it |
31
+ | `get_source_path_from_route` | the module behind a URL |
32
+ | `get_patches` | what is edited but not yet published |
33
+ | `validate_content` | what the Studio would show as an error |
34
+
35
+ Writing:
36
+
37
+ | Tool | |
38
+ | ---------------------------- | --------------------------------------------------- |
39
+ | `create_patch` | change a value at a path |
40
+ | `duplicate_source` | copy an array item or record entry |
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.images()` gallery |
43
+ | `upload_image` | add one — see below |
44
+
45
+ Every write is validated against the schema before it is stored, and refused
46
+ rather than saved broken. A patch lands unpublished, exactly where the Studio
47
+ puts an edit, so a human still reviews and publishes it.
48
+
49
+ ## Image uploads need `sharp`
50
+
51
+ The tool that uploads an image is not part of the default set, because reading
52
+ the dimensions out of a JPEG and re-encoding it to WebP needs an image library,
53
+ and `sharp` is a native dependency no project should acquire without asking for
54
+ it. Install it yourself and pass it in:
55
+
56
+ ```sh
57
+ npm install sharp
58
+ ```
59
+
60
+ ```ts
61
+ import sharp from "sharp";
62
+ import { initValMcp, createValImageTools } from "@valbuild/mcp";
63
+ import { sharpImageProcessor } from "@valbuild/mcp/sharp";
64
+
65
+ const { valMcpAuthorize, valMcpTools } = initValMcp(valModules, config, {
66
+ extraTools: createValImageTools(sharpImageProcessor(sharp)),
67
+ });
68
+ ```
69
+
70
+ Leave `extraTools` out and everything else still works — an agent can then read,
71
+ validate and edit content, but not add an image.
72
+
73
+ Remotely stored images (`s.images({ remote: true })`) work through the same tool.
74
+ Adding one uploads nothing to Val's content host — the bytes go into the patch
75
+ store, and the push happens at publish — so the only thing it needs is the
76
+ project's bucket list, read with your app's own credential (its API key, or the
77
+ `val login` token in your project during local development).
78
+
79
+ The design notes are in [`docs/plans/mcp.md`](https://github.com/valbuild/val/blob/main/docs/plans/mcp.md).
@@ -0,0 +1,137 @@
1
+ function _regeneratorDefine(e, r, n, t) {
2
+ var i = Object.defineProperty;
3
+ try {
4
+ i({}, "", {});
5
+ } catch (e) {
6
+ i = 0;
7
+ }
8
+ _regeneratorDefine = function (e, r, n, t) {
9
+ function o(r, n) {
10
+ _regeneratorDefine(e, r, function (e) {
11
+ return this._invoke(r, n, e);
12
+ });
13
+ }
14
+ r ? i ? i(e, r, {
15
+ value: n,
16
+ enumerable: !t,
17
+ configurable: !t,
18
+ writable: !t
19
+ }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
20
+ }, _regeneratorDefine(e, r, n, t);
21
+ }
22
+
23
+ function _regenerator() {
24
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
25
+ var e,
26
+ t,
27
+ r = "function" == typeof Symbol ? Symbol : {},
28
+ n = r.iterator || "@@iterator",
29
+ o = r.toStringTag || "@@toStringTag";
30
+ function i(r, n, o, i) {
31
+ var c = n && n.prototype instanceof Generator ? n : Generator,
32
+ u = Object.create(c.prototype);
33
+ return _regeneratorDefine(u, "_invoke", function (r, n, o) {
34
+ var i,
35
+ c,
36
+ u,
37
+ f = 0,
38
+ p = o || [],
39
+ y = !1,
40
+ G = {
41
+ p: 0,
42
+ n: 0,
43
+ v: e,
44
+ a: d,
45
+ f: d.bind(e, 4),
46
+ d: function (t, r) {
47
+ return i = t, c = 0, u = e, G.n = r, a;
48
+ }
49
+ };
50
+ function d(r, n) {
51
+ for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
52
+ var o,
53
+ i = p[t],
54
+ d = G.p,
55
+ l = i[2];
56
+ r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
57
+ }
58
+ if (o || r > 1) return a;
59
+ throw y = !0, n;
60
+ }
61
+ return function (o, p, l) {
62
+ if (f > 1) throw TypeError("Generator is already running");
63
+ for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
64
+ i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
65
+ try {
66
+ if (f = 2, i) {
67
+ if (c || (o = "next"), t = i[o]) {
68
+ if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
69
+ if (!t.done) return t;
70
+ u = t.value, c < 2 && (c = 0);
71
+ } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
72
+ i = e;
73
+ } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
74
+ } catch (t) {
75
+ i = e, c = 1, u = t;
76
+ } finally {
77
+ f = 1;
78
+ }
79
+ }
80
+ return {
81
+ value: t,
82
+ done: y
83
+ };
84
+ };
85
+ }(r, o, i), !0), u;
86
+ }
87
+ var a = {};
88
+ function Generator() {}
89
+ function GeneratorFunction() {}
90
+ function GeneratorFunctionPrototype() {}
91
+ t = Object.getPrototypeOf;
92
+ var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
93
+ return this;
94
+ }), t),
95
+ u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
96
+ function f(e) {
97
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
98
+ }
99
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
100
+ return this;
101
+ }), _regeneratorDefine(u, "toString", function () {
102
+ return "[object Generator]";
103
+ }), (_regenerator = function () {
104
+ return {
105
+ w: i,
106
+ m: f
107
+ };
108
+ })();
109
+ }
110
+
111
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
112
+ try {
113
+ var i = n[a](c),
114
+ u = i.value;
115
+ } catch (n) {
116
+ return void e(n);
117
+ }
118
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
119
+ }
120
+ function _asyncToGenerator(n) {
121
+ return function () {
122
+ var t = this,
123
+ e = arguments;
124
+ return new Promise(function (r, o) {
125
+ var a = n.apply(t, e);
126
+ function _next(n) {
127
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
128
+ }
129
+ function _throw(n) {
130
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
131
+ }
132
+ _next(void 0);
133
+ });
134
+ };
135
+ }
136
+
137
+ export { _asyncToGenerator as _, _regenerator as a };
@@ -0,0 +1,140 @@
1
+ 'use strict';
2
+
3
+ function _regeneratorDefine(e, r, n, t) {
4
+ var i = Object.defineProperty;
5
+ try {
6
+ i({}, "", {});
7
+ } catch (e) {
8
+ i = 0;
9
+ }
10
+ _regeneratorDefine = function (e, r, n, t) {
11
+ function o(r, n) {
12
+ _regeneratorDefine(e, r, function (e) {
13
+ return this._invoke(r, n, e);
14
+ });
15
+ }
16
+ r ? i ? i(e, r, {
17
+ value: n,
18
+ enumerable: !t,
19
+ configurable: !t,
20
+ writable: !t
21
+ }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
22
+ }, _regeneratorDefine(e, r, n, t);
23
+ }
24
+
25
+ function _regenerator() {
26
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
27
+ var e,
28
+ t,
29
+ r = "function" == typeof Symbol ? Symbol : {},
30
+ n = r.iterator || "@@iterator",
31
+ o = r.toStringTag || "@@toStringTag";
32
+ function i(r, n, o, i) {
33
+ var c = n && n.prototype instanceof Generator ? n : Generator,
34
+ u = Object.create(c.prototype);
35
+ return _regeneratorDefine(u, "_invoke", function (r, n, o) {
36
+ var i,
37
+ c,
38
+ u,
39
+ f = 0,
40
+ p = o || [],
41
+ y = !1,
42
+ G = {
43
+ p: 0,
44
+ n: 0,
45
+ v: e,
46
+ a: d,
47
+ f: d.bind(e, 4),
48
+ d: function (t, r) {
49
+ return i = t, c = 0, u = e, G.n = r, a;
50
+ }
51
+ };
52
+ function d(r, n) {
53
+ for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
54
+ var o,
55
+ i = p[t],
56
+ d = G.p,
57
+ l = i[2];
58
+ r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
59
+ }
60
+ if (o || r > 1) return a;
61
+ throw y = !0, n;
62
+ }
63
+ return function (o, p, l) {
64
+ if (f > 1) throw TypeError("Generator is already running");
65
+ for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
66
+ i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
67
+ try {
68
+ if (f = 2, i) {
69
+ if (c || (o = "next"), t = i[o]) {
70
+ if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
71
+ if (!t.done) return t;
72
+ u = t.value, c < 2 && (c = 0);
73
+ } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
74
+ i = e;
75
+ } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
76
+ } catch (t) {
77
+ i = e, c = 1, u = t;
78
+ } finally {
79
+ f = 1;
80
+ }
81
+ }
82
+ return {
83
+ value: t,
84
+ done: y
85
+ };
86
+ };
87
+ }(r, o, i), !0), u;
88
+ }
89
+ var a = {};
90
+ function Generator() {}
91
+ function GeneratorFunction() {}
92
+ function GeneratorFunctionPrototype() {}
93
+ t = Object.getPrototypeOf;
94
+ var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
95
+ return this;
96
+ }), t),
97
+ u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
98
+ function f(e) {
99
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
100
+ }
101
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
102
+ return this;
103
+ }), _regeneratorDefine(u, "toString", function () {
104
+ return "[object Generator]";
105
+ }), (_regenerator = function () {
106
+ return {
107
+ w: i,
108
+ m: f
109
+ };
110
+ })();
111
+ }
112
+
113
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
114
+ try {
115
+ var i = n[a](c),
116
+ u = i.value;
117
+ } catch (n) {
118
+ return void e(n);
119
+ }
120
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
121
+ }
122
+ function _asyncToGenerator(n) {
123
+ return function () {
124
+ var t = this,
125
+ e = arguments;
126
+ return new Promise(function (r, o) {
127
+ var a = n.apply(t, e);
128
+ function _next(n) {
129
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
130
+ }
131
+ function _throw(n) {
132
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
133
+ }
134
+ _next(void 0);
135
+ });
136
+ };
137
+ }
138
+
139
+ exports._asyncToGenerator = _asyncToGenerator;
140
+ exports._regenerator = _regenerator;
@@ -0,0 +1,140 @@
1
+ 'use strict';
2
+
3
+ function _regeneratorDefine(e, r, n, t) {
4
+ var i = Object.defineProperty;
5
+ try {
6
+ i({}, "", {});
7
+ } catch (e) {
8
+ i = 0;
9
+ }
10
+ _regeneratorDefine = function (e, r, n, t) {
11
+ function o(r, n) {
12
+ _regeneratorDefine(e, r, function (e) {
13
+ return this._invoke(r, n, e);
14
+ });
15
+ }
16
+ r ? i ? i(e, r, {
17
+ value: n,
18
+ enumerable: !t,
19
+ configurable: !t,
20
+ writable: !t
21
+ }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
22
+ }, _regeneratorDefine(e, r, n, t);
23
+ }
24
+
25
+ function _regenerator() {
26
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
27
+ var e,
28
+ t,
29
+ r = "function" == typeof Symbol ? Symbol : {},
30
+ n = r.iterator || "@@iterator",
31
+ o = r.toStringTag || "@@toStringTag";
32
+ function i(r, n, o, i) {
33
+ var c = n && n.prototype instanceof Generator ? n : Generator,
34
+ u = Object.create(c.prototype);
35
+ return _regeneratorDefine(u, "_invoke", function (r, n, o) {
36
+ var i,
37
+ c,
38
+ u,
39
+ f = 0,
40
+ p = o || [],
41
+ y = !1,
42
+ G = {
43
+ p: 0,
44
+ n: 0,
45
+ v: e,
46
+ a: d,
47
+ f: d.bind(e, 4),
48
+ d: function (t, r) {
49
+ return i = t, c = 0, u = e, G.n = r, a;
50
+ }
51
+ };
52
+ function d(r, n) {
53
+ for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
54
+ var o,
55
+ i = p[t],
56
+ d = G.p,
57
+ l = i[2];
58
+ r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
59
+ }
60
+ if (o || r > 1) return a;
61
+ throw y = !0, n;
62
+ }
63
+ return function (o, p, l) {
64
+ if (f > 1) throw TypeError("Generator is already running");
65
+ for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
66
+ i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
67
+ try {
68
+ if (f = 2, i) {
69
+ if (c || (o = "next"), t = i[o]) {
70
+ if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
71
+ if (!t.done) return t;
72
+ u = t.value, c < 2 && (c = 0);
73
+ } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
74
+ i = e;
75
+ } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
76
+ } catch (t) {
77
+ i = e, c = 1, u = t;
78
+ } finally {
79
+ f = 1;
80
+ }
81
+ }
82
+ return {
83
+ value: t,
84
+ done: y
85
+ };
86
+ };
87
+ }(r, o, i), !0), u;
88
+ }
89
+ var a = {};
90
+ function Generator() {}
91
+ function GeneratorFunction() {}
92
+ function GeneratorFunctionPrototype() {}
93
+ t = Object.getPrototypeOf;
94
+ var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
95
+ return this;
96
+ }), t),
97
+ u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
98
+ function f(e) {
99
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
100
+ }
101
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
102
+ return this;
103
+ }), _regeneratorDefine(u, "toString", function () {
104
+ return "[object Generator]";
105
+ }), (_regenerator = function () {
106
+ return {
107
+ w: i,
108
+ m: f
109
+ };
110
+ })();
111
+ }
112
+
113
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
114
+ try {
115
+ var i = n[a](c),
116
+ u = i.value;
117
+ } catch (n) {
118
+ return void e(n);
119
+ }
120
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
121
+ }
122
+ function _asyncToGenerator(n) {
123
+ return function () {
124
+ var t = this,
125
+ e = arguments;
126
+ return new Promise(function (r, o) {
127
+ var a = n.apply(t, e);
128
+ function _next(n) {
129
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
130
+ }
131
+ function _throw(n) {
132
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
133
+ }
134
+ _next(void 0);
135
+ });
136
+ };
137
+ }
138
+
139
+ exports._asyncToGenerator = _asyncToGenerator;
140
+ exports._regenerator = _regenerator;
@@ -0,0 +1,14 @@
1
+ import { type ValToolImpl } from "../tools/defineTool.js";
2
+ import type { ValImageProcessor } from "./types.js";
3
+ import { type RemoteSettingsLoader } from "./remoteUploadTarget.js";
4
+ export declare function createValImageTools(processor: ValImageProcessor, options?: {
5
+ /**
6
+ * Where a remote image's project settings come from.
7
+ *
8
+ * Only tests pass this. It exists because the real loader talks to the
9
+ * content host to learn a project's public id and bucket list, and a suite
10
+ * that had to reach one would be testing the network rather than the ref
11
+ * this builds from the answer.
12
+ */
13
+ loadRemoteSettings?: RemoteSettingsLoader;
14
+ }): ValToolImpl[];
@@ -0,0 +1,2 @@
1
+ export { createValImageTools } from "./imageTools.js";
2
+ export type { ValImageEncodeRequest, ValImageProcessor, ValImageProcessorResult, } from "./types.js";