@opencode-ai/ai
Advanced tools
@@ -243,3 +243,3 @@ import { Effect, Schema } from "effect"; | ||
| if (part.type === "text") { | ||
| parts.push({ text: part.text }); | ||
| parts.push({ text: part.text, thoughtSignature: thoughtSignature(part.providerMetadata) }); | ||
| continue; | ||
@@ -442,5 +442,7 @@ } | ||
| const events = []; | ||
| const lifecycle = state.reasoningSignature | ||
| ? Lifecycle.reasoningEnd(state.lifecycle, events, "reasoning-0", googleMetadata({ thoughtSignature: state.reasoningSignature })) | ||
| : state.lifecycle; | ||
| let lifecycle = state.lifecycle; | ||
| if (state.reasoningSignature !== undefined) | ||
| lifecycle = Lifecycle.reasoningEnd(lifecycle, events, "reasoning-0", googleMetadata({ thoughtSignature: state.reasoningSignature })); | ||
| if (state.textSignature !== undefined) | ||
| lifecycle = Lifecycle.textEnd(lifecycle, events, "text-0", googleMetadata({ thoughtSignature: state.textSignature })); | ||
| Lifecycle.finish(lifecycle, events, { | ||
@@ -473,12 +475,19 @@ reason: { | ||
| let reasoningSignature = nextState.reasoningSignature; | ||
| let textSignature = nextState.textSignature; | ||
| for (const part of candidate.content.parts) { | ||
| if ("thoughtSignature" in part && part.thoughtSignature && "thought" in part && part.thought) | ||
| reasoningSignature = part.thoughtSignature; | ||
| const signature = "thoughtSignature" in part && part.thoughtSignature ? part.thoughtSignature : undefined; | ||
| // Gemini attaches replay signatures to thought parts, visible text, or function calls; | ||
| // each block kind must retain the signature attached to its own parts. | ||
| if (signature !== undefined && "thought" in part && part.thought) | ||
| reasoningSignature = signature; | ||
| else if (signature !== undefined && "text" in part) | ||
| textSignature = signature; | ||
| if ("text" in part && part.text.length > 0) { | ||
| if (part.thought) { | ||
| lifecycle = Lifecycle.reasoningDelta(lifecycle, events, "reasoning-0", part.text, part.thoughtSignature ? googleMetadata({ thoughtSignature: part.thoughtSignature }) : undefined); | ||
| lifecycle = Lifecycle.reasoningDelta(lifecycle, events, "reasoning-0", part.text, signature ? googleMetadata({ thoughtSignature: signature }) : undefined); | ||
| continue; | ||
| } | ||
| lifecycle = Lifecycle.reasoningEnd(lifecycle, events, "reasoning-0", reasoningSignature ? googleMetadata({ thoughtSignature: reasoningSignature }) : undefined); | ||
| lifecycle = Lifecycle.textDelta(lifecycle, events, "text-0", part.text); | ||
| lifecycle = Lifecycle.textDelta(lifecycle, events, "text-0", part.text, textSignature ? googleMetadata({ thoughtSignature: textSignature }) : undefined); | ||
| textSignature = undefined; | ||
| continue; | ||
@@ -511,2 +520,3 @@ } | ||
| reasoningSignature, | ||
| textSignature, | ||
| finishReason: candidate.finishReason ?? nextState.finishReason, | ||
@@ -513,0 +523,0 @@ }, |
@@ -10,3 +10,3 @@ import { LLMEvent, type FinishReasonDetails, type ProviderMetadata, type Usage } from "../../schema/index.js"; | ||
| export declare const textStart: (state: State, events: LLMEvent[], id: string, providerMetadata?: ProviderMetadata) => State; | ||
| export declare const textDelta: (state: State, events: LLMEvent[], id: string, text: string) => State; | ||
| export declare const textDelta: (state: State, events: LLMEvent[], id: string, text: string, providerMetadata?: ProviderMetadata) => State; | ||
| export declare const reasoningStart: (state: State, events: LLMEvent[], id: string, providerMetadata?: ProviderMetadata) => State; | ||
@@ -13,0 +13,0 @@ export declare const reasoningDelta: (state: State, events: LLMEvent[], id: string, text: string, providerMetadata?: ProviderMetadata) => State; |
@@ -16,5 +16,5 @@ import { LLMEvent } from "../../schema/index.js"; | ||
| }; | ||
| export const textDelta = (state, events, id, text) => { | ||
| export const textDelta = (state, events, id, text, providerMetadata) => { | ||
| const started = textStart(state, events, id); | ||
| events.push(LLMEvent.textDelta({ id, text })); | ||
| events.push(LLMEvent.textDelta({ id, text, providerMetadata })); | ||
| return started; | ||
@@ -21,0 +21,0 @@ }; |
+3
-3
| { | ||
| "$schema": "https://json.schemastore.org/package.json", | ||
| "version": "0.0.0-dev-17856", | ||
| "version": "0.0.0-dev-17860", | ||
| "name": "@opencode-ai/ai", | ||
@@ -33,3 +33,3 @@ "type": "module", | ||
| "@effect/platform-node": "4.0.0-rc.110", | ||
| "@opencode-ai/http-recorder": "0.0.0-dev-17856", | ||
| "@opencode-ai/http-recorder": "0.0.0-dev-17860", | ||
| "@tsconfig/bun": "1.0.9", | ||
@@ -43,3 +43,3 @@ "@types/bun": "1.3.13", | ||
| "@smithy/util-utf8": "4.2.2", | ||
| "@opencode-ai/schema": "0.0.0-dev-17856", | ||
| "@opencode-ai/schema": "0.0.0-dev-17860", | ||
| "aws4fetch": "1.0.20", | ||
@@ -46,0 +46,0 @@ "effect": "4.0.0-rc.110", |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
1186901
0.07%27356
0.04%+ Added
- Removed