@monotykamary/pi-better-grok 0.3.6 → 0.3.7
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/index.ts +3 -0
- package/package.json +7 -6
- package/src/xai-models.ts +22 -12
package/index.ts
CHANGED
|
@@ -771,6 +771,9 @@ export default function betterGrok(pi: ExtensionAPI): void {
|
|
|
771
771
|
registerGrok47OnProviders(
|
|
772
772
|
(name, config) => pi.registerProvider(name, config),
|
|
773
773
|
getAll.call(registry),
|
|
774
|
+
typeof registry.getModelsOfType === "function"
|
|
775
|
+
? [...registry.getModelsOfType("image"), ...registry.getModelsOfType("classifier")]
|
|
776
|
+
: [],
|
|
774
777
|
);
|
|
775
778
|
} catch {
|
|
776
779
|
// Catalog registration must not break session startup.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monotykamary/pi-better-grok",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"description": "Improve Grok/xAI in pi with fast mode, subscription usage stats, banked reset redemption, multiprovider pools, footer polish, and settings — mirroring pi-better-openai.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"footer",
|
|
@@ -43,11 +43,12 @@
|
|
|
43
43
|
"lint": "oxlint --deny-warnings index.ts src/*.ts tests/*.ts",
|
|
44
44
|
"lint:fix": "oxlint --fix index.ts src/*.ts tests/*.ts",
|
|
45
45
|
"test": "vitest run",
|
|
46
|
-
"typecheck": "tsc --noEmit"
|
|
46
|
+
"typecheck": "tsc --noEmit",
|
|
47
|
+
"test:pi": "node scripts/test-pi-compat.mjs"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
|
-
"@earendil-works/pi-coding-agent": "0.
|
|
50
|
-
"@earendil-works/pi-tui": "0.
|
|
50
|
+
"@earendil-works/pi-coding-agent": "0.99.0",
|
|
51
|
+
"@earendil-works/pi-tui": "0.99.0",
|
|
51
52
|
"@types/node": "~22.19.0",
|
|
52
53
|
"oxfmt": "^0.47.0",
|
|
53
54
|
"oxlint": "^1.62.0",
|
|
@@ -59,8 +60,8 @@
|
|
|
59
60
|
"@earendil-works/pi-tui": "*"
|
|
60
61
|
},
|
|
61
62
|
"overrides": {
|
|
62
|
-
"@earendil-works/pi-agent-core": "0.
|
|
63
|
-
"@earendil-works/pi-ai": "0.
|
|
63
|
+
"@earendil-works/pi-agent-core": "0.99.0",
|
|
64
|
+
"@earendil-works/pi-ai": "0.99.0",
|
|
64
65
|
"brace-expansion": "5.0.9",
|
|
65
66
|
"nanoid": "3.3.18",
|
|
66
67
|
"postcss": "8.5.25",
|
package/src/xai-models.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import type { ProviderModelConfig } from "@earendil-works/pi-coding-agent";
|
|
4
4
|
|
|
5
|
+
type ProviderChatModelConfig = Extract<ProviderModelConfig, { type?: "chat" }>;
|
|
6
|
+
|
|
5
7
|
export const GROK_47_ID = "grok-4.7";
|
|
6
8
|
export const GROK_47_NAME = "Grok 4.7";
|
|
7
9
|
|
|
@@ -38,7 +40,7 @@ const GROK_47_THINKING_LEVEL_MAP = {
|
|
|
38
40
|
* Native xAI Grok 4.7, cloned from pi-core's grok-4.6 catalog plus the public
|
|
39
41
|
* 4.7 card. Used as an in-memory fallback when models.json cannot be updated.
|
|
40
42
|
*/
|
|
41
|
-
export const GROK_47_FALLBACK:
|
|
43
|
+
export const GROK_47_FALLBACK: ProviderChatModelConfig = {
|
|
42
44
|
id: GROK_47_ID,
|
|
43
45
|
name: GROK_47_NAME,
|
|
44
46
|
api: "openai-responses",
|
|
@@ -72,21 +74,21 @@ export const GROK_47_MODELS_JSON_DEFINITION = {
|
|
|
72
74
|
export type CatalogModel = {
|
|
73
75
|
id: string;
|
|
74
76
|
name: string;
|
|
75
|
-
api?:
|
|
77
|
+
api?: ProviderChatModelConfig["api"];
|
|
76
78
|
provider: string;
|
|
77
79
|
baseUrl?: string;
|
|
78
80
|
reasoning: boolean;
|
|
79
|
-
thinkingLevelMap?:
|
|
80
|
-
input:
|
|
81
|
-
cost:
|
|
82
|
-
promptCache?:
|
|
81
|
+
thinkingLevelMap?: ProviderChatModelConfig["thinkingLevelMap"];
|
|
82
|
+
input: ProviderChatModelConfig["input"];
|
|
83
|
+
cost: ProviderChatModelConfig["cost"];
|
|
84
|
+
promptCache?: ProviderChatModelConfig["promptCache"];
|
|
83
85
|
contextWindow: number;
|
|
84
86
|
maxTokens: number;
|
|
85
87
|
headers?: Record<string, string>;
|
|
86
|
-
compat?:
|
|
88
|
+
compat?: ProviderChatModelConfig["compat"];
|
|
87
89
|
};
|
|
88
90
|
|
|
89
|
-
export function catalogModelToProviderConfig(model: CatalogModel):
|
|
91
|
+
export function catalogModelToProviderConfig(model: CatalogModel): ProviderChatModelConfig {
|
|
90
92
|
return {
|
|
91
93
|
id: model.id,
|
|
92
94
|
name: model.name,
|
|
@@ -104,7 +106,7 @@ export function catalogModelToProviderConfig(model: CatalogModel): ProviderModel
|
|
|
104
106
|
};
|
|
105
107
|
}
|
|
106
108
|
|
|
107
|
-
export function grok47FromTemplate(template: CatalogModel | undefined):
|
|
109
|
+
export function grok47FromTemplate(template: CatalogModel | undefined): ProviderChatModelConfig {
|
|
108
110
|
if (!template) {
|
|
109
111
|
return {
|
|
110
112
|
...GROK_47_FALLBACK,
|
|
@@ -143,7 +145,9 @@ export function grok47FromTemplate(template: CatalogModel | undefined): Provider
|
|
|
143
145
|
* Return the existing models plus grok-4.7, or undefined when 4.7 is already present
|
|
144
146
|
* or the provider has nothing to layer onto.
|
|
145
147
|
*/
|
|
146
|
-
export function upsertGrok47(
|
|
148
|
+
export function upsertGrok47(
|
|
149
|
+
existing: readonly CatalogModel[],
|
|
150
|
+
): ProviderChatModelConfig[] | undefined {
|
|
147
151
|
if (existing.length === 0) return undefined;
|
|
148
152
|
if (existing.some((model) => model.id === GROK_47_ID)) return undefined;
|
|
149
153
|
const template =
|
|
@@ -153,7 +157,7 @@ export function upsertGrok47(existing: readonly CatalogModel[]): ProviderModelCo
|
|
|
153
157
|
return [...existing.map(catalogModelToProviderConfig), grok47FromTemplate(template)];
|
|
154
158
|
}
|
|
155
159
|
|
|
156
|
-
export type Grok47Registration = { provider: string; models:
|
|
160
|
+
export type Grok47Registration = { provider: string; models: ProviderChatModelConfig[] };
|
|
157
161
|
|
|
158
162
|
export function grok47Registrations(all: readonly CatalogModel[]): Grok47Registration[] {
|
|
159
163
|
const byProvider = new Map<string, CatalogModel[]>();
|
|
@@ -173,10 +177,16 @@ export function grok47Registrations(all: readonly CatalogModel[]): Grok47Registr
|
|
|
173
177
|
export function registerGrok47OnProviders(
|
|
174
178
|
registerProvider: (name: string, config: { models: ProviderModelConfig[] }) => void,
|
|
175
179
|
all: readonly CatalogModel[],
|
|
180
|
+
nonChat: readonly (Exclude<ProviderModelConfig, ProviderChatModelConfig> & {
|
|
181
|
+
provider: string;
|
|
182
|
+
})[] = [],
|
|
176
183
|
): string[] {
|
|
177
184
|
const registered: string[] = [];
|
|
178
185
|
for (const entry of grok47Registrations(all)) {
|
|
179
|
-
|
|
186
|
+
// Pi 0.99 replaces every operation when a legacy catalog is registered.
|
|
187
|
+
registerProvider(entry.provider, {
|
|
188
|
+
models: [...entry.models, ...nonChat.filter((model) => model.provider === entry.provider)],
|
|
189
|
+
});
|
|
180
190
|
registered.push(entry.provider);
|
|
181
191
|
}
|
|
182
192
|
return registered;
|