veryfront 0.1.150 → 0.1.152
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/esm/deno.js +1 -1
- package/esm/src/agent/ag-ui-handler.d.ts.map +1 -1
- package/esm/src/agent/ag-ui-handler.js +6 -0
- package/esm/src/agent/index.d.ts +1 -0
- package/esm/src/agent/index.d.ts.map +1 -1
- package/esm/src/agent/index.js +1 -0
- package/esm/src/agent/runtime-ag-ui-contract.d.ts +207 -0
- package/esm/src/agent/runtime-ag-ui-contract.d.ts.map +1 -0
- package/esm/src/agent/runtime-ag-ui-contract.js +109 -0
- package/esm/src/internal-agents/ag-ui-sse.d.ts.map +1 -1
- package/esm/src/internal-agents/ag-ui-sse.js +12 -0
- package/esm/src/internal-agents/schema.d.ts +14 -68
- package/esm/src/internal-agents/schema.d.ts.map +1 -1
- package/esm/src/internal-agents/schema.js +8 -98
- package/esm/src/provider/runtime-loader.d.ts.map +1 -1
- package/esm/src/provider/runtime-loader.js +9 -32
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -1
- package/src/deno.js +1 -1
- package/src/src/agent/ag-ui-handler.ts +6 -0
- package/src/src/agent/index.ts +10 -0
- package/src/src/agent/runtime-ag-ui-contract.ts +144 -0
- package/src/src/internal-agents/ag-ui-sse.ts +12 -0
- package/src/src/internal-agents/schema.ts +22 -129
- package/src/src/provider/runtime-loader.ts +9 -39
- package/src/src/utils/version-constant.ts +1 -1
|
@@ -732,14 +732,14 @@ function buildAnthropicGenerateResult(payload: unknown): {
|
|
|
732
732
|
};
|
|
733
733
|
}
|
|
734
734
|
|
|
735
|
-
function
|
|
735
|
+
function parseSseChunk(chunk: string): {
|
|
736
736
|
events: Array<unknown | "[DONE]">;
|
|
737
737
|
remainder: string;
|
|
738
738
|
} {
|
|
739
|
-
const blocks = chunk.split(
|
|
739
|
+
const blocks = chunk.split(/\r?\n\r?\n/);
|
|
740
740
|
const remainder = blocks.pop() ?? "";
|
|
741
741
|
const events = blocks.flatMap((block) => {
|
|
742
|
-
const dataLines = block.split(
|
|
742
|
+
const dataLines = block.split(/\r?\n/)
|
|
743
743
|
.filter((line) => line.startsWith("data:"))
|
|
744
744
|
.map((line) => line.slice(5).trimStart());
|
|
745
745
|
|
|
@@ -773,7 +773,7 @@ async function* streamAnthropicCompatibleParts(
|
|
|
773
773
|
|
|
774
774
|
for await (const chunk of stream) {
|
|
775
775
|
buffer += decoder.decode(chunk, { stream: true });
|
|
776
|
-
const parsed =
|
|
776
|
+
const parsed = parseSseChunk(buffer);
|
|
777
777
|
buffer = parsed.remainder;
|
|
778
778
|
|
|
779
779
|
for (const event of parsed.events) {
|
|
@@ -912,7 +912,7 @@ async function* streamAnthropicCompatibleParts(
|
|
|
912
912
|
}
|
|
913
913
|
|
|
914
914
|
if (buffer.trim().length > 0) {
|
|
915
|
-
const parsed =
|
|
915
|
+
const parsed = parseSseChunk(`${buffer}\n\n`);
|
|
916
916
|
for (const event of parsed.events) {
|
|
917
917
|
if (event === "[DONE]") {
|
|
918
918
|
continue;
|
|
@@ -1313,7 +1313,7 @@ async function* streamGoogleCompatibleParts(
|
|
|
1313
1313
|
|
|
1314
1314
|
for await (const chunk of stream) {
|
|
1315
1315
|
buffer += decoder.decode(chunk, { stream: true });
|
|
1316
|
-
const parsed =
|
|
1316
|
+
const parsed = parseSseChunk(buffer);
|
|
1317
1317
|
buffer = parsed.remainder;
|
|
1318
1318
|
|
|
1319
1319
|
for (const event of parsed.events) {
|
|
@@ -1367,7 +1367,7 @@ async function* streamGoogleCompatibleParts(
|
|
|
1367
1367
|
}
|
|
1368
1368
|
|
|
1369
1369
|
if (buffer.trim().length > 0) {
|
|
1370
|
-
const parsed =
|
|
1370
|
+
const parsed = parseSseChunk(`${buffer}\n\n`);
|
|
1371
1371
|
for (const event of parsed.events) {
|
|
1372
1372
|
if (event === "[DONE]") {
|
|
1373
1373
|
continue;
|
|
@@ -1430,36 +1430,6 @@ function buildOpenAIGenerateResult(payload: unknown): {
|
|
|
1430
1430
|
};
|
|
1431
1431
|
}
|
|
1432
1432
|
|
|
1433
|
-
function parseOpenAISseChunk(chunk: string): {
|
|
1434
|
-
events: Array<unknown | "[DONE]">;
|
|
1435
|
-
remainder: string;
|
|
1436
|
-
} {
|
|
1437
|
-
const blocks = chunk.split("\n\n");
|
|
1438
|
-
const remainder = blocks.pop() ?? "";
|
|
1439
|
-
const events = blocks.flatMap((block) => {
|
|
1440
|
-
const dataLines = block.split("\n")
|
|
1441
|
-
.filter((line) => line.startsWith("data:"))
|
|
1442
|
-
.map((line) => line.slice(5).trimStart());
|
|
1443
|
-
|
|
1444
|
-
if (!dataLines.length) {
|
|
1445
|
-
return [];
|
|
1446
|
-
}
|
|
1447
|
-
|
|
1448
|
-
const payload = dataLines.join("\n").trim();
|
|
1449
|
-
if (payload === "[DONE]") {
|
|
1450
|
-
return ["[DONE]" as const];
|
|
1451
|
-
}
|
|
1452
|
-
|
|
1453
|
-
try {
|
|
1454
|
-
return [JSON.parse(payload) as unknown];
|
|
1455
|
-
} catch {
|
|
1456
|
-
return [];
|
|
1457
|
-
}
|
|
1458
|
-
});
|
|
1459
|
-
|
|
1460
|
-
return { events, remainder };
|
|
1461
|
-
}
|
|
1462
|
-
|
|
1463
1433
|
async function* streamOpenAICompatibleParts(
|
|
1464
1434
|
stream: ReadableStream<Uint8Array>,
|
|
1465
1435
|
): AsyncIterable<unknown> {
|
|
@@ -1471,7 +1441,7 @@ async function* streamOpenAICompatibleParts(
|
|
|
1471
1441
|
|
|
1472
1442
|
for await (const chunk of stream) {
|
|
1473
1443
|
buffer += decoder.decode(chunk, { stream: true });
|
|
1474
|
-
const parsed =
|
|
1444
|
+
const parsed = parseSseChunk(buffer);
|
|
1475
1445
|
buffer = parsed.remainder;
|
|
1476
1446
|
|
|
1477
1447
|
for (const event of parsed.events) {
|
|
@@ -1545,7 +1515,7 @@ async function* streamOpenAICompatibleParts(
|
|
|
1545
1515
|
}
|
|
1546
1516
|
|
|
1547
1517
|
if (buffer.trim().length > 0) {
|
|
1548
|
-
const parsed =
|
|
1518
|
+
const parsed = parseSseChunk(`${buffer}\n\n`);
|
|
1549
1519
|
for (const event of parsed.events) {
|
|
1550
1520
|
if (event === "[DONE]") {
|
|
1551
1521
|
continue;
|