@crewhaus/streaming-tool-executor 0.1.4 → 0.1.6

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/src/load.test.ts DELETED
@@ -1,60 +0,0 @@
1
- import { describe, expect, test } from "bun:test";
2
- /**
3
- * T7 load test for streaming-tool-executor: 50 tool_use blocks arrive
4
- * on the stream, all running a fast read-only no-op tool. We confirm
5
- * completion under a time budget, no race-induced lost results, and
6
- * stable ordering of results vs. finalContent.
7
- *
8
- * Section 17 refactor: the test now feeds an AsyncIterable<StreamEvent>
9
- * instead of the old AnthropicLikeStream event emitter.
10
- */
11
- import type { StreamEvent } from "@crewhaus/adapter-anthropic";
12
- import { buildTool } from "@crewhaus/tool-builder";
13
- import { z } from "zod";
14
- import { executeStreaming } from "./index";
15
-
16
- const noop = buildTool({
17
- name: "Read",
18
- description: "noop read",
19
- inputSchema: z.object({ id: z.number() }),
20
- readOnly: true,
21
- concurrencySafe: true,
22
- execute: async (input) => `r:${input.id}`,
23
- });
24
-
25
- async function* fiftyToolUseStream(): AsyncIterable<StreamEvent> {
26
- yield { kind: "message_start" };
27
- for (let i = 0; i < 50; i++) {
28
- yield {
29
- kind: "content_block_start",
30
- index: i,
31
- block: { type: "tool_use", id: `tu_${i}`, name: "Read", input: {} },
32
- };
33
- yield {
34
- kind: "content_block_delta",
35
- index: i,
36
- delta: { type: "input_json_delta", partial_json: JSON.stringify({ id: i }) },
37
- };
38
- yield { kind: "content_block_stop", index: i };
39
- // Mimic realistic mid-stream arrival.
40
- await new Promise<void>((r) => setImmediate(r));
41
- }
42
- yield { kind: "message_delta", stopReason: "tool_use" };
43
- yield { kind: "message_stop" };
44
- }
45
-
46
- describe("streaming-tool-executor — T7 load", () => {
47
- test("50 tool_use blocks complete under 1s and preserve order", async () => {
48
- const start = Date.now();
49
- const out = await executeStreaming(fiftyToolUseStream(), {
50
- toolByName: new Map([["Read", noop]]),
51
- });
52
- const elapsed = Date.now() - start;
53
- expect(elapsed).toBeLessThan(1000);
54
- expect(out.toolResults.length).toBe(50);
55
-
56
- // Order matches finalContent block order.
57
- const expectedIds = Array.from({ length: 50 }, (_, i) => `tu_${i}`);
58
- expect(out.toolResults.map((r) => r.tool_use_id)).toEqual(expectedIds);
59
- });
60
- });