fix: use native Pi identity and refresh provider catalogs
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import type { AssistantMessage, Message, ToolResultMessage, Usage, Tool } from "@earendil-works/pi-ai";
|
||||
import { normalizeContext } from "@earendil-works/pi-ai";
|
||||
import { Type } from "typebox";
|
||||
@@ -183,6 +184,7 @@ export async function runPdfReaderAgent(
|
||||
// BYOK (owner, 2026-09-22): the level rides the injected engine — no
|
||||
// factory pin to consult (engine.level is the resolved/clamped value).
|
||||
const reasoning = engine.level;
|
||||
const sessionId = randomUUID();
|
||||
const prompt = [
|
||||
`PDF path: ${pdfPath}`,
|
||||
`Question (what the teacher needs from this document): ${input.question || "(no question — give a structural overview)"}`,
|
||||
@@ -207,6 +209,7 @@ export async function runPdfReaderAgent(
|
||||
INSTRUCTIONS,
|
||||
messages,
|
||||
toolDeclarations,
|
||||
sessionId,
|
||||
reasoning,
|
||||
opts.abortSignal,
|
||||
opts.chatId ? providerEventObserver(opts.chatId, "job:pdfReader") : undefined,
|
||||
@@ -395,6 +398,7 @@ async function streamOnce(
|
||||
systemPrompt: string,
|
||||
messages: Message[],
|
||||
tools: Tool[],
|
||||
sessionId: string,
|
||||
reasoning: ThinkingLevel | undefined,
|
||||
abortSignal?: AbortSignal,
|
||||
onProviderStreamEvent?: ProviderEventObserver,
|
||||
@@ -403,6 +407,7 @@ async function streamOnce(
|
||||
// and tool declarations fold into a leading system message.
|
||||
// normalizeContext is the library's only Context→TranscriptContext entry.
|
||||
const stream = engine.streamFn(engine.model, normalizeContext({ systemPrompt, messages, tools }), {
|
||||
sessionId,
|
||||
reasoning: reasoning && reasoning !== "off" ? reasoning : undefined,
|
||||
signal: abortSignal,
|
||||
onProviderStreamEvent: onProviderStreamEvent as never,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Agent, type AgentEvent, type AgentMessage, type AgentTool } from "@earendil-works/pi-agent-core";
|
||||
import type { AssistantMessage, ToolResultMessage, Usage } from "@earendil-works/pi-ai";
|
||||
import { piEngineFor, type PiEngine } from "../models.ts";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { APP_IDENTITY, piEngineFor, type PiEngine } from "../models.ts";
|
||||
import { providerEventObserver } from "../provider-events.ts";
|
||||
import type { ModelRole } from "../../../config.ts";
|
||||
|
||||
@@ -64,6 +65,9 @@ export async function runSubagent(tools: AgentTool<any, any>[], opts: SubagentRu
|
||||
// Debug recorder (owner, 2026-10-04): raw provider events per job run.
|
||||
const providerEvents = opts.chatId ? providerEventObserver(opts.chatId, `job:${opts.role}`) : undefined;
|
||||
const agent = new Agent({
|
||||
identity: APP_IDENTITY,
|
||||
// One unsaved conversation per invocation, stable through every turn.
|
||||
sessionId: randomUUID(),
|
||||
initialState: {
|
||||
systemPrompt: opts.systemPrompt,
|
||||
model: engine.model,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import type { AssistantMessage, Message, Tool, ToolResultMessage, Usage } from "@earendil-works/pi-ai";
|
||||
import { normalizeContext } from "@earendil-works/pi-ai";
|
||||
import { Type } from "typebox";
|
||||
@@ -142,6 +143,7 @@ export async function runVisualMaker(input: VisualMakerInput, opts: VisualMakerO
|
||||
// BYOK (owner, 2026-09-22): the level rides the injected engine — no
|
||||
// factory pin to consult (engine.level is the resolved/clamped value).
|
||||
const reasoning = engine.level;
|
||||
const sessionId = randomUUID();
|
||||
const prompt = [
|
||||
"Brief for ONE precise figure (from the teacher, verbatim — it is everything you know):",
|
||||
brief,
|
||||
@@ -164,6 +166,7 @@ export async function runVisualMaker(input: VisualMakerInput, opts: VisualMakerO
|
||||
INSTRUCTIONS,
|
||||
messages,
|
||||
toolDeclarations,
|
||||
sessionId,
|
||||
reasoning,
|
||||
opts.abortSignal,
|
||||
opts.chatId ? providerEventObserver(opts.chatId, "job:visualMaker") : undefined,
|
||||
@@ -317,6 +320,7 @@ async function streamOnce(
|
||||
systemPrompt: string,
|
||||
messages: Message[],
|
||||
tools: Tool[],
|
||||
sessionId: string,
|
||||
reasoning: ThinkingLevel | undefined,
|
||||
abortSignal?: AbortSignal,
|
||||
onProviderStreamEvent?: ProviderEventObserver,
|
||||
@@ -325,6 +329,7 @@ async function streamOnce(
|
||||
// and tool declarations fold into a leading system message.
|
||||
// normalizeContext is the library's only Context→TranscriptContext entry.
|
||||
const stream = engine.streamFn(engine.model, normalizeContext({ systemPrompt, messages, tools }), {
|
||||
sessionId,
|
||||
reasoning: reasoning && reasoning !== "off" ? reasoning : undefined,
|
||||
signal: abortSignal,
|
||||
onProviderStreamEvent: onProviderStreamEvent as never,
|
||||
|
||||
Reference in New Issue
Block a user