@opencode-ai/ai 0.0.0-dev-17518 → 0.0.0-dev-17545
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.d.ts +6 -0
- package/dist/protocols/gemini.js +26 -16
- package/package.json +3 -3
|
@@ -210,6 +210,12 @@ export declare const protocol: Protocol<{
|
|
|
210
210
|
} | undefined;
|
|
211
211
|
readonly finishReason?: string | undefined;
|
|
212
212
|
}[] | undefined;
|
|
213
|
+
readonly promptFeedback?: {
|
|
214
|
+
readonly [x: string]: unknown;
|
|
215
|
+
readonly blockReason?: string | undefined;
|
|
216
|
+
readonly blockReasonMessage?: string | undefined;
|
|
217
|
+
readonly safetyRatings?: unknown;
|
|
218
|
+
} | undefined;
|
|
213
219
|
readonly usageMetadata?: {
|
|
214
220
|
readonly cachedContentTokenCount?: number | undefined;
|
|
215
221
|
readonly thoughtsTokenCount?: number | undefined;
|
package/dist/protocols/gemini.js
CHANGED
|
@@ -125,8 +125,14 @@ const GeminiCandidate = Schema.Struct({
|
|
|
125
125
|
content: Schema.optional(GeminiContent),
|
|
126
126
|
finishReason: Schema.optional(Schema.String),
|
|
127
127
|
});
|
|
128
|
+
const GeminiPromptFeedback = Schema.StructWithRest(Schema.Struct({
|
|
129
|
+
blockReason: Schema.optional(Schema.String),
|
|
130
|
+
blockReasonMessage: Schema.optional(Schema.String),
|
|
131
|
+
safetyRatings: Schema.optional(Schema.Unknown),
|
|
132
|
+
}), [Schema.Record(Schema.String, Schema.Unknown)]);
|
|
128
133
|
const GeminiEvent = Schema.Struct({
|
|
129
134
|
candidates: optionalArray(GeminiCandidate),
|
|
135
|
+
promptFeedback: Schema.optional(GeminiPromptFeedback),
|
|
130
136
|
usageMetadata: Schema.optional(GeminiUsage),
|
|
131
137
|
});
|
|
132
138
|
// =============================================================================
|
|
@@ -401,25 +407,29 @@ const mapFinishReason = (finishReason, hasToolCalls) => {
|
|
|
401
407
|
return "error";
|
|
402
408
|
return "unknown";
|
|
403
409
|
};
|
|
404
|
-
const finish = (state) =>
|
|
405
|
-
?
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
410
|
+
const finish = (state) => {
|
|
411
|
+
const promptBlockReason = state.finishReason === undefined ? state.promptFeedback?.blockReason : undefined;
|
|
412
|
+
const finishReason = state.finishReason ?? promptBlockReason;
|
|
413
|
+
if (finishReason === undefined && state.usage === undefined)
|
|
414
|
+
return [];
|
|
415
|
+
const events = [];
|
|
416
|
+
const lifecycle = state.reasoningSignature
|
|
417
|
+
? Lifecycle.reasoningEnd(state.lifecycle, events, "reasoning-0", googleMetadata({ thoughtSignature: state.reasoningSignature }))
|
|
418
|
+
: state.lifecycle;
|
|
419
|
+
Lifecycle.finish(lifecycle, events, {
|
|
420
|
+
reason: {
|
|
421
|
+
normalized: promptBlockReason === undefined ? mapFinishReason(finishReason, state.hasToolCalls) : "content-filter",
|
|
422
|
+
raw: finishReason,
|
|
423
|
+
},
|
|
424
|
+
usage: state.usage,
|
|
425
|
+
providerMetadata: state.promptFeedback === undefined ? undefined : googleMetadata({ promptFeedback: state.promptFeedback }),
|
|
426
|
+
});
|
|
427
|
+
return events;
|
|
428
|
+
};
|
|
420
429
|
const step = (state, event) => {
|
|
421
430
|
const nextState = {
|
|
422
431
|
...state,
|
|
432
|
+
promptFeedback: event.promptFeedback ?? state.promptFeedback,
|
|
423
433
|
usage: event.usageMetadata ? (mapUsage(event.usageMetadata) ?? state.usage) : state.usage,
|
|
424
434
|
};
|
|
425
435
|
const candidate = event.candidates?.[0];
|
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-17545",
|
|
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-beta.101",
|
|
33
|
-
"@opencode-ai/http-recorder": "0.0.0-dev-
|
|
33
|
+
"@opencode-ai/http-recorder": "0.0.0-dev-17545",
|
|
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-17545",
|
|
43
43
|
"aws4fetch": "1.0.20",
|
|
44
44
|
"effect": "4.0.0-beta.101",
|
|
45
45
|
"google-auth-library": "10.5.0"
|