@hyperdreamer/pi-webui 1.23.0 → 1.24.1
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/assets/{CodeViewer-BzNoYPSF.js → CodeViewer-DgVx_yzp.js} +1 -1
- package/dist/client/assets/{UnifiedDiffViewer-CRHwLTaV.js → UnifiedDiffViewer-BFBQjlJd.js} +1 -1
- package/dist/client/assets/{index-KEEW1V12.js → index-Bsp7hXcN.js} +500 -497
- package/dist/client/assets/{mathjaxEngine-CuLcV2r3.js → mathjaxEngine-CVXA3FNR.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/config.js +11 -3
- package/dist/config.js.map +1 -1
- package/dist/plugin-api.d.ts +16 -2
- package/dist/server/sessions/extensionEntries.js +89 -0
- package/dist/server/sessions/extensionEntries.js.map +1 -0
- package/dist/server/sessions/piSessionService.js +37 -0
- package/dist/server/sessions/piSessionService.js.map +1 -1
- package/dist/server/sessions/sessionRoutes.js +12 -0
- package/dist/server/sessions/sessionRoutes.js.map +1 -1
- package/dist/server/sessions/utilityModelExtension.js +4 -2
- package/dist/server/sessions/utilityModelExtension.js.map +1 -1
- package/dist/server/sessions/utilityModelResolver.js +16 -4
- package/dist/server/sessions/utilityModelResolver.js.map +1 -1
- package/dist/server/sessions/utilityModelSettingsRoutes.js +23 -12
- package/dist/server/sessions/utilityModelSettingsRoutes.js.map +1 -1
- package/dist/server/sessions/utilityModelSettingsService.js +5 -3
- package/dist/server/sessions/utilityModelSettingsService.js.map +1 -1
- package/dist/shared/apiTypes.d.ts +66 -3
- package/dist/shared/apiTypes.js +4 -0
- package/dist/shared/apiTypes.js.map +1 -1
- package/dist/shared/capabilities.js +3 -0
- package/dist/shared/capabilities.js.map +1 -1
- package/dist/shared/federatedRoutes.js +1 -0
- package/dist/shared/federatedRoutes.js.map +1 -1
- package/docs/config.md +12 -0
- package/docs/plugins.md +51 -2
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ import { open, readFile, writeFile } from "node:fs/promises";
|
|
|
5
5
|
import { createAgentSessionFromServices, createAgentSessionRuntime, createAgentSessionServices, createEditToolDefinition, defineTool, readStoredCredential, SessionManager, } from "@earendil-works/pi-coding-agent";
|
|
6
6
|
import { projectBrowserMessage } from "../browserMessageProjection.js";
|
|
7
7
|
import { pageMessagesAtSafeBoundary } from "./messagePaging.js";
|
|
8
|
+
import { sessionExtensionEntriesFromBranch, sessionExtensionEntry } from "./extensionEntries.js";
|
|
8
9
|
import { exportSessionHistoryHtml } from "./sessionHistoryExport.js";
|
|
9
10
|
import { BUILTIN_COMMANDS } from "./builtinCommands.js";
|
|
10
11
|
import { SessionCommandService, clientSessionFromRuntime, } from "./sessionCommandService.js";
|
|
@@ -404,6 +405,15 @@ export class PiSessionService {
|
|
|
404
405
|
constructor(events, deps) {
|
|
405
406
|
this.events = events;
|
|
406
407
|
this.active = new Map();
|
|
408
|
+
/**
|
|
409
|
+
* Read ordering for extension entries, monotonic for this service lifetime.
|
|
410
|
+
*
|
|
411
|
+
* It is deliberately not per runtime: a runtime can be stopped and cold opened again while the
|
|
412
|
+
* browser keeps the same event socket, so a per-runtime counter would restart and a client would
|
|
413
|
+
* reject the new runtime's reads as superseded. A client only needs this to increase within one
|
|
414
|
+
* session, which a shared counter provides without keeping per-session state.
|
|
415
|
+
*/
|
|
416
|
+
this.extensionReadRevision = 0;
|
|
407
417
|
this.pendingSessionOpens = new Map();
|
|
408
418
|
this.activities = new Map();
|
|
409
419
|
this.generationMetrics = new WeakMap();
|
|
@@ -1410,6 +1420,27 @@ export class PiSessionService {
|
|
|
1410
1420
|
const systemPrompt = (await this.getOrOpen(ref)).state.systemPrompt;
|
|
1411
1421
|
return systemPrompt === undefined ? {} : { systemPrompt };
|
|
1412
1422
|
}
|
|
1423
|
+
/**
|
|
1424
|
+
* Extension-owned entries for one session, oldest first.
|
|
1425
|
+
*
|
|
1426
|
+
* These are Pi `custom` entries: state written by an extension and deliberately excluded from
|
|
1427
|
+
* the model context. They are read from the session branch rather than from the conversation
|
|
1428
|
+
* projection, because the projection is chat content and these entries are not chat content.
|
|
1429
|
+
*/
|
|
1430
|
+
async extensionEntries(ref) {
|
|
1431
|
+
const session = await this.getOrOpen(ref);
|
|
1432
|
+
// Single consistent tick, like `streamSnapshot`: the watermark is read before the branch so
|
|
1433
|
+
// an entry appended after it is published with a higher seq and is replayed by the client,
|
|
1434
|
+
// while an entry already in the branch can only be replayed into an idempotent replacement.
|
|
1435
|
+
const seq = this.events.currentSeq(session.sessionId);
|
|
1436
|
+
// Ordering between reads is a separate fact from the event watermark: the branch can change
|
|
1437
|
+
// without publishing an event, so two reads can share a `seq`. This counter keeps increasing
|
|
1438
|
+
// for the service lifetime, so reopening a stopped session cannot hand a client a read that
|
|
1439
|
+
// looks older than what it already applied.
|
|
1440
|
+
this.extensionReadRevision += 1;
|
|
1441
|
+
const readRevision = this.extensionReadRevision;
|
|
1442
|
+
return { entries: sessionExtensionEntriesFromBranch(session.sessionManager.getBranch()), seq, readRevision };
|
|
1443
|
+
}
|
|
1413
1444
|
/**
|
|
1414
1445
|
* Join-time snapshot of the in-flight assistant stream. The `seq` watermark and
|
|
1415
1446
|
* the partial are read together in one synchronous tick (no await between the
|
|
@@ -4781,6 +4812,12 @@ function toClientEvent(event) {
|
|
|
4781
4812
|
isError: getBoolean(event, "isError") === true,
|
|
4782
4813
|
};
|
|
4783
4814
|
}
|
|
4815
|
+
if (eventType === "entry_appended") {
|
|
4816
|
+
// Pi emits this when an extension persists its own state. Non-custom entries keep the
|
|
4817
|
+
// existing payload-free `pi.event` passthrough so this adds no new traffic for them.
|
|
4818
|
+
const entry = sessionExtensionEntry(getProperty(event, "entry"));
|
|
4819
|
+
return entry === undefined ? { type: "pi.event", eventType } : { type: "session.extensionEntry", entry };
|
|
4820
|
+
}
|
|
4784
4821
|
if (eventType === "agent_start")
|
|
4785
4822
|
return { type: "agent.start" };
|
|
4786
4823
|
if (eventType === "agent_end")
|