@evandu/super-pi 0.1.245 → 0.1.247
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/agents/super-pi-task/index.ts +7 -58
- package/agents/super-pi-task/workflow-schema.ts +34 -0
- package/dist/client/.super-pi-client-sources.json +6 -5
- package/dist/client/assets/{CodeMirrorEditor-DXz3TlpL.js → CodeMirrorEditor-CfRZBw_k.js} +1 -1
- package/dist/client/assets/{GitDiffEditor-8bvWRIwo.js → GitDiffEditor-CxVEErgk.js} +1 -1
- package/dist/client/assets/{index-CU4rNgq5.js → index-D-5yq-Mj.js} +13 -13
- package/dist/client/assets/index-oGFfK21_.css +1 -0
- package/dist/client/index.html +2 -2
- package/dist/server/application/conversation-service.js +5 -0
- package/dist/server/application/workspace-service.d.ts +2 -0
- package/dist/server/application/workspace-service.js +57 -5
- package/dist/server/command-handler.js +7 -0
- package/dist/server/runtime.js +4 -1
- package/dist/server/store.d.ts +5 -0
- package/dist/server/store.js +41 -0
- package/dist/server/thinking-level-discovery.js +25 -1
- package/dist/server/types.d.ts +10 -0
- package/package.json +1 -1
- package/dist/.super-pi-check-inputs.json +0 -4
- package/dist/client/assets/index-E2qh6Qge.css +0 -1
package/dist/client/index.html
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
<link rel="alternate icon" href="/favicon.ico" />
|
|
9
9
|
<link rel="apple-touch-icon" href="/favicon.svg" />
|
|
10
10
|
<title>Super Pi</title>
|
|
11
|
-
<script type="module" crossorigin src="/assets/index-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-D-5yq-Mj.js"></script>
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-XKyaHtl9.js">
|
|
13
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
13
|
+
<link rel="stylesheet" crossorigin href="/assets/index-oGFfK21_.css">
|
|
14
14
|
</head>
|
|
15
15
|
<body>
|
|
16
16
|
<div id="root"></div>
|
|
@@ -309,6 +309,7 @@ export class ConversationService {
|
|
|
309
309
|
* Sets the active model on a conversation, validating against Pi's catalog.
|
|
310
310
|
*/
|
|
311
311
|
async setModel(conversationId, provider, modelId) {
|
|
312
|
+
const previous = this.store.conversation(conversationId);
|
|
312
313
|
const catalog = await this.runtime.catalog();
|
|
313
314
|
const option = catalog.source === "pi"
|
|
314
315
|
? catalog.models.find((model) => model.provider === provider && model.modelId === modelId)
|
|
@@ -324,6 +325,10 @@ export class ConversationService {
|
|
|
324
325
|
throw new Error("找不到这个工作区。");
|
|
325
326
|
assertModelAllowed(this.store.modelFilterRules(), workspace, selection);
|
|
326
327
|
await this.store.setConversationModel(conversationId, selection);
|
|
328
|
+
const thinking = await this.runtime.catalog(selection);
|
|
329
|
+
if (thinking.source === "pi" && previous?.thinkingLevel && !thinking.levels.includes(previous.thinkingLevel)) {
|
|
330
|
+
await this.store.setConversationThinking(conversationId, undefined);
|
|
331
|
+
}
|
|
327
332
|
this.broadcaster.broadcastState();
|
|
328
333
|
await this.catalogService.broadcastCatalog(selection, conversationId);
|
|
329
334
|
}
|
|
@@ -47,4 +47,6 @@ export declare class WorkspaceService {
|
|
|
47
47
|
* Updates workspace default settings (model, thinking level, default agent).
|
|
48
48
|
*/
|
|
49
49
|
updateSettings(workspaceId: string, settings: WorkspaceSettingsUpdate): Promise<void>;
|
|
50
|
+
/** Validates once for every mounted workspace, then persists the shared defaults in one write. */
|
|
51
|
+
updateMountedWorkspaceSettings(settings: Pick<WorkspaceSettingsUpdate, "model" | "thinkingLevel">): Promise<number>;
|
|
50
52
|
}
|
|
@@ -80,10 +80,20 @@ export class WorkspaceService {
|
|
|
80
80
|
? { provider: option.provider, modelId: option.modelId, label: option.label }
|
|
81
81
|
: { provider: requested.provider, modelId: requested.modelId, label: requested.modelId };
|
|
82
82
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
let thinkingLevel = settings.thinkingLevel ?? undefined;
|
|
84
|
+
if (thinkingLevel) {
|
|
85
|
+
const modelChanged = settings.model !== undefined && (selection?.provider !== workspace.defaultModel?.provider ||
|
|
86
|
+
selection?.modelId !== workspace.defaultModel?.modelId);
|
|
87
|
+
const targetModel = settings.model === null ? undefined : selection ?? workspace.defaultModel;
|
|
88
|
+
const catalog = await this.runtime.catalog(targetModel);
|
|
89
|
+
if (catalog.source === "pi" && !catalog.levels.includes(thinkingLevel)) {
|
|
90
|
+
if (modelChanged) {
|
|
91
|
+
// A saved thinking level belongs to its model; switching models follows Pi's own default.
|
|
92
|
+
thinkingLevel = undefined;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
throw this.catalogService.notOffered(`思考等级 ${thinkingLevel}`, catalog);
|
|
96
|
+
}
|
|
87
97
|
}
|
|
88
98
|
}
|
|
89
99
|
let agentToStore;
|
|
@@ -126,9 +136,51 @@ export class WorkspaceService {
|
|
|
126
136
|
assertModelAllowed(this.store.modelFilterRules(), workspace, selection);
|
|
127
137
|
await this.store.setWorkspaceDefaults(workspaceId, {
|
|
128
138
|
model: selection,
|
|
129
|
-
thinkingLevel
|
|
139
|
+
thinkingLevel,
|
|
130
140
|
agentId: agentToStore,
|
|
131
141
|
});
|
|
132
142
|
this.broadcaster.broadcastState();
|
|
133
143
|
}
|
|
144
|
+
/** Validates once for every mounted workspace, then persists the shared defaults in one write. */
|
|
145
|
+
async updateMountedWorkspaceSettings(settings) {
|
|
146
|
+
const workspaces = this.store.snapshot().workspaces.filter((item) => !item.closedAt);
|
|
147
|
+
if (!workspaces.length)
|
|
148
|
+
throw new Error("没有可更新的工作区。");
|
|
149
|
+
let selection;
|
|
150
|
+
if (settings.model) {
|
|
151
|
+
const available = await this.runtime.catalog();
|
|
152
|
+
const option = available.source === "pi"
|
|
153
|
+
? available.models.find((model) => model.provider === settings.model?.provider && model.modelId === settings.model?.modelId)
|
|
154
|
+
: undefined;
|
|
155
|
+
if (available.source === "pi" && !option) {
|
|
156
|
+
throw this.catalogService.notOffered(`模型 ${settings.model.provider}/${settings.model.modelId}`, available);
|
|
157
|
+
}
|
|
158
|
+
selection = option
|
|
159
|
+
? { provider: option.provider, modelId: option.modelId, label: option.label }
|
|
160
|
+
: { provider: settings.model.provider, modelId: settings.model.modelId, label: settings.model.modelId };
|
|
161
|
+
}
|
|
162
|
+
const thinkingLevel = settings.thinkingLevel ?? undefined;
|
|
163
|
+
if (thinkingLevel) {
|
|
164
|
+
if (!selection)
|
|
165
|
+
throw new Error("请先选择具体模型,再设置思考等级。");
|
|
166
|
+
const modelCatalog = await this.runtime.catalog(selection);
|
|
167
|
+
if (modelCatalog.source === "pi" && !modelCatalog.levels.includes(thinkingLevel)) {
|
|
168
|
+
throw this.catalogService.notOffered(`思考等级 ${thinkingLevel}`, modelCatalog);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (selection) {
|
|
172
|
+
for (const workspace of workspaces) {
|
|
173
|
+
try {
|
|
174
|
+
assertModelAllowed(this.store.snapshot().modelFilterRules, workspace, selection);
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
178
|
+
throw new Error(`无法批量修改:工作区「${workspace.name}」不允许该模型。${detail}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const updated = await this.store.setMountedWorkspaceDefaults({ model: selection, thinkingLevel });
|
|
183
|
+
this.broadcaster.broadcastState();
|
|
184
|
+
return updated;
|
|
185
|
+
}
|
|
134
186
|
}
|
|
@@ -176,6 +176,13 @@ export class CommandHandler {
|
|
|
176
176
|
});
|
|
177
177
|
return;
|
|
178
178
|
}
|
|
179
|
+
if (command.type === "workspaces.settings.bulk") {
|
|
180
|
+
await this.workspaceService.updateMountedWorkspaceSettings({
|
|
181
|
+
model: command.model,
|
|
182
|
+
thinkingLevel: command.thinkingLevel,
|
|
183
|
+
});
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
179
186
|
if (command.type === "conversation.create") {
|
|
180
187
|
return await this.conversationService.createConversation(command.workspaceId, undefined, command.cwd);
|
|
181
188
|
}
|
package/dist/server/runtime.js
CHANGED
|
@@ -34,6 +34,7 @@ import { loadConversationImages } from "./upload.js";
|
|
|
34
34
|
import { describeToolCall, describeToolCallArgs, describeToolCallInProgress, extractPartialResultText, extractToolResultText, readQuestionCall } from "./tool-calls.js";
|
|
35
35
|
import { InlineThinkingSplitter, stripInlineThinking } from "./inline-thinking.js";
|
|
36
36
|
import { toolTargetPath } from "./file-changes.js";
|
|
37
|
+
import { offeredThinkingLevels, readThinkingLevelMap } from "../shared/thinking-levels.js";
|
|
37
38
|
const traceLatency = (conversationId, phase, startedAt, extra = "") => {
|
|
38
39
|
if (process.env.SUPER_PI_TRACE_LATENCY !== "1")
|
|
39
40
|
return;
|
|
@@ -3231,7 +3232,9 @@ export function describeModel(value) {
|
|
|
3231
3232
|
// check is here because this runs against a field read off the wire from a process that does no
|
|
3232
3233
|
// validation of its own.
|
|
3233
3234
|
const input = Array.isArray(model.input) ? model.input.filter((value) => typeof value === "string") : [];
|
|
3234
|
-
|
|
3235
|
+
const thinkingLevelMap = readThinkingLevelMap(model.thinkingLevelMap);
|
|
3236
|
+
const thinkingLevels = thinkingLevelMap ? offeredThinkingLevels(thinkingLevelMap) : undefined;
|
|
3237
|
+
return { provider: model.provider, modelId: model.id, label, detail: `${model.provider}/${model.id}`, reasoning: model.reasoning === true, contextWindow: typeof model.contextWindow === "number" ? model.contextWindow : 0, maxTokens: typeof model.maxTokens === "number" ? model.maxTokens : 0, imageInput: input.includes("image"), ...(thinkingLevels ? { thinkingLevels } : {}) };
|
|
3235
3238
|
}
|
|
3236
3239
|
export function describeModels(value) {
|
|
3237
3240
|
if (!Array.isArray(value))
|
package/dist/server/store.d.ts
CHANGED
|
@@ -254,6 +254,11 @@ export declare class Store {
|
|
|
254
254
|
thinkingLevel?: string;
|
|
255
255
|
agentId?: string | null;
|
|
256
256
|
}): Promise<Workspace>;
|
|
257
|
+
/** Applies the shared model defaults to every mounted workspace and writes them together. */
|
|
258
|
+
setMountedWorkspaceDefaults(defaults: {
|
|
259
|
+
model?: ModelSelection;
|
|
260
|
+
thinkingLevel?: string;
|
|
261
|
+
}): Promise<number>;
|
|
257
262
|
/**
|
|
258
263
|
* TAKES A WORKSPACE OUT OF THE SIDEBAR. IT DOES NOT DELETE ANYTHING.
|
|
259
264
|
*
|
package/dist/server/store.js
CHANGED
|
@@ -1264,6 +1264,47 @@ export class Store {
|
|
|
1264
1264
|
await this.persist();
|
|
1265
1265
|
return structuredClone(workspace);
|
|
1266
1266
|
}
|
|
1267
|
+
/** Applies the shared model defaults to every mounted workspace and writes them together. */
|
|
1268
|
+
async setMountedWorkspaceDefaults(defaults) {
|
|
1269
|
+
const workspaces = this.state.workspaces.filter((workspace) => !workspace.closedAt);
|
|
1270
|
+
if (!workspaces.length)
|
|
1271
|
+
throw new Error("没有可更新的工作区。");
|
|
1272
|
+
const previous = workspaces.map((workspace) => ({
|
|
1273
|
+
workspace,
|
|
1274
|
+
defaultModel: workspace.defaultModel ? { ...workspace.defaultModel } : undefined,
|
|
1275
|
+
defaultThinkingLevel: workspace.defaultThinkingLevel,
|
|
1276
|
+
updatedAt: workspace.updatedAt,
|
|
1277
|
+
}));
|
|
1278
|
+
for (const workspace of workspaces) {
|
|
1279
|
+
if (defaults.model === undefined)
|
|
1280
|
+
delete workspace.defaultModel;
|
|
1281
|
+
else
|
|
1282
|
+
workspace.defaultModel = { ...defaults.model };
|
|
1283
|
+
if (defaults.thinkingLevel === undefined)
|
|
1284
|
+
delete workspace.defaultThinkingLevel;
|
|
1285
|
+
else
|
|
1286
|
+
workspace.defaultThinkingLevel = defaults.thinkingLevel;
|
|
1287
|
+
workspace.updatedAt = now();
|
|
1288
|
+
}
|
|
1289
|
+
try {
|
|
1290
|
+
await this.persist();
|
|
1291
|
+
}
|
|
1292
|
+
catch (error) {
|
|
1293
|
+
for (const saved of previous) {
|
|
1294
|
+
if (saved.defaultModel)
|
|
1295
|
+
saved.workspace.defaultModel = saved.defaultModel;
|
|
1296
|
+
else
|
|
1297
|
+
delete saved.workspace.defaultModel;
|
|
1298
|
+
if (saved.defaultThinkingLevel === undefined)
|
|
1299
|
+
delete saved.workspace.defaultThinkingLevel;
|
|
1300
|
+
else
|
|
1301
|
+
saved.workspace.defaultThinkingLevel = saved.defaultThinkingLevel;
|
|
1302
|
+
saved.workspace.updatedAt = saved.updatedAt;
|
|
1303
|
+
}
|
|
1304
|
+
throw error;
|
|
1305
|
+
}
|
|
1306
|
+
return workspaces.length;
|
|
1307
|
+
}
|
|
1267
1308
|
/**
|
|
1268
1309
|
* TAKES A WORKSPACE OUT OF THE SIDEBAR. IT DOES NOT DELETE ANYTHING.
|
|
1269
1310
|
*
|
|
@@ -70,6 +70,18 @@ const MINIMAX_FLASH_LEVELS = {
|
|
|
70
70
|
xhigh: "xhigh",
|
|
71
71
|
max: "max",
|
|
72
72
|
};
|
|
73
|
+
const KIMI_K31_PRO_MODEL = "kimi-k3.1-pro";
|
|
74
|
+
const KIMI_API_ORIGINS = new Set(["https://api.moonshot.ai", "https://api.moonshot.cn"]);
|
|
75
|
+
const KIMI_API_PATHS = new Set(["", "/v1", "/v1/models"]);
|
|
76
|
+
const KIMI_K31_PRO_LEVELS = {
|
|
77
|
+
off: null,
|
|
78
|
+
minimal: null,
|
|
79
|
+
low: "low",
|
|
80
|
+
medium: null,
|
|
81
|
+
high: "high",
|
|
82
|
+
xhigh: null,
|
|
83
|
+
max: "max",
|
|
84
|
+
};
|
|
73
85
|
/**
|
|
74
86
|
* The official endpoint, or undefined.
|
|
75
87
|
*
|
|
@@ -89,6 +101,15 @@ function officialMinimaxEndpoint(baseUrl) {
|
|
|
89
101
|
return false;
|
|
90
102
|
}
|
|
91
103
|
}
|
|
104
|
+
function officialKimiEndpoint(baseUrl) {
|
|
105
|
+
try {
|
|
106
|
+
const parsed = new URL(baseUrl.trim());
|
|
107
|
+
return KIMI_API_ORIGINS.has(parsed.origin) && KIMI_API_PATHS.has(parsed.pathname.replace(/\/+$/, ""));
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
92
113
|
/**
|
|
93
114
|
* The levels a provider DECLARED for a model, when it declared them properly.
|
|
94
115
|
*
|
|
@@ -148,11 +169,14 @@ export function discoverThinkingLevels(entry, context) {
|
|
|
148
169
|
const declared = declaredLevels(entry);
|
|
149
170
|
if (declared)
|
|
150
171
|
return declared;
|
|
172
|
+
const id = typeof entry.id === "string" ? entry.id.trim().toLowerCase() : "";
|
|
173
|
+
if (id === KIMI_K31_PRO_MODEL && officialKimiEndpoint(context.baseUrl)) {
|
|
174
|
+
return { ...KIMI_K31_PRO_LEVELS };
|
|
175
|
+
}
|
|
151
176
|
// THE OFFICIAL MINIMAX ENDPOINT, AND ONLY THAT ONE - the origin and the path both, because a map
|
|
152
177
|
// is only true of the endpoint it was learned from.
|
|
153
178
|
if (!officialMinimaxEndpoint(context.baseUrl))
|
|
154
179
|
return undefined;
|
|
155
|
-
const id = typeof entry.id === "string" ? entry.id.trim().toLowerCase() : "";
|
|
156
180
|
if (id !== MINIMAX_FLASH_MODEL)
|
|
157
181
|
return undefined;
|
|
158
182
|
return { ...MINIMAX_FLASH_LEVELS };
|
package/dist/server/types.d.ts
CHANGED
|
@@ -380,6 +380,8 @@ export type ModelSelection = {
|
|
|
380
380
|
* one boolean instead of a modality list it would have to interpret. It is CATALOG state, never
|
|
381
381
|
* conversation state: a copy frozen onto a conversation would be wrong the moment Pi changed a
|
|
382
382
|
* model, and nothing reads one - see the note on `setConversationModel`.
|
|
383
|
+
* `thinkingLevels` is the similarly small, derived list for a model-specific settings picker; the
|
|
384
|
+
* active session's levels cannot stand in for a different model selected as a workspace default.
|
|
383
385
|
*/
|
|
384
386
|
export type ModelOption = ModelSelection & {
|
|
385
387
|
detail: string;
|
|
@@ -387,6 +389,7 @@ export type ModelOption = ModelSelection & {
|
|
|
387
389
|
contextWindow: number;
|
|
388
390
|
maxTokens: number;
|
|
389
391
|
imageInput: boolean;
|
|
392
|
+
thinkingLevels?: string[];
|
|
390
393
|
};
|
|
391
394
|
/**
|
|
392
395
|
* What the picker lists, read from Pi and cached by the runtime.
|
|
@@ -1566,6 +1569,13 @@ export type ClientCommandBody =
|
|
|
1566
1569
|
} | null;
|
|
1567
1570
|
thinkingLevel: string | null;
|
|
1568
1571
|
agentId?: string | null;
|
|
1572
|
+
} | {
|
|
1573
|
+
type: "workspaces.settings.bulk";
|
|
1574
|
+
model: {
|
|
1575
|
+
provider: string;
|
|
1576
|
+
modelId: string;
|
|
1577
|
+
} | null;
|
|
1578
|
+
thinkingLevel: string | null;
|
|
1569
1579
|
} | {
|
|
1570
1580
|
type: "conversation.create";
|
|
1571
1581
|
workspaceId: string;
|
package/package.json
CHANGED