Skip to content
This repository was archived by the owner on Feb 23, 2026. It is now read-only.

Commit 9b7fbd8

Browse files
authored
Merge pull request #71 from runbasehq/dev
New property executionId on NormalizedChunks
2 parents a817fb2 + 35af6c5 commit 9b7fbd8

File tree

7 files changed

+68
-6
lines changed

7 files changed

+68
-6
lines changed

packages/mcp-check/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# mcp-testing-library
22

3+
## 0.4.8
4+
5+
### Patch Changes
6+
7+
- Add new property executionId on NormalizedChunks
8+
39
## 0.4.7
410

511
### Patch Changes

packages/mcp-check/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mcp-check",
33
"module": "dist/src/index.js",
4-
"version": "0.4.7",
4+
"version": "0.4.8",
55
"type": "module",
66
"main": "dist/src/index.js",
77
"types": "dist/src/index.d.ts",

packages/mcp-check/src/chunks/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ export type NormalizedChunkType =
244244
export interface BaseNormalizedChunk {
245245
/** The type of chunk being processed */
246246
type: NormalizedChunkType;
247+
/** Unique execution ID for this streaming session */
248+
executionId: string;
247249
/** Timestamp when the chunk was received */
248250
timestamp: number;
249251
/** Index of the chunk within the stream */

packages/mcp-check/src/providers/anthropic.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type {
1313
BetaRawContentBlockStopEvent,
1414
} from "@anthropic-ai/sdk/resources/beta.js";
1515
import type { BetaRateLimitError } from "@anthropic-ai/sdk/resources";
16+
import { nanoid } from "../utils/nanoid.js";
1617

1718
type AnthropicChunk =
1819
| BetaRawContentBlockDeltaEvent
@@ -33,8 +34,8 @@ type AnthropicChunk =
3334

3435
type OnlyLiteralStrings<T> = T extends string
3536
? string extends T
36-
? never
37-
: T
37+
? never
38+
: T
3839
: never;
3940

4041
export type AnthropicModel = OnlyLiteralStrings<Anthropic.Model>;
@@ -71,6 +72,8 @@ export class AnthropicProvider extends Provider {
7172
private content: string = "";
7273
/** Current model being used for the request */
7374
private currentModel: string = "";
75+
/** Unique execution ID for this streaming session */
76+
private executionId: string = "";
7477

7578
/**
7679
* Creates a new AnthropicProvider instance.
@@ -132,6 +135,7 @@ export class AnthropicProvider extends Provider {
132135
this.currentToolName = null;
133136
this.content = "";
134137
this.currentModel = model;
138+
this.executionId = nanoid();
135139

136140
const stream = this.client.beta.messages.stream({
137141
model: model.replace("anthropic/", "") as Anthropic.Model,
@@ -236,9 +240,12 @@ export class AnthropicProvider extends Provider {
236240
protected normalizeChunk(chunk: AnthropicChunk): NormalizedChunk | null {
237241
const timestamp = Date.now();
238242

243+
console.log(chunk);
244+
239245
if (chunk.type === "rate_limit_error") {
240246
return {
241247
provider: "anthropic",
248+
executionId: this.executionId,
242249
timestamp,
243250
index: -1,
244251
type: "error",
@@ -249,9 +256,10 @@ export class AnthropicProvider extends Provider {
249256

250257
const baseChunk: Pick<
251258
NormalizedChunkAnthropic,
252-
"provider" | "timestamp" | "index" | "originalChunk"
259+
"provider" | "executionId" | "timestamp" | "index" | "originalChunk"
253260
> = {
254261
provider: "anthropic",
262+
executionId: this.executionId,
255263
timestamp,
256264
index: chunk.index,
257265
originalChunk: chunk,

packages/mcp-check/src/providers/openai.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Provider } from "./provider.js";
44
import type { StreamResult, NormalizedChunk, NormalizedChunkOpenAI } from "../chunks/types.js";
55
import type { ProviderConfig } from "./types.js";
66
import type { McpServer } from "../index.js";
7+
import { nanoid } from "../utils/nanoid.js";
78

89
type OpenAIChunk = Responses.ResponseOutputItemDoneEvent | Responses.ResponseContentPartAddedEvent | Responses.ResponseTextDeltaEvent | Responses.ResponseMcpCallArgumentsDeltaEvent | Responses.ResponseOutputItemAddedEvent | Responses.ResponseErrorEvent;
910

@@ -50,6 +51,8 @@ export class OpenAIProvider extends Provider {
5051
private content: string = "";
5152
/** Current model being used for the request */
5253
private currentModel: string = "";
54+
/** Unique execution ID for this streaming session */
55+
private executionId: string = "";
5356

5457
/**
5558
* Creates a new OpenAIProvider instance.
@@ -110,6 +113,7 @@ export class OpenAIProvider extends Provider {
110113
this.toolCalls = {};
111114
this.content = "";
112115
this.currentModel = model;
116+
this.executionId = nanoid();
113117

114118
const response = await this.client.responses.create({
115119
model: model.replace("openai/", "") as ChatModel,
@@ -203,6 +207,7 @@ export class OpenAIProvider extends Provider {
203207
if (chunk.type === "error") {
204208
return {
205209
provider: "openai",
210+
executionId: this.executionId,
206211
timestamp,
207212
index: -1,
208213
type: "error",
@@ -211,8 +216,9 @@ export class OpenAIProvider extends Provider {
211216
};
212217
}
213218

214-
const baseChunk: Pick<NormalizedChunkOpenAI, "provider" | "timestamp" | "index" | "originalChunk"> = {
219+
const baseChunk: Pick<NormalizedChunkOpenAI, "provider" | "executionId" | "timestamp" | "index" | "originalChunk"> = {
215220
provider: "openai",
221+
executionId: this.executionId,
216222
timestamp,
217223
index: chunk.output_index,
218224
originalChunk: chunk,

packages/mcp-check/src/providers/openrouter.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type {
1414
NormalizedChunk,
1515
NormalizedChunkOpenAI,
1616
} from "../chunks/types.js";
17+
import { nanoid } from "../utils/nanoid.js";
1718

1819
/**
1920
* Type alias for OpenRouter model names.
@@ -69,6 +70,8 @@ export class OpenRouterProvider extends Provider {
6970
private content: string = "";
7071
/** Current model being used for the request */
7172
private currentModel: string = "";
73+
/** Unique execution ID for this streaming session */
74+
private executionId: string = "";
7275

7376
/**
7477
* Creates a new OpenRouterProvider instance.
@@ -135,6 +138,7 @@ export class OpenRouterProvider extends Provider {
135138
this.toolCalls = {};
136139
this.content = "";
137140
this.currentModel = model;
141+
this.executionId = nanoid();
138142

139143
const mcp = await this.connectMcp();
140144
const tools = await this.listAndConvertTools(mcp);
@@ -531,6 +535,7 @@ export class OpenRouterProvider extends Provider {
531535
if (chunk.type === "error") {
532536
return {
533537
provider: "openrouter",
538+
executionId: this.executionId,
534539
timestamp,
535540
index: -1,
536541
type: "error",
@@ -541,9 +546,10 @@ export class OpenRouterProvider extends Provider {
541546

542547
const baseChunk: Pick<
543548
NormalizedChunkOpenAI,
544-
"provider" | "timestamp" | "index" | "originalChunk"
549+
"provider" | "executionId" | "timestamp" | "index" | "originalChunk"
545550
> = {
546551
provider: "openrouter",
552+
executionId: this.executionId,
547553
timestamp,
548554
index: chunk.output_index,
549555
originalChunk: chunk,
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* @ts-self-types="./index.d.ts" */
2+
3+
// This alphabet uses `A-Za-z0-9_-` symbols.
4+
// The order of characters is optimized for better gzip and brotli compression.
5+
// References to the same file (works both for gzip and brotli):
6+
// `'use`, `andom`, and `rict'`
7+
// References to the brotli default dictionary:
8+
// `-26T`, `1983`, `40px`, `75px`, `bush`, `jack`, `mind`, `very`, and `wolf`
9+
let urlAlphabet =
10+
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
11+
12+
export let customAlphabet = (alphabet: string, defaultSize = 21) => {
13+
return (size = defaultSize) => {
14+
let id = ''
15+
// A compact alternative for `for (var i = 0; i < step; i++)`.
16+
let i = size | 0
17+
while (i--) {
18+
// `| 0` is more compact and faster than `Math.floor()`.
19+
id += alphabet[(Math.random() * alphabet.length) | 0]
20+
}
21+
return id
22+
}
23+
}
24+
25+
export let nanoid = (size = 21) => {
26+
let id = ''
27+
// A compact alternative for `for (var i = 0; i < step; i++)`.
28+
let i = size | 0
29+
while (i--) {
30+
// `| 0` is more compact and faster than `Math.floor()`.
31+
id += urlAlphabet[(Math.random() * 64) | 0]
32+
}
33+
return id
34+
}

0 commit comments

Comments
 (0)