mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 08:02:17 +00:00
WIP: Refactor agent package - not compiling
- Renamed AppMessage to AgentMessage throughout - New agent-loop.ts with AgentLoopContext, AgentLoopConfig - Removed transport abstraction, Agent now takes streamFn directly - Extracted streamProxy to proxy.ts utility - Removed agent-loop from pi-ai (now in agent package) - Updated consumers (coding-agent, mom) for AgentMessage rename - Tests updated but some consumers still need migration Known issues: - AgentTool, AgentToolResult not exported from pi-ai - Attachment not exported from pi-agent-core - ProviderTransport removed but still referenced - messageTransformer -> convertToLlm migration incomplete - CustomMessages declaration merging not working properly
This commit is contained in:
parent
f7ef44dc38
commit
a055fd4481
32 changed files with 1312 additions and 2009 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import type { AppMessage } from "@mariozechner/pi-agent-core";
|
||||
import type { AgentMessage } from "@mariozechner/pi-agent-core";
|
||||
import type { ImageContent, TextContent } from "@mariozechner/pi-ai";
|
||||
import { randomUUID } from "crypto";
|
||||
import {
|
||||
|
|
@ -36,7 +36,7 @@ export interface SessionEntryBase {
|
|||
|
||||
export interface SessionMessageEntry extends SessionEntryBase {
|
||||
type: "message";
|
||||
message: AppMessage;
|
||||
message: AgentMessage;
|
||||
}
|
||||
|
||||
export interface ThinkingLevelChangeEntry extends SessionEntryBase {
|
||||
|
|
@ -130,7 +130,7 @@ export interface SessionTreeNode {
|
|||
}
|
||||
|
||||
export interface SessionContext {
|
||||
messages: AppMessage[];
|
||||
messages: AgentMessage[];
|
||||
thinkingLevel: string;
|
||||
model: { provider: string; modelId: string } | null;
|
||||
}
|
||||
|
|
@ -154,7 +154,7 @@ export const SUMMARY_SUFFIX = `
|
|||
</summary>`;
|
||||
|
||||
/** Exported for compaction.test.ts */
|
||||
export function createSummaryMessage(summary: string, timestamp: string): AppMessage {
|
||||
export function createSummaryMessage(summary: string, timestamp: string): AgentMessage {
|
||||
return {
|
||||
role: "user",
|
||||
content: SUMMARY_PREFIX + summary + SUMMARY_SUFFIX,
|
||||
|
|
@ -162,8 +162,8 @@ export function createSummaryMessage(summary: string, timestamp: string): AppMes
|
|||
};
|
||||
}
|
||||
|
||||
/** Convert CustomMessageEntry to AppMessage format */
|
||||
function createCustomMessage(entry: CustomMessageEntry): AppMessage {
|
||||
/** Convert CustomMessageEntry to AgentMessage format */
|
||||
function createCustomMessage(entry: CustomMessageEntry): AgentMessage {
|
||||
return {
|
||||
role: "user",
|
||||
content: entry.content,
|
||||
|
|
@ -323,7 +323,7 @@ export function buildSessionContext(
|
|||
// 1. Emit summary first (entry = compaction)
|
||||
// 2. Emit kept messages (from firstKeptEntryId up to compaction)
|
||||
// 3. Emit messages after compaction
|
||||
const messages: AppMessage[] = [];
|
||||
const messages: AgentMessage[] = [];
|
||||
|
||||
if (compaction) {
|
||||
// Emit summary first
|
||||
|
|
@ -595,7 +595,7 @@ export class SessionManager {
|
|||
}
|
||||
|
||||
/** Append a message as child of current leaf, then advance leaf. Returns entry id. */
|
||||
appendMessage(message: AppMessage): string {
|
||||
appendMessage(message: AgentMessage): string {
|
||||
const entry: SessionMessageEntry = {
|
||||
type: "message",
|
||||
id: generateId(this.byId),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue