@theokit/sdk 4.37.1 → 4.37.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.
@@ -3294,7 +3294,7 @@ var HISTOGRAM_NAMES = {
3294
3294
  };
3295
3295
  function safeRequire(moduleName) {
3296
3296
  try {
3297
- const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-S3WZ7NHF.cjs', document.baseURI).href)));
3297
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-W52DKZBR.cjs', document.baseURI).href)));
3298
3298
  return r(moduleName);
3299
3299
  } catch {
3300
3300
  return void 0;
@@ -3519,7 +3519,7 @@ var cachedOtel;
3519
3519
  function loadOtel() {
3520
3520
  if (cachedOtel === void 0) {
3521
3521
  try {
3522
- const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-S3WZ7NHF.cjs', document.baseURI).href)));
3522
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-W52DKZBR.cjs', document.baseURI).href)));
3523
3523
  const mod = r("@opentelemetry/api");
3524
3524
  cachedOtel = mod;
3525
3525
  } catch {
@@ -6904,6 +6904,31 @@ var HttpMcpClient = class extends BaseMcpClient {
6904
6904
  * Never overwritten by a later one: a server that re-issues mid-session would otherwise split
6905
6905
  * the session in two, and the second half would not see the first half's state.
6906
6906
  */
6907
+ /**
6908
+ * Read one JSON-RPC response, in either encoding the server may choose.
6909
+ *
6910
+ * Streamable HTTP lets the server answer a POST with `application/json` OR `text/event-stream`,
6911
+ * and the client advertises both. Reading the body with `response.json()` unconditionally is what
6912
+ * turned a working server into `Unexpected token 'e', "event: mes"... is not valid JSON` the
6913
+ * moment the Accept header started asking for SSE — measured against a real server, not imagined.
6914
+ *
6915
+ * Only the `data:` payload is JSON; `event:` / `id:` / `retry:` lines and comments are framing.
6916
+ * A single JSON-RPC reply arrives as one event, so the FIRST parseable `data:` is the answer.
6917
+ */
6918
+ async readBody(response) {
6919
+ const tipo = response.headers.get("content-type") ?? "";
6920
+ if (!tipo.includes("text/event-stream")) return await response.json();
6921
+ const texto = await response.text();
6922
+ for (const linha of texto.split(/\r?\n/)) {
6923
+ if (!linha.startsWith("data:")) continue;
6924
+ const carga = linha.slice(5).trim();
6925
+ if (carga === "") continue;
6926
+ return JSON.parse(carga);
6927
+ }
6928
+ throw new chunkMHCKWQR3_cjs.NetworkError(`MCP ${this.name} returned an event stream with no data payload`, {
6929
+ code: "mcp_http_error"
6930
+ });
6931
+ }
6907
6932
  captureSession(response) {
6908
6933
  if (this.sessionId !== void 0) return;
6909
6934
  const issued = response.headers.get("mcp-session-id");
@@ -6934,7 +6959,7 @@ var HttpMcpClient = class extends BaseMcpClient {
6934
6959
  }
6935
6960
  this.captureSession(response);
6936
6961
  try {
6937
- return await response.json();
6962
+ return await this.readBody(response);
6938
6963
  } catch (cause) {
6939
6964
  if (isAbortLike(cause)) throw mcpTimeoutError(this.name, timeoutMs);
6940
6965
  throw cause;
@@ -10480,5 +10505,5 @@ exports.generateCronId = generateCronId;
10480
10505
  exports.getPricingEntry = getPricingEntry;
10481
10506
  exports.openRouterMemoryEmbeddingProviderAdapter = openRouterMemoryEmbeddingProviderAdapter;
10482
10507
  exports.resolveApiKey = resolveApiKey;
10483
- //# sourceMappingURL=chunk-S3WZ7NHF.cjs.map
10484
- //# sourceMappingURL=chunk-S3WZ7NHF.cjs.map
10508
+ //# sourceMappingURL=chunk-W52DKZBR.cjs.map
10509
+ //# sourceMappingURL=chunk-W52DKZBR.cjs.map