@emseepea/create-progress-streaming-server 0.0.2 → 0.0.4

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 CHANGED
@@ -1,22 +1,65 @@
1
1
  # `@emseepea/create-progress-streaming-server`
2
2
 
3
- Create a private, standalone Em See Pea project whose tool streams progress.
4
- The package builds its starter from the maintained
5
- [progress streaming example](https://github.com/emseepea/emseepea/tree/main/examples/streaming-progress).
3
+ This directory is both the maintained example and its public npm initializer.
6
4
 
7
- ## Create the Project
5
+ ## Use This Template
8
6
 
9
- This initializer is queued for the next pre-alpha release and is not yet
10
- available from npm.
7
+ Use this template for a tool that reports bounded progress while its HTTP call
8
+ remains open. Choose the [tool server](../tool-server/README.md) when the result
9
+ can return promptly. This template does not add replay, reconnectable sessions,
10
+ or subscriptions. [Compare all eight templates](https://emseepea.github.io/emseepea/examples/).
11
+
12
+ ## Create a Project
11
13
 
12
14
  ```sh
13
- npm init @emseepea/progress-streaming-server@next -- my-server
15
+ npm init @emseepea/progress-streaming-server -- my-server
14
16
  ```
15
17
 
18
+ <!-- generated-project-readme -->
19
+
20
+ ## Streaming Progress Example
21
+
22
+ Choose this example when a tool takes long enough that people benefit from
23
+ seeing progress before the final answer.
24
+
25
+ The public tool reports progress during its request. A client can ask for
26
+ server-sent events (SSE), which carry progress over the same `POST` request.
27
+ Without that request, the tool returns one JSON response when it finishes.
28
+
29
+ ## Run
30
+
31
+ From this directory:
32
+
16
33
  ```sh
17
- cd my-server
18
34
  npm install
19
- npm test
20
- npm run lint
35
+ npm run build
21
36
  npm start
22
37
  ```
38
+
39
+ The server listens on `http://127.0.0.1:3000/mcp` by default. Set `PORT` to
40
+ choose another port. This example starts locally and does not configure a proxy.
41
+
42
+ To adapt it for a public server, see
43
+ [Use Progress Behind a Proxy](https://github.com/emseepea/emseepea/blob/main/packages/framework/README.md#use-progress-behind-a-proxy).
44
+ It does not add saved sessions, replay, subscriptions, or recovery after
45
+ reconnecting.
46
+
47
+ ## Check This Example
48
+
49
+ [Ordinary tests](test/) live in `test/`.
50
+ The [AI tool-choice and understanding test](eval/meaning.test.mjs) lives separately in `eval/`.
51
+ The commands below run each suite independently.
52
+
53
+ Run its build and progress-stream checks:
54
+
55
+ ```sh
56
+ npm test
57
+ ```
58
+
59
+ Check that Claude chooses the germination tool and keeps progress separate from the result:
60
+
61
+ ```sh
62
+ npm run test:llm
63
+ ```
64
+
65
+ If Claude is not already signed in, run `claude auth login` first.
@@ -22,9 +22,8 @@ choose another port. This example starts locally and does not configure a proxy.
22
22
 
23
23
  To adapt it for a public server, see
24
24
  [Use Progress Behind a Proxy](https://github.com/emseepea/emseepea/blob/main/packages/framework/README.md#use-progress-behind-a-proxy).
25
- That option is available in the current source, not yet in a published npm
26
- release. It does not add saved sessions, replay, subscriptions, or recovery
27
- after reconnecting.
25
+ It does not add saved sessions, replay, subscriptions, or recovery after
26
+ reconnecting.
28
27
 
29
28
  ## Check This Example
30
29
 
@@ -38,7 +37,7 @@ Run its build and progress-stream checks:
38
37
  npm test
39
38
  ```
40
39
 
41
- Check that Claude chooses the roast tool and keeps progress separate from the result:
40
+ Check that Claude chooses the germination tool and keeps progress separate from the result:
42
41
 
43
42
  ```sh
44
43
  npm run test:llm
@@ -0,0 +1,24 @@
1
+ import { toolSelectionTest } from "@emseepea/testing/semantic";
2
+
3
+ toolSelectionTest("Progress stages remain distinct from the final germination result", {
4
+ server: new URL("../dist/server.js", import.meta.url),
5
+ question:
6
+ "Run the sample-tray pea germination trial. Name the tray, list the progress " +
7
+ "stages, and report the final status and germination result. Keep progress and the completed result " +
8
+ "distinct.",
9
+ criticalFacts: [
10
+ "sample-tray",
11
+ "soak",
12
+ "sow",
13
+ "sprout",
14
+ "complete",
15
+ "8",
16
+ "10"
17
+ ],
18
+ criteria:
19
+ "The answer identifies soak, sow, and sprout as progress stages, then " +
20
+ "separately reports the completed final result of 8 out of 10 germinated seeds " +
21
+ "for sample-tray. It does not treat an intermediate progress stage as the final " +
22
+ "result.",
23
+ expectedTools: ["run-germination-trial"],
24
+ });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "emseepea-starter",
3
3
  "version": "0.0.0",
4
- "private": true,
4
+ "description": "Create an Em See Pea server that streams tool progress.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "scripts": {
@@ -13,17 +13,18 @@
13
13
  "test:llm:built": "emseepea-test eval",
14
14
  "lint": "oxlint src test eval"
15
15
  },
16
- "dependencies": {
17
- "@emseepea/server": "0.1.0",
18
- "zod": "4.4.3"
19
- },
20
16
  "devDependencies": {
21
- "@emseepea/testing": "0.2.1",
17
+ "@emseepea/testing": "0.2.2",
22
18
  "@types/node": "24.13.3",
23
19
  "typescript": "6.0.3",
24
20
  "oxlint": "1.80.0"
25
21
  },
26
22
  "engines": {
27
23
  "node": ">=22"
24
+ },
25
+ "private": true,
26
+ "dependencies": {
27
+ "@emseepea/server": "0.2.2",
28
+ "zod": "4.4.3"
28
29
  }
29
30
  }
@@ -0,0 +1,26 @@
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: "run-germination-trial",
7
+ access: "public",
8
+ description: "Run a sample pea germination trial with bounded progress.",
9
+ inputSchema: z.object({ tray: z.literal("sample-tray") }),
10
+ outputSchema: z.object({
11
+ tray: z.literal("sample-tray"),
12
+ status: z.literal("complete"),
13
+ germinatedSeeds: z.literal(8),
14
+ totalSeeds: z.literal(10),
15
+ stages: z.tuple([z.literal("soak"), z.literal("sow"), z.literal("sprout")]),
16
+ }),
17
+ async handler({ tray }, { reportProgress, signal }) {
18
+ const stages: ["soak", "sow", "sprout"] = ["soak", "sow", "sprout"];
19
+ for (const [index, stage] of stages.entries()) {
20
+ await reportProgress({ progress: index + 1, total: stages.length, message: stage });
21
+ await delay(150, undefined, { signal });
22
+ }
23
+ const data = { tray, status: "complete" as const, germinatedSeeds: 8 as const, totalSeeds: 10 as const, stages };
24
+ return { text: `${tray} completed with 8 of 10 pea seeds germinated`, data };
25
+ },
26
+ })) satisfies CapabilityModuleFactory;
@@ -1,13 +1,13 @@
1
1
  import { createEmseepea, discoverCapabilities, serveEmseepea } from "@emseepea/server";
