@aliou/pi-neuralwatt 0.19.1 → 0.19.2
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/CHANGELOG.md +6 -0
- package/dist/provider/index.js +35 -0
- package/extensions/command-quotas/components/quota-tabs.ts +1 -1
- package/extensions/command-quotas/components/quotas-display.ts +1 -1
- package/extensions/provider/commands/settings/api-base-url-editor.ts +1 -1
- package/package.json +3 -3
- package/src/models/public-models.ts +33 -0
- package/extensions/shared/truncate.ts +0 -292
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @aliou/pi-extension-template
|
|
2
2
|
|
|
3
|
+
## 0.19.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0c42dbd: Add Kimi K3.1 Pro and Kimi K3.1 Pro (flex) to the offline fallback model table (fixes #146). New Moonshot flagship family: 1M context, vision, reasoning efforts max/high/medium/low/none with `xhigh` → `max` and `minimal` → `low` aliases; flex variant priced at the 0.65 discount multiplier.
|
|
8
|
+
|
|
3
9
|
## 0.19.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/provider/index.js
CHANGED
|
@@ -507,6 +507,41 @@ const NEURALWATT_MODELS = [
|
|
|
507
507
|
costMultiplier: .65
|
|
508
508
|
}
|
|
509
509
|
]],
|
|
510
|
+
[{
|
|
511
|
+
cost: {
|
|
512
|
+
input: 2,
|
|
513
|
+
output: 10,
|
|
514
|
+
cacheRead: .2
|
|
515
|
+
},
|
|
516
|
+
vision: true,
|
|
517
|
+
reasoningMetadata: {
|
|
518
|
+
supported_efforts: [
|
|
519
|
+
"max",
|
|
520
|
+
"high",
|
|
521
|
+
"medium",
|
|
522
|
+
"low",
|
|
523
|
+
"none"
|
|
524
|
+
],
|
|
525
|
+
mandatory: false,
|
|
526
|
+
effort_aliases: {
|
|
527
|
+
xhigh: "max",
|
|
528
|
+
minimal: "low"
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}, [{
|
|
532
|
+
id: "kimi-k3.1-pro",
|
|
533
|
+
name: "Kimi K3.1 Pro",
|
|
534
|
+
contextWindow: 1048560,
|
|
535
|
+
maxOutputTokens: null,
|
|
536
|
+
reasoning: true
|
|
537
|
+
}, {
|
|
538
|
+
id: "kimi-k3.1-pro-flex",
|
|
539
|
+
name: "Kimi K3.1 Pro (flex)",
|
|
540
|
+
contextWindow: 1048560,
|
|
541
|
+
maxOutputTokens: null,
|
|
542
|
+
reasoning: true,
|
|
543
|
+
costMultiplier: .65
|
|
544
|
+
}]],
|
|
510
545
|
[{
|
|
511
546
|
cost: {
|
|
512
547
|
input: .435,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { truncateToWidth } from "@aliou/pi-utils-ui";
|
|
1
2
|
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
2
3
|
import type { NeuralwattQuotas } from "../../../src/types/quota-api";
|
|
3
4
|
import {
|
|
@@ -10,7 +11,6 @@ import {
|
|
|
10
11
|
formatTokens,
|
|
11
12
|
formatUsd,
|
|
12
13
|
} from "../../../src/utils/quota-format";
|
|
13
|
-
import { truncateToWidth } from "../../shared/truncate";
|
|
14
14
|
import { renderProgressBar } from "./progress-bar";
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { truncateToWidth } from "@aliou/pi-utils-ui";
|
|
1
2
|
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
2
3
|
import { DynamicBorder } from "@earendil-works/pi-coding-agent";
|
|
3
4
|
import type { Component, TUI } from "@earendil-works/pi-tui";
|
|
4
5
|
import { Loader, matchesKey } from "@earendil-works/pi-tui";
|
|
5
6
|
import type { NeuralwattQuotas } from "../../../src/types/quota-api";
|
|
6
|
-
import { truncateToWidth } from "../../shared/truncate";
|
|
7
7
|
import {
|
|
8
8
|
renderCreditsTab,
|
|
9
9
|
renderSubscriptionTab,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { truncateToWidth } from "@aliou/pi-utils-ui";
|
|
1
2
|
import type { Component, SettingsListTheme } from "@earendil-works/pi-tui";
|
|
2
3
|
import { Input, Key, matchesKey } from "@earendil-works/pi-tui";
|
|
3
|
-
import { truncateToWidth } from "../../../shared/truncate";
|
|
4
4
|
|
|
5
5
|
export interface ApiBaseUrlEditorOptions {
|
|
6
6
|
initial: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aliou/pi-neuralwatt",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@aliou/pi-utils-settings": "^0.24.0",
|
|
46
|
-
"@aliou/pi-utils-ui": "^0.
|
|
46
|
+
"@aliou/pi-utils-ui": "^0.6.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"@earendil-works/pi-ai": "1.5.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"typebox": "*"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@aliou/biome-plugins": "^0.
|
|
55
|
+
"@aliou/biome-plugins": "^0.18.1",
|
|
56
56
|
"@biomejs/biome": "^2.6.4",
|
|
57
57
|
"@changesets/cli": "^2.27.11",
|
|
58
58
|
"@earendil-works/pi-ai": "1.5.0",
|
|
@@ -88,6 +88,19 @@ const KIMI_K3: NeuralwattModelFamily = {
|
|
|
88
88
|
},
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
+
// MoonshotAI. K3.1 Pro is a separate flagship from K3: cheaper, multimodal
|
|
92
|
+
// with a broader effort contract (max/high/medium/low/none, default max),
|
|
93
|
+
// aliasing `xhigh` to `max` and `minimal` to `low`.
|
|
94
|
+
const KIMI_K3_1_PRO: NeuralwattModelFamily = {
|
|
95
|
+
cost: { input: 2, output: 10, cacheRead: 0.2 },
|
|
96
|
+
vision: true,
|
|
97
|
+
reasoningMetadata: {
|
|
98
|
+
supported_efforts: ["max", "high", "medium", "low", "none"],
|
|
99
|
+
mandatory: false,
|
|
100
|
+
effort_aliases: { xhigh: "max", minimal: "low" },
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
|
|
91
104
|
// Xiaomi. MiMo-V2.6-Pro only has two reasoning behaviors: `high` (default)
|
|
92
105
|
// and `none`; the API aliases every other effort onto those, with `minimal`
|
|
93
106
|
// landing on `none`.
|
|
@@ -281,6 +294,26 @@ const FAMILIES: [NeuralwattModelFamily, NeuralwattVariantSpec[]][] = [
|
|
|
281
294
|
},
|
|
282
295
|
],
|
|
283
296
|
],
|
|
297
|
+
[
|
|
298
|
+
KIMI_K3_1_PRO,
|
|
299
|
+
[
|
|
300
|
+
{
|
|
301
|
+
id: "kimi-k3.1-pro",
|
|
302
|
+
name: "Kimi K3.1 Pro",
|
|
303
|
+
contextWindow: 1048560,
|
|
304
|
+
maxOutputTokens: null,
|
|
305
|
+
reasoning: true,
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
id: "kimi-k3.1-pro-flex",
|
|
309
|
+
name: "Kimi K3.1 Pro (flex)",
|
|
310
|
+
contextWindow: 1048560,
|
|
311
|
+
maxOutputTokens: null,
|
|
312
|
+
reasoning: true,
|
|
313
|
+
costMultiplier: 0.65,
|
|
314
|
+
},
|
|
315
|
+
],
|
|
316
|
+
],
|
|
284
317
|
[
|
|
285
318
|
MIMO_V2_6_PRO,
|
|
286
319
|
[
|
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
import { visibleWidth } from "@earendil-works/pi-tui";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Truncate text to `maxWidth` display cells, appending `ellipsis` when text
|
|
5
|
-
* overflows. Unlike `truncateToWidth` from `@earendil-works/pi-tui`, this
|
|
6
|
-
* never injects resets (so caller-applied styling survives truncation) and
|
|
7
|
-
* its CSI parser accepts every escape sequence final, so non-SGR sequences
|
|
8
|
-
* neither swallow visible text nor skew the measured width.
|
|
9
|
-
*/
|
|
10
|
-
export function truncateToWidth(
|
|
11
|
-
text: string,
|
|
12
|
-
maxWidth: number,
|
|
13
|
-
ellipsis = "…",
|
|
14
|
-
pad = false,
|
|
15
|
-
): string {
|
|
16
|
-
if (maxWidth <= 0) return "";
|
|
17
|
-
if (text.length === 0) return pad ? " ".repeat(maxWidth) : "";
|
|
18
|
-
|
|
19
|
-
const ellipsisWidth = visibleWidth(ellipsis);
|
|
20
|
-
if (ellipsisWidth >= maxWidth) {
|
|
21
|
-
const textWidth = visibleWidth(text);
|
|
22
|
-
if (textWidth <= maxWidth) {
|
|
23
|
-
return pad ? text + " ".repeat(maxWidth - textWidth) : text;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const clippedEllipsis = truncateFragmentToWidth(ellipsis, maxWidth);
|
|
27
|
-
if (clippedEllipsis.width === 0) {
|
|
28
|
-
return pad ? " ".repeat(maxWidth) : "";
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return finalizeTruncatedResult(
|
|
32
|
-
"",
|
|
33
|
-
0,
|
|
34
|
-
clippedEllipsis.text,
|
|
35
|
-
clippedEllipsis.width,
|
|
36
|
-
maxWidth,
|
|
37
|
-
pad,
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (isPrintableAscii(text)) {
|
|
42
|
-
if (text.length <= maxWidth) {
|
|
43
|
-
return pad ? text + " ".repeat(maxWidth - text.length) : text;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const targetWidth = maxWidth - ellipsisWidth;
|
|
47
|
-
return finalizeTruncatedResult(
|
|
48
|
-
text.slice(0, targetWidth),
|
|
49
|
-
targetWidth,
|
|
50
|
-
ellipsis,
|
|
51
|
-
ellipsisWidth,
|
|
52
|
-
maxWidth,
|
|
53
|
-
pad,
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const targetWidth = maxWidth - ellipsisWidth;
|
|
58
|
-
let result = "";
|
|
59
|
-
let visibleSoFar = 0;
|
|
60
|
-
let keptWidth = 0;
|
|
61
|
-
let keepContiguousPrefix = true;
|
|
62
|
-
let overflowed = false;
|
|
63
|
-
let exhaustedInput = false;
|
|
64
|
-
const hasAnsi = text.includes("\u001b");
|
|
65
|
-
const hasTabs = text.includes("\t");
|
|
66
|
-
|
|
67
|
-
if (!hasAnsi && !hasTabs) {
|
|
68
|
-
for (const { segment } of segmenter.segment(text)) {
|
|
69
|
-
const width = visibleWidth(segment);
|
|
70
|
-
if (keepContiguousPrefix && keptWidth + width <= targetWidth) {
|
|
71
|
-
result += segment;
|
|
72
|
-
keptWidth += width;
|
|
73
|
-
} else {
|
|
74
|
-
keepContiguousPrefix = false;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
visibleSoFar += width;
|
|
78
|
-
if (visibleSoFar > maxWidth) {
|
|
79
|
-
overflowed = true;
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
exhaustedInput = !overflowed;
|
|
84
|
-
} else {
|
|
85
|
-
let index = 0;
|
|
86
|
-
let pendingAnsi = "";
|
|
87
|
-
while (index < text.length) {
|
|
88
|
-
const ansi = readAnsiSequence(text, index);
|
|
89
|
-
if (ansi) {
|
|
90
|
-
pendingAnsi += ansi;
|
|
91
|
-
index += ansi.length;
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (text[index] === "\t") {
|
|
96
|
-
if (keepContiguousPrefix && keptWidth + 3 <= targetWidth) {
|
|
97
|
-
if (pendingAnsi) {
|
|
98
|
-
result += pendingAnsi;
|
|
99
|
-
pendingAnsi = "";
|
|
100
|
-
}
|
|
101
|
-
result += "\t";
|
|
102
|
-
keptWidth += 3;
|
|
103
|
-
} else {
|
|
104
|
-
keepContiguousPrefix = false;
|
|
105
|
-
pendingAnsi = "";
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
visibleSoFar += 3;
|
|
109
|
-
if (visibleSoFar > maxWidth) {
|
|
110
|
-
overflowed = true;
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
index++;
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
let end = index;
|
|
118
|
-
while (end < text.length && text[end] !== "\t") {
|
|
119
|
-
const nextAnsi = readAnsiSequence(text, end);
|
|
120
|
-
if (nextAnsi) break;
|
|
121
|
-
end++;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
for (const { segment } of segmenter.segment(text.slice(index, end))) {
|
|
125
|
-
const width = visibleWidth(segment);
|
|
126
|
-
if (keepContiguousPrefix && keptWidth + width <= targetWidth) {
|
|
127
|
-
if (pendingAnsi) {
|
|
128
|
-
result += pendingAnsi;
|
|
129
|
-
pendingAnsi = "";
|
|
130
|
-
}
|
|
131
|
-
result += segment;
|
|
132
|
-
keptWidth += width;
|
|
133
|
-
} else {
|
|
134
|
-
keepContiguousPrefix = false;
|
|
135
|
-
pendingAnsi = "";
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
visibleSoFar += width;
|
|
139
|
-
if (visibleSoFar > maxWidth) {
|
|
140
|
-
overflowed = true;
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (overflowed) break;
|
|
146
|
-
index = end;
|
|
147
|
-
}
|
|
148
|
-
exhaustedInput = index >= text.length;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (!overflowed && exhaustedInput) {
|
|
152
|
-
return pad ? text + " ".repeat(Math.max(0, maxWidth - visibleSoFar)) : text;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return finalizeTruncatedResult(
|
|
156
|
-
result,
|
|
157
|
-
keptWidth,
|
|
158
|
-
ellipsis,
|
|
159
|
-
ellipsisWidth,
|
|
160
|
-
maxWidth,
|
|
161
|
-
pad,
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const segmenter = new Intl.Segmenter(undefined, { granularity: "grapheme" });
|
|
166
|
-
|
|
167
|
-
function isPrintableAscii(text: string): boolean {
|
|
168
|
-
for (let index = 0; index < text.length; index++) {
|
|
169
|
-
const code = text.charCodeAt(index);
|
|
170
|
-
if (code < 0x20 || code > 0x7e) return false;
|
|
171
|
-
}
|
|
172
|
-
return true;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function truncateFragmentToWidth(
|
|
176
|
-
text: string,
|
|
177
|
-
maxWidth: number,
|
|
178
|
-
): { text: string; width: number } {
|
|
179
|
-
if (maxWidth <= 0 || text.length === 0) {
|
|
180
|
-
return { text: "", width: 0 };
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (isPrintableAscii(text)) {
|
|
184
|
-
const clipped = text.slice(0, maxWidth);
|
|
185
|
-
return { text: clipped, width: clipped.length };
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const hasAnsi = text.includes("\u001b");
|
|
189
|
-
const hasTabs = text.includes("\t");
|
|
190
|
-
if (!hasAnsi && !hasTabs) {
|
|
191
|
-
let result = "";
|
|
192
|
-
let width = 0;
|
|
193
|
-
|
|
194
|
-
for (const { segment } of segmenter.segment(text)) {
|
|
195
|
-
const segmentWidth = visibleWidth(segment);
|
|
196
|
-
if (width + segmentWidth > maxWidth) break;
|
|
197
|
-
result += segment;
|
|
198
|
-
width += segmentWidth;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
return { text: result, width };
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
let result = "";
|
|
205
|
-
let width = 0;
|
|
206
|
-
let index = 0;
|
|
207
|
-
let pendingAnsi = "";
|
|
208
|
-
|
|
209
|
-
while (index < text.length) {
|
|
210
|
-
const ansi = readAnsiSequence(text, index);
|
|
211
|
-
if (ansi) {
|
|
212
|
-
pendingAnsi += ansi;
|
|
213
|
-
index += ansi.length;
|
|
214
|
-
continue;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
if (text[index] === "\t") {
|
|
218
|
-
if (width + 3 > maxWidth) break;
|
|
219
|
-
if (pendingAnsi) {
|
|
220
|
-
result += pendingAnsi;
|
|
221
|
-
pendingAnsi = "";
|
|
222
|
-
}
|
|
223
|
-
result += "\t";
|
|
224
|
-
width += 3;
|
|
225
|
-
index++;
|
|
226
|
-
continue;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
let end = index;
|
|
230
|
-
while (end < text.length && text[end] !== "\t") {
|
|
231
|
-
const nextAnsi = readAnsiSequence(text, end);
|
|
232
|
-
if (nextAnsi) break;
|
|
233
|
-
end++;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
for (const { segment } of segmenter.segment(text.slice(index, end))) {
|
|
237
|
-
const segmentWidth = visibleWidth(segment);
|
|
238
|
-
if (width + segmentWidth > maxWidth) {
|
|
239
|
-
return { text: result, width };
|
|
240
|
-
}
|
|
241
|
-
if (pendingAnsi) {
|
|
242
|
-
result += pendingAnsi;
|
|
243
|
-
pendingAnsi = "";
|
|
244
|
-
}
|
|
245
|
-
result += segment;
|
|
246
|
-
width += segmentWidth;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
index = end;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
return { text: result, width };
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function finalizeTruncatedResult(
|
|
256
|
-
prefix: string,
|
|
257
|
-
prefixWidth: number,
|
|
258
|
-
ellipsis: string,
|
|
259
|
-
ellipsisWidth: number,
|
|
260
|
-
maxWidth: number,
|
|
261
|
-
pad: boolean,
|
|
262
|
-
): string {
|
|
263
|
-
const width = prefixWidth + ellipsisWidth;
|
|
264
|
-
const result = ellipsis.length > 0 ? `${prefix}${ellipsis}` : prefix;
|
|
265
|
-
return pad ? result + " ".repeat(Math.max(0, maxWidth - width)) : result;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
function readAnsiSequence(text: string, index: number): string | null {
|
|
269
|
-
const ESCAPE = "\u001b";
|
|
270
|
-
if (text[index] !== ESCAPE) return null;
|
|
271
|
-
|
|
272
|
-
const next = text[index + 1];
|
|
273
|
-
if (next === "[") {
|
|
274
|
-
const code = text.slice(index);
|
|
275
|
-
const pattern = new RegExp(`^${ESCAPE}\\[[0-?]*[ -/]*[@-~]`, "u");
|
|
276
|
-
const match = code.match(pattern);
|
|
277
|
-
return match?.[0] ?? text[index];
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
if (next === "]" || next === "_") {
|
|
281
|
-
const rest = text.slice(index);
|
|
282
|
-
const bel = rest.indexOf("\u0007");
|
|
283
|
-
const st = rest.indexOf("\u001b\\");
|
|
284
|
-
const end = [bel, st]
|
|
285
|
-
.filter((value) => value >= 0)
|
|
286
|
-
.sort((a, b) => a - b)[0];
|
|
287
|
-
if (end === undefined) return text[index];
|
|
288
|
-
return rest.slice(0, end + (end === st ? 2 : 1));
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
return text.slice(index, Math.min(index + 2, text.length));
|
|
292
|
-
}
|