pipeai 0.8.0 → 0.8.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.
package/README.md CHANGED
@@ -299,6 +299,23 @@ const pipeline = Workflow.create<Ctx>()
299
299
  });
300
300
  ```
301
301
 
302
+ An inline `.step(id, fn)` handler receives `{ ctx, input, writer? }`. When the workflow runs via `.stream(...)`, `writer` is the same `UIMessageStreamWriter` the agent steps merge into — so an inline step can surface mid-pipeline progress (status/data parts) to the client before the terminal agent starts emitting tokens. `writer` is `undefined` in generate mode (`.generate(...)`), so guard with `?.`:
303
+
304
+ ```ts
305
+ const pipeline = Workflow.create<Ctx>()
306
+ .step("plan", async ({ ctx, input, writer }) => {
307
+ writer?.write({ type: "data-status", data: { phase: "planning" } });
308
+ return planner.run(ctx, input);
309
+ })
310
+ .step("search", async ({ ctx, input, writer }) => {
311
+ writer?.write({ type: "data-status", data: { phase: "searching", queries: input.queries.length } });
312
+ return ctx.search.run(input.queries);
313
+ })
314
+ .step(synthesizerAgent); // terminal streaming agent
315
+ ```
316
+
317
+ For ambient writer access from helper functions called *inside* a step, compose the AI SDK's `createUIMessageStream` directly — pipeai only threads `writer` into the inline step handler itself.
318
+
302
319
  ### Running a workflow
303
320
 
304
321
  ```ts
package/dist/index.cjs CHANGED
@@ -710,7 +710,9 @@ var SealedWorkflow = class _SealedWorkflow {
710
710
  }
711
711
  },
712
712
  ...options?.onError ? { onError: options.onError } : {},
713
- ...options?.onFinish ? { onFinish: options.onFinish } : {}
713
+ ...options?.onFinish ? { onFinish: options.onFinish } : {},
714
+ ...options?.originalMessages ? { originalMessages: options.originalMessages } : {},
715
+ ...options?.generateId ? { generateId: options.generateId } : {}
714
716
  });
715
717
  return {
716
718
  stream,
@@ -990,7 +992,7 @@ var SealedWorkflow = class _SealedWorkflow {
990
992
  await runWithWriter(writer, async () => {
991
993
  const result = await agent.stream(ctx, state.output, agentCallOpts);
992
994
  if (options?.handleStream) {
993
- await options.handleStream({ result, writer, ctx });
995
+ await options.handleStream({ result, writer, ctx, input });
994
996
  } else {
995
997
  writer.merge(result.toUIMessageStream());
996
998
  }
@@ -1219,7 +1221,9 @@ var ResumedWorkflow = class extends SealedWorkflow {
1219
1221
  }
1220
1222
  },
1221
1223
  ...options?.onError ? { onError: options.onError } : {},
1222
- ...options?.onFinish ? { onFinish: options.onFinish } : {}
1224
+ ...options?.onFinish ? { onFinish: options.onFinish } : {},
1225
+ ...options?.originalMessages ? { originalMessages: options.originalMessages } : {},
1226
+ ...options?.generateId ? { generateId: options.generateId } : {}
1223
1227
  });
1224
1228
  return { stream, output: outputPromise };
1225
1229
  }
@@ -1281,7 +1285,9 @@ var CheckpointResumedWorkflow = class extends SealedWorkflow {
1281
1285
  }
1282
1286
  },
1283
1287
  ...options?.onError ? { onError: options.onError } : {},
1284
- ...options?.onFinish ? { onFinish: options.onFinish } : {}
1288
+ ...options?.onFinish ? { onFinish: options.onFinish } : {},
1289
+ ...options?.originalMessages ? { originalMessages: options.originalMessages } : {},
1290
+ ...options?.generateId ? { generateId: options.generateId } : {}
1285
1291
  });
1286
1292
  return { stream, output: outputPromise };
1287
1293
  }
@@ -1336,7 +1342,10 @@ var Workflow = class _Workflow extends SealedWorkflow {
1336
1342
  execute: async (state) => {
1337
1343
  state.output = await fn({
1338
1344
  ctx: state.ctx,
1339
- input: state.output
1345
+ input: state.output,
1346
+ // Present in stream mode (undefined in generate mode), letting the
1347
+ // inline step emit UIMessageChunk parts onto the workflow's stream.
1348
+ writer: state.writer
1340
1349
  });
1341
1350
  }
1342
1351
  };