@workflow/world-testing 4.1.3 → 4.1.4

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.
@@ -48631,7 +48631,7 @@ init_dist();
48631
48631
  init_node();
48632
48632
 
48633
48633
  // ../core/dist/version.js
48634
- var version2 = "4.2.3";
48634
+ var version2 = "4.2.4";
48635
48635
 
48636
48636
  // ../core/dist/runtime/world.js
48637
48637
  var import_node_module = require("node:module");
@@ -58076,7 +58076,7 @@ var import_oidc3 = __toESM(require_dist(), 1);
58076
58076
  init_dist();
58077
58077
 
58078
58078
  // ../world-vercel/dist/version.js
58079
- var version3 = "4.1.1";
58079
+ var version3 = "4.1.2";
58080
58080
 
58081
58081
  // ../world-vercel/dist/utils.js
58082
58082
  var HTTP_DEBUG_ENABLED = typeof process !== "undefined" && typeof process.env.DEBUG === "string" && (process.env.DEBUG.includes("workflow:") || process.env.DEBUG === "*");
@@ -59292,28 +59292,6 @@ __name(createStorage2, "createStorage");
59292
59292
  // ../world-vercel/dist/streamer.js
59293
59293
  init_zod();
59294
59294
  var MAX_CHUNKS_PER_REQUEST = 1e3;
