@opencode-ai/ai 0.0.0-dev-17856 → 0.0.0-dev-17863
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/protocols/gemini.js
CHANGED
|
@@ -240,7 +240,7 @@ const lowerMessages = Effect.fn("Gemini.lowerMessages")(function* (request) {
|
|
|
240
240
|
if (!ProviderShared.supportsContent(part, ["text", "reasoning", "tool-call"]))
|
|
241
241
|
return yield* ProviderShared.unsupportedContent("Gemini", "assistant", ["text", "reasoning", "tool-call"]);
|
|
242
242
|
if (part.type === "text") {
|
|
243
|
-
parts.push({ text: part.text });
|
|
243
|
+
parts.push({ text: part.text, thoughtSignature: thoughtSignature(part.providerMetadata) });
|
|
244
244
|
continue;
|
|
245
245
|
}
|
|
246
246
|
if (part.type === "reasoning") {
|
|
@@ -438,9 +438,11 @@ const finish = (state) => {
|
|
|
438
438
|
if (finishReason === undefined && state.usage === undefined)
|
|
439
439
|
return [];
|
|
440
440
|
const events = [];
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
: state.
|
|
441
|
+
let lifecycle = state.lifecycle;
|
|
442
|
+
if (state.reasoningSignature !== undefined)
|
|
443
|
+
lifecycle = Lifecycle.reasoningEnd(lifecycle, events, "reasoning-0", googleMetadata({ thoughtSignature: state.reasoningSignature }));
|
|
444
|
+
if (state.textSignature !== undefined)
|
|
445
|
+
lifecycle = Lifecycle.textEnd(lifecycle, events, "text-0", googleMetadata({ thoughtSignature: state.textSignature }));
|
|
444
446
|
Lifecycle.finish(lifecycle, events, {
|
|
445
447
|
reason: {
|
|
446
448
|
normalized: promptBlockReason === undefined ? mapFinishReason(finishReason, state.hasToolCalls) : "content-filter",
|
|
@@ -468,16 +470,23 @@ const step = (state, event) => {
|
|
|
468
470
|
let lifecycle = nextState.lifecycle;
|
|
469
471
|
let nextToolCallId = nextState.nextToolCallId;
|
|
470
472
|
let reasoningSignature = nextState.reasoningSignature;
|
|
473
|
+
let textSignature = nextState.textSignature;
|
|
471
474
|
for (const part of candidate.content.parts) {
|
|
472
|
-
|
|
473
|
-
|
|
475
|
+
const signature = "thoughtSignature" in part && part.thoughtSignature ? part.thoughtSignature : undefined;
|
|
476
|
+
// Gemini attaches replay signatures to thought parts, visible text, or function calls;
|
|
477
|
+
// each block kind must retain the signature attached to its own parts.
|
|
478
|
+
if (signature !== undefined && "thought" in part && part.thought)
|
|
479
|
+
reasoningSignature = signature;
|
|
480
|
+
else if (signature !== undefined && "text" in part)
|
|
481
|
+
textSignature = signature;
|
|
474
482
|
if ("text" in part && part.text.length > 0) {
|
|
475
483
|
if (part.thought) {
|
|
476
|
-
lifecycle = Lifecycle.reasoningDelta(lifecycle, events, "reasoning-0", part.text,
|
|
484
|
+
lifecycle = Lifecycle.reasoningDelta(lifecycle, events, "reasoning-0", part.text, signature ? googleMetadata({ thoughtSignature: signature }) : undefined);
|
|
477
485
|
continue;
|
|
478
486
|
}
|
|
479
487
|
lifecycle = Lifecycle.reasoningEnd(lifecycle, events, "reasoning-0", reasoningSignature ? googleMetadata({ thoughtSignature: reasoningSignature }) : undefined);
|
|
480
|
-
lifecycle = Lifecycle.textDelta(lifecycle, events, "text-0", part.text);
|
|
488
|
+
lifecycle = Lifecycle.textDelta(lifecycle, events, "text-0", part.text, textSignature ? googleMetadata({ thoughtSignature: textSignature }) : undefined);
|
|
489
|
+
textSignature = undefined;
|
|
481
490
|
continue;
|
|
482
491
|
}
|
|
483
492
|
if ("functionCall" in part) {
|
|
@@ -505,6 +514,7 @@ const step = (state, event) => {
|
|
|
505
514
|
lifecycle,
|
|
506
515
|
nextToolCallId,
|
|
507
516
|
reasoningSignature,
|
|
517
|
+
textSignature,
|
|
508
518
|
finishReason: candidate.finishReason ?? nextState.finishReason,
|
|
509
519
|
},
|
|
510
520
|
events,
|
|
@@ -7,7 +7,7 @@ export interface State {
|
|
|
7
7
|
export declare const initial: () => State;
|
|
8
8
|
export declare const stepStart: (state: State, events: LLMEvent[]) => State;
|
|
9
9
|
export declare const textStart: (state: State, events: LLMEvent[], id: string, providerMetadata?: ProviderMetadata) => State;
|
|
10
|
-
export declare const textDelta: (state: State, events: LLMEvent[], id: string, text: string) => State;
|
|
10
|
+
export declare const textDelta: (state: State, events: LLMEvent[], id: string, text: string, providerMetadata?: ProviderMetadata) => State;
|
|
11
11
|
export declare const reasoningStart: (state: State, events: LLMEvent[], id: string, providerMetadata?: ProviderMetadata) => State;
|
|
12
12
|
export declare const reasoningDelta: (state: State, events: LLMEvent[], id: string, text: string, providerMetadata?: ProviderMetadata) => State;
|
|
13
13
|
export declare const reasoningEnd: (state: State, events: LLMEvent[], id: string, providerMetadata?: ProviderMetadata) => State;
|
|
@@ -13,9 +13,9 @@ export const textStart = (state, events, id, providerMetadata) => {
|
|
|
13
13
|
events.push(LLMEvent.textStart({ id, providerMetadata }));
|
|
14
14
|
return { ...stepped, text: new Set([...stepped.text, id]) };
|
|
15
15
|
};
|
|
16
|
-
export const textDelta = (state, events, id, text) => {
|
|
16
|
+
export const textDelta = (state, events, id, text, providerMetadata) => {
|
|
17
17
|
const started = textStart(state, events, id);
|
|
18
|
-
events.push(LLMEvent.textDelta({ id, text }));
|
|
18
|
+
events.push(LLMEvent.textDelta({ id, text, providerMetadata }));
|
|
19
19
|
return started;
|
|
20
20
|
};
|
|
21
21
|
export const reasoningStart = (state, events, id, providerMetadata) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-17863",
|
|
4
4
|
"name": "@opencode-ai/ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@clack/prompts": "1.0.0-alpha.1",
|
|
32
32
|
"@effect/platform-node": "4.0.0-rc.110",
|
|
33
|
-
"@opencode-ai/http-recorder": "0.0.0-dev-
|
|
33
|
+
"@opencode-ai/http-recorder": "0.0.0-dev-17863",
|
|
34
34
|
"@tsconfig/bun": "1.0.9",
|
|
35
35
|
"@types/bun": "1.3.13",
|
|
36
36
|
"@typescript/native-preview": "7.0.0-dev.20251207.1",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@smithy/eventstream-codec": "4.2.14",
|
|
41
41
|
"@smithy/util-utf8": "4.2.2",
|
|
42
|
-
"@opencode-ai/schema": "0.0.0-dev-
|
|
42
|
+
"@opencode-ai/schema": "0.0.0-dev-17863",
|
|
43
43
|
"aws4fetch": "1.0.20",
|
|
44
44
|
"effect": "4.0.0-rc.110",
|
|
45
45
|
"google-auth-library": "10.5.0"
|