@core-ai/google-genai 0.13.1 → 0.14.0

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 (2) hide show
  1. package/dist/index.js +19 -0
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -439,6 +439,7 @@ async function* transformStream(stream) {
439
439
  const bufferedToolCalls = /* @__PURE__ */ new Map();
440
440
  let finishReason = "unknown";
441
441
  let sawToolCalls = false;
442
+ let textOpen = false;
442
443
  let reasoningOpen = false;
443
444
  let usage = {
444
445
  inputTokens: 0,
@@ -459,10 +460,25 @@ async function* transformStream(stream) {
459
460
  providerMetadata: { google: {} }
460
461
  };
461
462
  };
463
+ const startText = function* () {
464
+ if (textOpen) {
465
+ return;
466
+ }
467
+ textOpen = true;
468
+ yield { type: "text-start" };
469
+ };
470
+ const closeText = function* () {
471
+ if (!textOpen) {
472
+ return;
473
+ }
474
+ textOpen = false;
475
+ yield { type: "text-end" };
476
+ };
462
477
  for await (const chunk of stream) {
463
478
  usage = mapUsage(chunk, usage);
464
479
  const reasoningDeltas = extractReasoningDeltas(chunk);
465
480
  if (reasoningDeltas.length > 0) {
481
+ yield* closeText();
466
482
  if (!reasoningOpen) {
467
483
  reasoningOpen = true;
468
484
  yield {
@@ -481,6 +497,7 @@ async function* transformStream(stream) {
481
497
  if (reasoningEnd2) {
482
498
  yield reasoningEnd2;
483
499
  }
500
+ yield* startText();
484
501
  yield {
485
502
  type: "text-delta",
486
503
  text: chunk.text
@@ -488,6 +505,7 @@ async function* transformStream(stream) {
488
505
  }
489
506
  const functionCalls = chunk.functionCalls ?? [];
490
507
  if (functionCalls.length > 0) {
508
+ yield* closeText();
491
509
  const reasoningEnd2 = closeReasoning();
492
510
  if (reasoningEnd2) {
493
511
  yield reasoningEnd2;
@@ -538,6 +556,7 @@ async function* transformStream(stream) {
538
556
  if (reasoningEnd) {
539
557
  yield reasoningEnd;
540
558
  }
559
+ yield* closeText();
541
560
  for (const toolCall of bufferedToolCalls.values()) {
542
561
  yield {
543
562
  type: "tool-call-end",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@core-ai/google-genai",
3
- "version": "0.13.1",
3
+ "version": "0.14.0",
4
4
  "description": "Google GenAI provider package for @core-ai/core-ai",
5
5
  "license": "MIT",
6
6
  "author": "Omnifact (https://omnifact.ai)",
@@ -45,7 +45,7 @@
45
45
  "test:watch": "vitest"
46
46
  },
47
47
  "dependencies": {
48
- "@core-ai/core-ai": "^0.13.1",
48
+ "@core-ai/core-ai": "^0.14.0",
49
49
  "@google/genai": "^1.42.0"
50
50
  },
51
51
  "peerDependencies": {