59295
- var STREAM_CONTROL_FRAME_SIZE = 13;
59296
- var STREAM_CONTROL_MAGIC = new Uint8Array([87, 70, 67, 84]);
59297
- function parseStreamControlFrame(buffer) {
59298
- if (buffer.length < STREAM_CONTROL_FRAME_SIZE)
59299
- return null;
59300
- const offset = buffer.length - STREAM_CONTROL_FRAME_SIZE;
59301
- if (buffer[offset] !== 0 || buffer[offset + 1] !== 0 || buffer[offset + 2] !== 0 || buffer[offset + 3] !== 0) {
59302
- return null;
59303
- }
59304
- if (buffer[offset + 9] !== STREAM_CONTROL_MAGIC[0] || buffer[offset + 10] !== STREAM_CONTROL_MAGIC[1] || buffer[offset + 11] !== STREAM_CONTROL_MAGIC[2] || buffer[offset + 12] !== STREAM_CONTROL_MAGIC[3]) {
59305
- return null;
59306
- }
59307
- const flags = buffer[offset + 4];
59308
- const view = new DataView(buffer.buffer, buffer.byteOffset + offset + 5, 4);
59309
- const nextIndex = view.getUint32(0, false);
59310
- return {
59311
- done: (flags & 1) === 1,
59312
- nextIndex,
59313
- totalLength: STREAM_CONTROL_FRAME_SIZE
59314
- };
59315
- }
59316
- __name(parseStreamControlFrame, "parseStreamControlFrame");
59317
59295
  function getStreamUrl(name, runId, httpConfig) {
59318
59296
  if (runId) {
59319
59297
  return new URL(`${httpConfig.baseUrl}/v2/runs/${encodeURIComponent(runId)}/stream/${encodeURIComponent(name)}`);
@@ -59404,64 +59382,21 @@ function createStreamer2(config3) {
59404
59382
  }
59405
59383
  },
59406
59384
  async readFromStream(name, startIndex) {
59407
- let currentStartIndex = startIndex ?? 0;
59408
- const MAX_RECONNECTS = 50;
59409
- let reconnectCount = 0;
59410
- const connect2 = /* @__PURE__ */ __name(async () => {
59411
- const httpConfig = await getHttpConfig(config3);
59412
- const url2 = new URL(`${httpConfig.baseUrl}/v3/stream/${encodeURIComponent(name)}`);
59413
- url2.searchParams.set("startIndex", String(currentStartIndex));
59414
- const response = await fetch(url2, {
59415
- headers: httpConfig.headers
59416
- });
59417
- if (!response.ok) {
59418
- throw new Error(`Failed to fetch stream: ${response.status}`);
59419
- }
59420
- if (!response.body) {
59421
- throw new Error("No response body for stream");
59422
- }
59423
- return response;
59424
- }, "connect");
59425
- const readFull = /* @__PURE__ */ __name(async () => {
59426
- const response = await connect2();
59427
- const buffer = new Uint8Array(await response.arrayBuffer());
59428
- const control = parseStreamControlFrame(buffer);
59429
- if (control) {
59430
- const dataLen = buffer.length - control.totalLength;
59431
- return {
59432
- data: dataLen > 0 ? buffer.subarray(0, dataLen) : new Uint8Array(0),
59433
- control
59434
- };
59435
- }
59436
- return { data: buffer, control: null };
59437
- }, "readFull");
59438
- const parts = [];
59439
- for (; ; ) {
59440
- const { data, control } = await readFull();
59441
- if (data.length > 0) {
59442
- parts.push(data);
59443
- }
59444
- if (!control || control.done) {
59445
- break;
59446
- }
59447
- reconnectCount++;
59448
- if (reconnectCount > MAX_RECONNECTS) {
59449
- throw new Error(`Stream exceeded maximum reconnection attempts (${MAX_RECONNECTS})`);
59450
- }
59451
- currentStartIndex = control.nextIndex;
59385
+ const httpConfig = await getHttpConfig(config3);
59386
+ const url2 = getStreamUrl(name, void 0, httpConfig);
59387
+ if (typeof startIndex === "number") {
59388
+ url2.searchParams.set("startIndex", String(startIndex));
59452
59389
  }
59453
- let emitted = false;
59454
- return new ReadableStream({
59455
- pull(controller) {
59456
- if (!emitted) {
59457
- emitted = true;
59458
- for (const part of parts) {
59459
- controller.enqueue(part);
59460
- }
59461
- }
59462
- controller.close();
59463
- }
59390
+ const response = await fetch(url2, {
59391
+ headers: httpConfig.headers
59464
59392
  });
59393
+ if (!response.ok) {
59394
+ throw new Error(`Failed to fetch stream: ${response.status}`);
59395
+ }
59396
+ if (!response.body) {
59397
+ throw new Error("No response body for stream");
59398
+ }
59399
+ return response.body;
59465
59400
  },
59466
59401
  async getStreamChunks(name, runId, options) {
59467
59402
  const params = new URLSearchParams();
@@ -11,9 +11,9 @@
11
11
  "stepId": "step//./workflows/noop//noop"
12
12
  }
13
13
  },
14
- "workflows/addition.ts": {
15
- "add": {
16
- "stepId": "step//./workflows/addition//add"
14
+ "workflows/hooks.ts": {
15
+ "writeEvent": {
16
+ "stepId": "step//./workflows/hooks//writeEvent"
17
17
  }
18
18
  },
19
19
  "workflow/dist/internal/builtins.js": {
@@ -35,9 +35,9 @@
35
35
  "stepId": "step//./workflows/retriable-and-fatal//stepThatThrowsRetryableError"
36
36
  }
37
37
  },
38
- "workflows/hooks.ts": {
39
- "writeEvent": {
40
- "stepId": "step//./workflows/hooks//writeEvent"
38
+ "workflows/addition.ts": {
39
+ "add": {
40
+ "stepId": "step//./workflows/addition//add"
41
41
  }
42
42
  }
43
43
  },
@@ -108,16 +108,16 @@
108
108
  }
109
109
  }
110
110
  },
111
- "workflows/addition.ts": {
112
- "addition": {
113
- "workflowId": "workflow//./workflows/addition//addition",
111
+ "workflows/hooks.ts": {
112
+ "collectWithHook": {
113
+ "workflowId": "workflow//./workflows/hooks//collectWithHook",
114
114
  "graph": {
115
115
  "nodes": [
116
116
  {
117
117
  "id": "start",
118
118
  "type": "workflowStart",
119
119
  "data": {
120
- "label": "Start: addition",
120
+ "label": "Start: collectWithHook",
121
121
  "nodeKind": "workflow_start"
122
122
  }
123
123
  },
@@ -174,16 +174,16 @@
174
174
  }
175
175
  }
176
176
  },
177
- "workflows/hooks.ts": {
178
- "collectWithHook": {
179
- "workflowId": "workflow//./workflows/hooks//collectWithHook",
177
+ "workflows/addition.ts": {
178
+ "addition": {
179
+ "workflowId": "workflow//./workflows/addition//addition",
180
180
  "graph": {
181
181
  "nodes": [
182
182
  {
183
183
  "id": "start",
184
184
  "type": "workflowStart",
185
185
  "data": {
186
- "label": "Start: collectWithHook",
186
+ "label": "Start: addition",
187
187
  "nodeKind": "workflow_start"
188
188
  }
189
189
  },