@syncagent/js 0.1.1 → 0.1.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/dist/index.js CHANGED
@@ -30,12 +30,21 @@ function parseDataStreamChunk(chunk) {
30
30
  const lines = chunk.split("\n");
31
31
  for (const line of lines) {
32
32
  const trimmed = line.trim();
33
- if (!trimmed || !trimmed.startsWith("0:")) continue;
34
- try {
35
- const parsed = JSON.parse(trimmed.substring(2));
36
- if (typeof parsed === "string") tokens.push(parsed);
37
- } catch {
33
+ if (!trimmed) continue;
34
+ if (trimmed.startsWith("0:")) {
35
+ try {
36
+ const parsed = JSON.parse(trimmed.substring(2));
37
+ if (typeof parsed === "string") {
38
+ tokens.push(parsed);
39
+ continue;
40
+ }
41
+ } catch {
42
+ }
43
+ }
44
+ if (/^\d+:/.test(trimmed) || trimmed.startsWith("data:") || trimmed.startsWith("event:")) {
45
+ continue;
38
46
  }
47
+ tokens.push(line);
39
48
  }
40
49
  return tokens;
41
50
  }
package/dist/index.mjs CHANGED
@@ -4,12 +4,21 @@ function parseDataStreamChunk(chunk) {
4
4
  const lines = chunk.split("\n");
5
5
  for (const line of lines) {
6
6
  const trimmed = line.trim();
7
- if (!trimmed || !trimmed.startsWith("0:")) continue;
8
- try {
9
- const parsed = JSON.parse(trimmed.substring(2));
10
- if (typeof parsed === "string") tokens.push(parsed);
11
- } catch {
7
+ if (!trimmed) continue;
8
+ if (trimmed.startsWith("0:")) {
9
+ try {
10
+ const parsed = JSON.parse(trimmed.substring(2));
11
+ if (typeof parsed === "string") {
12
+ tokens.push(parsed);
13
+ continue;
14
+ }
15
+ } catch {
16
+ }
17
+ }
18
+ if (/^\d+:/.test(trimmed) || trimmed.startsWith("data:") || trimmed.startsWith("event:")) {
19
+ continue;
12
20
  }
21
+ tokens.push(line);
13
22
  }
14
23
  return tokens;
15
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncagent/js",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "SyncAgent JavaScript SDK — AI database agent for any app",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",