Archived
refactor: expose session streamFn on PiAgentSession
Add a narrow `agent: { streamFn: StreamFn }` field to the PiAgentSession
interface, sourced structurally from the real AgentSession.agent (Agent,
from the stable @earendil-works/pi-agent-core package). This is the
resolved-auth/headers/retry "call this model" function pi's own
compaction/branch-summarization code uses internally, and will let
sessionNameGenerator.ts drop its dependency on the deprecated pi-ai
/compat provider registry in a follow-up leg.
No adapter object was needed: AgentSession's real .agent field already
structurally satisfies the new narrow shape, so defaultCreateAgentRuntime
needed no changes.
Adds a unit test proving the field is wired end-to-end via the injected
runtime creator. sessionNameGenerator.ts itself is untouched (leg C).
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { open, readFile, writeFile } from "node:fs/promises";
|
||||
import type { ImageContent } from "@earendil-works/pi-ai";
|
||||
import type { StreamFn } from "@earendil-works/pi-agent-core";
|
||||
import {
|
||||
AuthStorage,
|
||||
createAgentSessionFromServices,
|
||||
@@ -232,6 +233,15 @@ export interface PiAgentSession {
|
||||
setThinkingLevel(level: ClientThinkingLevel): void;
|
||||
cycleThinkingLevel(): ClientThinkingLevel | undefined;
|
||||
setSessionName(name: string): void;
|
||||
/**
|
||||
* Narrow re-expression of `AgentSession.agent` (an `@earendil-works/pi-agent-core`
|
||||
* `Agent`), exposing only `streamFn` — the resolved-auth/headers/retry "call this
|
||||
* model" function pi's own compaction/branch-summarization code uses internally.
|
||||
* Lets callers (e.g. session title generation) issue one-off model calls without
|
||||
* depending on pi-ai's deprecated `/compat` provider registry or leaking the full
|
||||
* `Agent`/`AgentSession` surface.
|
||||
*/
|
||||
agent: { streamFn: StreamFn };
|
||||
}
|
||||
|
||||
export interface PiSessionRuntime {
|
||||
|
||||
Reference in New Issue
Block a user