2
2
 
3
3
  const running = await serveEmseepea(createEmseepea({
4
- name: "emseepea-streaming-progress",
4
+ name: "emseepea-progress-streaming-server",
5
5
  version: "0.0.0",
6
- instructions: "Use roast-sample-batch for the sample roast run.",
6
+ instructions: "Use run-germination-trial for the sample pea germination trial.",
7
7
  ...await discoverCapabilities(new URL("./capabilities/", import.meta.url)),
8
8
  }), { port: Number.parseInt(process.env.PORT ?? "3000", 10) });
9
9
 
10
- console.log(`Em See Pea streaming-progress example listening at ${running.url}`);
10
+ console.log(`Em See Pea progress-streaming-server example listening at ${running.url}`);
11
11
 
12
12
  async function shutdown(): Promise<void> {
13
13
  await running.close();
@@ -3,20 +3,21 @@ import test from "node:test";
3
3
 
4
4
  import { startMcpServer } from "@emseepea/testing";
5
5
 
6
- test("reports bounded progress before returning the final roast result", async (t) => {
6
+ test("reports bounded progress before returning the final germination result", async (t) => {
7
7
  const running = await startMcpServer(t, new URL("../dist/server.js", import.meta.url));
8
8
  const client = await running.connect();
9
9
  const progress = [];
10
10
  const result = await client.callTool(
11
- { name: "roast-sample-batch", arguments: { batch: "sample-batch" } },
11
+ { name: "run-germination-trial", arguments: { tray: "sample-tray" } },
12
12
  { onprogress: (update) => progress.push(update) },
13
13
  );
14
14
 
15
- assert.deepEqual(progress.map(({ message }) => message), ["charge", "first crack", "cool"]);
15
+ assert.deepEqual(progress.map(({ message }) => message), ["soak", "sow", "sprout"]);
16
16
  assert.deepEqual(result.structuredContent, {
17
- batch: "sample-batch",
17
+ tray: "sample-tray",
18
18
  status: "complete",
19
- roastedGrams: 820,
20
- stages: ["charge", "first crack", "cool"],
19
+ germinatedSeeds: 8,
20
+ totalSeeds: 10,
21
+ stages: ["soak", "sow", "sprout"],
21
22
  });
22
23
  });
package/package.json CHANGED
@@ -1,22 +1,37 @@
1
1
  {
2
2
  "name": "@emseepea/create-progress-streaming-server",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "Create an Em See Pea server that streams tool progress.",
5
5
  "license": "MIT",
6
- "repository": {
7
- "type": "git",
8
- "url": "git+https://github.com/emseepea/emseepea.git",
9
- "directory": "packages/create-progress-streaming-server"
10
- },
11
- "homepage": "https://emseepea.github.io/emseepea/examples/",
12
- "bugs": "https://github.com/emseepea/emseepea/issues",
13
- "publishConfig": { "access": "public", "provenance": true, "tag": "next" },
14
6
  "type": "module",
15
- "bin": { "create-progress-streaming-server": "./dist/create.mjs" },
16
- "files": ["dist"],
7
+ "starterDependencies": ["@emseepea/server", "zod"],
17
8
  "scripts": {
18
- "build": "node ../../scripts/build-initializer.mjs",
19
- "prepack": "npm run build"
9
+ "build": "npm run build:example && npm run build:initializer",
10
+ "build:example": "tsc -p tsconfig.json",
11
+ "build:initializer": "node ../../scripts/build-initializer.mjs",
12
+ "start": "node dist/server.js",
13
+ "test": "npm run build && npm run test:built",
14
+ "test:built": "node --test test/*.test.mjs",
15
+ "test:llm": "npm run build && npm run test:llm:built",
16
+ "test:llm:built": "emseepea-test eval",
17
+ "lint": "oxlint src test eval",
18
+ "prepack": "npm run build:initializer"
19
+ },
20
+ "devDependencies": {
21
+ "@emseepea/server": "0.2.2",
22
+ "zod": "4.4.3",
23
+ "@emseepea/testing": "0.2.2",
24
+ "@types/node": "24.13.3",
25
+ "typescript": "6.0.3",
26
+ "oxlint": "1.80.0"
20
27
  },
21
- "engines": { "node": ">=22" }
28
+ "engines": {
29
+ "node": ">=22"
30
+ },
31
+ "repository": { "type": "git", "url": "git+https://github.com/emseepea/emseepea.git", "directory": "examples/progress-streaming-server" },
32
+ "homepage": "https://emseepea.github.io/emseepea/examples/",
33
+ "bugs": "https://github.com/emseepea/emseepea/issues",
34
+ "publishConfig": { "access": "public", "provenance": true },
35
+ "bin": { "create-progress-streaming-server": "./initializer-dist/create.mjs" },
36
+ "files": ["initializer-dist"]
22
37
  }
@@ -1,23 +0,0 @@
1
- import { toolSelectionTest } from "@emseepea/testing/semantic";
2
-
3
- toolSelectionTest("Progress stages remain distinct from the final roast result", {
4
- server: new URL("../dist/server.js", import.meta.url),
5
- question:
6
- "Run sample-batch. Name the batch, list the progress stages, and report the " +
7
- "final status and final roasted mass. Keep progress and the completed result " +
8
- "distinct.",
9
- criticalFacts: [
10
- "sample-batch",
11
- "charge",
12
- "first crack",
13
- "cool",
14
- "complete",
15
- "820"
16
- ],
17
- criteria:
18
- "The answer identifies charge, first crack, and cool as progress stages, then " +
19
- "separately reports the completed final result of 820 roasted grams for " +
20
- "sample-batch. It does not treat an intermediate progress stage as the final " +
21
- "result.",
22
- expectedTools: ["roast-sample-batch"],
23
- });
@@ -1,25 +0,0 @@
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;
File without changes
File without changes