pi-web-ui 0.111.0 → 0.112.0
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 +55 -2
- package/bin/frp-manager.mjs +9 -2
- package/dist/server/agent-service.js +1325 -488
- package/dist/server/approval-audit.js +119 -0
- package/dist/server/approval-default-rules.js +4 -4
- package/dist/server/approval-rules.js +42 -17
- package/dist/server/attachment-store.js +8 -8
- package/dist/server/canvas/canvas-agent-tool.js +6 -0
- package/dist/server/canvas/canvas-orchestrator.js +88 -21
- package/dist/server/client-state.js +28 -0
- package/dist/server/delegate-mode.js +6 -3
- package/dist/server/delegate-task.js +18 -3
- package/dist/server/dispatch-domain-handlers.js +3 -0
- package/dist/server/dsh/dsh-agent-service.js +242 -11
- package/dist/server/dsh/dsh-serialize.js +1 -1
- package/dist/server/durable/durable-driver.js +75 -9
- package/dist/server/durable/durable-loader.js +1 -14
- package/dist/server/durable/durable-models.js +107 -0
- package/dist/server/durable/index.js +0 -4
- package/dist/server/engine-probe.js +76 -37
- package/dist/server/eval-tool.js +28 -3
- package/dist/server/goal-service.js +7 -0
- package/dist/server/index.js +344 -56
- package/dist/server/json-utils.js +57 -0
- package/dist/server/marker-service.js +8 -0
- package/dist/server/message-window.js +43 -10
- package/dist/server/model-admin.js +68 -106
- package/dist/server/model-resolver.js +66 -44
- package/dist/server/plan-manager.js +3 -6
- package/dist/server/plugin-api-catalog.js +1 -0
- package/dist/server/plugin-assets.js +238 -0
- package/dist/server/plugin-facilities.js +22 -0
- package/dist/server/plugin-ui-slots.js +1 -0
- package/dist/server/plugins.js +199 -5
- package/dist/server/preset-fields.js +25 -1
- package/dist/server/preset-share.js +5 -2
- package/dist/server/prompt-assembler.js +2 -1
- package/dist/server/prompt-composer.js +18 -8
- package/dist/server/protocol-version.js +1 -1
- package/dist/server/queue-utils.js +156 -0
- package/dist/server/sdk-builtin-extensions.js +85 -0
- package/dist/server/server-config.js +66 -0
- package/dist/server/session-parser.js +49 -13
- package/dist/server/session-search.js +4 -3
- package/dist/server/settings-service.js +38 -5
- package/dist/server/soft-cap.js +8 -6
- package/dist/server/subagent-helpers.js +22 -1
- package/dist/server/subagent-notify.js +93 -0
- package/dist/server/subagent-security-gate.js +282 -0
- package/dist/server/subagent-templates.js +8 -0
- package/dist/server/subagents.js +144 -17
- package/dist/server/terminals.js +196 -8
- package/dist/server/text-quote.js +61 -0
- package/dist/server/tool-approval.js +63 -4
- package/dist/server/tool-guards.js +208 -0
- package/dist/server/tool-host-factories.js +46 -10
- package/dist/server/tool-overrides.js +21 -11
- package/dist/server/universal/driver-base.js +8 -0
- package/dist/server/universal/drivers/claude-code.js +20 -3
- package/dist/server/universal/drivers/dsh-driver.js +3 -0
- package/dist/server/universal/index.js +0 -1
- package/dist/server/universal/universal-session.js +87 -10
- package/dist/server/worktree-service.js +189 -1
- package/docs/dsh-engine.md +1 -5
- package/package.json +1 -1
- package/plugin-sdk/client-utils.mjs +192 -5
- package/plugin-sdk/index.d.ts +63 -1
- package/plugin-sdk/index.mjs +94 -0
- package/plugin-sdk/package.json +5 -1
- package/plugins/catalog.json +11 -0
- package/web/dist/assets/{TerminalPanel-BiUNySMA.js → TerminalPanel-Dqr1dK28.js} +1 -1
- package/web/dist/assets/index-Dh8BX-lP.js +720 -0
- package/web/dist/assets/index-DqrC1I_a.css +1 -0
- package/web/dist/index.html +11 -2
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/index-B0ajS__T.js +0 -697
- package/web/dist/assets/index-BHik5WGG.css +0 -1
|
@@ -281,3 +281,110 @@ export function resolveDurableModelChoice(modelId, fallbackList, agentDir) {
|
|
|
281
281
|
modelId: trimmed,
|
|
282
282
|
};
|
|
283
283
|
}
|
|
284
|
+
/**
|
|
285
|
+
* 根据模型配置(reasoning 与 thinkingLevelMap)解析支持的思考强度档位。
|
|
286
|
+
*/
|
|
287
|
+
export function calculateSupportedThinkingLevels(modelDef) {
|
|
288
|
+
if (!modelDef) {
|
|
289
|
+
return ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
290
|
+
}
|
|
291
|
+
if (modelDef.reasoning === false) {
|
|
292
|
+
return ["off"];
|
|
293
|
+
}
|
|
294
|
+
const allLevels = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
295
|
+
if (modelDef.thinkingLevelMap && typeof modelDef.thinkingLevelMap === "object") {
|
|
296
|
+
return allLevels.filter((lvl) => {
|
|
297
|
+
const mapped = modelDef.thinkingLevelMap?.[lvl];
|
|
298
|
+
if (mapped === null)
|
|
299
|
+
return false;
|
|
300
|
+
if (lvl === "xhigh" || lvl === "max")
|
|
301
|
+
return mapped !== undefined;
|
|
302
|
+
return true;
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
// 默认具备 reasoning 能力时支持 off, minimal, low, medium, high
|
|
306
|
+
return ["off", "minimal", "low", "medium", "high"];
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* 快速同步解析指定模型的思考能力(优先 models 容器,次之 models.json / models-store.json / cachedModels)。
|
|
310
|
+
*/
|
|
311
|
+
export function resolveDurableThinkingLevels(modelId, options) {
|
|
312
|
+
if (!modelId || !modelId.trim() || modelId === "default") {
|
|
313
|
+
return ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
314
|
+
}
|
|
315
|
+
const choice = resolveDurableModelChoice(modelId, options?.cachedModels, options?.agentDir);
|
|
316
|
+
const provider = choice?.provider;
|
|
317
|
+
const bareModelId = choice?.modelId;
|
|
318
|
+
// 1. 尝试从已装配的 models 容器中取
|
|
319
|
+
if (options?.modelsContainer && typeof options.modelsContainer.getModel === "function" && provider && bareModelId) {
|
|
320
|
+
try {
|
|
321
|
+
const m = options.modelsContainer.getModel(provider, bareModelId);
|
|
322
|
+
if (m) {
|
|
323
|
+
return calculateSupportedThinkingLevels(m);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
catch {
|
|
327
|
+
/* ignore */
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
// 2. 尝试从 models.json 中取
|
|
331
|
+
try {
|
|
332
|
+
const { providers } = readModelsJson(options?.agentDir);
|
|
333
|
+
if (provider && providers[provider]?.models && Array.isArray(providers[provider].models)) {
|
|
334
|
+
const list = providers[provider].models;
|
|
335
|
+
const found = list.find((m) => m.id === bareModelId);
|
|
336
|
+
if (found) {
|
|
337
|
+
return calculateSupportedThinkingLevels(found);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
// 若按 provider 未匹配,遍历所有 provider 寻找裸模型 ID 匹配
|
|
341
|
+
for (const pConfig of Object.values(providers)) {
|
|
342
|
+
if (Array.isArray(pConfig?.models)) {
|
|
343
|
+
const found = pConfig.models.find((m) => m.id === bareModelId);
|
|
344
|
+
if (found) {
|
|
345
|
+
return calculateSupportedThinkingLevels(found);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
catch {
|
|
351
|
+
/* ignore */
|
|
352
|
+
}
|
|
353
|
+
// 3. 尝试从 models-store.json 中取
|
|
354
|
+
try {
|
|
355
|
+
const userAgentDir = options?.agentDir || join(homedir(), ".pi", "agent");
|
|
356
|
+
const storePath = join(userAgentDir, "models-store.json");
|
|
357
|
+
if (existsSync(storePath)) {
|
|
358
|
+
const store = JSON.parse(readFileSync(storePath, "utf8"));
|
|
359
|
+
if (provider && Array.isArray(store[provider]?.models)) {
|
|
360
|
+
const found = store[provider].models.find((m) => m.id === bareModelId);
|
|
361
|
+
if (found) {
|
|
362
|
+
return calculateSupportedThinkingLevels(found);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
// 若按 provider 未匹配,遍历 store 所有 provider 寻找裸模型 ID 匹配
|
|
366
|
+
for (const pData of Object.values(store)) {
|
|
367
|
+
if (Array.isArray(pData?.models)) {
|
|
368
|
+
const found = pData.models.find((m) => m.id === bareModelId);
|
|
369
|
+
if (found) {
|
|
370
|
+
return calculateSupportedThinkingLevels(found);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
catch {
|
|
377
|
+
/* ignore */
|
|
378
|
+
}
|
|
379
|
+
// 4. 尝试从 cachedModels 中取
|
|
380
|
+
if (options?.cachedModels && options.cachedModels.length > 0) {
|
|
381
|
+
const found = options.cachedModels.find((m) => m.id === modelId ||
|
|
382
|
+
m.id.endsWith(`/${bareModelId}`) ||
|
|
383
|
+
(provider && m.provider === provider && m.id.endsWith(bareModelId)));
|
|
384
|
+
if (found && found.reasoning === false) {
|
|
385
|
+
return ["off"];
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
// 未明确识别或通用兜底
|
|
389
|
+
return ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
390
|
+
}
|
|
@@ -2,7 +2,3 @@
|
|
|
2
2
|
* server/durable/index.ts — Pi Durable 独立智能体引擎模块统一出口。
|
|
3
3
|
*/
|
|
4
4
|
export { DurableAgentService } from "./durable-agent-service.js";
|
|
5
|
-
export { DurableAgentDriver } from "./durable-driver.js";
|
|
6
|
-
export { openDurableStorage } from "./durable-storage.js";
|
|
7
|
-
export { setupDurableRegistry } from "./durable-tools.js";
|
|
8
|
-
export { DEFAULT_DURABLE_CAPABILITIES, resolveDurableCapabilities } from "./durable-capabilities.js";
|
|
@@ -34,20 +34,47 @@ const CACHE_TTL_MS = 5000;
|
|
|
34
34
|
/** 远端 npm registry 查询缓存:5 分钟 */
|
|
35
35
|
const REGISTRY_CACHE_TTL_MS = 5 * 60 * 1000;
|
|
36
36
|
const registryCache = new Map();
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
/** 引擎状态原子字典:单一事实源,收敛 status / probedAt / updating 三元组,杜绝独立状态撕裂 */
|
|
38
|
+
const engineRegistry = new Map([
|
|
39
|
+
[
|
|
40
|
+
"pi",
|
|
41
|
+
{
|
|
42
|
+
status: { id: "pi", installed: true, packageName: ENGINE_PACKAGES.pi.packageName, version: VERSION },
|
|
43
|
+
probedAt: 0,
|
|
44
|
+
updating: false,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
[
|
|
48
|
+
"dsh",
|
|
49
|
+
{
|
|
50
|
+
status: { id: "dsh", installed: false, packageName: ENGINE_PACKAGES.dsh.packageName },
|
|
51
|
+
probedAt: 0,
|
|
52
|
+
updating: false,
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
"claude",
|
|
57
|
+
{
|
|
58
|
+
status: { id: "claude", installed: false, packageName: ENGINE_PACKAGES.claude.packageName },
|
|
59
|
+
probedAt: 0,
|
|
60
|
+
updating: false,
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
[
|
|
64
|
+
"durable",
|
|
65
|
+
{
|
|
66
|
+
status: { id: "durable", installed: false, packageName: ENGINE_PACKAGES.durable.packageName },
|
|
67
|
+
probedAt: 0,
|
|
68
|
+
updating: false,
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
]);
|
|
72
|
+
function toPublicStatus(entry) {
|
|
73
|
+
return {
|
|
74
|
+
...entry.status,
|
|
75
|
+
...(entry.updating ? { updating: true } : {}),
|
|
76
|
+
};
|
|
44
77
|
}
|
|
45
|
-
let cachedStatuses = [
|
|
46
|
-
{ id: "pi", installed: true, packageName: ENGINE_PACKAGES.pi.packageName, version: VERSION },
|
|
47
|
-
{ id: "dsh", installed: false, packageName: ENGINE_PACKAGES.dsh.packageName },
|
|
48
|
-
{ id: "claude", installed: false, packageName: ENGINE_PACKAGES.claude.packageName },
|
|
49
|
-
{ id: "durable", installed: false, packageName: ENGINE_PACKAGES.durable.packageName },
|
|
50
|
-
];
|
|
51
78
|
/**
|
|
52
79
|
* 查询全局包在 npm 远端的最新版本号(带 5 分钟缓存)。
|
|
53
80
|
*/
|
|
@@ -222,10 +249,9 @@ export async function probeDurable(force = false) {
|
|
|
222
249
|
export async function probeEngine(id, force = false) {
|
|
223
250
|
if (id === "pi")
|
|
224
251
|
return probePi();
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
return found;
|
|
252
|
+
const entry = engineRegistry.get(id);
|
|
253
|
+
if (!force && entry && entry.probedAt > 0 && Date.now() - entry.probedAt < CACHE_TTL_MS) {
|
|
254
|
+
return toPublicStatus(entry);
|
|
229
255
|
}
|
|
230
256
|
let result;
|
|
231
257
|
if (id === "dsh") {
|
|
@@ -241,23 +267,23 @@ export async function probeEngine(id, force = false) {
|
|
|
241
267
|
result = { id: id, installed: false };
|
|
242
268
|
}
|
|
243
269
|
await enrichWithUpdateInfo(result, force);
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
else
|
|
249
|
-
cachedStatuses.push(result);
|
|
250
|
-
return {
|
|
251
|
-
...result,
|
|
252
|
-
...(updatingEngineIds.has(id) ? { updating: true } : {}),
|
|
270
|
+
const updatedEntry = {
|
|
271
|
+
status: result,
|
|
272
|
+
probedAt: Date.now(),
|
|
273
|
+
updating: entry?.updating ?? false,
|
|
253
274
|
};
|
|
275
|
+
engineRegistry.set(id, updatedEntry);
|
|
276
|
+
return toPublicStatus(updatedEntry);
|
|
254
277
|
}
|
|
255
278
|
/**
|
|
256
279
|
* 探测全部已知引擎并返回最新状态列表(带 TTL 缓存防抖)。
|
|
257
280
|
*/
|
|
258
281
|
export async function probeAllEngines(force = false) {
|
|
259
|
-
|
|
260
|
-
|
|
282
|
+
const now = Date.now();
|
|
283
|
+
const entries = Array.from(engineRegistry.values());
|
|
284
|
+
const allFresh = entries.every((e) => e.probedAt > 0 && now - e.probedAt < CACHE_TTL_MS);
|
|
285
|
+
if (!force && allFresh && entries.length > 0) {
|
|
286
|
+
return entries.map(toPublicStatus);
|
|
261
287
|
}
|
|
262
288
|
const [pi, dsh, claude, durable] = await Promise.all([probePi(), probeDsh(), probeClaude(), probeDurable()]);
|
|
263
289
|
await Promise.all([
|
|
@@ -266,21 +292,29 @@ export async function probeAllEngines(force = false) {
|
|
|
266
292
|
enrichWithUpdateInfo(claude, force),
|
|
267
293
|
enrichWithUpdateInfo(durable, force),
|
|
268
294
|
]);
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
295
|
+
const timestamp = Date.now();
|
|
296
|
+
const results = [pi, dsh, claude, durable];
|
|
297
|
+
for (const res of results) {
|
|
298
|
+
const existing = engineRegistry.get(res.id);
|
|
299
|
+
engineRegistry.set(res.id, {
|
|
300
|
+
status: res,
|
|
301
|
+
probedAt: timestamp,
|
|
302
|
+
updating: existing?.updating ?? false,
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
return Array.from(engineRegistry.values()).map(toPublicStatus);
|
|
272
306
|
}
|
|
273
307
|
/**
|
|
274
308
|
* 同步获取当前缓存的引擎探测结果(握手帧或即时读取使用)。
|
|
275
309
|
*/
|
|
276
310
|
export function getCachedEngineStatuses() {
|
|
277
|
-
return
|
|
311
|
+
return Array.from(engineRegistry.values()).map(toPublicStatus);
|
|
278
312
|
}
|
|
279
313
|
/**
|
|
280
314
|
* 查询指定引擎是否正在执行后台更新子进程。
|
|
281
315
|
*/
|
|
282
316
|
export function isEngineUpdating(engineId) {
|
|
283
|
-
return
|
|
317
|
+
return engineRegistry.get(engineId)?.updating ?? false;
|
|
284
318
|
}
|
|
285
319
|
/**
|
|
286
320
|
* 在后台子进程中执行引擎全局包更新(npm i -g <pkg>@latest)。
|
|
@@ -291,10 +325,12 @@ export async function updateEngineBackground(engineId, options) {
|
|
|
291
325
|
if (!meta || !meta.packageName) {
|
|
292
326
|
return { ok: false, error: `不支持或未知的引擎「${engineId}」` };
|
|
293
327
|
}
|
|
294
|
-
|
|
328
|
+
const currentEntry = engineRegistry.get(engineId);
|
|
329
|
+
if (currentEntry?.updating) {
|
|
295
330
|
return { ok: false, error: `引擎「${engineId}」正在后台更新中,请勿重复操作` };
|
|
296
331
|
}
|
|
297
|
-
|
|
332
|
+
if (currentEntry)
|
|
333
|
+
currentEntry.updating = true;
|
|
298
334
|
const pkg = meta.packageName;
|
|
299
335
|
const timeoutMs = Math.max(10_000, Number(options?.timeoutMs ?? 300_000));
|
|
300
336
|
const isWin = process.platform === "win32";
|
|
@@ -367,7 +403,9 @@ export async function updateEngineBackground(engineId, options) {
|
|
|
367
403
|
};
|
|
368
404
|
}
|
|
369
405
|
finally {
|
|
370
|
-
|
|
406
|
+
const finalEntry = engineRegistry.get(engineId);
|
|
407
|
+
if (finalEntry)
|
|
408
|
+
finalEntry.updating = false;
|
|
371
409
|
}
|
|
372
410
|
}
|
|
373
411
|
/**
|
|
@@ -375,7 +413,8 @@ export async function updateEngineBackground(engineId, options) {
|
|
|
375
413
|
*/
|
|
376
414
|
export function collectInstalledEngineTargets() {
|
|
377
415
|
const out = [];
|
|
378
|
-
for (const
|
|
416
|
+
for (const entry of engineRegistry.values()) {
|
|
417
|
+
const status = entry.status;
|
|
379
418
|
// pi-core 在 collectTargets 中已有独立专属条目(PI_CORE_PACKAGE),此处收纳其他已安装引擎全局包
|
|
380
419
|
if (status.id !== "pi" && status.installed && status.packageName && status.version) {
|
|
381
420
|
out.push({
|
package/dist/server/eval-tool.js
CHANGED
|
@@ -70,6 +70,16 @@ function resolvePythonCmd() {
|
|
|
70
70
|
const PYTHON_DRIVER_SCRIPT = `
|
|
71
71
|
import sys, io, ast, json, traceback, os
|
|
72
72
|
|
|
73
|
+
# 跨平台编码对齐:Windows 默认代码页(如 CP936/GBK)读取 UTF-8 管道会导致多字节截断、
|
|
74
|
+
# 反斜杠被吞噬破坏 JSON 结构(报 Expecting ',' delimiter)或触发 UnicodeDecodeError。
|
|
75
|
+
# 强制标准流一律按 UTF-8 重配并附带容错替换策略,避免解码死锁。
|
|
76
|
+
if hasattr(sys.stdin, "reconfigure"):
|
|
77
|
+
sys.stdin.reconfigure(encoding="utf-8", errors="replace")
|
|
78
|
+
if hasattr(sys.stdout, "reconfigure"):
|
|
79
|
+
sys.stdout.reconfigure(encoding="utf-8", errors="backslashreplace")
|
|
80
|
+
if hasattr(sys.stderr, "reconfigure"):
|
|
81
|
+
sys.stderr.reconfigure(encoding="utf-8", errors="backslashreplace")
|
|
82
|
+
|
|
73
83
|
WORKDIR = os.environ.get('PI_EVAL_WORKDIR', '')
|
|
74
84
|
PROJECT_DIR = os.environ.get('PI_EVAL_PROJECT_DIR', '')
|
|
75
85
|
|
|
@@ -119,7 +129,7 @@ for line in sys.stdin:
|
|
|
119
129
|
except Exception as e:
|
|
120
130
|
resp = {'ok': False, 'stdout': '', 'stderr': '', 'result': None, 'error': traceback.format_exc()}
|
|
121
131
|
|
|
122
|
-
sys.stdout.write('__PI_EVAL_RES__' + json.dumps(resp, ensure_ascii=
|
|
132
|
+
sys.stdout.write('__PI_EVAL_RES__' + json.dumps(resp, ensure_ascii=True) + '\\n')
|
|
123
133
|
sys.stdout.flush()
|
|
124
134
|
`;
|
|
125
135
|
const NODE_DRIVER_SCRIPT = `
|
|
@@ -247,6 +257,19 @@ export function sanitizeEvalEnv(sourceEnv) {
|
|
|
247
257
|
}
|
|
248
258
|
return cleanEnv;
|
|
249
259
|
}
|
|
260
|
+
/**
|
|
261
|
+
* 传输层 ASCII 安全序列化:
|
|
262
|
+
* 将所有非 ASCII 字符(> 0x7F,含中文、特殊符号与 Emoji 代理对)转义为标准 JSON \uXXXX 格式。
|
|
263
|
+
* 纯 7-bit ASCII 传输流在跨平台任何操作系统本地代码页(如 Windows CP936/GBK/Shift-JIS)下
|
|
264
|
+
* 绝不会发生反斜杠 0x5C 被多字节汉字首字节“吞噬”导致 JSON 结构损毁或崩溃的问题。
|
|
265
|
+
*/
|
|
266
|
+
export function toAsciiJson(data) {
|
|
267
|
+
const raw = JSON.stringify(data);
|
|
268
|
+
if (!/[^\x00-\x7F]/.test(raw)) {
|
|
269
|
+
return raw;
|
|
270
|
+
}
|
|
271
|
+
return raw.replace(/[^\x00-\x7F]/g, (c) => "\\u" + c.charCodeAt(0).toString(16).padStart(4, "0"));
|
|
272
|
+
}
|
|
250
273
|
/** 单个持久内核工作进程包装。 */
|
|
251
274
|
class EvalKernel {
|
|
252
275
|
language;
|
|
@@ -277,6 +300,8 @@ class EvalKernel {
|
|
|
277
300
|
...sanitizeEvalEnv(process.env),
|
|
278
301
|
PI_EVAL_WORKDIR: this.workdir,
|
|
279
302
|
PI_EVAL_PROJECT_DIR: this.cwd,
|
|
303
|
+
PYTHONUTF8: "1",
|
|
304
|
+
PYTHONIOENCODING: "utf-8",
|
|
280
305
|
},
|
|
281
306
|
};
|
|
282
307
|
if (this.language === "py") {
|
|
@@ -284,7 +309,7 @@ class EvalKernel {
|
|
|
284
309
|
if (!pyCmd) {
|
|
285
310
|
throw new Error("Python executable not found in PATH. Please install Python or use language: 'js'.");
|
|
286
311
|
}
|
|
287
|
-
this.proc = spawn(pyCmd, ["-u", "-c", PYTHON_DRIVER_SCRIPT], spawnOpts);
|
|
312
|
+
this.proc = spawn(pyCmd, ["-X", "utf8", "-u", "-c", PYTHON_DRIVER_SCRIPT], spawnOpts);
|
|
288
313
|
}
|
|
289
314
|
else {
|
|
290
315
|
// js / ts:独立 node -e 驱动,ts 时带 --experimental-strip-types 支持 TypeScript 原生剥离执行。
|
|
@@ -403,7 +428,7 @@ class EvalKernel {
|
|
|
403
428
|
const item = this.queue.shift();
|
|
404
429
|
this.current = item;
|
|
405
430
|
try {
|
|
406
|
-
this.proc.stdin.write(
|
|
431
|
+
this.proc.stdin.write(toAsciiJson(item.req) + "\n");
|
|
407
432
|
}
|
|
408
433
|
catch (err) {
|
|
409
434
|
this.current = null;
|
|
@@ -1531,6 +1531,13 @@ export class GoalService {
|
|
|
1531
1531
|
}
|
|
1532
1532
|
conv.goal.phase = "idle";
|
|
1533
1533
|
}
|
|
1534
|
+
/** 会话关闭/移除时(removeConversation)彻底终止目标循环并清理关联的执行者与向导。 */
|
|
1535
|
+
notifyConversationRemoved(conv) {
|
|
1536
|
+
this.notifyTakeover(conv);
|
|
1537
|
+
if (this.wizardOwnerId === conv.id) {
|
|
1538
|
+
void this.abortWizard();
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1534
1541
|
/** 读某会话累计用量(取不到返回 undefined;getSessionStats 会遍历转写,只在轮次边界调)。 */
|
|
1535
1542
|
sessionUsage(session) {
|
|
1536
1543
|
try {
|