@alpic80/rivet-core 1.24.2-aidon.1 → 1.24.2-aidon.11

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.
@@ -6244,6 +6244,7 @@ var SubGraphNodeImpl = class extends NodeImpl {
6244
6244
  }
6245
6245
  return outputs;
6246
6246
  } catch (err) {
6247
+ context.trace(`Error Processing subgraph: ${getError(err).message}`);
6247
6248
  if (!this.data.useErrorOutput) {
6248
6249
  throw err;
6249
6250
  }
@@ -10546,8 +10547,9 @@ var HttpCallNodeImpl = class extends NodeImpl {
10546
10547
  ];
10547
10548
  }
10548
10549
  getBody() {
10550
+ var _a;
10549
10551
  return import_ts_dedent.dedent`
10550
- ${this.data.useMethodInput ? "(Method Using Input)" : this.data.method} ${this.data.useUrlInput ? "(URL Using Input)" : this.data.url} ${this.data.useHeadersInput ? "\nHeaders: (Using Input)" : this.data.headers.trim() ? `
10552
+ ${this.data.useMethodInput ? "(Method Using Input)" : this.data.method} ${this.data.useUrlInput ? "(URL Using Input)" : this.data.url} ${this.data.useHeadersInput ? "\nHeaders: (Using Input)" : ((_a = this.data.headers) == null ? void 0 : _a.trim()) ? `
10551
10553
  Headers: ${this.data.headers}` : ""}${this.data.useBodyInput ? "\nBody: (Using Input)" : this.data.body.trim() ? `
10552
10554
  Body: ${this.data.body}` : ""}${this.data.errorOnNon200 ? "\nError on non-200" : ""}
10553
10555
  `;
@@ -10563,7 +10565,7 @@ Body: ${this.data.body}` : ""}${this.data.errorOnNon200 ? "\nError on non-200" :
10563
10565
  };
10564
10566
  }
