ovr 7.0.0-next.0 → 7.0.0-next.1
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/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +28 -1
- package/package.json +1 -1
- package/src/mcp/index.ts +33 -2
package/dist/mcp/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,EAAU,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,KAAK,OAAO,EAAS,MAAM,qBAAqB,CAAC;AAG1D,OAAO,EAAE,KAAK,EAAuB,MAAM,mBAAmB,CAAC;AAmC/D,yBAAiB,GAAG,CAAC;IACpB;;;;OAIG;IACH,KAAY,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI;QAChD;;;;WAIG;QACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAEvB,gDAAgD;QAChD,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;QAE/B;;;;WAIG;QACH,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAE9B;;;;WAIG;QACH,QAAQ,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC;KACzB,CAAC;IAEF,gEAAgE;IAChE,UAAiB,IAAI;QACpB,qEAAqE;QACrE,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE;YAClB,yCAAyC;YACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;YAExB;;;;eAIG;YACH,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;YAEp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AC,CAAC,MAAM,CAAC,EAAE;YAClB,yCAAyC;YACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;YAExB;;;;eAIG;YACH,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;YAEpE;;;;eAIG;YACH,KAAK,CACJ,GAAG,EAAE,GAAG,CAAC,KAAK,EACd,QAAQ,EAAE,MAAM,GACd,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC;SACzC,CAAC;KACF;CACD;AAED;;;;;;;GAOG;AACH,qBAAa,GAAG,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;;IA8CzC,wCAAwC;IACxC,YAAY,OAAO,GAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAM,EAEvC;IAED;;;;;OAKG;IACH,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,KAAK,CAAC,CAAC,CAgD7D;CAyjCD"}
|
package/dist/mcp/index.js
CHANGED
|
@@ -486,7 +486,8 @@ export class Mcp {
|
|
|
486
486
|
Object.assign(properties, schema.properties);
|
|
487
487
|
for (const field of (schema.required ?? []))
|
|
488
488
|
required.add(field);
|
|
489
|
-
// a tool's arguments are JSON, so a file is sent as its contents
|
|
489
|
+
// a tool's arguments are JSON, so a file is sent as its contents,
|
|
490
|
+
// and a JSON field as the value it parses, not a string of it
|
|
490
491
|
for (const name in shape) {
|
|
491
492
|
const field = shape[name];
|
|
492
493
|
if (field.type === "file")
|
|
@@ -494,6 +495,10 @@ export class Mcp {
|
|
|
494
495
|
...properties[name],
|
|
495
496
|
...(field.parts > 1 ? { items: Mcp.#file } : Mcp.#file),
|
|
496
497
|
};
|
|
498
|
+
else if (Mcp.#whole(field)) {
|
|
499
|
+
const { type: _, contentMediaType: __, contentSchema, ...keywords } = properties[name];
|
|
500
|
+
properties[name] = { ...contentSchema, ...keywords };
|
|
501
|
+
}
|
|
497
502
|
}
|
|
498
503
|
}
|
|
499
504
|
for (const [param, key] of Mcp.#params(route)) {
|
|
@@ -539,6 +544,17 @@ export class Mcp {
|
|
|
539
544
|
},
|
|
540
545
|
required: ["name"],
|
|
541
546
|
};
|
|
547
|
+
/**
|
|
548
|
+
* @param field Form field
|
|
549
|
+
* @returns `true` for a field that parses its one value as JSON, such as
|
|
550
|
+
* `Field.textarea().json(schema)`, also when made optional
|
|
551
|
+
*/
|
|
552
|
+
static #whole(field) {
|
|
553
|
+
let def = field.def;
|
|
554
|
+
while (def && def.type !== "json")
|
|
555
|
+
def = "inner" in def ? def.inner.def : undefined;
|
|
556
|
+
return Boolean(def);
|
|
557
|
+
}
|
|
542
558
|
/**
|
|
543
559
|
* @param value Tool argument for a file field
|
|
544
560
|
* @returns The file, `undefined` when the argument does not describe one
|
|
@@ -649,6 +665,17 @@ export class Mcp {
|
|
|
649
665
|
if (pathParams.has(name) && !field)
|
|
650
666
|
continue;
|
|
651
667
|
const upload = !read && field?.type === "file";
|
|
668
|
+
// a JSON field reads one value, so an array is sent whole, as its
|
|
669
|
+
// input schema describes it
|
|
670
|
+
const whole = field && Mcp.#whole(field);
|
|
671
|
+
if (whole && value != null) {
|
|
672
|
+
const text = JSON.stringify(value);
|
|
673
|
+
if (read)
|
|
674
|
+
url.searchParams.append(name, text);
|
|
675
|
+
else
|
|
676
|
+
body.append(name, text);
|
|
677
|
+
continue;
|
|
678
|
+
}
|
|
652
679
|
for (const item of Array.isArray(value) ? value : [value]) {
|
|
653
680
|
if (item == null || item === false)
|
|
654
681
|
continue;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ovr",
|
|
3
3
|
"description": "Web apps anyone can use. Each route serves people a page and agents Markdown and MCP tools, with forms, Postgres, and passkey sign-in built in.",
|
|
4
|
-
"version": "7.0.0-next.
|
|
4
|
+
"version": "7.0.0-next.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
package/src/mcp/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type App, agents, direct, mount } from "../app/index.js";
|
|
2
2
|
import { type Context, agent } from "../context/index.js";
|
|
3
|
-
import { forms } from "../form/index.js";
|
|
3
|
+
import { type Field, forms } from "../form/index.js";
|
|
4
4
|
import type { Middleware } from "../middleware/index.js";
|
|
5
5
|
import { Route, parameters, schemas } from "../route/index.js";
|
|
6
6
|
import { Schema } from "../schema/index.js";
|
|
@@ -665,7 +665,8 @@ export class Mcp<P extends string = string> {
|
|
|
665
665
|
Object.assign(properties, schema.properties);
|
|
666
666
|
for (const field of (schema.required ?? []) as string[])
|
|
667
667
|
required.add(field);
|
|
668
|
-
// a tool's arguments are JSON, so a file is sent as its contents
|
|
668
|
+
// a tool's arguments are JSON, so a file is sent as its contents,
|
|
669
|
+
// and a JSON field as the value it parses, not a string of it
|
|
669
670
|
for (const name in shape) {
|
|
670
671
|
const field = shape[name]!;
|
|
671
672
|
if (field.type === "file")
|
|
@@ -673,6 +674,15 @@ export class Mcp<P extends string = string> {
|
|
|
673
674
|
...(properties[name] as Json),
|
|
674
675
|
...(field.parts > 1 ? { items: Mcp.#file } : Mcp.#file),
|
|
675
676
|
};
|
|
677
|
+
else if (Mcp.#whole(field)) {
|
|
678
|
+
const {
|
|
679
|
+
type: _,
|
|
680
|
+
contentMediaType: __,
|
|
681
|
+
contentSchema,
|
|
682
|
+
...keywords
|
|
683
|
+
} = properties[name] as Json;
|
|
684
|
+
properties[name] = { ...(contentSchema as Json), ...keywords };
|
|
685
|
+
}
|
|
676
686
|
}
|
|
677
687
|
}
|
|
678
688
|
|
|
@@ -729,6 +739,18 @@ export class Mcp<P extends string = string> {
|
|
|
729
739
|
required: ["name"],
|
|
730
740
|
};
|
|
731
741
|
|
|
742
|
+
/**
|
|
743
|
+
* @param field Form field
|
|
744
|
+
* @returns `true` for a field that parses its one value as JSON, such as
|
|
745
|
+
* `Field.textarea().json(schema)`, also when made optional
|
|
746
|
+
*/
|
|
747
|
+
static #whole(field: Field.Any) {
|
|
748
|
+
let def: Schema.Def | undefined = field.def;
|
|
749
|
+
while (def && def.type !== "json")
|
|
750
|
+
def = "inner" in def ? def.inner.def : undefined;
|
|
751
|
+
return Boolean(def);
|
|
752
|
+
}
|
|
753
|
+
|
|
732
754
|
/**
|
|
733
755
|
* @param value Tool argument for a file field
|
|
734
756
|
* @returns The file, `undefined` when the argument does not describe one
|
|
@@ -860,6 +882,15 @@ export class Mcp<P extends string = string> {
|
|
|
860
882
|
// a parameter is in the path, and also sent when a field has its name
|
|
861
883
|
if (pathParams.has(name) && !field) continue;
|
|
862
884
|
const upload = !read && field?.type === "file";
|
|
885
|
+
// a JSON field reads one value, so an array is sent whole, as its
|
|
886
|
+
// input schema describes it
|
|
887
|
+
const whole = field && Mcp.#whole(field);
|
|
888
|
+
if (whole && value != null) {
|
|
889
|
+
const text = JSON.stringify(value);
|
|
890
|
+
if (read) url.searchParams.append(name, text);
|
|
891
|
+
else body.append(name, text);
|
|
892
|
+
continue;
|
|
893
|
+
}
|
|
863
894
|
for (const item of Array.isArray(value) ? value : [value]) {
|
|
864
895
|
if (item == null || item === false) continue;
|
|
865
896
|
if (upload) {
|