@emseepea/server 0.3.0 → 0.3.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/README.md +16 -22
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ package supports and what it does not support.
|
|
|
19
19
|
import { createEmseepea, defineMappedTool, defineTool, serveEmseepea } from "@emseepea/server";
|
|
20
20
|
import { z } from "zod";
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
const outputSchema = z.object({
|
|
23
23
|
name: z.string(),
|
|
24
24
|
peaType: z.enum(["shelling", "snap"]),
|
|
25
25
|
growthHabit: z.enum(["bush", "climbing"]),
|
|
@@ -31,7 +31,7 @@ const getPeaVariety = defineTool({
|
|
|
31
31
|
access: "public",
|
|
32
32
|
description: "Get the type, growth habit, and maturity time for one pea variety.",
|
|
33
33
|
inputSchema: z.object({ name: z.string() }),
|
|
34
|
-
outputSchema
|
|
34
|
+
outputSchema,
|
|
35
35
|
handler: ({ name }) => {
|
|
36
36
|
const data = {
|
|
37
37
|
name,
|
|
@@ -241,7 +241,7 @@ const getPeaVariety = defineTool({
|
|
|
241
241
|
icons: [{ src: "https://garden.example/icons/pea.png", mimeType: "image/png" }],
|
|
242
242
|
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
243
243
|
inputSchema: z.object({ name: z.string() }),
|
|
244
|
-
outputSchema
|
|
244
|
+
outputSchema,
|
|
245
245
|
handler,
|
|
246
246
|
});
|
|
247
247
|
```
|
|
@@ -374,39 +374,33 @@ Prefer an open, bounded schema when the backend can add valid values
|
|
|
374
374
|
independently.
|
|
375
375
|
|
|
376
376
|
```ts
|
|
377
|
-
const
|
|
378
|
-
const
|
|
377
|
+
const inputSchema = z.object({ name: z.string().max(200) });
|
|
378
|
+
const backendInputSchema = z.object({ search: z.string().max(200) });
|
|
379
|
+
const backendTaxon = z.object({
|
|
379
380
|
id: z.number().int().positive(),
|
|
380
381
|
name: z.string().max(200),
|
|
381
382
|
rank: z.string().max(40),
|
|
382
383
|
observations_count: z.number().int().nonnegative(),
|
|
383
384
|
});
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
observations_count: z.number().int().nonnegative(),
|
|
390
|
-
}),
|
|
385
|
+
const outputSchema = backendTaxon.extend({
|
|
386
|
+
source: z.literal("catalogue-service"),
|
|
387
|
+
});
|
|
388
|
+
const backendOutputSchema = z.object({
|
|
389
|
+
record: backendTaxon,
|
|
391
390
|
});
|
|
392
391
|
|
|
393
392
|
const getPeaTaxon = defineMappedTool({
|
|
394
393
|
name: "get-pea-taxon",
|
|
395
394
|
access: "public",
|
|
396
395
|
description: "Get a pea taxon from the catalogue service.",
|
|
397
|
-
inputSchema
|
|
398
|
-
outputSchema
|
|
399
|
-
backendInputSchema
|
|
400
|
-
backendOutputSchema
|
|
396
|
+
inputSchema,
|
|
397
|
+
outputSchema,
|
|
398
|
+
backendInputSchema,
|
|
399
|
+
backendOutputSchema,
|
|
401
400
|
mapInput: ({ name }) => ({ search: name }),
|
|
402
401
|
adapter: async (command, { signal }) => backend.findTaxon(command, { signal }),
|
|
403
402
|
mapOutput: ({ record }) => {
|
|
404
|
-
const data = {
|
|
405
|
-
id: record.id,
|
|
406
|
-
name: record.name,
|
|
407
|
-
rank: record.rank,
|
|
408
|
-
observations_count: record.observations_count,
|
|
409
|
-
};
|
|
403
|
+
const data = { ...record, source: "catalogue-service" as const };
|
|
410
404
|
return { text: `${data.name} has rank ${data.rank} and ${data.observations_count} recorded observations.`, data };
|
|
411
405
|
},
|
|
412
406
|
});
|