Add Pi package extension

This commit is contained in:
Federico Jaramillo Martinez
2026-05-09 20:30:40 +02:00
parent fc24e06324
commit 8b41a2ac12
9 changed files with 211 additions and 14 deletions
+14 -4
View File
@@ -85,13 +85,23 @@ function systemdEscape(value: string): string {
return value.replaceAll("\\", "\\\\").replaceAll('"', '\\"');
}
function sessiondExec(): string {
const configured = process.env["PI_WEB_SESSIOND_EXEC"]?.trim();
return configured === undefined || configured === "" ? "pi-web-sessiond" : configured;
}
function webExec(): string {
const configured = process.env["PI_WEB_SERVER_EXEC"]?.trim();
return configured === undefined || configured === "" ? "pi-web-server" : configured;
}
function sessiondUnit(): string {
return `[Unit]
Description=Pi Web session daemon
[Service]
Type=simple
ExecStart=/usr/bin/env bash -lc ${shellSingleQuote("exec pi-web-sessiond")}
ExecStart=/usr/bin/env bash -lc ${shellSingleQuote(`exec ${sessiondExec()}`)}
Restart=on-failure
RestartSec=2
@@ -109,7 +119,7 @@ Wants=${sessiondServiceName}
[Service]
Type=simple
${configEnvironment}ExecStart=/usr/bin/env bash -lc ${shellSingleQuote("exec pi-web-server")}
${configEnvironment}ExecStart=/usr/bin/env bash -lc ${shellSingleQuote(`exec ${webExec()}`)}
Restart=on-failure
RestartSec=2
@@ -130,8 +140,8 @@ async function writeInitialConfig(options: InstallOptions): Promise<string> {
async function install(args: string[]): Promise<void> {
const options = parseInstallOptions(args);
if (!hasCommand("systemctl")) throw new Error("systemctl was not found in a bash login shell");
if (!hasCommand("pi-web-server")) throw new Error("pi-web-server was not found in a bash login shell. Is pi-web installed globally?");
if (!hasCommand("pi-web-sessiond")) throw new Error("pi-web-sessiond was not found in a bash login shell. Is pi-web installed globally?");
if (process.env["PI_WEB_SERVER_EXEC"] === undefined && !hasCommand("pi-web-server")) throw new Error("pi-web-server was not found in a bash login shell. Is pi-web installed globally?");
if (process.env["PI_WEB_SESSIOND_EXEC"] === undefined && !hasCommand("pi-web-sessiond")) throw new Error("pi-web-sessiond was not found in a bash login shell. Is pi-web installed globally?");
const configPath = await writeInitialConfig(options);
+1 -1
View File
@@ -19,7 +19,7 @@ export function applyTranscriptEvent(messages: ChatLine[], event: SessionUiEvent
function applyMessageEndMeta(messages: ChatLine[], rawMessage: unknown): ChatLine[] | undefined {
const ended = normalizeMessage(rawMessage)[0];
if (ended === undefined || ended.meta === undefined) return undefined;
if (ended?.meta === undefined) return undefined;
const index = findLastMatchingRole(messages, ended.role);
if (index < 0) return undefined;
return messages.map((message, i) => i === index ? withMessageMeta(message, rawMessage) : message);
@@ -77,7 +77,7 @@ export class SessionController {
const [page, status] = await Promise.all([api.messages(session.id, { limit: MESSAGE_PAGE_SIZE }), api.status(session.id)]);
if (seq !== this.selectionSeq || this.getState().selectedSession?.id !== session.id) return;
const history = this.mergeAndCacheHistory(session.id, page);
const isReceivingPartialStream = status.isStreaming === true;
const isReceivingPartialStream = status.isStreaming;
this.catchupStreamSessionId = isReceivingPartialStream ? session.id : undefined;
this.setState({ messages: normalizeMessages(history.messages), messagePageStart: history.start, messagePageTotal: history.total, isLoadingEarlierMessages: false, isReceivingPartialStream, status, activity: this.getState().sessionActivities[session.id] });
this.applyStatus(status);