@alpic80/rivet-core 1.24.0-aidon.4 → 1.24.0-aidon.5

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.
@@ -21882,13 +21882,16 @@ var dotProductSimilarity = (a, b) => {
21882
21882
  };
21883
21883
 
21884
21884
  // src/api/streaming.ts
21885
+ function nodeMatches(spec, event) {
21886
+ var _a;
21887
+ return (spec == null ? void 0 : spec.includes(event.node.id)) || (spec == null ? void 0 : spec.includes((_a = event.node.data) == null ? void 0 : _a.id)) || (spec == null ? void 0 : spec.includes(event.node.title));
21888
+ }
21885
21889
  async function* getProcessorEvents(processor, spec) {
21886
- var _a, _b, _c, _d, _e, _f;
21887
21890
  const previousIndexes = /* @__PURE__ */ new Map();
21888
21891
  const usages = [];
21889
21892
  for await (const event of processor.events()) {
21890
21893
  if (event.type === "partialOutput") {
21891
- if (spec.partialOutputs === true || ((_a = spec.partialOutputs) == null ? void 0 : _a.includes(event.node.id)) || ((_b = spec.partialOutputs) == null ? void 0 : _b.includes(event.node.title))) {
21894
+ if (spec.partialOutputs === true || nodeMatches(spec.partialOutputs, event)) {
21892
21895
  const currentOutput = coerceType(event.outputs["response"], "string");
21893
21896
  const delta = currentOutput.slice(previousIndexes.get(event.node.id) ?? 0);
21894
21897
  yield {
@@ -21931,7 +21934,7 @@ async function* getProcessorEvents(processor, spec) {
21931
21934
  };
21932
21935
  }
21933
21936
  } else if (event.type === "nodeStart") {
21934
- if (spec.nodeStart === true || ((_c = spec.nodeStart) == null ? void 0 : _c.includes(event.node.id)) || ((_d = spec.nodeStart) == null ? void 0 : _d.includes(event.node.title))) {
21937
+ if (spec.nodeStart === true || nodeMatches(spec.nodeStart, event)) {
21935
21938
  yield {
21936
21939
  type: "nodeStart",
21937
21940
  inputs: event.inputs,
@@ -21946,7 +21949,7 @@ async function* getProcessorEvents(processor, spec) {
21946
21949
  usages.push(usage);
21947
21950
  }
21948
21951
  }
21949
- if (spec.nodeFinish === true || ((_e = spec.nodeFinish) == null ? void 0 : _e.includes(event.node.id)) || ((_f = spec.nodeFinish) == null ? void 0 : _f.includes(event.node.title))) {
21952
+ if (spec.nodeFinish === true || nodeMatches(spec.nodeFinish, event)) {
21950
21953
  yield {
21951
21954
  type: "nodeFinish",
21952
21955
  outputs: event.outputs,
@@ -21992,11 +21995,17 @@ function getSingleNodeStream(processor, arg) {
21992
21995
  }
21993
21996
  return new ReadableStream({
21994
21997
  async start(controller) {
21998
+ var _a;
21995
21999
  try {
21996
22000
  for await (const event of getProcessorEvents(processor, spec)) {
21997
22001
  if (event.type === "partialOutput") {
21998
22002
  controller.enqueue(`data: ${JSON.stringify(event.delta)}
21999
22003
 
22004
+ `);
22005
+ } else if (event.type === "nodeFinish") {
22006
+ const value = (_a = event.outputs["valueOutput"]) == null ? void 0 : _a.value;
22007
+ controller.enqueue(`data: ${JSON.stringify(value)}
22008
+
22000
22009
  `);
22001
22010
  } else if (event.type === "error") {
22002
22011
  controller.enqueue(`error: ${JSON.stringify(event.error)}