pi-mono/apps/p2/plugins/logs/contract.ts
Mario Zechner 05dc8d239d feat: add apps/p2 (imported from pi-private at 7dadff697)
p2 (Pi Mobile on Chord v2) moves from pi-private into pi as one commit. Root scripts that loop all workspaces
use --if-present; npm test, ./test.sh and the release script cover packages/* only (p2: cd apps/p2 && npm test);
sync-versions also updates apps' workspace pins.
2026-11-03 13:39:06 +00:00

23 lines
829 B
TypeScript

import { arr, num, obj, type Static, str, union } from "@earendil-works/pi-schema";
import { literal, param, remote, serverHost } from "@p2/app/v1";
export const LogLineSchema = obj({
id: num(),
time: num(),
level: union([literal("stdout"), literal("stderr"), literal("event"), literal("error")]),
text: str(),
});
export type LogLine = Static<typeof LogLineSchema>;
export const LogSourcesSchema = arr(obj({ id: str(), lines: num(), updatedAt: num() }));
export { LogNotices, NoticesSchema } from "@p2/app/v1";
/** Owner-only diagnostics. Changing source acquires a new view, not a new worker. */
export const Logs = remote("p2.logs", {
version: 1,
params: { source: param.str({ max: 128 }) },
hostAddress: serverHost,
variants: {
owner: { state: { sources: LogSourcesSchema, lines: arr(LogLineSchema) } },
},
});