@emseepea/create-progress-streaming-server 0.0.0 → 0.0.2
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.
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
2
|
+
import { defineStreamingTool, type CapabilityModuleFactory } from "@emseepea/server";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
export default (() => defineStreamingTool({
|
|
6
|
+
name: "roast-sample-batch",
|
|
7
|
+
access: "public",
|
|
8
|
+
description: "Run a sample coffee-roasting batch with bounded progress.",
|
|
9
|
+
inputSchema: z.object({ batch: z.literal("sample-batch") }),
|
|
10
|
+
outputSchema: z.object({
|
|
11
|
+
batch: z.literal("sample-batch"),
|
|
12
|
+
status: z.literal("complete"),
|
|
13
|
+
roastedGrams: z.literal(820),
|
|
14
|
+
stages: z.tuple([z.literal("charge"), z.literal("first crack"), z.literal("cool")]),
|
|
15
|
+
}),
|
|
16
|
+
async handler({ batch }, { reportProgress, signal }) {
|
|
17
|
+
const stages: ["charge", "first crack", "cool"] = ["charge", "first crack", "cool"];
|
|
18
|
+
for (const [index, stage] of stages.entries()) {
|
|
19
|
+
await reportProgress({ progress: index + 1, total: stages.length, message: stage });
|
|
20
|
+
await delay(150, undefined, { signal });
|
|
21
|
+
}
|
|
22
|
+
const data = { batch, status: "complete" as const, roastedGrams: 820 as const, stages };
|
|
23
|
+
return { text: `${batch} completed at 820 roasted grams`, data };
|
|
24
|
+
},
|
|
25
|
+
})) satisfies CapabilityModuleFactory;
|
|
@@ -1,34 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createEmseepea, defineStreamingTool, serveEmseepea } from "@emseepea/server";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
|
|
5
|
-
const roastBatch = defineStreamingTool({
|
|
6
|
-
name: "roast-sample-batch",
|
|
7
|
-
access: "public",
|
|
8
|
-
description: "Run a sample coffee-roasting batch with bounded progress.",
|
|
9
|
-
inputSchema: z.object({ batch: z.literal("sample-batch") }),
|
|
10
|
-
outputSchema: z.object({
|
|
11
|
-
batch: z.literal("sample-batch"),
|
|
12
|
-
status: z.literal("complete"),
|
|
13
|
-
roastedGrams: z.literal(820),
|
|
14
|
-
stages: z.tuple([z.literal("charge"), z.literal("first crack"), z.literal("cool")]),
|
|
15
|
-
}),
|
|
16
|
-
async handler({ batch }, { reportProgress, signal }) {
|
|
17
|
-
const stages: ["charge", "first crack", "cool"] = ["charge", "first crack", "cool"];
|
|
18
|
-
for (const [index, stage] of stages.entries()) {
|
|
19
|
-
await reportProgress({ progress: index + 1, total: stages.length, message: stage });
|
|
20
|
-
await delay(150, undefined, { signal });
|
|
21
|
-
}
|
|
22
|
-
const data = { batch, status: "complete" as const, roastedGrams: 820 as const, stages };
|
|
23
|
-
return { text: `${batch} completed at 820 roasted grams`, data };
|
|
24
|
-
},
|
|
25
|
-
});
|
|
1
|
+
import { createEmseepea, discoverCapabilities, serveEmseepea } from "@emseepea/server";
|
|
26
2
|
|
|
27
3
|
const running = await serveEmseepea(createEmseepea({
|
|
28
4
|
name: "emseepea-streaming-progress",
|
|
29
5
|
version: "0.0.0",
|
|
30
6
|
instructions: "Use roast-sample-batch for the sample roast run.",
|
|
31
|
-
|
|
7
|
+
...await discoverCapabilities(new URL("./capabilities/", import.meta.url)),
|
|
32
8
|
}), { port: Number.parseInt(process.env.PORT ?? "3000", 10) });
|
|
33
9
|
|
|
34
10
|
console.log(`Em See Pea streaming-progress example listening at ${running.url}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emseepea/create-progress-streaming-server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Create an Em See Pea server that streams tool progress.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -10,19 +10,13 @@
|
|
|
10
10
|
},
|
|
11
11
|
"homepage": "https://emseepea.github.io/emseepea/examples/",
|
|
12
12
|
"bugs": "https://github.com/emseepea/emseepea/issues",
|
|
13
|
-
"publishConfig": {
|
|
14
|
-
"access": "public",
|
|
15
|
-
"provenance": false,
|
|
16
|
-
"tag": "next"
|
|
17
|
-
},
|
|
13
|
+
"publishConfig": { "access": "public", "provenance": true, "tag": "next" },
|
|
18
14
|
"type": "module",
|
|
19
|
-
"bin": {
|
|
20
|
-
|
|
15
|
+
"bin": { "create-progress-streaming-server": "./dist/create.mjs" },
|
|
16
|
+
"files": ["dist"],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "node ../../scripts/build-initializer.mjs",
|
|
19
|
+
"prepack": "npm run build"
|
|
21
20
|
},
|
|
22
|
-
"
|
|
23
|
-
"dist"
|
|
24
|
-
],
|
|
25
|
-
"engines": {
|
|
26
|
-
"node": ">=22"
|
|
27
|
-
}
|
|
21
|
+
"engines": { "node": ">=22" }
|
|
28
22
|
}
|