@opencode-ai/ai
Advanced tools
@@ -204,2 +204,4 @@ import { Schema } from "effect"; | ||
| lifecycle: Lifecycle.State; | ||
| nextReasoningId: number; | ||
| nextTextId: number; | ||
| }>; | ||
@@ -206,0 +208,0 @@ export declare const route: Route<{ |
+49
-12
@@ -467,6 +467,10 @@ import { Effect, Option, Schema } from "effect"; | ||
| let lifecycle = state.lifecycle; | ||
| if (state.reasoningSignature !== undefined) | ||
| lifecycle = Lifecycle.reasoningEnd(lifecycle, events, "reasoning-0", providerMetadata(state.providerMetadataKey, { thoughtSignature: state.reasoningSignature })); | ||
| if (state.textSignature !== undefined) | ||
| lifecycle = Lifecycle.textEnd(lifecycle, events, "text-0", providerMetadata(state.providerMetadataKey, { thoughtSignature: state.textSignature })); | ||
| if (state.reasoningId !== undefined) | ||
| lifecycle = Lifecycle.reasoningEnd(lifecycle, events, state.reasoningId, state.reasoningSignature === undefined | ||
| ? undefined | ||
| : providerMetadata(state.providerMetadataKey, { thoughtSignature: state.reasoningSignature })); | ||
| if (state.textId !== undefined) | ||
| lifecycle = Lifecycle.textEnd(lifecycle, events, state.textId, state.textSignature === undefined | ||
| ? undefined | ||
| : providerMetadata(state.providerMetadataKey, { thoughtSignature: state.textSignature })); | ||
| Lifecycle.finish(lifecycle, events, { | ||
@@ -513,2 +517,6 @@ reason: { | ||
| let textSignature = nextState.textSignature; | ||
| let reasoningId = nextState.reasoningId; | ||
| let textId = nextState.textId; | ||
| let nextReasoningId = nextState.nextReasoningId; | ||
| let nextTextId = nextState.nextTextId; | ||
| // Supplier ids must be tracked across chunks of the same response, not just within one event's parts. | ||
@@ -536,9 +544,28 @@ const seenCallIds = new Set(nextState.seenCallIds); | ||
| if (part.thought) { | ||
| lifecycle = Lifecycle.reasoningDelta(lifecycle, events, "reasoning-0", part.text, signature ? providerMetadata(state.providerMetadataKey, { thoughtSignature: signature }) : undefined); | ||
| if (textId !== undefined) { | ||
| lifecycle = Lifecycle.textEnd(lifecycle, events, textId, textSignature | ||
| ? providerMetadata(state.providerMetadataKey, { thoughtSignature: textSignature }) | ||
| : undefined); | ||
| textId = undefined; | ||
| textSignature = undefined; | ||
| } | ||
| if (reasoningId === undefined) { | ||
| reasoningId = `reasoning-${nextReasoningId}`; | ||
| nextReasoningId += 1; | ||
| } | ||
| lifecycle = Lifecycle.reasoningDelta(lifecycle, events, reasoningId, part.text, signature ? providerMetadata(state.providerMetadataKey, { thoughtSignature: signature }) : undefined); | ||
| continue; | ||
| } | ||
| lifecycle = Lifecycle.reasoningEnd(lifecycle, events, "reasoning-0", reasoningSignature | ||
| ? providerMetadata(state.providerMetadataKey, { thoughtSignature: reasoningSignature }) | ||
| : undefined); | ||
| lifecycle = Lifecycle.textDelta(lifecycle, events, "text-0", part.text, textSignature ? providerMetadata(state.providerMetadataKey, { thoughtSignature: textSignature }) : undefined); | ||
| if (reasoningId !== undefined) { | ||
| lifecycle = Lifecycle.reasoningEnd(lifecycle, events, reasoningId, reasoningSignature | ||
| ? providerMetadata(state.providerMetadataKey, { thoughtSignature: reasoningSignature }) | ||
| : undefined); | ||
| reasoningId = undefined; | ||
| reasoningSignature = undefined; | ||
| } | ||
| if (textId === undefined) { | ||
| textId = `text-${nextTextId}`; | ||
| nextTextId += 1; | ||
| } | ||
| lifecycle = Lifecycle.textDelta(lifecycle, events, textId, part.text, textSignature ? providerMetadata(state.providerMetadataKey, { thoughtSignature: textSignature }) : undefined); | ||
| textSignature = undefined; | ||
@@ -558,5 +585,9 @@ continue; | ||
| const id = supplied !== undefined && !duplicate ? supplied : `tool_${crypto.randomUUID().replaceAll("-", "")}`; | ||
| lifecycle = Lifecycle.reasoningEnd(lifecycle, events, "reasoning-0", reasoningSignature | ||
| ? providerMetadata(state.providerMetadataKey, { thoughtSignature: reasoningSignature }) | ||
| : undefined); | ||
| if (reasoningId !== undefined) { | ||
| lifecycle = Lifecycle.reasoningEnd(lifecycle, events, reasoningId, reasoningSignature | ||
| ? providerMetadata(state.providerMetadataKey, { thoughtSignature: reasoningSignature }) | ||
| : undefined); | ||
| reasoningId = undefined; | ||
| reasoningSignature = undefined; | ||
| } | ||
| lifecycle = Lifecycle.stepStart(lifecycle, events); | ||
@@ -581,2 +612,6 @@ events.push(LLMEvent.toolCall({ | ||
| textSignature, | ||
| reasoningId, | ||
| textId, | ||
| nextReasoningId, | ||
| nextTextId, | ||
| seenCallIds, | ||
@@ -608,2 +643,4 @@ finishReason: candidate.finishReason ?? nextState.finishReason, | ||
| lifecycle: Lifecycle.initial(), | ||
| nextReasoningId: 0, | ||
| nextTextId: 0, | ||
| }), | ||
@@ -610,0 +647,0 @@ step, |
+3
-3
| { | ||
| "$schema": "https://json.schemastore.org/package.json", | ||
| "version": "0.0.0-dev-18697", | ||
| "version": "0.0.0-dev-18698", | ||
| "name": "@opencode-ai/ai", | ||
@@ -33,3 +33,3 @@ "type": "module", | ||
| "@effect/platform-node": "4.0.0-rc.112", | ||
| "@opencode-ai/http-recorder": "0.0.0-dev-18697", | ||
| "@opencode-ai/http-recorder": "0.0.0-dev-18698", | ||
| "@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-18697", | ||
| "@opencode-ai/schema": "0.0.0-dev-18698", | ||
| "aws4fetch": "1.0.20", | ||
@@ -46,0 +46,0 @@ "effect": "4.0.0-rc.112", |
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.
1543180
0.1%35588
0.11%+ Added
- Removed