@evandu/super-pi 0.1.189 → 0.1.191
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"hash": "
|
|
2
|
+
"hash": "6424fb1180b1abf97982cd18b4b280d0336d3fa6246bd8083df8419b5f97b495",
|
|
3
3
|
"files": {
|
|
4
4
|
"src/client/App.tsx": "4e9bcb3e0987b741dd721c7c9e2ad84a7c1ba79202b38092fda568f9b484d4c0",
|
|
5
5
|
"src/client/CodeMirrorEditor.tsx": "b6b6479effa1482eda710f04a26f3af843515526e129ca5bc70692cca9074b09",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"src/client/KnowledgePanel.tsx": "4f7230cfe610cd86d63aa143c82f6195b3c4208ef0bea703f92104ef27237704",
|
|
13
13
|
"src/client/MarkdownView.tsx": "4f04a8f3c9381946e5d2f957ac4fb74a6b16272e90375fb4dc6bd3a43d7c744d",
|
|
14
14
|
"src/client/MemoryPanel.tsx": "59a74f5789f43708245b6f62ba3b873ad91804f64c1e352403d5b7dffd478fdc",
|
|
15
|
-
"src/client/ProjectControlPanel.tsx": "
|
|
15
|
+
"src/client/ProjectControlPanel.tsx": "7a72153048c439fc15fd76df494b753e3fe8e0eb3ad1c9a41fbfda742006d89b",
|
|
16
16
|
"src/client/ProjectExecutionTools.tsx": "56e2868633bfb50d1921b4813b7428ddfa19098d0b8e17a9ed9c61e3b33b0b39",
|
|
17
17
|
"src/client/ScheduledTasksPanel.tsx": "74f8bea76cbe540b4eb22163ba28ed56920643de5948d1c5c8c37604f52368c3",
|
|
18
18
|
"src/client/SlashCommandMenu.tsx": "69cd0a9d5e35f41f703e91a845e5bd750c952d2957be03b5528e156e60bf6ecb",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"src/client/types.ts": "ef0586e206d0f229ed0e81e72397e1ddfd82c00ae7133d06d20892605e6f1ff4",
|
|
41
41
|
"src/client/vite-env.d.ts": "65996936fbb042915f7b74a200fcdde7e410f32a669b1ab9597cfaa4b0faddb5"
|
|
42
42
|
},
|
|
43
|
-
"recordedAt": "2026-11-
|
|
43
|
+
"recordedAt": "2026-11-11T21:28:42.047Z"
|
|
44
44
|
}
|
|
@@ -1218,8 +1218,17 @@ export class ProjectService {
|
|
|
1218
1218
|
this.admission(p);
|
|
1219
1219
|
if (!this.orchestrator)
|
|
1220
1220
|
throw new Error("会话编排服务未就绪");
|
|
1221
|
-
|
|
1222
|
-
|
|
1221
|
+
/* STARTING A PROJECT THAT IS ALREADY RUNNING IS NOT AN ERROR. `create` starts the project in
|
|
1222
|
+
one call - that is what the ceremony-free project is for - so the natural next call is
|
|
1223
|
+
`start`, and it used to answer 「项目负责人正在执行,请勿重复启动」. A model that created a
|
|
1224
|
+
project and then started it was doing exactly what the tool's own contract says it may do,
|
|
1225
|
+
and the refusal taught it nothing except that the tool lies. So the project is returned as
|
|
1226
|
+
it is: no second leader is spawned (the spawn below only happens when there is no owner),
|
|
1227
|
+
and the caller learns the state it asked about. */
|
|
1228
|
+
if (p.ownerConversationId && busy(this.store.conversation(p.ownerConversationId)?.status)) {
|
|
1229
|
+
this.event(p, "start_skipped", "项目已经在执行中,重复启动被忽略", undefined, actor);
|
|
1230
|
+
return p;
|
|
1231
|
+
}
|
|
1223
1232
|
if (!p.ownerConversationId) {
|
|
1224
1233
|
const effective = p.defaultLeaderProfile;
|
|
1225
1234
|
p.ownerConversationId = (await this.orchestrator.spawn({
|
|
@@ -78,3 +78,37 @@ export declare function readStoreWindows(agentDir: string): ModelStore;
|
|
|
78
78
|
* taking the smallest is exactly how a million-token model ended up believing it had 128,000.
|
|
79
79
|
*/
|
|
80
80
|
export declare function arbitrateContextWindow(declared: Map<string, number>, store: ModelStore, provider: string, modelId: string, reported?: number): number | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* THE RESOLVER A LIVE SESSION HANDS ITS MODEL THROUGH.
|
|
83
|
+
*
|
|
84
|
+
* WHY THIS IS A FUNCTION AND NOT A CLOSURE. The rule above is a pure function, and it has had a gate
|
|
85
|
+
* for a while - but the rule is only HALF of the runtime path. The other half is the code that reads
|
|
86
|
+
* the two files, asks the model runtime for the whole model object, and hands that object to Pi.
|
|
87
|
+
* That half lived inside `pi-session.ts` as an inline closure, where nothing could reach it: the pure
|
|
88
|
+
* function was tested, and the code that actually decides what window a session runs on was not.
|
|
89
|
+
*
|
|
90
|
+
* This is that code, extracted, so it can be driven with a temporary directory and a fake model
|
|
91
|
+
* runtime - no server, no socket, no browser, no model.
|
|
92
|
+
*
|
|
93
|
+
* WHAT IT DOES, IN ORDER:
|
|
94
|
+
*
|
|
95
|
+
* 1. Reads the person's `models.json` and the provider's catalogue `models-store.json`.
|
|
96
|
+
* 2. Asks the model runtime for the WHOLE model object for `(provider, modelId)`.
|
|
97
|
+
* 3. Arbitrates the window across the three sources.
|
|
98
|
+
* 4. Hands the WHOLE model back, carrying the arbitrated window.
|
|
99
|
+
*
|
|
100
|
+
* THE FILES ARE READ ONCE, WHEN THE RESOLVER IS CREATED - which is where the session used to read
|
|
101
|
+
* them. A live session therefore keeps the windows it started with, exactly as it did before, and a
|
|
102
|
+
* person editing `models.json` mid-turn does not silently change the window of a running session.
|
|
103
|
+
*/
|
|
104
|
+
export declare function createModelResolver(options: {
|
|
105
|
+
agentDir: string;
|
|
106
|
+
modelRuntime: {
|
|
107
|
+
getModel?: (provider: string, modelId: string) => unknown;
|
|
108
|
+
};
|
|
109
|
+
}): (provider: string, modelId: string) => ({
|
|
110
|
+
provider: string;
|
|
111
|
+
id: string;
|
|
112
|
+
contextWindow?: number;
|
|
113
|
+
[key: string]: unknown;
|
|
114
|
+
} | undefined);
|
|
@@ -195,3 +195,40 @@ export function arbitrateContextWindow(declared, store, provider, modelId, repor
|
|
|
195
195
|
return reported;
|
|
196
196
|
return exact ?? deliberate ?? storeEntry?.contextWindow ?? reported;
|
|
197
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* THE RESOLVER A LIVE SESSION HANDS ITS MODEL THROUGH.
|
|
200
|
+
*
|
|
201
|
+
* WHY THIS IS A FUNCTION AND NOT A CLOSURE. The rule above is a pure function, and it has had a gate
|
|
202
|
+
* for a while - but the rule is only HALF of the runtime path. The other half is the code that reads
|
|
203
|
+
* the two files, asks the model runtime for the whole model object, and hands that object to Pi.
|
|
204
|
+
* That half lived inside `pi-session.ts` as an inline closure, where nothing could reach it: the pure
|
|
205
|
+
* function was tested, and the code that actually decides what window a session runs on was not.
|
|
206
|
+
*
|
|
207
|
+
* This is that code, extracted, so it can be driven with a temporary directory and a fake model
|
|
208
|
+
* runtime - no server, no socket, no browser, no model.
|
|
209
|
+
*
|
|
210
|
+
* WHAT IT DOES, IN ORDER:
|
|
211
|
+
*
|
|
212
|
+
* 1. Reads the person's `models.json` and the provider's catalogue `models-store.json`.
|
|
213
|
+
* 2. Asks the model runtime for the WHOLE model object for `(provider, modelId)`.
|
|
214
|
+
* 3. Arbitrates the window across the three sources.
|
|
215
|
+
* 4. Hands the WHOLE model back, carrying the arbitrated window.
|
|
216
|
+
*
|
|
217
|
+
* THE FILES ARE READ ONCE, WHEN THE RESOLVER IS CREATED - which is where the session used to read
|
|
218
|
+
* them. A live session therefore keeps the windows it started with, exactly as it did before, and a
|
|
219
|
+
* person editing `models.json` mid-turn does not silently change the window of a running session.
|
|
220
|
+
*/
|
|
221
|
+
export function createModelResolver(options) {
|
|
222
|
+
const declared = readDeclaredWindows(options.agentDir);
|
|
223
|
+
const catalogue = readStoreWindows(options.agentDir);
|
|
224
|
+
return (provider, modelId) => {
|
|
225
|
+
const found = options.modelRuntime.getModel?.(provider, modelId);
|
|
226
|
+
if (!found || typeof found !== "object")
|
|
227
|
+
return undefined;
|
|
228
|
+
const model = found;
|
|
229
|
+
const window = arbitrateContextWindow(declared, catalogue, provider, modelId, model.contextWindow);
|
|
230
|
+
// The model is handed to Pi WHOLE - it is what the agent runs on - so this is where the
|
|
231
|
+
// corrected window has to be. A model Super Pi has no opinion about is handed over untouched.
|
|
232
|
+
return window === undefined ? model : { ...model, contextWindow: window };
|
|
233
|
+
};
|
|
234
|
+
}
|
|
@@ -27,7 +27,7 @@ import { existsSync, statSync } from "node:fs";
|
|
|
27
27
|
import { open, readdir } from "node:fs/promises";
|
|
28
28
|
import { StringDecoder } from "node:string_decoder";
|
|
29
29
|
import { dirname, join, resolve } from "node:path";
|
|
30
|
-
import {
|
|
30
|
+
import { createModelResolver } from "./model-context-window.js";
|
|
31
31
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
32
32
|
const traceSession = (conversationId, phase, startedAt, extra = "") => {
|
|
33
33
|
if (process.env.SUPER_PI_TRACE_LATENCY !== "1")
|
|
@@ -327,26 +327,10 @@ export async function createPiSession(creation) {
|
|
|
327
327
|
// It is attached to the session rather than kept beside it because the session is what outlives a
|
|
328
328
|
// turn: a model change applies to a LIVE session, and the live session is the thing that has to be
|
|
329
329
|
// able to answer "give me this model whole".
|
|
330
|
-
// THE WINDOW THE MODEL REALLY HAS. Pi's remote catalogue can overwrite the `contextWindow` the
|
|
331
|
-
// PERSON configured in `models.json` (Pi's own merge lets the catalogue win), and a provider
|
|
332
|
-
// that reports a million tokens makes Pi's auto-compaction wait for 983,616 tokens - while the
|
|
333
|
-
// model refuses at its real 128,000. The overflow recovery then asks the same too-long
|
|
334
|
-
// conversation of the same too-small model, and the session stops working entirely.
|
|
335
330
|
//
|
|
336
|
-
//
|
|
337
|
-
//
|
|
338
|
-
|
|
339
|
-
const catalogue = readStoreWindows(agentDir);
|
|
340
|
-
live.resolveModel = (provider, modelId) => {
|
|
341
|
-
const found = modelRuntime.getModel?.(provider, modelId);
|
|
342
|
-
if (!found || typeof found !== "object")
|
|
343
|
-
return undefined;
|
|
344
|
-
const model = found;
|
|
345
|
-
const window = arbitrateContextWindow(declared, catalogue, provider, modelId, model.contextWindow);
|
|
346
|
-
// The model is handed to Pi WHOLE - it is what the agent runs on - so this is where the
|
|
347
|
-
// corrected window has to be. A model Super Pi has no opinion about is handed over untouched.
|
|
348
|
-
return window === undefined ? model : { ...model, contextWindow: window };
|
|
349
|
-
};
|
|
331
|
+
// The window the model REALLY has is arbitrated inside the resolver - see
|
|
332
|
+
// `model-context-window.ts` for the whole reasoning and for the tests that hold it in place.
|
|
333
|
+
live.resolveModel = createModelResolver({ agentDir, modelRuntime });
|
|
350
334
|
return live;
|
|
351
335
|
})();
|
|
352
336
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evandu/super-pi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.191",
|
|
4
4
|
"description": "Web control plane and companion for Pi",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -95,6 +95,8 @@
|
|
|
95
95
|
"scripts/session-orchestrator-tools.test.mjs",
|
|
96
96
|
"scripts/project-service.test.mjs",
|
|
97
97
|
"scripts/project-ceremony-free.test.mjs",
|
|
98
|
+
"scripts/session-model-resolver.test.mjs",
|
|
99
|
+
"scripts/project-mechanism-guards.test.mjs",
|
|
98
100
|
"scripts/dead-end-decision.test.mjs",
|
|
99
101
|
"scripts/project-report-exception-title.test.mjs",
|
|
100
102
|
"scripts/project-report-decision-layout.test.mjs",
|
|
@@ -265,7 +267,9 @@
|
|
|
265
267
|
"scripts/session-reporting.test.mjs",
|
|
266
268
|
"scripts/project-panel-reporting.test.mjs",
|
|
267
269
|
"scripts/session-row-escalation.test.mjs",
|
|
268
|
-
"scripts/mutation-lock-coverage.test.mjs"
|
|
270
|
+
"scripts/mutation-lock-coverage.test.mjs",
|
|
271
|
+
"scripts/real-context-window.test.mjs",
|
|
272
|
+
"scripts/session-reminder-pmo-rights.test.mjs"
|
|
269
273
|
],
|
|
270
274
|
"check:browser": [
|
|
271
275
|
"scripts/update-button-browser.test.mjs",
|