10565
10567
  async process(inputs, context) {
10566
- var _a;
10568
+ var _a, _b;
10567
10569
  const method = getInputOrData(this.data, inputs, "method", "string");
10568
10570
  const url = getInputOrData(this.data, inputs, "url", "string");
10569
10571
  try {
@@ -10581,7 +10583,7 @@ Body: ${this.data.body}` : ""}${this.data.errorOnNon200 ? "\nError on non-200" :
10581
10583
  } else {
10582
10584
  headers = coerceType(headersInput, "object");
10583
10585
  }
10584
- } else if (this.data.headers.trim()) {
10586
+ } else if ((_a = this.data.headers) == null ? void 0 : _a.trim()) {
10585
10587
  headers = JSON.parse(this.data.headers);
10586
10588
  }
10587
10589
  let body;
@@ -10627,7 +10629,7 @@ Body: ${this.data.body}` : ""}${this.data.errorOnNon200 ? "\nError on non-200" :
10627
10629
  type: "string",
10628
10630
  value: responseText
10629
10631
  };
10630
- if ((_a = response.headers.get("content-type")) == null ? void 0 : _a.includes("application/json")) {
10632
+ if ((_b = response.headers.get("content-type")) == null ? void 0 : _b.includes("application/json")) {
10631
10633
  const jsonData = JSON.parse(responseText);
10632
10634
  output["json"] = {
10633
10635
  type: "object",
@@ -13874,6 +13876,13 @@ var getMCPBaseInputs = (data) => {
13874
13876
  description: "The endpoint URL for the MCP server"
13875
13877
  });
13876
13878
  }
13879
+ if (data.transportType === "http" && data.useHeadersInput) {
13880
+ inputs.push({
13881
+ dataType: "object",
13882
+ id: "headers",
13883
+ title: "Headers"
13884
+ });
13885
+ }
13877
13886
  return inputs;
13878
13887
  };
13879
13888
 
@@ -13894,6 +13903,7 @@ var MCPDiscoveryNodeImpl = class extends NodeImpl {
13894
13903
  version: "1.0.0",
13895
13904
  transportType: "stdio",
13896
13905
  serverUrl: "http://localhost:8080/mcp",
13906
+ headers: "",
13897
13907
  serverId: "",
13898
13908
  useNameInput: false,
13899
13909
  useVersionInput: false,
@@ -13966,13 +13976,22 @@ var MCPDiscoveryNodeImpl = class extends NodeImpl {
13966
13976
  }
13967
13977
  ];
13968
13978
  if (this.data.transportType === "http") {
13969
- editors.push({
13970
- type: "string",
13971
- label: "Server URL",
13972
- dataKey: "serverUrl",
13973
- useInputToggleDataKey: "useServerUrlInput",
13974
- helperMessage: "The base URL endpoint for the MCP server with `/mcp`"
13975
- });
13979
+ editors.push(
13980
+ {
13981
+ type: "string",
13982
+ label: "Server URL",
13983
+ dataKey: "serverUrl",
13984
+ useInputToggleDataKey: "useServerUrlInput",
13985
+ helperMessage: "The base URL endpoint for the MCP server with `/mcp`"
13986
+ },
13987
+ {
13988
+ type: "code",
13989
+ label: "Headers",
13990
+ dataKey: "headers",
13991
+ useInputToggleDataKey: "useHeadersInput",
13992
+ language: "json"
13993
+ }
13994
+ );
13976
13995
  } else if (this.data.transportType === "stdio") {
13977
13996
  const serverOptions = await getServerOptions(context);
13978
13997
  editors.push({
@@ -13986,15 +14005,19 @@ var MCPDiscoveryNodeImpl = class extends NodeImpl {
13986
14005
  return editors;
13987
14006
  }
13988
14007
  getBody(context) {
14008
+ var _a;
13989
14009
  let base;
14010
+ let headers = "";
13990
14011
  if (this.data.transportType === "http") {
13991
14012
  base = this.data.useServerUrlInput ? "(Using Server URL Input)" : this.data.serverUrl;
14013
+ headers = this.data.useHeadersInput ? "\nHeaders: (Using Input)" : ((_a = this.data.headers) == null ? void 0 : _a.trim()) ? `
14014
+ Headers: ${this.data.headers}` : "";
13992
14015
  } else {
13993
14016
  base = `Server ID: ${this.data.serverId || "(None)"}`;
13994
14017
  }
13995
14018
  const namePart = `Name: ${this.data.name}`;
13996
14019
  const versionPart = `Version: ${this.data.version}`;
13997
- const parts = [namePart, versionPart, base];
14020
+ const parts = [namePart, versionPart, base, headers];
13998
14021
  if (context.executor !== "nodejs") {
13999
14022
  parts.push("(Requires Node Executor)");
14000
14023
  }
@@ -14011,6 +14034,7 @@ var MCPDiscoveryNodeImpl = class extends NodeImpl {
14011
14034
  };
14012
14035
  }
14013
14036
  async process(inputs, context) {
14037
+ var _a;
14014
14038
  const name = getInputOrData(this.data, inputs, "name", "string");
14015
14039
  const version = getInputOrData(this.data, inputs, "version", "string");
14016
14040
  const transportType = getInputOrData(this.data, inputs, "transportType", "string");
@@ -14031,8 +14055,21 @@ var MCPDiscoveryNodeImpl = class extends NodeImpl {
14031
14055
  "Include /mcp in your server URL. For example: http://localhost:8080/mcp"
14032
14056
  );
14033
14057
  }
14034
- tools = await context.mcpProvider.getHTTPTools({ name, version }, serverUrl);
14035
- prompts = await context.mcpProvider.getHTTPrompts({ name, version }, serverUrl);
14058
+ let headers;
14059
+ if (this.data.useHeadersInput) {
14060
+ const headersInput = inputs["headers"];
14061
+ if ((headersInput == null ? void 0 : headersInput.type) === "string") {
14062
+ headers = JSON.parse(headersInput.value);
14063
+ } else if ((headersInput == null ? void 0 : headersInput.type) === "object") {
14064
+ headers = headersInput.value;
14065
+ } else {
14066
+ headers = coerceType(headersInput, "object");
14067
+ }
14068
+ } else if ((_a = this.data.headers) == null ? void 0 : _a.trim()) {
14069
+ headers = JSON.parse(this.data.headers);
14070
+ }
14071
+ tools = await context.mcpProvider.getHTTPTools({ name, version }, serverUrl, headers);
14072
+ prompts = await context.mcpProvider.getHTTPrompts({ name, version }, serverUrl, headers);
14036
14073
  } else if (transportType === "stdio") {
14037
14074
  const serverId = this.data.serverId ?? "";
14038
14075
  const mcpConfig = await loadMCPConfiguration(context);
@@ -14099,6 +14136,7 @@ var MCPToolCallNodeImpl = class extends NodeImpl {
14099
14136
  version: "1.0.0",
14100
14137
  transportType: "stdio",
14101
14138
  serverUrl: "http://localhost:8080/mcp",
14139
+ headers: "",
14102
14140
  serverId: "",
14103
14141
  toolName: "",
14104
14142
  toolArguments: import_ts_dedent69.dedent`
@@ -14200,17 +14238,26 @@ var MCPToolCallNodeImpl = class extends NodeImpl {
14200
14238
  label: "Tool ID",
14201
14239
  dataKey: "toolCallId",
14202
14240
  useInputToggleDataKey: "useToolCallIdInput",
14203
- helperMessage: "The name for the MCP Tool Call"
14241
+ helperMessage: "The ID associated with the tool call"
14204
14242
  }
14205
14243
  ];
14206
14244
  if (this.data.transportType === "http") {
14207
- editors.push({
14208
- type: "string",
14209
- label: "Server URL",
14210
- dataKey: "serverUrl",
14211
- useInputToggleDataKey: "useServerUrlInput",
14212
- helperMessage: "The endpoint URL for the MCP server to connect"
14213
- });
14245
+ editors.push(
14246
+ {
14247
+ type: "string",
14248
+ label: "Server URL",
14249
+ dataKey: "serverUrl",
14250
+ useInputToggleDataKey: "useServerUrlInput",
14251
+ helperMessage: "The base URL endpoint for the MCP server with `/mcp`"
14252
+ },
14253
+ {
14254
+ type: "code",
14255
+ label: "Headers",
14256
+ dataKey: "headers",
14257
+ useInputToggleDataKey: "useHeadersInput",
14258
+ language: "json"
14259
+ }
14260
+ );
14214
14261
  } else if (this.data.transportType === "stdio") {
14215
14262
  const serverOptions = await getServerOptions(context);
14216
14263
  editors.push({
@@ -14224,15 +14271,19 @@ var MCPToolCallNodeImpl = class extends NodeImpl {
14224
14271
  return editors;
14225
14272
  }
14226
14273
  getBody(context) {
14274
+ var _a;
14227
14275
  let base;
14276
+ let headers = "";
14228
14277
  if (this.data.transportType === "http") {
14229
14278
  base = this.data.useServerUrlInput ? "(Using Server URL Input)" : this.data.serverUrl;
14279
+ headers = this.data.useHeadersInput ? "\nHeaders: (Using Input)" : ((_a = this.data.headers) == null ? void 0 : _a.trim()) ? `
14280
+ Headers: ${this.data.headers}` : "";
14230
14281
  } else {
14231
14282
  base = `Server ID: ${this.data.serverId || "(None)"}`;
14232
14283
  }
14233
14284
  const namePart = `Name: ${this.data.name}`;
14234
14285
  const versionPart = `Version: ${this.data.version}`;
14235
- const parts = [namePart, versionPart, base];
14286
+ const parts = [namePart, versionPart, base, headers];
14236
14287
  if (context.executor !== "nodejs") {
14237
14288
  parts.push("(Requires Node Executor)");
14238
14289
  }
@@ -14249,6 +14300,7 @@ var MCPToolCallNodeImpl = class extends NodeImpl {
14249
14300
  };
14250
14301
  }
14251
14302
  async process(inputs, context) {
14303
+ var _a;
14252
14304
  const name = getInputOrData(this.data, inputs, "name", "string");
14253
14305
  const version = getInputOrData(this.data, inputs, "version", "string");
14254
14306
  const toolName = getInputOrData(this.data, inputs, "toolName", "string");
@@ -14293,7 +14345,20 @@ var MCPToolCallNodeImpl = class extends NodeImpl {
14293
14345
  "Include /mcp in your server URL. For example: http://localhost:8080/mcp"
14294
14346
  );
14295
14347
  }
14296
- toolResponse = await context.mcpProvider.httpToolCall({ name, version }, serverUrl, toolCall);
14348
+ let headers;
14349
+ if (this.data.useHeadersInput) {
14350
+ const headersInput = inputs["headers"];
14351
+ if ((headersInput == null ? void 0 : headersInput.type) === "string") {
14352
+ headers = JSON.parse(headersInput.value);
14353
+ } else if ((headersInput == null ? void 0 : headersInput.type) === "object") {
14354
+ headers = headersInput.value;
14355
+ } else {
14356
+ headers = coerceType(headersInput, "object");
14357
+ }
14358
+ } else if ((_a = this.data.headers) == null ? void 0 : _a.trim()) {
14359
+ headers = JSON.parse(this.data.headers);
14360
+ }
14361
+ toolResponse = await context.mcpProvider.httpToolCall({ name, version }, serverUrl, headers, toolCall);
14297
14362
  } else if (transportType === "stdio") {
14298
14363
  const serverId = this.data.serverId ?? "";
14299
14364
  const mcpConfig = await loadMCPConfiguration(context);
@@ -14346,6 +14411,7 @@ var MCPGetPromptNodeImpl = class extends NodeImpl {
14346
14411
  version: "1.0.0",
14347
14412
  transportType: "stdio",
14348
14413
  serverUrl: "http://localhost:8080/mcp",
14414
+ headers: "",
14349
14415
  serverId: "",
14350
14416
  promptName: "",
14351
14417
  promptArguments: import_ts_dedent.dedent`
@@ -14430,13 +14496,22 @@ var MCPGetPromptNodeImpl = class extends NodeImpl {
14430
14496
  }
14431
14497
  ];
14432
14498
  if (this.data.transportType === "http") {
14433
- editors.push({
14434
- type: "string",
14435
- label: "Server URL",
14436
- dataKey: "serverUrl",
14437
- useInputToggleDataKey: "useServerUrlInput",
14438
- helperMessage: "The endpoint URL for the MCP server to connect"
14439
- });
14499
+ editors.push(
14500
+ {
14501
+ type: "string",
14502
+ label: "Server URL",
14503
+ dataKey: "serverUrl",
14504
+ useInputToggleDataKey: "useServerUrlInput",
14505
+ helperMessage: "The base URL endpoint for the MCP server with `/mcp`"
14506
+ },
14507
+ {
14508
+ type: "code",
14509
+ label: "Headers",
14510
+ dataKey: "headers",
14511
+ useInputToggleDataKey: "useHeadersInput",
14512
+ language: "json"
14513
+ }
14514
+ );
14440
14515
  } else if (this.data.transportType === "stdio") {
14441
14516
  const serverOptions = await getServerOptions(context);
14442
14517
  editors.push({
@@ -14450,15 +14525,19 @@ var MCPGetPromptNodeImpl = class extends NodeImpl {
14450
14525
  return editors;
14451
14526
  }
14452
14527
  getBody(context) {
14528
+ var _a;
14453
14529
  let base;
14530
+ let headers = "";
14454
14531
  if (this.data.transportType === "http") {
14455
14532
  base = this.data.useServerUrlInput ? "(Using Server URL Input)" : this.data.serverUrl;
14533
+ headers = this.data.useHeadersInput ? "\nHeaders: (Using Input)" : ((_a = this.data.headers) == null ? void 0 : _a.trim()) ? `
14534
+ Headers: ${this.data.headers}` : "";
14456
14535
  } else {
14457
14536
  base = `Server ID: ${this.data.serverId || "(None)"}`;
14458
14537
  }
14459
14538
  const namePart = `Name: ${this.data.name}`;
14460
14539
  const versionPart = `Version: ${this.data.version}`;
14461
- const parts = [namePart, versionPart, base];
14540
+ const parts = [namePart, versionPart, base, headers];
14462
14541
  if (context.executor !== "nodejs") {
14463
14542
  parts.push("(Requires Node Executor)");
14464
14543
  }
@@ -14475,6 +14554,7 @@ var MCPGetPromptNodeImpl = class extends NodeImpl {
14475
14554
  };
14476
14555
  }
14477
14556
  async process(inputs, context) {
14557
+ var _a;
14478
14558
  const name = getInputOrData(this.data, inputs, "name", "string");
14479
14559
  const version = getInputOrData(this.data, inputs, "version", "string");
14480
14560
  const promptName = getInputOrData(this.data, inputs, "promptName", "string");
@@ -14518,7 +14598,20 @@ var MCPGetPromptNodeImpl = class extends NodeImpl {
14518
14598
  "Include /mcp in your server URL. For example: http://localhost:8080/mcp"
14519
14599
  );
14520
14600
  }
14521
- getPromptResponse = await context.mcpProvider.getHTTPrompt({ name, version }, serverUrl, getPromptRequest);
14601
+ let headers;
14602
+ if (this.data.useHeadersInput) {
14603
+ const headersInput = inputs["headers"];
14604
+ if ((headersInput == null ? void 0 : headersInput.type) === "string") {
14605
+ headers = JSON.parse(headersInput.value);
14606
+ } else if ((headersInput == null ? void 0 : headersInput.type) === "object") {
14607
+ headers = headersInput.value;
14608
+ } else {
14609
+ headers = coerceType(headersInput, "object");
14610
+ }
14611
+ } else if ((_a = this.data.headers) == null ? void 0 : _a.trim()) {
14612
+ headers = JSON.parse(this.data.headers);
14613
+ }
14614
+ getPromptResponse = await context.mcpProvider.getHTTPrompt({ name, version }, serverUrl, headers, getPromptRequest);
14522
14615
  } else if (transportType === "stdio") {
14523
14616
  const serverId = this.data.serverId ?? "";
14524
14617
  const mcpConfig = await loadMCPConfiguration(context);
@@ -15330,6 +15423,7 @@ var GraphProcessor = class _GraphProcessor {
15330
15423
  if (this.#running) {
15331
15424
  throw new Error("Cannot process graph while already processing");
15332
15425
  }
15426
+ this.#emitTraceEvent(`Process graph called. Context:${JSON.stringify(context)}, Inputs: ${JSON.stringify(inputs)}, Context Values: ${JSON.stringify(contextValues)}`);
15333
15427
  this.#initProcessState();
15334
15428
  this.#context = context;
15335
15429
  this.#graphInputs = inputs;
@@ -15339,8 +15433,11 @@ var GraphProcessor = class _GraphProcessor {
15339
15433
  this.#emitter.emit("error", { error });
15340
15434
  });
15341
15435
  }
15436
+ this.#emitTraceEvent(`Process graph calling loadProjectReferences`);
15342
15437
  await this.#loadProjectReferences();
15438
+ this.#emitTraceEvent(`Process graph called loadProjectReferences`);
15343
15439
  this.#preprocessGraph();
15440
+ this.#emitTraceEvent(`Process graph called preprocessGraph`);
15344
15441
  if (!this.#isSubProcessor) {
15345
15442
  await this.#emitter.emit("start", {
15346
15443
  contextValues: this.#contextValues,
@@ -16609,7 +16706,7 @@ var ChatAidonNodeImpl = class extends ChatNodeImpl {
16609
16706
  }
16610
16707
  return path;
16611
16708
  }
16612
- async callToolGet(parsedArgs, schemaDetail, path, data) {
16709
+ async callToolGet(schemaDetail, path, parsedArgs, data) {
16613
16710
  const queryParams = new URLSearchParams(
16614
16711
  parsedArgs.parameters
16615
16712
  ).toString();
@@ -16687,7 +16784,7 @@ var ChatAidonNodeImpl = class extends ChatNodeImpl {
16687
16784
  if (schemaDetail.requestInBody) {
16688
16785
  data = await this.callToolPost(schemaDetail, path, functionCall.arguments, data);
16689
16786
  } else {
16690
- data = await this.callToolGet(functionCall.arguments, schemaDetail, path, data);
16787
+ data = await this.callToolGet(schemaDetail, path, functionCall.arguments, data);
16691
16788
  }
16692
16789
  messages["value"].push({
16693
16790
  type: "function",
@@ -16763,6 +16860,21 @@ function chatAidonNode() {
16763
16860
  var aidonPlugin = {
16764
16861
  id: "aidon",
16765
16862
  name: "Aidon",
16863
+ configSpec: {
16864
+ aidonURL: {
16865
+ type: "string",
16866
+ label: "Aidon URL",
16867
+ description: "The URL for the Aidon application.",
16868
+ helperText: "Defaults to https://app.aidon.ai. URL for the Aidon application.",
16869
+ default: "https://app.aidon.ai"
16870
+ },
16871
+ aidonKey: {
16872
+ type: "secret",
16873
+ label: "Aidon API Key",
16874
+ description: "The API Key for the Aidon application.",
16875
+ helperText: "API Key for the Aidon application."
16876
+ }
16877
+ },
16766
16878
  register: (register) => {
16767
16879
  register(chatAidonNode());
16768
16880
  }
@@ -18928,7 +19040,7 @@ var ChatHuggingFaceNodeImpl = {
18928
19040
  const repetitionPenalty = getInputOrData(data, inputData, "repetitionPenalty", "number");
18929
19041
  const topP = getInputOrData(data, inputData, "topP", "number");
18930
19042
  const topK = getInputOrData(data, inputData, "topK", "number");
18931
- const hf = endpoint ? new import_inference.HfInferenceEndpoint(endpoint, accessToken) : new import_inference.HfInference(accessToken);
19043
+ const hf = endpoint ? new import_inference.InferenceClient(accessToken, { endpointUrl: endpoint }) : new import_inference.InferenceClient(accessToken);
18932
19044
  const generationStream = hf.textGenerationStream({
18933
19045
  inputs: prompt,
18934
19046
  model,
@@ -19126,18 +19238,21 @@ var TextToImageHuggingFaceNodeImpl = {
19126
19238
  const negativePrompt = getInputOrData(data, inputData, "negativePrompt") || void 0;
19127
19239
  const guidanceScale = getInputOrData(data, inputData, "guidanceScale", "number");
19128
19240
  const numInferenceSteps = getInputOrData(data, inputData, "numInferenceSteps", "number");
19129
- const hf = endpoint ? new import_inference2.HfInferenceEndpoint(endpoint, accessToken) : new import_inference2.HfInference(accessToken);
19130
- const image = await hf.textToImage({
19131
- inputs: prompt,
19132
- model,
19133
- parameters: {
19134
- width,
19135
- height,
19136
- negative_prompt: negativePrompt,
19137
- guidance_scale: guidanceScale,
19138
- num_inference_steps: numInferenceSteps
19139
- }
19140
- });
19241
+ const hf = endpoint ? new import_inference2.InferenceClient(accessToken, { endpointUrl: endpoint }) : new import_inference2.InferenceClient(accessToken);
19242
+ const image = await hf.textToImage(
19243
+ {
19244
+ inputs: prompt,
19245
+ model,
19246
+ parameters: {
19247
+ width,
19248
+ height,
19249
+ negative_prompt: negativePrompt,
19250
+ guidance_scale: guidanceScale,
19251
+ num_inference_steps: numInferenceSteps
19252
+ }
19253
+ },
19254
+ { outputType: "blob" }
19255
+ );
19141
19256
  return {
19142
19257
  ["output"]: {
19143
19258
  type: "image",
@@ -22971,11 +23086,13 @@ function nodeMatches(spec, event) {
22971
23086
  async function* getProcessorEvents(processor, spec) {
22972
23087
  const previousIndexes = /* @__PURE__ */ new Map();
22973
23088
  const usages = [];
23089
+ let hasDelta = false;
22974
23090
  for await (const event of processor.events()) {
22975
23091
  if (event.type === "partialOutput") {
22976
23092
  if (spec.partialOutputs === true || nodeMatches(spec.partialOutputs, event)) {
22977
23093
  const currentOutput = coerceType(event.outputs["response"], "string");
22978
23094
  const delta = currentOutput.slice(previousIndexes.get(event.node.id) ?? 0);
23095
+ hasDelta = true;
22979
23096
  yield {
22980
23097
  type: "partialOutput",
22981
23098
  nodeId: event.node.id,
@@ -23031,7 +23148,7 @@ async function* getProcessorEvents(processor, spec) {
23031
23148
  usages.push(usage);
23032
23149
  }
23033
23150
  }
23034
- if (spec.nodeFinish === true || nodeMatches(spec.nodeFinish, event)) {
23151
+ if ((spec.nodeFinish === true || nodeMatches(spec.nodeFinish, event)) && !(spec.removeFinalOutput && hasDelta)) {
23035
23152
  yield {
23036
23153
  type: "nodeFinish",
23037
23154
  outputs: event.outputs,
@@ -23071,10 +23188,14 @@ data: ${JSON.stringify(data)}
23071
23188
  return new ReadableStream({
23072
23189
  async start(controller) {
23073
23190
  const userEventHandler = async (eventName, data) => {
23074
- sendEvent(controller, "event", {
23075
- name: eventName,
23076
- message: coerceType(data, "string")
23077
- });
23191
+ const graphEvent = {
23192
+ type: "event",
23193
+ graphEvent: {
23194
+ name: eventName,
23195
+ message: coerceType(data, "string")
23196
+ }
23197
+ };
23198
+ sendEvent(controller, "event", graphEvent);
23078
23199
  };
23079
23200
  const streamEvents = createOnStreamUserEvents(spec.userStreamEvents, userEventHandler);
23080
23201
  if (streamEvents) {
@@ -23108,6 +23229,21 @@ function getSingleNodeStream(processor, arg) {
23108
23229
  async start(controller) {
23109
23230
  var _a;
23110
23231
  try {
23232
+ const userEventHandler = async (eventName, data) => {
23233
+ const payload = {
23234
+ name: eventName,
23235
+ message: coerceType(data, "string")
23236
+ };
23237
+ controller.enqueue(`event: ${JSON.stringify(payload)}
23238
+
23239
+ `);
23240
+ };
23241
+ const streamEvents = createOnStreamUserEvents(spec.userStreamEvents, userEventHandler);
23242
+ if (streamEvents) {
23243
+ for (const [name, fn] of Object.entries(streamEvents)) {
23244
+ processor.onUserEvent(name, fn);
23245
+ }
23246
+ }
23111
23247
  for await (const event of getProcessorEvents(processor, spec)) {
23112
23248
  if (event.type === "partialOutput") {
23113
23249
  controller.enqueue(`data: ${JSON.stringify(event.delta)}