@narumitw/pi-btw 0.49.3 → 0.49.5
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/package.json +1 -1
- package/src/btw.ts +10 -10
- package/src/side-thread.ts +2 -1
package/package.json
CHANGED
package/src/btw.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
clampThinkingLevel,
|
|
4
4
|
getSupportedThinkingLevels,
|
|
5
5
|
type Model,
|
|
6
|
+
type ProviderHeaders,
|
|
6
7
|
} from "@earendil-works/pi-ai";
|
|
7
8
|
import {
|
|
8
9
|
BorderedLoader,
|
|
@@ -76,15 +77,10 @@ interface LoadBtwThinkingLevelOptions {
|
|
|
76
77
|
warn?: (message: string) => void;
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
getApiKeyAndHeaders
|
|
82
|
-
|
|
83
|
-
): Promise<
|
|
84
|
-
| { ok: true; apiKey?: string; headers?: Record<string, string>; env?: Record<string, string> }
|
|
85
|
-
| { ok: false; error: string }
|
|
86
|
-
>;
|
|
87
|
-
}
|
|
80
|
+
type BtwModelRegistry = Pick<
|
|
81
|
+
ExtensionCommandContext["modelRegistry"],
|
|
82
|
+
"find" | "getApiKeyAndHeaders"
|
|
83
|
+
>;
|
|
88
84
|
|
|
89
85
|
interface ResolveBtwModelOptions {
|
|
90
86
|
settings: BtwSettings;
|
|
@@ -154,11 +150,15 @@ export async function resolveBtwModel({
|
|
|
154
150
|
function hasRequestAuth(auth: SideQuestionAuth): boolean {
|
|
155
151
|
return Boolean(
|
|
156
152
|
auth.apiKey ||
|
|
157
|
-
(auth.headers
|
|
153
|
+
providerHeadersHaveValue(auth.headers) ||
|
|
158
154
|
(auth.env && Object.keys(auth.env).length > 0),
|
|
159
155
|
);
|
|
160
156
|
}
|
|
161
157
|
|
|
158
|
+
function providerHeadersHaveValue(headers: ProviderHeaders | undefined): boolean {
|
|
159
|
+
return headers !== undefined && Object.values(headers).some((value) => value !== null);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
162
|
export async function loadBtwThinkingLevel(
|
|
163
163
|
currentThinkingLevel: BtwThinkingLevel,
|
|
164
164
|
options: LoadBtwThinkingLevelOptions = {},
|
package/src/side-thread.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
Context,
|
|
5
5
|
Message,
|
|
6
6
|
Model,
|
|
7
|
+
ProviderHeaders,
|
|
7
8
|
SimpleStreamOptions,
|
|
8
9
|
UserMessage,
|
|
9
10
|
} from "@earendil-works/pi-ai";
|
|
@@ -22,7 +23,7 @@ export type BtwThinkingLevel = (typeof BTW_THINKING_LEVELS)[number];
|
|
|
22
23
|
|
|
23
24
|
export interface SideQuestionAuth {
|
|
24
25
|
apiKey?: string;
|
|
25
|
-
headers?:
|
|
26
|
+
headers?: ProviderHeaders;
|
|
26
27
|
env?: Record<string, string>;
|
|
27
28
|
}
|
|
28
29
|
|