mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
* origin/main: (25 commits) fix(tui): prevent phantom alt-screen selections feat(tui): add draggable transient scrollbars fix(coding-agent): avoid auth read lock contention fix(ai): route Fireworks Kimi K3 through OpenAI compatibility docs(client): document Bun Unix transport support feat(client): add Unix socket transport fix: forward autocompleteMaxVisible to custom editors (#7369) fix(ai): scope Codex sockets to accounts docs(client): note promise helper removal refactor(client): retain ES2022 compatibility refactor(client): simplify lifecycle architecture refactor(client): tighten lifecycle state modeling feat(client): add runtime-neutral session client fix(coding-agent): decouple auth lock error tests fix: custom-compaction through provider via new model runtime complete (#7325) fix(ai): preserve Anthropic initial stream block content (#7358) fix(coding-agent): update vulnerable brace-expansion fix(ai): keep signed empty text/thinking blocks in google history (#7362) feat(tui): add stacked alt-screen flashes (#7361) fix(coding-agent): reload credentials before reads ...
67 lines
2.3 KiB
TypeScript
67 lines
2.3 KiB
TypeScript
import { PiClient } from "@earendil-works/pi-client";
|
|
import { createAssistantMessageEventStream, Type } from "@earendil-works/pi-ai";
|
|
import { complete, getModel, getProviders, streamSimple } from "@earendil-works/pi-ai/compat";
|
|
import {
|
|
Agent,
|
|
bashExecutionToText,
|
|
convertToLlm,
|
|
createCustomMessage,
|
|
createInMemorySessionStore,
|
|
createSessionRepository,
|
|
FileError,
|
|
formatPromptTemplateInvocation,
|
|
formatSkillInvocation,
|
|
formatSkillsForSystemPrompt,
|
|
getOrThrow,
|
|
ok,
|
|
parseCommandArgs,
|
|
streamProxy,
|
|
toError,
|
|
truncateHead,
|
|
} from "@earendil-works/pi-agent-core";
|
|
import { decodeCbor, encodeCbor, PROTOCOL_VERSION } from "@earendil-works/pi-protocol";
|
|
|
|
// Keep this entry browser-safe. It is bundled by scripts/check-browser-smoke.mjs
|
|
// to catch accidental Node-only runtime imports in browser-facing package exports.
|
|
const model = getModel("google", "gemini-2.5-flash");
|
|
const schema = Type.Object({ prompt: Type.String() });
|
|
const stream = createAssistantMessageEventStream();
|
|
|
|
const agent = new Agent({ initialState: { model }, streamFn: streamSimple });
|
|
agent.steer({ role: "user", content: [{ type: "text", text: "queued" }], timestamp: 0 });
|
|
const repo = createSessionRepository({ store: createInMemorySessionStore() });
|
|
const result = getOrThrow(ok({ value: 1 }));
|
|
const customMessage = createCustomMessage("note", "hello", true, undefined, "2026-01-01T00:00:00.000Z");
|
|
const llmMessages = convertToLlm([customMessage]);
|
|
const skill = { name: "browser-safe", description: "Smoke test", content: "Use browser APIs.", filePath: "/skills/browser-safe/SKILL.md" };
|
|
|
|
console.log(
|
|
model.id,
|
|
getProviders().length,
|
|
typeof complete,
|
|
schema.type,
|
|
typeof stream.push,
|
|
agent.hasQueuedMessages(),
|
|
typeof repo.create,
|
|
result.value,
|
|
llmMessages.length,
|
|
bashExecutionToText({
|
|
role: "bashExecution",
|
|
command: "echo ok",
|
|
output: "ok",
|
|
exitCode: 0,
|
|
cancelled: false,
|
|
truncated: false,
|
|
timestamp: 0,
|
|
}),
|
|
formatSkillsForSystemPrompt([skill]).length,
|
|
formatSkillInvocation(skill).length,
|
|
formatPromptTemplateInvocation({ name: "example", content: "$1 $@" }, parseCommandArgs('one "two three"')),
|
|
truncateHead("a\nb", { maxLines: 1 }).content,
|
|
new FileError("not_found", "missing").code,
|
|
toError("boom").message,
|
|
typeof streamProxy,
|
|
typeof PiClient,
|
|
PROTOCOL_VERSION,
|
|
decodeCbor(encodeCbor({ browser: true })),
|
|
);
|