@alpic80/rivet-core 1.24.2-aidon.1 → 1.24.2-aidon.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.
@@ -22971,11 +22971,13 @@ function nodeMatches(spec, event) {
22971
22971
  async function* getProcessorEvents(processor, spec) {
22972
22972
  const previousIndexes = /* @__PURE__ */ new Map();
22973
22973
  const usages = [];
22974
+ let hasDelta = false;
22974
22975
  for await (const event of processor.events()) {
22975
22976
  if (event.type === "partialOutput") {
22976
22977
  if (spec.partialOutputs === true || nodeMatches(spec.partialOutputs, event)) {
22977
22978
  const currentOutput = coerceType(event.outputs["response"], "string");
22978
22979
  const delta = currentOutput.slice(previousIndexes.get(event.node.id) ?? 0);
22980
+ hasDelta = true;
22979
22981
  yield {
22980
22982
  type: "partialOutput",
22981
22983
  nodeId: event.node.id,
@@ -23031,7 +23033,7 @@ async function* getProcessorEvents(processor, spec) {
23031
23033
  usages.push(usage);
23032
23034
  }
23033
23035
  }
23034
- if (spec.nodeFinish === true || nodeMatches(spec.nodeFinish, event)) {
23036
+ if ((spec.nodeFinish === true || nodeMatches(spec.nodeFinish, event)) && !(spec.removeFinalOutput && hasDelta)) {
23035
23037
  yield {
23036
23038
  type: "nodeFinish",
23037
23039
  outputs: event.outputs,
@@ -23108,6 +23110,21 @@ function getSingleNodeStream(processor, arg) {
23108
23110
  async start(controller) {
23109
23111
  var _a;
23110
23112
  try {
23113
+ const userEventHandler = async (eventName, data) => {
23114
+ const payload = {
23115
+ name: eventName,
23116
+ message: coerceType(data, "string")
23117
+ };
23118
+ controller.enqueue(`event: ${JSON.stringify(payload)}
23119
+
23120
+ `);
23121
+ };
23122
+ const streamEvents = createOnStreamUserEvents(spec.userStreamEvents, userEventHandler);
23123
+ if (streamEvents) {
23124
+ for (const [name, fn] of Object.entries(streamEvents)) {
23125
+ processor.onUserEvent(name, fn);
23126
+ }
23127
+ }
23111
23128
  for await (const event of getProcessorEvents(processor, spec)) {
23112
23129
  if (event.type === "partialOutput") {
23113
23130
  controller.enqueue(`data: ${JSON.stringify(event.delta)}