mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-21 17:00:45 +00:00
WIP: Major cleanup - move Attachment to consumers, simplify agent API
- Removed Attachment from agent package (now in web-ui/coding-agent) - Agent.prompt now takes (text, images?: ImageContent[]) - Removed transports from web-ui (duplicate of agent package) - Updated coding-agent to use local message types - Updated mom package for new agent API Remaining: Fix AgentInterface.ts to compose UserMessageWithAttachments
This commit is contained in:
parent
f86dea2e4f
commit
6ddc7418da
57 changed files with 167 additions and 1061 deletions
|
|
@ -1,15 +1,15 @@
|
|||
import { Agent, type AgentEvent, type Attachment, ProviderTransport } from "@mariozechner/pi-agent-core";
|
||||
import { getModel } from "@mariozechner/pi-ai";
|
||||
import { Agent, type AgentEvent } from "@mariozechner/pi-agent-core";
|
||||
import { getModel, type ImageContent } from "@mariozechner/pi-ai";
|
||||
import {
|
||||
AgentSession,
|
||||
AuthStorage,
|
||||
convertToLlm,
|
||||
formatSkillsForPrompt,
|
||||
loadSkillsFromDir,
|
||||
ModelRegistry,
|
||||
messageTransformer,
|
||||
type Skill,
|
||||
} from "@mariozechner/pi-coding-agent";
|
||||
import { existsSync, readFileSync, statSync } from "fs";
|
||||
import { existsSync, readFileSync } from "fs";
|
||||
import { mkdir, writeFile } from "fs/promises";
|
||||
import { homedir } from "os";
|
||||
import { join } from "path";
|
||||
|
|
@ -716,7 +716,7 @@ function createRunner(sandboxConfig: SandboxConfig, channelId: string, channelDi
|
|||
const timestamp = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}${offsetSign}${offsetHours}:${offsetMins}`;
|
||||
let userMessage = `[${timestamp}] [${ctx.message.userName || "unknown"}]: ${ctx.message.text}`;
|
||||
|
||||
const imageAttachments: Attachment[] = [];
|
||||
const imageAttachments: ImageContent[] = [];
|
||||
const nonImagePaths: string[] = [];
|
||||
|
||||
for (const a of ctx.message.attachments || []) {
|
||||
|
|
@ -725,14 +725,10 @@ function createRunner(sandboxConfig: SandboxConfig, channelId: string, channelDi
|
|||
|
||||
if (mimeType && existsSync(fullPath)) {
|
||||
try {
|
||||
const stats = statSync(fullPath);
|
||||
imageAttachments.push({
|
||||
id: a.local,
|
||||
type: "image",
|
||||
fileName: a.local.split("/").pop() || a.local,
|
||||
mimeType,
|
||||
size: stats.size,
|
||||
content: readFileSync(fullPath).toString("base64"),
|
||||
data: readFileSync(fullPath).toString("base64"),
|
||||
});
|
||||
} catch {
|
||||
nonImagePaths.push(fullPath);
|
||||
|
|
@ -755,7 +751,7 @@ function createRunner(sandboxConfig: SandboxConfig, channelId: string, channelDi
|
|||
};
|
||||
await writeFile(join(channelDir, "last_prompt.jsonl"), JSON.stringify(debugContext, null, 2));
|
||||
|
||||
await session.prompt(userMessage, imageAttachments.length > 0 ? { attachments: imageAttachments } : undefined);
|
||||
await session.prompt(userMessage, imageAttachments.length > 0 ? { images: imageAttachments } : undefined);
|
||||
|
||||
// Wait for queued messages
|
||||
await queueChain;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue