chore: upgrade pi-mono deps to 0.31.1
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { type ChildProcessWithoutNullStreams, spawn } from "node:child_process";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import type { AgentTool, AgentToolResult } from "@mariozechner/pi-ai";
|
||||
import type { AgentTool, AgentToolResult } from "@mariozechner/pi-agent-core";
|
||||
import { Type } from "@sinclair/typebox";
|
||||
|
||||
import {
|
||||
@@ -94,7 +94,7 @@ export type BashToolDetails =
|
||||
|
||||
export function createBashTool(
|
||||
defaults?: BashToolDefaults,
|
||||
// biome-ignore lint/suspicious/noExplicitAny: TypeBox schema type from pi-ai uses a different module instance.
|
||||
// biome-ignore lint/suspicious/noExplicitAny: TypeBox schema type from pi-agent-core uses a different module instance.
|
||||
): AgentTool<any, BashToolDetails> {
|
||||
const defaultBackgroundMs = clampNumber(
|
||||
defaults?.backgroundMs ?? readEnvInt("PI_BASH_YIELD_MS"),
|
||||
@@ -358,7 +358,7 @@ const processSchema = Type.Object({
|
||||
|
||||
export function createProcessTool(
|
||||
defaults?: ProcessToolDefaults,
|
||||
// biome-ignore lint/suspicious/noExplicitAny: TypeBox schema type from pi-ai uses a different module instance.
|
||||
// biome-ignore lint/suspicious/noExplicitAny: TypeBox schema type from pi-agent-core uses a different module instance.
|
||||
): AgentTool<any> {
|
||||
if (defaults?.cleanupMs !== undefined) {
|
||||
setJobTtlMs(defaults.cleanupMs);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import crypto from "node:crypto";
|
||||
import fs from "node:fs/promises";
|
||||
|
||||
import type { AgentTool, AgentToolResult } from "@mariozechner/pi-ai";
|
||||
import type { AgentTool, AgentToolResult } from "@mariozechner/pi-agent-core";
|
||||
import { Type } from "@sinclair/typebox";
|
||||
import {
|
||||
browserCloseTab,
|
||||
@@ -46,7 +46,7 @@ import { callGateway } from "../gateway/call.js";
|
||||
import { detectMime, imageMimeFromFormat } from "../media/mime.js";
|
||||
import { sanitizeToolResultImages } from "./tool-images.js";
|
||||
|
||||
// biome-ignore lint/suspicious/noExplicitAny: TypeBox schema type from pi-ai uses a different module instance.
|
||||
// biome-ignore lint/suspicious/noExplicitAny: TypeBox schema type from pi-agent-core uses a different module instance.
|
||||
type AnyAgentTool = AgentTool<any, unknown>;
|
||||
|
||||
const DEFAULT_GATEWAY_URL = "ws://127.0.0.1:18789";
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
|
||||
import type { AppMessage } from "@mariozechner/pi-agent-core";
|
||||
import type { AgentToolResult, AssistantMessage } from "@mariozechner/pi-ai";
|
||||
import type {
|
||||
AgentMessage,
|
||||
AgentToolResult,
|
||||
} from "@mariozechner/pi-agent-core";
|
||||
import type { AssistantMessage } from "@mariozechner/pi-ai";
|
||||
|
||||
import { sanitizeContentBlocksImages } from "./tool-images.js";
|
||||
import type { WorkspaceBootstrapFile } from "./workspace.js";
|
||||
@@ -36,12 +39,12 @@ export async function ensureSessionHeader(params: {
|
||||
type ContentBlock = AgentToolResult<unknown>["content"][number];
|
||||
|
||||
export async function sanitizeSessionMessagesImages(
|
||||
messages: AppMessage[],
|
||||
messages: AgentMessage[],
|
||||
label: string,
|
||||
): Promise<AppMessage[]> {
|
||||
): Promise<AgentMessage[]> {
|
||||
// We sanitize historical session messages because Anthropic can reject a request
|
||||
// if the transcript contains oversized base64 images (see MAX_IMAGE_DIMENSION_PX).
|
||||
const out: AppMessage[] = [];
|
||||
const out: AgentMessage[] = [];
|
||||
for (const msg of messages) {
|
||||
if (!msg || typeof msg !== "object") {
|
||||
out.push(msg);
|
||||
@@ -50,7 +53,7 @@ export async function sanitizeSessionMessagesImages(
|
||||
|
||||
const role = (msg as { role?: unknown }).role;
|
||||
if (role === "toolResult") {
|
||||
const toolMsg = msg as Extract<AppMessage, { role: "toolResult" }>;
|
||||
const toolMsg = msg as Extract<AgentMessage, { role: "toolResult" }>;
|
||||
const content = Array.isArray(toolMsg.content) ? toolMsg.content : [];
|
||||
const nextContent = (await sanitizeContentBlocksImages(
|
||||
content as ContentBlock[],
|
||||
@@ -61,7 +64,7 @@ export async function sanitizeSessionMessagesImages(
|
||||
}
|
||||
|
||||
if (role === "user") {
|
||||
const userMsg = msg as Extract<AppMessage, { role: "user" }>;
|
||||
const userMsg = msg as Extract<AgentMessage, { role: "user" }>;
|
||||
const content = userMsg.content;
|
||||
if (Array.isArray(content)) {
|
||||
const nextContent = (await sanitizeContentBlocksImages(
|
||||
|
||||
@@ -3,7 +3,7 @@ import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
|
||||
import type { AppMessage, ThinkingLevel } from "@mariozechner/pi-agent-core";
|
||||
import type { AgentMessage, ThinkingLevel } from "@mariozechner/pi-agent-core";
|
||||
import {
|
||||
type Api,
|
||||
type AssistantMessage,
|
||||
@@ -448,8 +448,7 @@ export async function runEmbeddedPiAgent(params: {
|
||||
model,
|
||||
thinkingLevel,
|
||||
systemPrompt,
|
||||
// TODO(steipete): Once pi-mono publishes file-magic MIME detection in `read` image payloads,
|
||||
// remove `createClawdisCodingTools()` and use upstream `codingTools` again.
|
||||
// Custom tool set: extra bash/process + read image sanitization.
|
||||
tools,
|
||||
sessionManager,
|
||||
settingsManager,
|
||||
@@ -502,7 +501,7 @@ export async function runEmbeddedPiAgent(params: {
|
||||
Math.max(1, params.timeoutMs),
|
||||
);
|
||||
|
||||
let messagesSnapshot: AppMessage[] = [];
|
||||
let messagesSnapshot: AgentMessage[] = [];
|
||||
let sessionIdUsed = session.sessionId;
|
||||
const onAbort = () => {
|
||||
abortRun();
|
||||
@@ -543,7 +542,7 @@ export async function runEmbeddedPiAgent(params: {
|
||||
const lastAssistant = messagesSnapshot
|
||||
.slice()
|
||||
.reverse()
|
||||
.find((m) => (m as AppMessage)?.role === "assistant") as
|
||||
.find((m) => (m as AgentMessage)?.role === "assistant") as
|
||||
| AssistantMessage
|
||||
| undefined;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { AgentEvent, AppMessage } from "@mariozechner/pi-agent-core";
|
||||
import type { AgentEvent, AgentMessage } from "@mariozechner/pi-agent-core";
|
||||
import type { AssistantMessage } from "@mariozechner/pi-ai";
|
||||
import type { AgentSession } from "@mariozechner/pi-coding-agent";
|
||||
|
||||
@@ -234,7 +234,7 @@ export function subscribeEmbeddedPiSession(params: {
|
||||
}
|
||||
|
||||
if (evt.type === "message_update") {
|
||||
const msg = (evt as AgentEvent & { message: AppMessage }).message;
|
||||
const msg = (evt as AgentEvent & { message: AgentMessage }).message;
|
||||
if (msg?.role === "assistant") {
|
||||
const assistantEvent = (
|
||||
evt as AgentEvent & { assistantMessageEvent?: unknown }
|
||||
@@ -298,7 +298,7 @@ export function subscribeEmbeddedPiSession(params: {
|
||||
}
|
||||
|
||||
if (evt.type === "message_end") {
|
||||
const msg = (evt as AgentEvent & { message: AppMessage }).message;
|
||||
const msg = (evt as AgentEvent & { message: AgentMessage }).message;
|
||||
if (msg?.role === "assistant") {
|
||||
const cleaned = params.enforceFinalTag
|
||||
? stripThinkingSegments(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { AgentTool, AgentToolResult } from "@mariozechner/pi-ai";
|
||||
import type { AgentTool, AgentToolResult } from "@mariozechner/pi-agent-core";
|
||||
import { codingTools, readTool } from "@mariozechner/pi-coding-agent";
|
||||
import { Type } from "@sinclair/typebox";
|
||||
|
||||
@@ -13,8 +13,8 @@ import {
|
||||
import { createClawdisTools } from "./clawdis-tools.js";
|
||||
import { sanitizeToolResultImages } from "./tool-images.js";
|
||||
|
||||
// TODO(steipete): Remove this wrapper once pi-mono ships file-magic MIME detection
|
||||
// for `read` image payloads in `@mariozechner/pi-coding-agent` (then switch back to `codingTools` directly).
|
||||
// NOTE(steipete): Upstream read now does file-magic MIME detection; we keep the wrapper
|
||||
// to normalize payloads and sanitize oversized images before they hit providers.
|
||||
type ToolContentBlock = AgentToolResult<unknown>["content"][number];
|
||||
type ImageContentBlock = Extract<ToolContentBlock, { type: "image" }>;
|
||||
type TextContentBlock = Extract<ToolContentBlock, { type: "text" }>;
|
||||
@@ -103,7 +103,7 @@ async function normalizeReadImageResult(
|
||||
return { ...result, content: nextContent };
|
||||
}
|
||||
|
||||
// biome-ignore lint/suspicious/noExplicitAny: TypeBox schema type from pi-ai uses a different module instance.
|
||||
// biome-ignore lint/suspicious/noExplicitAny: TypeBox schema type from pi-agent-core uses a different module instance.
|
||||
type AnyAgentTool = AgentTool<any, unknown>;
|
||||
|
||||
function extractEnumValues(schema: unknown): unknown[] | undefined {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { AgentToolResult } from "@mariozechner/pi-ai";
|
||||
import type { AgentToolResult } from "@mariozechner/pi-agent-core";
|
||||
|
||||
import { getImageMetadata, resizeToJpeg } from "../media/image-ops.js";
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ import {
|
||||
normalizeDiscordSlug,
|
||||
resolveDiscordChannelConfig,
|
||||
resolveDiscordGuildEntry,
|
||||
resolveGroupDmAllow,
|
||||
resolveDiscordReplyTarget,
|
||||
resolveGroupDmAllow,
|
||||
} from "./monitor.js";
|
||||
|
||||
const fakeGuild = (id: string, name: string) =>
|
||||
|
||||
@@ -14,7 +14,10 @@ import { formatAgentEnvelope } from "../auto-reply/envelope.js";
|
||||
import { getReplyFromConfig } from "../auto-reply/reply.js";
|
||||
import { SILENT_REPLY_TOKEN } from "../auto-reply/tokens.js";
|
||||
import type { ReplyPayload } from "../auto-reply/types.js";
|
||||
import type { DiscordSlashCommandConfig, ReplyToMode } from "../config/config.js";
|
||||
import type {
|
||||
DiscordSlashCommandConfig,
|
||||
ReplyToMode,
|
||||
} from "../config/config.js";
|
||||
import { loadConfig } from "../config/config.js";
|
||||
import { resolveStorePath, updateLastRoute } from "../config/sessions.js";
|
||||
import { danger, isVerbose, logVerbose, warn } from "../globals.js";
|
||||
|
||||
@@ -249,7 +249,9 @@ async function deliverReplies(params: {
|
||||
continue;
|
||||
}
|
||||
const replyToId =
|
||||
replyToMode === "off" ? undefined : resolveTelegramReplyId(reply.replyToId);
|
||||
replyToMode === "off"
|
||||
? undefined
|
||||
: resolveTelegramReplyId(reply.replyToId);
|
||||
const mediaList = reply.mediaUrls?.length
|
||||
? reply.mediaUrls
|
||||
: reply.mediaUrl
|
||||
|
||||
Reference in New Issue
Block a user