@introspection-sdk/introspection-node 0.5.0 → 0.5.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.
Files changed (47) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/http.d.ts +6 -19
  3. package/dist/http.d.ts.map +1 -1
  4. package/dist/http.js +14 -139
  5. package/dist/http.js.map +1 -1
  6. package/dist/pagination.d.ts +7 -0
  7. package/dist/pagination.d.ts.map +1 -0
  8. package/dist/pagination.js +7 -0
  9. package/dist/pagination.js.map +1 -0
  10. package/dist/resources/experiments.d.ts +6 -4
  11. package/dist/resources/experiments.d.ts.map +1 -1
  12. package/dist/resources/experiments.js +11 -15
  13. package/dist/resources/experiments.js.map +1 -1
  14. package/dist/resources/recipes.d.ts +6 -4
  15. package/dist/resources/recipes.d.ts.map +1 -1
  16. package/dist/resources/recipes.js +11 -15
  17. package/dist/resources/recipes.js.map +1 -1
  18. package/dist/resources/runtimes.d.ts +6 -4
  19. package/dist/resources/runtimes.d.ts.map +1 -1
  20. package/dist/resources/runtimes.js +11 -15
  21. package/dist/resources/runtimes.js.map +1 -1
  22. package/dist/runner-resources/conversations.d.ts +14 -10
  23. package/dist/runner-resources/conversations.d.ts.map +1 -1
  24. package/dist/runner-resources/conversations.js +24 -30
  25. package/dist/runner-resources/conversations.js.map +1 -1
  26. package/dist/runner-resources/files.d.ts +14 -11
  27. package/dist/runner-resources/files.d.ts.map +1 -1
  28. package/dist/runner-resources/files.js +31 -36
  29. package/dist/runner-resources/files.js.map +1 -1
  30. package/dist/runner-resources/tasks.d.ts +6 -4
  31. package/dist/runner-resources/tasks.d.ts.map +1 -1
  32. package/dist/runner-resources/tasks.js +11 -15
  33. package/dist/runner-resources/tasks.js.map +1 -1
  34. package/dist/streaming.d.ts +4 -5
  35. package/dist/streaming.d.ts.map +1 -1
  36. package/dist/streaming.js +4 -64
  37. package/dist/streaming.js.map +1 -1
  38. package/package.json +16 -15
  39. package/src/http.ts +15 -145
  40. package/src/pagination.ts +10 -0
  41. package/src/resources/experiments.ts +15 -14
  42. package/src/resources/recipes.ts +15 -14
  43. package/src/resources/runtimes.ts +15 -14
  44. package/src/runner-resources/conversations.ts +37 -33
  45. package/src/runner-resources/files.ts +52 -37
  46. package/src/runner-resources/tasks.ts +15 -14
  47. package/src/streaming.ts +4 -55
package/src/streaming.ts CHANGED
@@ -1,57 +1,6 @@
1
- import type { SseEvent } from "@introspection-sdk/types";
2
-
3
1
  /**
4
- * Parse a `text/event-stream` Response into an async-iterable of SSE
5
- * events. Minimal parser: handles `event:`, `data:` (multi-line),
6
- * `id:`, `retry:`; ignores comments and unknown fields.
2
+ * SSE parsing now lives in the shared `@introspection-sdk/http` core so
3
+ * the browser and Node SDKs stay byte-for-byte identical. Re-exported
4
+ * here to keep the existing `./streaming.js` import path stable.
7
5
  */
8
- export async function* parseSse(res: Response): AsyncIterable<SseEvent> {
9
- if (!res.body) return;
10
- const reader = res.body.getReader();
11
- const decoder = new TextDecoder();
12
- let buf = "";
13
- let event = "message";
14
- let data: string[] = [];
15
- let id: string | undefined;
16
- let retry: number | undefined;
17
- const flush = (): SseEvent | null => {
18
- if (data.length === 0 && event === "message" && id === undefined)
19
- return null;
20
- const ev: SseEvent = { event, data: data.join("\n") };
21
- if (id !== undefined) ev.id = id;
22
- if (retry !== undefined) ev.retry = retry;
23
- event = "message";
24
- data = [];
25
- id = undefined;
26
- retry = undefined;
27
- return ev;
28
- };
29
- while (true) {
30
- const { value, done } = await reader.read();
31
- if (done) break;
32
- buf += decoder.decode(value, { stream: true });
33
- let nl: number;
34
- while ((nl = buf.indexOf("\n")) >= 0) {
35
- const line = buf.slice(0, nl).replace(/\r$/, "");
36
- buf = buf.slice(nl + 1);
37
- if (line === "") {
38
- const ev = flush();
39
- if (ev) yield ev;
40
- continue;
41
- }
42
- if (line.startsWith(":")) continue;
43
- const colon = line.indexOf(":");
44
- const field = colon < 0 ? line : line.slice(0, colon);
45
- const valueRaw = colon < 0 ? "" : line.slice(colon + 1).replace(/^ /, "");
46
- if (field === "event") event = valueRaw;
47
- else if (field === "data") data.push(valueRaw);
48
- else if (field === "id") id = valueRaw;
49
- else if (field === "retry") {
50
- const n = Number(valueRaw);
51
- if (Number.isFinite(n)) retry = n;
52
- }
53
- }
54
- }
55
- const ev = flush();
56
- if (ev) yield ev;
57
- }
6
+ export { parseSse } from "@introspection-sdk/http";