@evandu/super-pi 0.1.246 → 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/dist/client/.super-pi-client-sources.json +6 -5
- package/dist/client/assets/{CodeMirrorEditor-B3K0I0eS.js → CodeMirrorEditor-CfRZBw_k.js} +1 -1
- package/dist/client/assets/{GitDiffEditor-DYmMQWS8.js → GitDiffEditor-CxVEErgk.js} +1 -1
- package/dist/client/assets/{index-Dx58PQcK.js → index-D-5yq-Mj.js} +13 -13
- package/dist/client/assets/{index-DGpbsE3E.css → index-oGFfK21_.css} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/application/workspace-service.d.ts +2 -0
- package/dist/server/application/workspace-service.js +42 -0
- 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/types.d.ts +10 -0
- package/package.json +1 -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>
|
|
@@ -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
|
}
|
|
@@ -141,4 +141,46 @@ export class WorkspaceService {
|
|
|
141
141
|
});
|
|
142
142
|
this.broadcaster.broadcastState();
|
|
143
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
|
+
}
|
|
144
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
|
*
|
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;
|