@opencode/ai 0.0.0-dev-20289 → 0.0.0-dev-20290
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.
|
@@ -8,6 +8,11 @@ import { Lifecycle } from "./utils/lifecycle.js";
|
|
|
8
8
|
import { ToolStream } from "./utils/tool-stream.js";
|
|
9
9
|
export declare const DEFAULT_BASE_URL = "https://api.mistral.ai/v1";
|
|
10
10
|
export declare const PATH = "/chat/completions";
|
|
11
|
+
declare const MistralThinkingUnit: Schema.StructWithRest<Schema.Struct<{
|
|
12
|
+
readonly type: Schema.optional<Schema.String>;
|
|
13
|
+
readonly text: Schema.optional<Schema.String>;
|
|
14
|
+
}>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>;
|
|
15
|
+
type MistralThinkingUnit = Schema.Schema.Type<typeof MistralThinkingUnit>;
|
|
11
16
|
declare const MistralThinkingContent: Schema.StructWithRest<Schema.Struct<{
|
|
12
17
|
readonly type: Schema.Literal<"thinking">;
|
|
13
18
|
readonly thinking: Schema.$Array<Schema.StructWithRest<Schema.Struct<{
|
|
@@ -212,6 +217,7 @@ interface ActiveContent {
|
|
|
212
217
|
readonly type: "text" | "reasoning";
|
|
213
218
|
readonly id: string;
|
|
214
219
|
readonly thinking?: MistralThinkingContent;
|
|
220
|
+
readonly thinkingUnits?: MistralThinkingUnit[];
|
|
215
221
|
}
|
|
216
222
|
export interface ParserState {
|
|
217
223
|
readonly tools: ToolStream.State<ToolKey>;
|
|
@@ -365,7 +365,7 @@ const closeActive = (state, events) => {
|
|
|
365
365
|
return state;
|
|
366
366
|
const lifecycle = state.active.type === "text"
|
|
367
367
|
? Lifecycle.textEnd(state.lifecycle, events, state.active.id)
|
|
368
|
-
: Lifecycle.reasoningEnd(state.lifecycle, events, state.active.id, thinkingMetadata(state.active.thinking
|
|
368
|
+
: Lifecycle.reasoningEnd(state.lifecycle, events, state.active.id, thinkingMetadata({ ...state.active.thinking, type: "thinking", thinking: state.active.thinkingUnits ?? [] }), thinkingText(state.active.thinkingUnits ?? []));
|
|
369
369
|
return { ...state, lifecycle, active: undefined };
|
|
370
370
|
};
|
|
371
371
|
const appendText = (state, events, text) => {
|
|
@@ -384,19 +384,22 @@ const appendThinking = (state, events, part) => {
|
|
|
384
384
|
const current = state.active?.type === "reasoning" ? state : closeActive(state, events);
|
|
385
385
|
const units = thinkingUnits(part.thinking);
|
|
386
386
|
const active = current.active ?? { type: "reasoning", id: `reasoning-${current.nextContent}` };
|
|
387
|
+
// Keep native units out of streamed events until the block is complete.
|
|
388
|
+
const accumulated = active.thinkingUnits ?? [];
|
|
389
|
+
accumulated.push(...units);
|
|
387
390
|
const thinking = {
|
|
388
391
|
...active.thinking,
|
|
389
392
|
...part,
|
|
390
393
|
type: "thinking",
|
|
391
|
-
thinking: [
|
|
394
|
+
thinking: [],
|
|
392
395
|
};
|
|
393
396
|
const text = thinkingText(units);
|
|
394
397
|
return {
|
|
395
398
|
...current,
|
|
396
399
|
lifecycle: text.length > 0
|
|
397
|
-
? Lifecycle.reasoningDelta(current.lifecycle, events, active.id, text
|
|
398
|
-
: Lifecycle.reasoningStart(current.lifecycle, events, active.id
|
|
399
|
-
active: { ...active, thinking },
|
|
400
|
+
? Lifecycle.reasoningDelta(current.lifecycle, events, active.id, text)
|
|
401
|
+
: Lifecycle.reasoningStart(current.lifecycle, events, active.id),
|
|
402
|
+
active: { ...active, thinking, thinkingUnits: accumulated },
|
|
400
403
|
nextContent: current.active ? current.nextContent : current.nextContent + 1,
|
|
401
404
|
};
|
|
402
405
|
};
|
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-20290",
|
|
4
4
|
"name": "@opencode/ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@clack/prompts": "1.0.0-alpha.1",
|
|
36
36
|
"@effect/platform-node": "4.0.0-rc.112",
|
|
37
|
-
"@opencode/http-recorder": "0.0.0-dev-
|
|
37
|
+
"@opencode/http-recorder": "0.0.0-dev-20290",
|
|
38
38
|
"@tsconfig/bun": "1.0.9",
|
|
39
39
|
"@types/bun": "1.4.0",
|
|
40
40
|
"@typescript/native-preview": "7.0.0-dev.20251207.1",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@aws-sdk/credential-providers": "3.1057.0",
|
|
45
45
|
"@smithy/eventstream-codec": "4.2.14",
|
|
46
46
|
"@smithy/util-utf8": "4.2.2",
|
|
47
|
-
"@opencode/schema": "0.0.0-dev-
|
|
47
|
+
"@opencode/schema": "0.0.0-dev-20290",
|
|
48
48
|
"aws4fetch": "1.0.20",
|
|
49
49
|
"effect": "4.0.0-rc.112",
|
|
50
50
|
"google-auth-library": "10.5.0"
|