Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

refactor(core,server): the interfaces that declare their own members say so (#792)

Myriad-Dreaminc7ea1ad66925
diff --git a/packages/core/test/kernel-modules.test.ts b/packages/core/test/kernel-modules.test.ts
index 7d6d0950..f8dc3245 100644
--- a/packages/core/test/kernel-modules.test.ts
+++ b/packages/core/test/kernel-modules.test.ts
@@ -581,11 +581,15 @@ describe("Interface, in both spellings", () => {
});
describe("class form: @Module / @Use / @Provide / @Bind", () => {
- abstract class Sessions extends Interface<{
- startTask(id: string): Promise<{ sessionId: string }>;
- statusOf(id: string): string;
- }>() {}
- abstract class Runner extends Interface<{ statusOf(id: string): string }>() {}
+ @Interface()
+ abstract class Sessions {
+ abstract startTask(id: string): Promise<{ sessionId: string }>;
+ abstract statusOf(id: string): string;
+ }
+ @Interface()
+ abstract class Runner {
+ abstract statusOf(id: string): string;
+ }
const t: IfaceTable = {
"SessionsModule#Sessions": {
name: "Sessions",
diff --git a/packages/server/src/auth/live-streams.ts b/packages/server/src/auth/live-streams.ts
index 10235d67..f9f86c51 100644
--- a/packages/server/src/auth/live-streams.ts
+++ b/packages/server/src/auth/live-streams.ts
@@ -21,18 +21,19 @@
import { Component, Interface } from "@prismshadow/penguin-core/kernel";
/** LiveStreams: the mechanism LiveStreamRegistry implements. */
-export abstract class LiveStreams extends Interface<{
+@Interface()
+export abstract class LiveStreams {
/**
* Track a live stream for `userId`. The returned call removes it again and must run on
* every exit path of the connection — an entry left behind names a stream nobody can
* close, and its `end` would be called on a connection that is already gone.
*/
- add(userId: string, end: () => void): () => void;
+ abstract add(userId: string, end: () => void): () => void;
/** End every stream this user is holding open; returns how many were ended. */
- endForUser(userId: string): number;
+ abstract endForUser(userId: string): number;
/** How many streams this user is holding open. */
- countFor(userId: string): number;
-}>() {}
+ abstract countFor(userId: string): number;
+}
/** One tracked stream. An object rather than the bare callback, so two streams sharing a callback identity stay two entries. */
interface TrackedStream {
diff --git a/packages/server/src/auth/password.ts b/packages/server/src/auth/password.ts
index 2e9170fd..f3dc74d0 100644
--- a/packages/server/src/auth/password.ts
+++ b/packages/server/src/auth/password.ts
@@ -113,9 +113,10 @@ export async function verifyAccountPassword(
}
/** Hashes the passwords this server writes; a test stands in a cheap one. */
-export abstract class PasswordHasher extends Interface<{
- hash(password: string): Promise<string>;
-}>() {}
+@Interface()
+export abstract class PasswordHasher {
+ abstract hash(password: string): Promise<string>;
+}
/** scrypt at full strength. */
@Component()
diff --git a/packages/server/src/auth/service.ts b/packages/server/src/auth/service.ts
index e6997dce..ce49aa19 100644
--- a/packages/server/src/auth/service.ts
+++ b/packages/server/src/auth/service.ts
@@ -379,6 +379,7 @@ export class AuthService implements Auth {
}
/** What signing a new user in needs of project administration — declared at the consumer. */
-export abstract class InitialProjectProvisioner extends Interface<{
- provisionInitialProject(user: UserRow, isAdmin: boolean): Promise<void>;
-}>() {}
+@Interface()
+export abstract class InitialProjectProvisioner {
+ abstract provisionInitialProject(user: UserRow, isAdmin: boolean): Promise<void>;
+}
diff --git a/packages/server/src/builtin-browser/module.ts b/packages/server/src/builtin-browser/module.ts
index d4b0e0b6..19440706 100644
--- a/packages/server/src/builtin-browser/module.ts
+++ b/packages/server/src/builtin-browser/module.ts
@@ -24,9 +24,10 @@ import { BuiltinBrowser } from "./service.js";
import type { BrowserShellPort } from "./shell-link.js";
/** The desktop shell's message port as the built-in browser reaches it; null outside the shell. */
-export abstract class BuiltinBrowserPort extends Interface<{
- current(): Opaque<"BrowserShellPort", BrowserShellPort> | null;
-}>() {}
+@Interface()
+export abstract class BuiltinBrowserPort {
+ abstract current(): Opaque<"BrowserShellPort", BrowserShellPort> | null;
+}
/** The real port: the one Electron gives a utilityProcess. */
@Component()
diff --git a/packages/server/src/hmr/capabilities.ts b/packages/server/src/hmr/capabilities.ts
index d25b3cd1..a8469a25 100644
--- a/packages/server/src/hmr/capabilities.ts
+++ b/packages/server/src/hmr/capabilities.ts
@@ -368,54 +368,59 @@ export function claimHmrCapabilities(resources: Resources): HmrClaim {
export abstract class Config extends Interface<ServerConfig>() {}
/** The SQLite handle (single-writer, one per process). Statements are host objects. */
-export abstract class Db extends Interface<{
- prepare(sql: string): Opaque<"StatementSync", ReturnType<DatabaseSync["prepare"]>>;
- exec(sql: string): void;
- close(): void;
-}>() {}
+@Interface()
+export abstract class Db {
+ abstract prepare(sql: string): Opaque<"StatementSync", ReturnType<DatabaseSync["prepare"]>>;
+ abstract exec(sql: string): void;
+ abstract close(): void;
+}
/** One SSE channel (the class in runtime/channel.ts satisfies this). */
export type ChannelApi = Pick<Channel, "publish" | "sendTo" | "subscribe" | "replayAfter">;
-export abstract class Channels extends Interface<{
- get(key: string): ChannelApi;
- peek(key: string): ChannelApi | undefined;
- broadcast(prefix: string, data: unknown, event?: string): void;
- dispose(): void;
- setActivityProbe(probe: (key: string) => boolean): void;
-}>() {}
+@Interface()
+export abstract class Channels {
+ abstract get(key: string): ChannelApi;
+ abstract peek(key: string): ChannelApi | undefined;
+ abstract broadcast(prefix: string, data: unknown, event?: string): void;
+ abstract dispose(): void;
+ abstract setActivityProbe(probe: (key: string) => boolean): void;
+}
/** Compile-time proof the hub satisfies the contract. */
export type _ChannelsCheck = ChannelHub extends Channels ? true : never;
/** The global fetch dispatcher's settings — runtime-owned, since a bundle's own undici is not the one `globalThis.fetch` routes through. */
-export abstract class Proxy extends Interface<{
- apply(settings: ProxySettings): void;
-}>() {}
+@Interface()
+export abstract class Proxy {
+ abstract apply(settings: ProxySettings): void;
+}
/** The hot-update host: the cross-generation resource registry and the current App. */
-export abstract class Hmr extends Interface<{
- resources: Resources;
- ensure(): Promise<Opaque<"PlatformInstance", Awaited<ReturnType<HmrHost["ensure"]>>>>;
- resolveWebSource(): Opaque<
+@Interface()
+export abstract class Hmr {
+ abstract resources: Resources;
+ abstract ensure(): Promise<Opaque<"PlatformInstance", Awaited<ReturnType<HmrHost["ensure"]>>>>;
+ abstract resolveWebSource(): Opaque<
"WebSource",
NonNullable<ReturnType<HmrHost["resolveWebSource"]>>
> | null;
- assetsDir(): string | null;
- dispose(): void;
-}>() {}
+ abstract assetsDir(): string | null;
+ abstract dispose(): void;
+}
export type _HmrCheck = HmrHost extends Hmr ? true : never;
/**
* The frozen operations (packages/hmr's main.ts), as the platform's routes drive them. The
* instance and the outcome are host objects to the contract, like `Hmr`'s.
*/
-export abstract class HmrControl extends Interface<{
- current(): Promise<Opaque<"PlatformInstance", Awaited<ReturnType<HmrHost["ensure"]>>>>;
- upgrade(
+@Interface()
+export abstract class HmrControl {
+ abstract current(): Promise<Opaque<"PlatformInstance", Awaited<ReturnType<HmrHost["ensure"]>>>>;
+ abstract upgrade(
target: Opaque<"UpgradeAllTarget", Parameters<HmrHost["upgradeAll"]>[0]>,
): Promise<Opaque<"UpgradeOutcome", Awaited<ReturnType<HmrHost["upgradeAll"]>>>>;
- endpoint(request: Opaque<"Request", Request>): Promise<Opaque<"Response", Response>>;
-}>() {}
+ abstract endpoint(request: Opaque<"Request", Request>): Promise<Opaque<"Response", Response>>;
+}
export type DesktopApi = Pick<
DesktopService,
@@ -438,9 +443,10 @@ export type DesktopApi = Pick<
>;
/** The desktop shell's service, or null when this server is not the shell's child. */
-export abstract class Desktop extends Interface<{
- current(): DesktopApi | null;
-}>() {}
+@Interface()
+export abstract class Desktop {
+ abstract current(): DesktopApi | null;
+}
export abstract class AuthState extends Interface<AuthRuntimeState>() {}
@@ -449,24 +455,32 @@ export abstract class Lifecycle extends Interface<
Pick<LifecycleService, "supervised" | "onRestartRequest" | "requestRestart">
>() {}
-export abstract class Log extends Interface<{
- line(text: string): void;
-}>() {}
+@Interface()
+export abstract class Log {
+ abstract line(text: string): void;
+}
/**
* Whether a registry resource group inherited from the previous App may be adopted — the
* platform node decides from the parked declaration (hmr/platform.ts); a
* module that parks handles asks before claiming them back.
*/
-export abstract class ResourceGroups extends Interface<{
- adoptable(group: string): boolean;
-}>() {}
+@Interface()
+export abstract class ResourceGroups {
+ abstract adoptable(group: string): boolean;
+}
/** A clock every node reads time through; a test replaces it. */
-export abstract class Clock extends Interface<{ now(): Date }>() {}
+@Interface()
+export abstract class Clock {
+ abstract now(): Date;
+}
/** Where the data lives — what most nodes actually want from the config. */
-export abstract class Paths extends Interface<{ root: string }>() {}
+@Interface()
+export abstract class Paths {
+ abstract root: string;
+}
/**
* A replacement for one node of the tree: the class the platform would build, and the
@@ -548,10 +562,11 @@ export interface ReassemblyChange {
write(): Promise<void>;
undo(): Promise<void>;
}
-export abstract class Reassembly extends Interface<{
+@Interface()
+export abstract class Reassembly {
/** Whether the re-assembled tree is the one now running; false when its boot failed and the previous one was restored. */
- reassemble(change?: ReassemblyChange): Promise<boolean>;
-}>() {}
+ abstract reassemble(change?: ReassemblyChange): Promise<boolean>;
+}
@Module()
export class AppReassembly {
@Provide() reassembly!: Reassembly;
diff --git a/packages/server/src/http/app.ts b/packages/server/src/http/app.ts
index 0b7d50cc..0b7fa4a0 100644
--- a/packages/server/src/http/app.ts
+++ b/packages/server/src/http/app.ts
@@ -16,9 +16,10 @@ import type { Errors } from "../mechanisms/observability.js";
import type { Settings } from "../mechanisms/settings.js";
/** The assembled business surface: one request in, one response (or a decline) out. */
-export abstract class Http extends Interface<{
- fetch(request: Opaque<"Request", Request>): Promise<Opaque<"Response", Response>>;
-}>() {}
+@Interface()
+export abstract class Http {
+ abstract fetch(request: Opaque<"Request", Request>): Promise<Opaque<"Response", Response>>;
+}
export interface HttpSlots {
/**
diff --git a/packages/server/src/http/routes/contributions.ts b/packages/server/src/http/routes/contributions.ts
index 3e672128..6a27260d 100644
--- a/packages/server/src/http/routes/contributions.ts
+++ b/packages/server/src/http/routes/contributions.ts
@@ -27,10 +27,11 @@ export function contributionsRoutes(deps: ContributionsRouteDeps): Hono<AppEnv>
* crosses this boundary — only data.
*/
-export abstract class WebShell extends Interface<{
+@Interface()
+export abstract class WebShell {
/** Every contribution to the web slots, by slot, in module order. */
- contributions(): ContributionsResponse;
-}>() {}
+ abstract contributions(): ContributionsResponse;
+}
export interface WebShellSlots {
/** A page: its route, whether it sits in the main nav, whether it is admin-only. */
diff --git a/packages/server/src/mechanisms/agents.ts b/packages/server/src/mechanisms/agents.ts
index 077f41d2..70287f67 100644
--- a/packages/server/src/mechanisms/agents.ts
+++ b/packages/server/src/mechanisms/agents.ts
@@ -29,10 +29,11 @@ import type { AgentListItem } from "../services/agent-service.js";
import type { BenchmarkCreateInput } from "../services/benchmark-service.js";
/** AgentConfig: the mechanism AgentConfigService implements. */
-export abstract class AgentConfig extends Interface<{
- exists(projectId: string, agentId: string): Promise<boolean>;
- requireExists(projectId: string, agentId: string): Promise<void>;
- readCardMeta(
+@Interface()
+export abstract class AgentConfig {
+ abstract exists(projectId: string, agentId: string): Promise<boolean>;
+ abstract requireExists(projectId: string, agentId: string): Promise<void>;
+ abstract readCardMeta(
projectId: string,
agentId: string,
): Promise<{
@@ -42,73 +43,103 @@ export abstract class AgentConfig extends Interface<{
version: number;
kernelOutdated: boolean;
}>;
- getConfig(projectId: string, agentId: string): Promise<AgentConfigView>;
- updateConfig(projectId: string, agentId: string, req: AgentConfigUpdateRequest): Promise<void>;
- resetConfig(projectId: string, agentId: string): Promise<void>;
- kernelUpdate(projectId: string, agentId: string): Promise<AgentKernelUpdateResponse>;
- insertTemplatePlaceholder(
+ abstract getConfig(projectId: string, agentId: string): Promise<AgentConfigView>;
+ abstract updateConfig(
+ projectId: string,
+ agentId: string,
+ req: AgentConfigUpdateRequest,
+ ): Promise<void>;
+ abstract resetConfig(projectId: string, agentId: string): Promise<void>;
+ abstract kernelUpdate(projectId: string, agentId: string): Promise<AgentKernelUpdateResponse>;
+ abstract insertTemplatePlaceholder(
projectId: string,
agentId: string,
feature: "vault" | "skills" | "schedules",
): Promise<AgentConfigView>;
- getVault(projectId: string, agentId: string): Promise<VaultResponse>;
- updateVault(projectId: string, agentId: string, req: VaultUpdateRequest): Promise<VaultResponse>;
-}>() {}
+ abstract getVault(projectId: string, agentId: string): Promise<VaultResponse>;
+ abstract updateVault(
+ projectId: string,
+ agentId: string,
+ req: VaultUpdateRequest,
+ ): Promise<VaultResponse>;
+}
/** Snapshots: the mechanism SnapshotService implements. */
-export abstract class Snapshots extends Interface<{
- currentVersion(projectId: string, agentId: string): Promise<number>;
- ensureSnapshot(projectId: string, agentId: string): Promise<{ version: number; file: string }>;
- exportArchive(
+@Interface()
+export abstract class Snapshots {
+ abstract currentVersion(projectId: string, agentId: string): Promise<number>;
+ abstract ensureSnapshot(
+ projectId: string,
+ agentId: string,
+ ): Promise<{ version: number; file: string }>;
+ abstract exportArchive(
projectId: string,
agentId: string,
): Promise<{ version: number; file: string; fileName: string }>;
- importArchive(
+ abstract importArchive(
projectId: string,
agentId: string,
archive: Buffer<ArrayBufferLike>,
opts: { confirm: boolean; preSnapshot?: boolean },
): Promise<{ version: number }>;
-}>() {}
+}
/** Memory: the mechanism MemoryService implements. */
-export abstract class Memory extends Interface<{
- overview(projectId: string, agentId: string): Promise<MemoryOverviewResponse>;
- insertTemplatePlaceholder(projectId: string, agentId: string): Promise<MemoryOverviewResponse>;
- listScopes(projectId: string, agentId: string): Promise<MemoryScopeInfo[]>;
- listFiles(projectId: string, agentId: string, scopeKey: string): Promise<MemoryFilesResponse>;
- readFile(
+@Interface()
+export abstract class Memory {
+ abstract overview(projectId: string, agentId: string): Promise<MemoryOverviewResponse>;
+ abstract insertTemplatePlaceholder(
+ projectId: string,
+ agentId: string,
+ ): Promise<MemoryOverviewResponse>;
+ abstract listScopes(projectId: string, agentId: string): Promise<MemoryScopeInfo[]>;
+ abstract listFiles(
+ projectId: string,
+ agentId: string,
+ scopeKey: string,
+ ): Promise<MemoryFilesResponse>;
+ abstract readFile(
projectId: string,
agentId: string,
scopeKey: string,
fileName: string,
): Promise<MemoryFileResponse>;
- exportScope(projectId: string, agentId: string, scopeKey: string): Promise<MemoryScopeExport>;
- importScope(
+ abstract exportScope(
+ projectId: string,
+ agentId: string,
+ scopeKey: string,
+ ): Promise<MemoryScopeExport>;
+ abstract importScope(
projectId: string,
agentId: string,
scopeKey: string,
request: { mode: MemoryImportMode; confirm: boolean; payload: unknown },
): Promise<MemoryImportResponse>;
- deleteFile(projectId: string, agentId: string, scopeKey: string, fileName: string): Promise<void>;
-}>() {}
+ abstract deleteFile(
+ projectId: string,
+ agentId: string,
+ scopeKey: string,
+ fileName: string,
+ ): Promise<void>;
+}
/** Benchmarks: the mechanism BenchmarkService implements. */
-export abstract class Benchmarks extends Interface<{
- list(projectId: string): Promise<BenchmarksResponse>;
+@Interface()
+export abstract class Benchmarks {
+ abstract list(projectId: string): Promise<BenchmarksResponse>;
/** Every id `create` refuses as taken, as names only, including a folder that does not list. */
- takenIds(projectId: string): Promise<string[]>;
- create(projectId: string, input: BenchmarkCreateInput): Promise<BenchmarkSummary>;
- remove(projectId: string, benchmarkId: string): Promise<void>;
- listCases(projectId: string, benchmarkId: string): Promise<BenchmarkCasesResponse>;
- listCaseFiles(
+ abstract takenIds(projectId: string): Promise<string[]>;
+ abstract create(projectId: string, input: BenchmarkCreateInput): Promise<BenchmarkSummary>;
+ abstract remove(projectId: string, benchmarkId: string): Promise<void>;
+ abstract listCases(projectId: string, benchmarkId: string): Promise<BenchmarkCasesResponse>;
+ abstract listCaseFiles(
projectId: string,
benchmarkId: string,
caseId: string,
rel: string,
material: CaseMaterial,
): Promise<WorkspaceFilesResponse>;
- readCaseFile(
+ abstract readCaseFile(
projectId: string,
benchmarkId: string,
caseId: string,
@@ -116,15 +147,16 @@ export abstract class Benchmarks extends Interface<{
material: CaseMaterial,
options?: WorkspaceFileReadOptions,
): Promise<WorkspaceFileContent>;
-}>() {}
+}
/** AgentLifecycle: the mechanism AgentService implements. */
-export abstract class AgentLifecycle extends Interface<{
- listAgents(projectId: string): Promise<AgentListItem[]>;
+@Interface()
+export abstract class AgentLifecycle {
+ abstract listAgents(projectId: string): Promise<AgentListItem[]>;
/** Every id `createAgent` refuses as taken, as names only, including a folder that does not list. */
- takenAgentIds(projectId: string): Promise<string[]>;
- deleteAgent(projectId: string, agentId: string): Promise<void>;
- createAgent(
+ abstract takenAgentIds(projectId: string): Promise<string[]>;
+ abstract deleteAgent(projectId: string, agentId: string): Promise<void>;
+ abstract createAgent(
projectId: string,
agentId: string,
name?: string,
@@ -133,10 +165,10 @@ export abstract class AgentLifecycle extends Interface<{
directory?: { path: string; names: readonly string[] },
archive?: Buffer<ArrayBufferLike>,
): Promise<AgentListItem>;
- pluginVersion(
+ abstract pluginVersion(
projectId: string,
agentId: string,
pluginName: string,
): Promise<{ installed: string | null; library: string | null }>;
- updatePlugin(projectId: string, agentId: string, pluginName: string): Promise<void>;
-}>() {}
+ abstract updatePlugin(projectId: string, agentId: string, pluginName: string): Promise<void>;
+}
diff --git a/packages/server/src/mechanisms/identity.ts b/packages/server/src/mechanisms/identity.ts
index c076b367..6c90196c 100644
--- a/packages/server/src/mechanisms/identity.ts
+++ b/packages/server/src/mechanisms/identity.ts
@@ -8,61 +8,67 @@ import type { UserInfo } from "../api/types.js";
import type { SessionVia } from "../auth/service.js";
/** Users: the mechanism UsersRepo implements. */
-export abstract class Users extends Interface<{
- insert(row: UserRow): void;
- findById(userId: string): UserRow | null;
- list(): UserRow[];
- count(): number;
- updatePassword(userId: string, passwordHash: string, isInitial: boolean): void;
- updateProfile(
+@Interface()
+export abstract class Users {
+ abstract insert(row: UserRow): void;
+ abstract findById(userId: string): UserRow | null;
+ abstract list(): UserRow[];
+ abstract count(): number;
+ abstract updatePassword(userId: string, passwordHash: string, isInitial: boolean): void;
+ abstract updateProfile(
userId: string,
patch: { displayName?: string | null; avatar?: string | null },
): void;
- delete(userId: string): void;
-}>() {}
+ abstract delete(userId: string): void;
+}
/** AuthSessions: the mechanism AuthSessionsRepo implements. */
-export abstract class AuthSessions extends Interface<{
- issue(opts: {
+@Interface()
+export abstract class AuthSessions {
+ abstract issue(opts: {
userId: string;
via: SessionViaValue;
now: Date;
ttlMs: number;
maxTtlMs?: number;
}): { token: string; expiresAt: string };
- insert(row: AuthSessionRow): void;
- findByTokenHash(tokenHash: string): AuthSessionRow | null;
- touch(tokenHash: string, expiresAt: string): void;
- delete(tokenHash: string): void;
- deleteExpired(nowIso: string): void;
- deleteByUser(userId: string): void;
- deleteByUserAndVia(userId: string, via: SessionViaValue): void;
-}>() {}
+ abstract insert(row: AuthSessionRow): void;
+ abstract findByTokenHash(tokenHash: string): AuthSessionRow | null;
+ abstract touch(tokenHash: string, expiresAt: string): void;
+ abstract delete(tokenHash: string): void;
+ abstract deleteExpired(nowIso: string): void;
+ abstract deleteByUser(userId: string): void;
+ abstract deleteByUserAndVia(userId: string, via: SessionViaValue): void;
+}
/** Auth: the mechanism AuthService implements. */
-export abstract class Auth extends Interface<{
- readonly sessionTtlMs: number;
- mintFirstLogin(): string | null;
- adminPasswordIs(password: string): Promise<boolean>;
- seedAdmin(): Promise<void>;
- redeemFirstLogin(given: string): string | null;
- adminPasswordIsInitial(): boolean;
- login(userId: string, password: string): Promise<{ user: UserInfo; token: string }>;
- loginDesktop(): { user: UserInfo; token: string };
- changePassword(userId: string, oldPassword: string, newPassword: string): Promise<void>;
- setInitialPassword(userId: string, newPassword: string): Promise<void>;
- logout(token: string): void;
- localApiToken(): string | null;
- authenticateApiToken(token: string): { user: UserRow; via: SessionVia } | null;
- authenticateWithMeta(token: string): { user: UserRow; via: SessionVia; renewed: boolean } | null;
- sessionIsLive(token: string): boolean;
- isAdmin(userId: string): boolean;
-}>() {}
+@Interface()
+export abstract class Auth {
+ abstract readonly sessionTtlMs: number;
+ abstract mintFirstLogin(): string | null;
+ abstract adminPasswordIs(password: string): Promise<boolean>;
+ abstract seedAdmin(): Promise<void>;
+ abstract redeemFirstLogin(given: string): string | null;
+ abstract adminPasswordIsInitial(): boolean;
+ abstract login(userId: string, password: string): Promise<{ user: UserInfo; token: string }>;
+ abstract loginDesktop(): { user: UserInfo; token: string };
+ abstract changePassword(userId: string, oldPassword: string, newPassword: string): Promise<void>;
+ abstract setInitialPassword(userId: string, newPassword: string): Promise<void>;
+ abstract logout(token: string): void;
+ abstract localApiToken(): string | null;
+ abstract authenticateApiToken(token: string): { user: UserRow; via: SessionVia } | null;
+ abstract authenticateWithMeta(
+ token: string,
+ ): { user: UserRow; via: SessionVia; renewed: boolean } | null;
+ abstract sessionIsLive(token: string): boolean;
+ abstract isAdmin(userId: string): boolean;
+}
/** Admin: the mechanism AdminService implements. */
-export abstract class Admin extends Interface<{
- listUsers(): UserInfo[];
- createUser(userId: string, password: string): Promise<UserInfo>;
- resetPassword(userId: string, password: string): Promise<void>;
- deleteUser(userId: string): Promise<void>;
-}>() {}
+@Interface()
+export abstract class Admin {
+ abstract listUsers(): UserInfo[];
+ abstract createUser(userId: string, password: string): Promise<UserInfo>;
+ abstract resetPassword(userId: string, password: string): Promise<void>;
+ abstract deleteUser(userId: string): Promise<void>;
+}
diff --git a/packages/server/src/mechanisms/messaging.ts b/packages/server/src/mechanisms/messaging.ts
index ba414577..6eb3391f 100644
--- a/packages/server/src/mechanisms/messaging.ts
+++ b/packages/server/src/mechanisms/messaging.ts
@@ -5,13 +5,14 @@ import { Interface } from "@prismshadow/penguin-core/kernel";
import type { MessagingBindingRow } from "../db/repos/messaging-bindings.js";
/** MessagingBindings: the mechanism MessagingBindingsRepo implements. */
-export abstract class MessagingBindings extends Interface<{
- find(sessionId: string, channel: string): MessagingBindingRow | null;
- findEnabled(sessionId: string): MessagingBindingRow | null;
- listForSession(sessionId: string): MessagingBindingRow[];
- findEnabledByAccount(channel: string, accountId: string): MessagingBindingRow | null;
- listAll(): MessagingBindingRow[];
- upsert(args: {
+@Interface()
+export abstract class MessagingBindings {
+ abstract find(sessionId: string, channel: string): MessagingBindingRow | null;
+ abstract findEnabled(sessionId: string): MessagingBindingRow | null;
+ abstract listForSession(sessionId: string): MessagingBindingRow[];
+ abstract findEnabledByAccount(channel: string, accountId: string): MessagingBindingRow | null;
+ abstract listAll(): MessagingBindingRow[];
+ abstract upsert(args: {
sessionId: string;
channel: string;
accountId: string;
@@ -20,9 +21,13 @@ export abstract class MessagingBindings extends Interface<{
finalReplyOnly?: boolean;
renderMarkdown?: boolean;
}): MessagingBindingRow;
- setEnabled(sessionId: string, channel: string, enabled: boolean): void;
- recordChat(sessionId: string, channel: string, chatId: string, isDirect: boolean): void;
- recordInboundWatermark(sessionId: string, channel: string, messageId: string | null): void;
- delete(sessionId: string, channel: string): void;
- deleteSession(sessionId: string): void;
-}>() {}
+ abstract setEnabled(sessionId: string, channel: string, enabled: boolean): void;
+ abstract recordChat(sessionId: string, channel: string, chatId: string, isDirect: boolean): void;
+ abstract recordInboundWatermark(
+ sessionId: string,
+ channel: string,
+ messageId: string | null,
+ ): void;
+ abstract delete(sessionId: string, channel: string): void;
+ abstract deleteSession(sessionId: string): void;
+}
diff --git a/packages/server/src/mechanisms/observability.ts b/packages/server/src/mechanisms/observability.ts
index f31d13fc..09d114ce 100644
--- a/packages/server/src/mechanisms/observability.ts
+++ b/packages/server/src/mechanisms/observability.ts
@@ -62,75 +62,84 @@ import type {
} from "../services/usage-service.js";
/** ErrorLog: the mechanism ErrorsRepo implements. */
-export abstract class ErrorLog extends Interface<{
- insert(r: ErrorRecordInsert): void;
- summary(projectId: string, f?: ErrorFilter): ErrorSummary;
- topCode(projectId: string, f?: ErrorFilter): ErrorCodeCount | null;
- recent(
+@Interface()
+export abstract class ErrorLog {
+ abstract insert(r: ErrorRecordInsert): void;
+ abstract summary(projectId: string, f?: ErrorFilter): ErrorSummary;
+ abstract topCode(projectId: string, f?: ErrorFilter): ErrorCodeCount | null;
+ abstract recent(
projectId: string,
f?: ErrorFilter,
limit?: number,
offset?: number,
utcOffsetMinutes?: number,
): ErrorItem[];
- rowCount(projectId: string, f?: ErrorFilter, utcOffsetMinutes?: number): number;
- deleteFiltered(projectId: string, f?: Omit<ErrorFilter, "includeGlobal">): number;
- deleteByAgent(projectId: string, agentId: string): void;
- deleteByProject(projectId: string): void;
-}>() {}
+ abstract rowCount(projectId: string, f?: ErrorFilter, utcOffsetMinutes?: number): number;
+ abstract deleteFiltered(projectId: string, f?: Omit<ErrorFilter, "includeGlobal">): number;
+ abstract deleteByAgent(projectId: string, agentId: string): void;
+ abstract deleteByProject(projectId: string): void;
+}
/** Errors: the mechanism ErrorRecorder implements. */
-export abstract class Errors extends Interface<{
- record(args: ErrorRecordArgs): void;
-}>() {}
+@Interface()
+export abstract class Errors {
+ abstract record(args: ErrorRecordArgs): void;
+}
/** UsageStore: the mechanism UsageRepo implements. */
-export abstract class UsageStore extends Interface<{
- insert(r: UsageRecordInsert): void;
- bucketByModel(projectId: string, f?: UsageFilter, tiers?: readonly PeakTier[]): UsageModelSums[];
- groupsByModel(
+@Interface()
+export abstract class UsageStore {
+ abstract insert(r: UsageRecordInsert): void;
+ abstract bucketByModel(
+ projectId: string,
+ f?: UsageFilter,
+ tiers?: readonly PeakTier[],
+ ): UsageModelSums[];
+ abstract groupsByModel(
projectId: string,
groupBy: UsageGroupBy,
f?: UsageFilter,
tiers?: readonly PeakTier[],
): UsageGroupModelSums[];
- seriesByModel(
+ abstract seriesByModel(
projectId: string,
granularity: UsageSeriesGranularity,
f?: UsageFilter,
tiers?: readonly PeakTier[],
): UsageSeriesModelSums[];
- agentSeries(
+ abstract agentSeries(
projectId: string,
granularity: UsageSeriesGranularity,
f?: UsageFilter,
): UsageAgentBucketCount[];
- distinctAgentIds(projectId: string): string[];
- distinctModels(projectId: string): { provider: string; modelId: string }[];
- deleteByProject(projectId: string): void;
-}>() {}
+ abstract distinctAgentIds(projectId: string): string[];
+ abstract distinctModels(projectId: string): { provider: string; modelId: string }[];
+ abstract deleteByProject(projectId: string): void;
+}
/** UsageRecording: the mechanism UsageRecorder implements. */
-export abstract class UsageRecording extends Interface<{
- record(ctx: UsageContext, msg: OmniMessage<OmniPayload>): Promise<void>;
-}>() {}
+@Interface()
+export abstract class UsageRecording {
+ abstract record(ctx: UsageContext, msg: OmniMessage<OmniPayload>): Promise<void>;
+}
/** UsageQueries: the mechanism UsageService implements. */
-export abstract class UsageQueries extends Interface<{
- query(projectId: string, q: UsageQuery): Promise<UsageResponse>;
- queryErrors(projectId: string, q: UsageErrorsQuery): UsageErrorsPage;
- clearErrors(projectId: string, q: UsageErrorsClearQuery): number;
- modelTotals(projectId: string): UsageModelTotals;
- costBySession(
+@Interface()
+export abstract class UsageQueries {
+ abstract query(projectId: string, q: UsageQuery): Promise<UsageResponse>;
+ abstract queryErrors(projectId: string, q: UsageErrorsQuery): UsageErrorsPage;
+ abstract clearErrors(projectId: string, q: UsageErrorsClearQuery): number;
+ abstract modelTotals(projectId: string): UsageModelTotals;
+ abstract costBySession(
projectId: string,
sessionIds: readonly string[],
fromTs: string,
toTs: string,
): Promise<Opaque<"CostBySession", { bySession: Map<string, number>; unpriced: boolean }>>;
- dailyCostForSessions(
+ abstract dailyCostForSessions(
projectId: string,
sessionIds: readonly string[],
fromTs: string,
toTs: string,
): Promise<Array<{ date: string; cost: number }>>;
-}>() {}
+}
diff --git a/packages/server/src/mechanisms/projects.ts b/packages/server/src/mechanisms/projects.ts
index 90dc3ff8..9b420f22 100644
--- a/packages/server/src/mechanisms/projects.ts
+++ b/packages/server/src/mechanisms/projects.ts
@@ -46,129 +46,141 @@ import type {
} from "../services/model-oauth-service.js";
/** Projects: the mechanism ProjectsRepo implements. */
-export abstract class Projects extends Interface<{
- insert(row: ProjectRow): void;
- findById(projectId: string): ProjectRow | null;
- listAll(): ProjectRow[];
- listAccessible(userId: string): AccessibleProjectRow[];
- listByOwner(userId: string): ProjectRow[];
- delete(projectId: string): void;
-}>() {}
+@Interface()
+export abstract class Projects {
+ abstract insert(row: ProjectRow): void;
+ abstract findById(projectId: string): ProjectRow | null;
+ abstract listAll(): ProjectRow[];
+ abstract listAccessible(userId: string): AccessibleProjectRow[];
+ abstract listByOwner(userId: string): ProjectRow[];
+ abstract delete(projectId: string): void;
+}
/** Members: the mechanism MembersRepo implements. */
-export abstract class Members extends Interface<{
- insert(row: MemberRow): void;
- isMember(projectId: string, userId: string): boolean;
- list(projectId: string): MemberRow[];
- delete(projectId: string, userId: string): void;
-}>() {}
+@Interface()
+export abstract class Members {
+ abstract insert(row: MemberRow): void;
+ abstract isMember(projectId: string, userId: string): boolean;
+ abstract list(projectId: string): MemberRow[];
+ abstract delete(projectId: string, userId: string): void;
+}
/** AgentIndex: the mechanism AgentsRepo implements. */
-export abstract class AgentIndex extends Interface<{
- insertOrIgnore(row: AgentRow): void;
- exists(projectId: string, agentId: string): boolean;
- list(projectId: string): AgentRow[];
- delete(projectId: string, agentId: string): void;
- deleteByProject(projectId: string): void;
-}>() {}
+@Interface()
+export abstract class AgentIndex {
+ abstract insertOrIgnore(row: AgentRow): void;
+ abstract exists(projectId: string, agentId: string): boolean;
+ abstract list(projectId: string): AgentRow[];
+ abstract delete(projectId: string, agentId: string): void;
+ abstract deleteByProject(projectId: string): void;
+}
/** Access: the mechanism ProjectAccess implements. */
-export abstract class Access extends Interface<{
- find(userId: string, projectId: string): (ProjectRow & { role: ProjectRole }) | null;
- requireProjectAccess(userId: string, projectId: string): ProjectRow & { role: ProjectRole };
- canAccess(userId: string, projectId: string): boolean;
- requireProjectOwner(userId: string, projectId: string): ProjectRow;
- accessibleProjectIds(userId: string): string[];
- listProjects(userId: string): Promise<ProjectSummary[]>;
-}>() {}
+@Interface()
+export abstract class Access {
+ abstract find(userId: string, projectId: string): (ProjectRow & { role: ProjectRole }) | null;
+ abstract requireProjectAccess(
+ userId: string,
+ projectId: string,
+ ): ProjectRow & { role: ProjectRole };
+ abstract canAccess(userId: string, projectId: string): boolean;
+ abstract requireProjectOwner(userId: string, projectId: string): ProjectRow;
+ abstract accessibleProjectIds(userId: string): string[];
+ abstract listProjects(userId: string): Promise<ProjectSummary[]>;
+}
/** ProjectLifecycle: the mechanism ProjectService implements. */
-export abstract class ProjectLifecycle extends Interface<{
- requireProjectAccess(userId: string, projectId: string): ProjectRow & { role: ProjectRole };
- canAccess(userId: string, projectId: string): boolean;
- requireProjectOwner(userId: string, projectId: string): ProjectRow;
- accessibleProjectIds(userId: string): string[];
- listProjects(userId: string): Promise<ProjectSummary[]>;
- createProject(owner: UserRow, projectId: string, name?: string): Promise<ProjectSummary>;
+@Interface()
+export abstract class ProjectLifecycle {
+ abstract requireProjectAccess(
+ userId: string,
+ projectId: string,
+ ): ProjectRow & { role: ProjectRole };
+ abstract canAccess(userId: string, projectId: string): boolean;
+ abstract requireProjectOwner(userId: string, projectId: string): ProjectRow;
+ abstract accessibleProjectIds(userId: string): string[];
+ abstract listProjects(userId: string): Promise<ProjectSummary[]>;
+ abstract createProject(owner: UserRow, projectId: string, name?: string): Promise<ProjectSummary>;
/** Every id `createProject` refuses as taken, as names only: the rows and the data root's entries. */
- takenProjectIds(): Promise<string[]>;
- provisionInitialProject(user: UserRow, isAdmin: boolean): Promise<void>;
- renameProject(userId: string, projectId: string, name: string): Promise<ProjectSummary>;
- deleteProject(userId: string, projectId: string): Promise<void>;
- destroyProject(projectId: string): Promise<void>;
- listMembers(userId: string, projectId: string): MemberInfo[];
- addMember(userId: string, projectId: string, targetUserId: string): MemberInfo;
- removeMember(userId: string, projectId: string, targetUserId: string): void;
-}>() {}
+ abstract takenProjectIds(): Promise<string[]>;
+ abstract provisionInitialProject(user: UserRow, isAdmin: boolean): Promise<void>;
+ abstract renameProject(userId: string, projectId: string, name: string): Promise<ProjectSummary>;
+ abstract deleteProject(userId: string, projectId: string): Promise<void>;
+ abstract destroyProject(projectId: string): Promise<void>;
+ abstract listMembers(userId: string, projectId: string): MemberInfo[];
+ abstract addMember(userId: string, projectId: string, targetUserId: string): MemberInfo;
+ abstract removeMember(userId: string, projectId: string, targetUserId: string): void;
+}
/** ProjectConfigStore: the mechanism ProjectConfigService implements. */
-export abstract class ProjectConfigStore extends Interface<{
- readRaw(projectId: string): Promise<RawTable>;
- loadConfig(projectId: string): Promise<ProjectConfig>;
- writeRaw(projectId: string, data: RawTable): Promise<void>;
- writeInitialConfig(projectId: string, name: string): Promise<void>;
- ensurePresetModels(projectId: string): Promise<boolean>;
- seedPresetPromotions(projectId: string): Promise<void>;
- getName(projectId: string): Promise<string | undefined>;
- setName(projectId: string, name: string): Promise<void>;
- getDefaultModelRef(projectId: string): Promise<ModelRef | undefined>;
- setDefaultModelRef(projectId: string, ref: ModelRefDto): Promise<ModelRefDto>;
- getChatDefaults(projectId: string): Promise<ChatDefaultsDto>;
- setChatDefaults(projectId: string, req: ChatDefaultsDto): Promise<ChatDefaultsDto>;
+@Interface()
+export abstract class ProjectConfigStore {
+ abstract readRaw(projectId: string): Promise<RawTable>;
+ abstract loadConfig(projectId: string): Promise<ProjectConfig>;
+ abstract writeRaw(projectId: string, data: RawTable): Promise<void>;
+ abstract writeInitialConfig(projectId: string, name: string): Promise<void>;
+ abstract ensurePresetModels(projectId: string): Promise<boolean>;
+ abstract seedPresetPromotions(projectId: string): Promise<void>;
+ abstract getName(projectId: string): Promise<string | undefined>;
+ abstract setName(projectId: string, name: string): Promise<void>;
+ abstract getDefaultModelRef(projectId: string): Promise<ModelRef | undefined>;
+ abstract setDefaultModelRef(projectId: string, ref: ModelRefDto): Promise<ModelRefDto>;
+ abstract getChatDefaults(projectId: string): Promise<ChatDefaultsDto>;
+ abstract setChatDefaults(projectId: string, req: ChatDefaultsDto): Promise<ChatDefaultsDto>;
/** The `[plugins]` key: the shared table and each machine's own, package name → requirement, in the file's order. */
- getPluginTables(projectId: string): Promise<PluginTables>;
+ abstract getPluginTables(projectId: string): Promise<PluginTables>;
/** Replaces the tables (a declarative PUT); answers what was written. */
- setPluginTables(projectId: string, tables: PluginTables): Promise<PluginTables>;
- getCommandPolicy(projectId: string): Promise<CommandPolicyDto>;
- setCommandPolicy(
+ abstract setPluginTables(projectId: string, tables: PluginTables): Promise<PluginTables>;
+ abstract getCommandPolicy(projectId: string): Promise<CommandPolicyDto>;
+ abstract setCommandPolicy(
projectId: string,
req: {
enabled?: boolean;
rules: { name: string; pattern: string; description?: string; enabled?: boolean }[];
},
): Promise<CommandPolicyDto>;
- getPricing(
+ abstract getPricing(
projectId: string,
provider: string,
modelId: string,
): Promise<TieredRates | undefined>;
- detectVision(
+ abstract detectVision(
projectId: string,
req: ModelVisionDetectRequest,
): Promise<ModelVisionDetectResponse>;
- testModel(projectId: string, req: ModelTestRequest): Promise<ModelTestResponse>;
- detectProtocol(
+ abstract testModel(projectId: string, req: ModelTestRequest): Promise<ModelTestResponse>;
+ abstract detectProtocol(
projectId: string,
req: ModelProtocolDetectRequest,
): Promise<ModelProtocolDetectResponse>;
- listEndpointModels(
+ abstract listEndpointModels(
req: EndpointModelListRequest,
listImpl?: (options: ListEndpointModelsOptions) => Promise<string[]>,
timeoutMs?: number,
): Promise<EndpointModelListResponse>;
- getModels(projectId: string): Promise<ModelsResponse>;
- updateModels(projectId: string, req: ModelsUpdateRequest): Promise<ModelsResponse>;
- setGroupApiKey(projectId: string, provider: string, apiKey: string): Promise<number>;
- setGroupApiKeyWithProviderAuthToken(
+ abstract getModels(projectId: string): Promise<ModelsResponse>;
+ abstract updateModels(projectId: string, req: ModelsUpdateRequest): Promise<ModelsResponse>;
+ abstract setGroupApiKey(projectId: string, provider: string, apiKey: string): Promise<number>;
+ abstract setGroupApiKeyWithProviderAuthToken(
projectId: string,
provider: string,
apiKey: string,
token: Omit<ModelProviderAuthToken, "provider" | "updatedAt">,
options?: { expectedRefreshToken?: string },
): Promise<number>;
- getGroupApiKey(projectId: string, provider: string): Promise<string | undefined>;
- setModelApiKeyResolver(
+ abstract getGroupApiKey(projectId: string, provider: string): Promise<string | undefined>;
+ abstract setModelApiKeyResolver(
resolver: (context: ModelRequestContext) => Promise<string | undefined>,
): void;
- mergePlatformModels(
+ abstract mergePlatformModels(
projectId: string,
provider: string,
catalog: PlatformModelCatalog,
apiKey: string,
applyKeyToExisting: boolean,
): Promise<PlatformModelApplyResult>;
- completeOnce(projectId: string, prompt: string): Promise<UtilityCompletion>;
-}>() {}
+ abstract completeOnce(projectId: string, prompt: string): Promise<UtilityCompletion>;
+}
export interface ModelPromotion {
provider: string;
@@ -177,14 +189,19 @@ export interface ModelPromotion {
}
/** Per-Project model promotions (web.db `model_promotions`). */
-export abstract class ModelPromotions extends Interface<{
- get(projectId: string, provider: string, modelId: string): number | undefined;
- list(projectId: string): ModelPromotion[];
+@Interface()
+export abstract class ModelPromotions {
+ abstract get(projectId: string, provider: string, modelId: string): number | undefined;
+ abstract list(projectId: string): ModelPromotion[];
/** Replaces every promotion of the Project, in one transaction. */
- replaceAll(projectId: string, rows: readonly ModelPromotion[]): void;
+ abstract replaceAll(projectId: string, rows: readonly ModelPromotion[]): void;
/** Replaces the promotions of one provider group, in one transaction. */
- replaceProvider(projectId: string, provider: string, rows: readonly ModelPromotion[]): void;
-}>() {}
+ abstract replaceProvider(
+ projectId: string,
+ provider: string,
+ rows: readonly ModelPromotion[],
+ ): void;
+}
export interface ModelProviderAuthToken {
provider: string;
@@ -194,35 +211,37 @@ export interface ModelProviderAuthToken {
}
/** Server-side OAuth refresh metadata for provider groups (web.db `model_provider_auth_tokens`). */
-export abstract class ModelProviderAuthTokens extends Interface<{
- get(projectId: string, provider: string): ModelProviderAuthToken | undefined;
- upsert(projectId: string, row: Omit<ModelProviderAuthToken, "updatedAt">): void;
- delete(projectId: string, provider: string): void;
-}>() {}
+@Interface()
+export abstract class ModelProviderAuthTokens {
+ abstract get(projectId: string, provider: string): ModelProviderAuthToken | undefined;
+ abstract upsert(projectId: string, row: Omit<ModelProviderAuthToken, "updatedAt">): void;
+ abstract delete(projectId: string, provider: string): void;
+}
/** ModelOAuth: the mechanism ModelOAuthService implements. */
-export abstract class ModelOAuth extends Interface<{
- start(input: {
+@Interface()
+export abstract class ModelOAuth {
+ abstract start(input: {
projectId: string;
userId: string;
provider: string;
mode: ModelOAuthMode;
callbackOrigin: string;
}): ModelOAuthStartResult;
- deposit(input: { flowId: string; projectId: string; code: string }): void;
- poll(input: { flowId: string; userId: string; projectId: string }): Promise<{
+ abstract deposit(input: { flowId: string; projectId: string; code: string }): void;
+ abstract poll(input: { flowId: string; userId: string; projectId: string }): Promise<{
status: ModelOAuthStatus;
provider: string;
error?: ModelOAuthErrorCode;
applied?: number;
}>;
- complete(input: {
+ abstract complete(input: {
flowId: string;
userId: string;
projectId: string;
code: string;
}): Promise<{ ok: true; applied: number } | { ok: false; error: ModelOAuthErrorCode }>;
-}>() {}
+}
/**
* ProjectEvents: the mechanism ProjectNotifier implements — a user-level event to everyone
diff --git a/packages/server/src/mechanisms/sessions.ts b/packages/server/src/mechanisms/sessions.ts
index 411d55f0..83c7b746 100644
--- a/packages/server/src/mechanisms/sessions.ts
+++ b/packages/server/src/mechanisms/sessions.ts
@@ -12,41 +12,44 @@ import type { ScheduleFileCache } from "../runtime/schedule-store.js";
import type { ScheduleEntryView } from "../runtime/scheduler.js";
/** SessionIndex: the mechanism SessionsRepo implements. */
-export abstract class SessionIndex extends Interface<{
- insert(row: SessionRow): void;
- insertOrIgnore(row: SessionRow): void;
- insertFork(sourceSessionId: string, row: SessionRow): SessionRow;
- markOrgClient(sessionIds: readonly string[]): void;
- markHasTrace(sessionId: string): void;
- markDriven(sessionId: string, at: string): void;
- touchLastActive(sessionId: string, at: string): void;
- findById(sessionId: string): SessionRow | null;
- listByAgent(projectId: string, agentId: string): SessionRow[];
- listByProject(projectId: string): SessionRow[];
- updateApprovalMode(sessionId: string, mode: ApprovalMode): void;
- updateSandbox(sessionId: string, sandbox: SandboxSettings): void;
- updateThinkingLevel(sessionId: string, level: ThinkingLevelName): void;
- updateTitle(sessionId: string, title: string): void;
- updateTitleIfNull(sessionId: string, title: string): void;
- setArchived(sessionId: string, archivedAt: string | null): void;
- replaceId(oldSessionId: string, newSessionId: string): void;
- deleteByAgent(projectId: string, agentId: string): void;
- deleteByProject(projectId: string): void;
- deleteById(sessionId: string): void;
-}>() {}
+@Interface()
+export abstract class SessionIndex {
+ abstract insert(row: SessionRow): void;
+ abstract insertOrIgnore(row: SessionRow): void;
+ abstract insertFork(sourceSessionId: string, row: SessionRow): SessionRow;
+ abstract markOrgClient(sessionIds: readonly string[]): void;
+ abstract markHasTrace(sessionId: string): void;
+ abstract markDriven(sessionId: string, at: string): void;
+ abstract touchLastActive(sessionId: string, at: string): void;
+ abstract findById(sessionId: string): SessionRow | null;
+ abstract listByAgent(projectId: string, agentId: string): SessionRow[];
+ abstract listByProject(projectId: string): SessionRow[];
+ abstract updateApprovalMode(sessionId: string, mode: ApprovalMode): void;
+ abstract updateSandbox(sessionId: string, sandbox: SandboxSettings): void;
+ abstract updateThinkingLevel(sessionId: string, level: ThinkingLevelName): void;
+ abstract updateTitle(sessionId: string, title: string): void;
+ abstract updateTitleIfNull(sessionId: string, title: string): void;
+ abstract setArchived(sessionId: string, archivedAt: string | null): void;
+ abstract replaceId(oldSessionId: string, newSessionId: string): void;
+ abstract deleteByAgent(projectId: string, agentId: string): void;
+ abstract deleteByProject(projectId: string): void;
+ abstract deleteById(sessionId: string): void;
+}
/** SessionOrigins: the mechanism SessionSources implements. */
-export abstract class SessionOrigins extends Interface<{
- set(sessionId: string, source: SessionSource | null): void;
- get(sessionId: string): SessionSource | null | undefined;
- delete(sessionId: string): void;
-}>() {}
+@Interface()
+export abstract class SessionOrigins {
+ abstract set(sessionId: string, source: SessionSource | null): void;
+ abstract get(sessionId: string): SessionSource | null | undefined;
+ abstract delete(sessionId: string): void;
+}
/** Schedules: the mechanism SchedulesRepo implements. */
-export abstract class Schedules extends Interface<{
- find(projectId: string, agentId: string, name: string): ScheduleStateRow | null;
- listByAgent(projectId: string, agentId: string): ScheduleStateRow[];
- registerOrSync(args: {
+@Interface()
+export abstract class Schedules {
+ abstract find(projectId: string, agentId: string, name: string): ScheduleStateRow | null;
+ abstract listByAgent(projectId: string, agentId: string): ScheduleStateRow[];
+ abstract registerOrSync(args: {
projectId: string;
agentId: string;
name: string;
@@ -54,36 +57,37 @@ export abstract class Schedules extends Interface<{
defHash: string;
creatorUserId: string | null;
}): { row: ScheduleStateRow; fresh: boolean };
- markSlot(projectId: string, agentId: string, name: string, slotMs: number): void;
- markFired(
+ abstract markSlot(projectId: string, agentId: string, name: string, slotMs: number): void;
+ abstract markFired(
projectId: string,
agentId: string,
name: string,
firedAt: string,
oneShot: boolean,
): void;
- markMissed(projectId: string, agentId: string, name: string): void;
- markInvalid(projectId: string, agentId: string, name: string, reason: string): void;
- delete(projectId: string, agentId: string, name: string): void;
- deleteMissing(projectId: string, agentId: string, presentNames: string[]): string[];
- deleteByAgent(projectId: string, agentId: string): void;
- deleteByProject(projectId: string): void;
-}>() {}
+ abstract markMissed(projectId: string, agentId: string, name: string): void;
+ abstract markInvalid(projectId: string, agentId: string, name: string, reason: string): void;
+ abstract delete(projectId: string, agentId: string, name: string): void;
+ abstract deleteMissing(projectId: string, agentId: string, presentNames: string[]): string[];
+ abstract deleteByAgent(projectId: string, agentId: string): void;
+ abstract deleteByProject(projectId: string): void;
+}
/** Scheduling: the mechanism Scheduler implements. */
-export abstract class Scheduling extends Interface<{
- readonly files: Opaque<"ScheduleFileCache", ScheduleFileCache>;
- start(): Promise<void>;
- stop(): void;
- tickOnce(): Promise<void>;
- reconcileAgent(projectId: string, agentId: string): Promise<void>;
- listAgent(
+@Interface()
+export abstract class Scheduling {
+ abstract readonly files: Opaque<"ScheduleFileCache", ScheduleFileCache>;
+ abstract start(): Promise<void>;
+ abstract stop(): void;
+ abstract tickOnce(): Promise<void>;
+ abstract reconcileAgent(projectId: string, agentId: string): Promise<void>;
+ abstract listAgent(
projectId: string,
agentId: string,
): Promise<{ entries: ScheduleEntryView[]; invalid: Array<{ name: string; error: string }> }>;
- listProject(projectId: string): Promise<{
+ abstract listProject(projectId: string): Promise<{
entries: Array<ScheduleEntryView & { agentId: string }>;
invalid: Array<{ agentId: string; name: string; error: string }>;
}>;
- dropEntry(projectId: string, agentId: string, name: string): void;
-}>() {}
+ abstract dropEntry(projectId: string, agentId: string, name: string): void;
+}
diff --git a/packages/server/src/mechanisms/settings.ts b/packages/server/src/mechanisms/settings.ts
index c5c13ebb..d1061c8d 100644
--- a/packages/server/src/mechanisms/settings.ts
+++ b/packages/server/src/mechanisms/settings.ts
@@ -4,26 +4,28 @@
import { Interface } from "@prismshadow/penguin-core/kernel";
/** Settings: the mechanism ServerSettingsRepo implements. */
-export abstract class Settings extends Interface<{
- get(key: string): string | null;
- set(key: string, value: string): void;
- getProxyForApp(): boolean;
- setProxyForApp(value: boolean): void;
- getProxyForAgent(): boolean;
- setProxyForAgent(value: boolean): void;
- getProxyUrl(): string | null;
- setProxyUrl(value: string | null): void;
- getAttachmentMaxMb(): number;
- setAttachmentMaxMb(value: number): void;
- getAttachmentTotalMb(): number;
- setAttachmentTotalMb(value: number): void;
- getAttachmentLimitsMb(): { attachmentMaxMb: number; attachmentTotalMb: number };
- getCompanyMode(): boolean;
- setCompanyMode(value: boolean): void;
-}>() {}
+@Interface()
+export abstract class Settings {
+ abstract get(key: string): string | null;
+ abstract set(key: string, value: string): void;
+ abstract getProxyForApp(): boolean;
+ abstract setProxyForApp(value: boolean): void;
+ abstract getProxyForAgent(): boolean;
+ abstract setProxyForAgent(value: boolean): void;
+ abstract getProxyUrl(): string | null;
+ abstract setProxyUrl(value: string | null): void;
+ abstract getAttachmentMaxMb(): number;
+ abstract setAttachmentMaxMb(value: number): void;
+ abstract getAttachmentTotalMb(): number;
+ abstract setAttachmentTotalMb(value: number): void;
+ abstract getAttachmentLimitsMb(): { attachmentMaxMb: number; attachmentTotalMb: number };
+ abstract getCompanyMode(): boolean;
+ abstract setCompanyMode(value: boolean): void;
+}
/** UiPrefsStore: the mechanism UiPrefsRepo implements. */
-export abstract class UiPrefsStore extends Interface<{
- get(userId: string): string | null;
- set(userId: string, prefsJson: string): void;
-}>() {}
+@Interface()
+export abstract class UiPrefsStore {
+ abstract get(userId: string): string | null;
+ abstract set(userId: string, prefsJson: string): void;
+}
diff --git a/packages/server/src/mechanisms/traces.ts b/packages/server/src/mechanisms/traces.ts
index 45e9bb55..fa14a933 100644
--- a/packages/server/src/mechanisms/traces.ts
+++ b/packages/server/src/mechanisms/traces.ts
@@ -49,22 +49,23 @@ import type {
import type { MessageCursor } from "../services/message-window.js";
/** TraceIndexStore: the mechanism TraceIndexRepo implements. */
-export abstract class TraceIndexStore extends Interface<{
- upsertFile(row: TraceFileRow): void;
- updateFileSize(
+@Interface()
+export abstract class TraceIndexStore {
+ abstract upsertFile(row: TraceFileRow): void;
+ abstract updateFileSize(
projectId: string,
agentId: string,
sessionId: string,
fileIndex: number,
sizeBytes: number,
): void;
- getPageStats(
+ abstract getPageStats(
projectId: string,
agentId: string,
sessionId: string,
fileIndex: number,
): string | null;
- setPageStats(
+ abstract setPageStats(
projectId: string,
agentId: string,
sessionId: string,
@@ -72,24 +73,38 @@ export abstract class TraceIndexStore extends Interface<{
sizeBytes: number,
pageStats: string,
): void;
- deleteFile(projectId: string, agentId: string, sessionId: string, fileIndex: number): void;
- listFilesByAgent(projectId: string, agentId: string): TraceFileRow[];
- listFilesBySession(projectId: string, agentId: string, sessionId: string): TraceFileRow[];
- findAgentBySession(projectId: string, sessionId: string): string | null;
- upsertSession(row: TraceSessionRow): void;
- getSession(sessionId: string): TraceSessionRow | null;
- listSessionsByAgent(projectId: string, agentId: string): TraceSessionRow[];
- deleteBySession(sessionId: string): void;
- deleteByAgent(projectId: string, agentId: string): void;
- deleteByProject(projectId: string): void;
-}>() {}
+ abstract deleteFile(
+ projectId: string,
+ agentId: string,
+ sessionId: string,
+ fileIndex: number,
+ ): void;
+ abstract listFilesByAgent(projectId: string, agentId: string): TraceFileRow[];
+ abstract listFilesBySession(
+ projectId: string,
+ agentId: string,
+ sessionId: string,
+ ): TraceFileRow[];
+ abstract findAgentBySession(projectId: string, sessionId: string): string | null;
+ abstract upsertSession(row: TraceSessionRow): void;
+ abstract getSession(sessionId: string): TraceSessionRow | null;
+ abstract listSessionsByAgent(projectId: string, agentId: string): TraceSessionRow[];
+ abstract deleteBySession(sessionId: string): void;
+ abstract deleteByAgent(projectId: string, agentId: string): void;
+ abstract deleteByProject(projectId: string): void;
+}
/** TraceIndex: the mechanism TraceIndexService implements. */
-export abstract class TraceIndex extends Interface<{
- readonly counters: { gateStats: number; dirScans: number; headReads: number };
- reconcileAgent(projectId: string, agentId: string, opts?: { force?: boolean }): Promise<void>;
- reconcileProject(projectId: string, opts?: { force?: boolean }): Promise<void>;
- registerImportedFile(args: {
+@Interface()
+export abstract class TraceIndex {
+ abstract readonly counters: { gateStats: number; dirScans: number; headReads: number };
+ abstract reconcileAgent(
+ projectId: string,
+ agentId: string,
+ opts?: { force?: boolean },
+ ): Promise<void>;
+ abstract reconcileProject(projectId: string, opts?: { force?: boolean }): Promise<void>;
+ abstract registerImportedFile(args: {
projectId: string;
agentId: string;
sessionId: string;
@@ -98,35 +113,48 @@ export abstract class TraceIndex extends Interface<{
sizeBytes: number;
records: OmniMessage[];
}): void;
- removeSession(projectId: string, agentId: string, sessionId: string): void;
- removeAgent(projectId: string, agentId: string): void;
- removeProject(projectId: string): void;
-}>() {}
+ abstract removeSession(projectId: string, agentId: string, sessionId: string): void;
+ abstract removeAgent(projectId: string, agentId: string): void;
+ abstract removeProject(projectId: string): void;
+}
/** Traces: the mechanism TraceService implements. */
-export abstract class Traces extends Interface<{
- observeShardRead?: ((path: string) => void) | undefined;
- deleteSessionTraces(projectId: string, agentId: string, sessionId: string): Promise<void>;
- readMessages(projectId: string, agentId: string, sessionId: string): Promise<HistoryMessage[]>;
- readMessagesPage(
+@Interface()
+export abstract class Traces {
+ abstract observeShardRead?: ((path: string) => void) | undefined;
+ abstract deleteSessionTraces(
+ projectId: string,
+ agentId: string,
+ sessionId: string,
+ ): Promise<void>;
+ abstract readMessages(
+ projectId: string,
+ agentId: string,
+ sessionId: string,
+ ): Promise<HistoryMessage[]>;
+ abstract readMessagesPage(
projectId: string,
agentId: string,
sessionId: string,
req: MessagesPageRequest,
): Promise<MessagesPageResult>;
- forkSessionTrace(
+ abstract forkSessionTrace(
projectId: string,
agentId: string,
sourceSessionId: string,
position: TracePosition,
): Promise<ForkTraceResult>;
- contextBreakdown(
+ abstract contextBreakdown(
projectId: string,
agentId: string,
sessionId: string,
): Promise<SessionContextParts>;
- listTraceFiles(projectId: string, agentId: string, sessionId: string): Promise<TraceFileInfo[]>;
- readEvents(
+ abstract listTraceFiles(
+ projectId: string,
+ agentId: string,
+ sessionId: string,
+ ): Promise<TraceFileInfo[]>;
+ abstract readEvents(
projectId: string,
agentId: string,
sessionId: string,
@@ -134,27 +162,27 @@ export abstract class Traces extends Interface<{
offset: number,
limit: number,
): Promise<TraceEventsResponse>;
- analyze(
+ abstract analyze(
projectId: string,
agentId: string,
sessionId: string,
index: number,
): Promise<TraceAnalysisResponse>;
- agentTraces(
+ abstract agentTraces(
projectId: string,
agentId: string,
paging: { offset: number; limit: number } | null,
opts?: { category?: SessionCategory },
): Promise<AgentTracesResponse>;
- readFileRaw(
+ abstract readFileRaw(
projectId: string,
agentId: string,
sessionId: string,
index: number,
): Promise<Buffer<ArrayBufferLike>>;
- importTraceFile(
+ abstract importTraceFile(
projectId: string,
agentId: string,
content: string,
): Promise<TraceImportResponse>;
-}>() {}
+}
diff --git a/packages/server/src/mechanisms/workspace.ts b/packages/server/src/mechanisms/workspace.ts
index 741ce6ab..f8955e26 100644
--- a/packages/server/src/mechanisms/workspace.ts
+++ b/packages/server/src/mechanisms/workspace.ts
@@ -10,28 +10,30 @@ import type {
import type { WorkspaceFilesResponse, WorkspaceSearchResponse } from "../api/types.js";
/** WorkspaceFiles: the mechanism WorkspaceFilesService implements. */
-export abstract class WorkspaceFiles extends Interface<{
- statExisting(workspace: string, rels: string[]): Promise<string[]>;
- statExistingWithMtime(workspace: string, rels: string[]): Promise<WorkspaceFileStat[]>;
- list(workspace: string, rel: string): Promise<WorkspaceFilesResponse>;
- read(
+@Interface()
+export abstract class WorkspaceFiles {
+ abstract statExisting(workspace: string, rels: string[]): Promise<string[]>;
+ abstract statExistingWithMtime(workspace: string, rels: string[]): Promise<WorkspaceFileStat[]>;
+ abstract list(workspace: string, rel: string): Promise<WorkspaceFilesResponse>;
+ abstract read(
workspace: string,
rel: string,
options?: WorkspaceFileReadOptions,
): Promise<WorkspaceFileContent>;
- write(
+ abstract write(
workspace: string,
rel: string,
data: Buffer<ArrayBufferLike>,
ifVersion?: string,
): Promise<void>;
- move(workspace: string, from: string, to: string, ifVersion?: string): Promise<void>;
- remove(workspace: string, rel: string, ifVersion?: string): Promise<void>;
- search(workspace: string, q: string): Promise<WorkspaceSearchResponse>;
- resolvePath(workspace: string, rel: string): Promise<string>;
-}>() {}
+ abstract move(workspace: string, from: string, to: string, ifVersion?: string): Promise<void>;
+ abstract remove(workspace: string, rel: string, ifVersion?: string): Promise<void>;
+ abstract search(workspace: string, q: string): Promise<WorkspaceSearchResponse>;
+ abstract resolvePath(workspace: string, rel: string): Promise<string>;
+}
/** FileReveal: opening a path in the machine's file manager, as RevealService implements it. */
-export abstract class FileReveal extends Interface<{
- reveal(filePath: string): Promise<void>;
-}>() {}
+@Interface()
+export abstract class FileReveal {
+ abstract reveal(filePath: string): Promise<void>;
+}
diff --git a/packages/server/src/runtime/messaging/bridge.ts b/packages/server/src/runtime/messaging/bridge.ts
index d5b66b65..b5fa2750 100644
--- a/packages/server/src/runtime/messaging/bridge.ts
+++ b/packages/server/src/runtime/messaging/bridge.ts
@@ -2189,11 +2189,12 @@ export class MessagingModule {
* The pacing and budgets the messaging bridge and its connectors run with. Every field is
* optional: absent, a connector applies its own default; a test stands in zeros.
*/
-export abstract class MessagingTuning extends Interface<{
- lineDelayMs?: number;
- inboundImageBudgetBytes?: number;
- qqTailFlushMs?: number;
- retryDelayMs?: (failures: number) => number;
-}>() {}
+@Interface()
+export abstract class MessagingTuning {
+ abstract lineDelayMs?: number;
+ abstract inboundImageBudgetBytes?: number;
+ abstract qqTailFlushMs?: number;
+ abstract retryDelayMs?: (failures: number) => number;
+}
@Component()
export class DefaultMessagingTuning implements MessagingTuning {}
diff --git a/packages/server/src/runtime/messaging/feishu-connector.ts b/packages/server/src/runtime/messaging/feishu-connector.ts
index 024df475..fadd93ef 100644
--- a/packages/server/src/runtime/messaging/feishu-connector.ts
+++ b/packages/server/src/runtime/messaging/feishu-connector.ts
@@ -334,9 +334,10 @@ export class FeishuMessaging {
}
/** The Lark SDK as a node, so a test stands in a fake for the network. */
-export abstract class FeishuSdkHandle extends Interface<{
- sdk: Opaque<"FeishuSdk", FeishuSdk>;
-}>() {}
+@Interface()
+export abstract class FeishuSdkHandle {
+ abstract sdk: Opaque<"FeishuSdk", FeishuSdk>;
+}
@Module()
export class FeishuSdkProvider {
@Provide() feishuSdk!: FeishuSdkHandle;
diff --git a/packages/server/src/runtime/messaging/qq-connector.ts b/packages/server/src/runtime/messaging/qq-connector.ts
index d0316997..0545a956 100644
--- a/packages/server/src/runtime/messaging/qq-connector.ts
+++ b/packages/server/src/runtime/messaging/qq-connector.ts
@@ -665,9 +665,10 @@ export class QqMessaging {
}
/** The QQ OpenAPI + gateway transport as a node, so a test stands in a fake for the network. */
-export abstract class QQTransportHandle extends Interface<{
- transport: Opaque<"QQTransport", QQTransport>;
-}>() {}
+@Interface()
+export abstract class QQTransportHandle {
+ abstract transport: Opaque<"QQTransport", QQTransport>;
+}
@Module()
export class QQTransportProvider {
@Provide() qqTransport!: QQTransportHandle;
diff --git a/packages/server/src/runtime/messaging/qq-scan.ts b/packages/server/src/runtime/messaging/qq-scan.ts
index eb315d38..024eab91 100644
--- a/packages/server/src/runtime/messaging/qq-scan.ts
+++ b/packages/server/src/runtime/messaging/qq-scan.ts
@@ -436,9 +436,10 @@ export class QQScanService {
}
/** The scan-to-connect transport as a node, so a test stands in a fake for the network. */
-export abstract class QQScanTransportHandle extends Interface<{
- transport: Opaque<"QQScanTransport", QQScanTransport>;
-}>() {}
+@Interface()
+export abstract class QQScanTransportHandle {
+ abstract transport: Opaque<"QQScanTransport", QQScanTransport>;
+}
@Module()
export class QQScanTransportProvider {
@Provide() qqScanTransport!: QQScanTransportHandle;
diff --git a/packages/server/src/runtime/messaging/telegram-connector.ts b/packages/server/src/runtime/messaging/telegram-connector.ts
index 6bf0cc6a..1b4048cf 100644
--- a/packages/server/src/runtime/messaging/telegram-connector.ts
+++ b/packages/server/src/runtime/messaging/telegram-connector.ts
@@ -622,9 +622,10 @@ export class TelegramMessaging {
}
/** The Bot API transport as a node, so a test stands in a fake for the network. */
-export abstract class TelegramTransportHandle extends Interface<{
- transport: Opaque<"TelegramTransport", TelegramTransport>;
-}>() {}
+@Interface()
+export abstract class TelegramTransportHandle {
+ abstract transport: Opaque<"TelegramTransport", TelegramTransport>;
+}
@Module()
export class TelegramTransportProvider {
@Provide() telegramTransport!: TelegramTransportHandle;
diff --git a/packages/server/src/runtime/messaging/wechat-connector.ts b/packages/server/src/runtime/messaging/wechat-connector.ts
index 99d47271..16ca108c 100644
--- a/packages/server/src/runtime/messaging/wechat-connector.ts
+++ b/packages/server/src/runtime/messaging/wechat-connector.ts
@@ -449,9 +449,10 @@ export class WechatMessaging {
}
/** The long-poll + CDN transport as a node, so a test stands in a fake for the network. */
-export abstract class WeChatTransportHandle extends Interface<{
- transport: Opaque<"WeChatTransport", WeChatTransport>;
-}>() {}
+@Interface()
+export abstract class WeChatTransportHandle {
+ abstract transport: Opaque<"WeChatTransport", WeChatTransport>;
+}
@Module()
export class WeChatTransportProvider {
@Provide() wechatTransport!: WeChatTransportHandle;
diff --git a/packages/server/src/runtime/messaging/wechat-scan.ts b/packages/server/src/runtime/messaging/wechat-scan.ts
index 260f90cf..39ad1266 100644
--- a/packages/server/src/runtime/messaging/wechat-scan.ts
+++ b/packages/server/src/runtime/messaging/wechat-scan.ts
@@ -469,9 +469,10 @@ export class WeChatScanService {
}
/** The scan-to-connect transport as a node, so a test stands in a fake for the network. */
-export abstract class WeChatScanTransportHandle extends Interface<{
- transport: Opaque<"WeChatScanTransport", WeChatScanTransport>;
-}>() {}
+@Interface()
+export abstract class WeChatScanTransportHandle {
+ abstract transport: Opaque<"WeChatScanTransport", WeChatScanTransport>;
+}
@Module()
export class WeChatScanTransportProvider {
@Provide() wechatScanTransport!: WeChatScanTransportHandle;
diff --git a/packages/server/src/runtime/session-manager.ts b/packages/server/src/runtime/session-manager.ts
index 13ce10f7..260d5819 100644
--- a/packages/server/src/runtime/session-manager.ts
+++ b/packages/server/src/runtime/session-manager.ts
@@ -2328,13 +2328,14 @@ export abstract class SessionServiceIface extends Interface<
>() {}
/** The per-spawn policies every Session's command environment is built with. */
-export abstract class SessionEnv extends Interface<{
- proxyEnv(): ProxyEnvPolicy | null;
- controlEnv(ctx: ControlEnvContext): Record<string, string>;
+@Interface()
+export abstract class SessionEnv {
+ abstract proxyEnv(): ProxyEnvPolicy | null;
+ abstract controlEnv(ctx: ControlEnvContext): Record<string, string>;
/** The directories at the FRONT of every command's PATH: the harness's own CLI shim (see CreateAgentOptions.pathPrepend). */
- pathPrepend(): string[];
- confineSpawn(ctx: ControlEnvContext): SpawnConfiner | null;
-}>() {}
+ abstract pathPrepend(): string[];
+ abstract confineSpawn(ctx: ControlEnvContext): SpawnConfiner | null;
+}
@Module()
export class SessionsModule {
@@ -2501,13 +2502,14 @@ export class SessionsModule {
}
/** Builds the loader a manager runs sessions through; a test stands in a fake session. */
-export abstract class SessionLoaders extends Interface<{
- create(
+@Interface()
+export abstract class SessionLoaders {
+ abstract create(
root: string,
sources: Opaque<"SessionOrigins", SessionOrigins>,
env: Opaque<"SessionLoaderEnv", Parameters<typeof createCoreSessionLoader>[2]>,
): Opaque<"SessionLoader", SessionLoader>;
-}>() {}
+}
@Component()
export class CoreSessionLoaders implements SessionLoaders {
create(
@@ -2520,11 +2522,12 @@ export class CoreSessionLoaders implements SessionLoaders {
}
/** Builds the title generator; a test stands in a notifier that never calls a model. */
-export abstract class TitleGenerators extends Interface<{
- create(
+@Interface()
+export abstract class TitleGenerators {
+ abstract create(
deps: Opaque<"TitleGeneratorDeps", ConstructorParameters<typeof TitleGenerator>[0]>,
): Opaque<"TitleNotifier", TitleNotifier>;
-}>() {}
+}
@Component()
export class DefaultTitleGenerators implements TitleGenerators {
create(deps: ConstructorParameters<typeof TitleGenerator>[0]): TitleNotifier {
diff --git a/packages/server/src/services/project-service.ts b/packages/server/src/services/project-service.ts
index 980e21f1..d6dc793e 100644
--- a/packages/server/src/services/project-service.ts
+++ b/packages/server/src/services/project-service.ts
@@ -364,6 +364,7 @@ export class ProjectService implements ProjectLifecycle {
}
/** What destroying a Project needs of the session runtime — declared at the consumer. */
-export abstract class ProjectRuns extends Interface<{
- abortProject(projectId: string): Promise<void>[];
-}>() {}
+@Interface()
+export abstract class ProjectRuns {
+ abstract abortProject(projectId: string): Promise<void>[];
+}
diff --git a/packages/server/src/services/update-check-service.ts b/packages/server/src/services/update-check-service.ts
index 974791bf..5fea7a34 100644
--- a/packages/server/src/services/update-check-service.ts
+++ b/packages/server/src/services/update-check-service.ts
@@ -38,12 +38,13 @@ export const SUCCESS_TTL_MS = 60 * 60 * 1000;
export const FAILURE_TTL_MS = 10 * 60 * 1000;
/** The network, as the update check reaches it; a test stands in a canned one. */
-export abstract class HttpFetch extends Interface<{
- fetch(
+@Interface()
+export abstract class HttpFetch {
+ abstract fetch(
input: string,
init?: Opaque<"RequestInit", RequestInit>,
): Promise<Opaque<"Response", Response>>;
-}>() {}
+}
@Component()
export class GlobalFetch implements HttpFetch {
fetch(input: string, init?: RequestInit): Promise<Response> {
diff --git a/packages/server/src/terminal/manager.ts b/packages/server/src/terminal/manager.ts
index 01099b50..a2ec09a3 100644
--- a/packages/server/src/terminal/manager.ts
+++ b/packages/server/src/terminal/manager.ts
@@ -287,18 +287,19 @@ function resourceId(sessionId: string): string {
export type Terminal = Opaque<"TerminalSession", TerminalSession>;
/** Live ptys: the spawn primitive behind /api/terminals and the terminal WebSocket. */
-export abstract class Terminals extends Interface<{
- create(request: CreateTerminalRequest): Promise<Terminal>;
- adopt(ids: readonly string[]): void;
- quiesce(): void;
- handleIds(): string[];
- require(id: string, userId: string): Terminal;
- get(id: string): Terminal | undefined;
- list(userId: string): Terminal[];
- listInfo(userId: string): TerminalSessionInfo[];
- kill(id: string, userId: string): void;
- disposeAll(): void;
-}>() {}
+@Interface()
+export abstract class Terminals {
+ abstract create(request: CreateTerminalRequest): Promise<Terminal>;
+ abstract adopt(ids: readonly string[]): void;
+ abstract quiesce(): void;
+ abstract handleIds(): string[];
+ abstract require(id: string, userId: string): Terminal;
+ abstract get(id: string): Terminal | undefined;
+ abstract list(userId: string): Terminal[];
+ abstract listInfo(userId: string): TerminalSessionInfo[];
+ abstract kill(id: string, userId: string): void;
+ abstract disposeAll(): void;
+}
/** The manager satisfies the contract; this keeps the two from drifting. */
export type _Check = TerminalManager extends Terminals ? true : never;