mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 05:00:16 +00:00
Add timestamp to messages
This commit is contained in:
parent
ef09efaac9
commit
55dc0b6e08
24 changed files with 388 additions and 220 deletions
|
|
@ -162,6 +162,7 @@ export class Agent {
|
|||
role: "user",
|
||||
content,
|
||||
attachments: attachments?.length ? attachments : undefined,
|
||||
timestamp: Date.now(),
|
||||
};
|
||||
|
||||
this.abortController = new AbortController();
|
||||
|
|
@ -311,6 +312,7 @@ export class Agent {
|
|||
},
|
||||
stopReason: this.abortController?.signal.aborted ? "aborted" : "error",
|
||||
errorMessage: err?.message || String(err),
|
||||
timestamp: Date.now(),
|
||||
};
|
||||
this.appendMessage(msg as AppMessage);
|
||||
this.patch({ error: err?.message || String(err) });
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ function streamSimpleProxy(
|
|||
cacheWrite: 0,
|
||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
||||
},
|
||||
timestamp: Date.now(),
|
||||
};
|
||||
|
||||
let reader: ReadableStreamDefaultReader<Uint8Array> | undefined;
|
||||
|
|
|
|||
|
|
@ -229,7 +229,14 @@ export class ToolMessage extends LitElement {
|
|||
|
||||
// Render tool content (renderer handles errors and styling)
|
||||
const result: ToolResultMessageType<any> | undefined = this.aborted
|
||||
? { role: "toolResult", isError: true, output: "", toolCallId: this.toolCall.id, toolName: this.toolCall.name }
|
||||
? {
|
||||
role: "toolResult",
|
||||
isError: true,
|
||||
output: "",
|
||||
toolCallId: this.toolCall.id,
|
||||
toolName: this.toolCall.name,
|
||||
timestamp: Date.now(),
|
||||
}
|
||||
: this.result;
|
||||
const renderResult = renderTool(
|
||||
toolName,
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ export class ProviderKeyInput extends LitElement {
|
|||
}
|
||||
|
||||
const context: Context = {
|
||||
messages: [{ role: "user", content: "Reply with: ok" }],
|
||||
messages: [{ role: "user", content: "Reply with: ok", timestamp: Date.now() }],
|
||||
};
|
||||
|
||||
const result = await complete(model, context, {
|
||||
|
|
|
|||
|
|
@ -208,13 +208,6 @@ export class SettingsDialog extends LitElement {
|
|||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Footer -->
|
||||
<div class="pt-4 flex-shrink-0">
|
||||
<p class="text-xs text-muted-foreground text-center">
|
||||
${i18n("Settings are stored locally in your browser")}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
})}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import type { AgentState } from "../../agent/agent.js";
|
||||
import { Store } from "../store.js";
|
||||
import type { SessionData, SessionMetadata, StoreConfig } from "../types.js";
|
||||
|
||||
|
|
@ -82,7 +83,12 @@ export class SessionsStore extends Store {
|
|||
}
|
||||
|
||||
// Alias methods for backward compatibility
|
||||
async saveSession(id: string, state: any, metadata: SessionMetadata | undefined, title?: string): Promise<void> {
|
||||
async saveSession(
|
||||
id: string,
|
||||
state: AgentState,
|
||||
metadata: SessionMetadata | undefined,
|
||||
title?: string,
|
||||
): Promise<void> {
|
||||
// If metadata is provided, use it; otherwise create it from state
|
||||
const meta: SessionMetadata = metadata || {
|
||||
id,
|
||||
|
|
@ -90,7 +96,7 @@ export class SessionsStore extends Store {
|
|||
createdAt: new Date().toISOString(),
|
||||
lastModified: new Date().toISOString(),
|
||||
messageCount: state.messages?.length || 0,
|
||||
usage: state.usage || {
|
||||
usage: {
|
||||
input: 0,
|
||||
output: 0,
|
||||
cacheRead: 0,
|
||||
|
|
|
|||
|
|
@ -100,7 +100,10 @@ export function createExtractDocumentTool(): AgentTool<typeof extractDocumentSch
|
|||
|
||||
// Extract filename from URL
|
||||
const urlParts = url.split("/");
|
||||
const fileName = urlParts[urlParts.length - 1]?.split("?")[0] || "document";
|
||||
let fileName = urlParts[urlParts.length - 1]?.split("?")[0] || "document";
|
||||
if (url.startsWith("https://arxiv.org/")) {
|
||||
fileName = fileName + ".pdf";
|
||||
}
|
||||
|
||||
// Use loadAttachment to process the document
|
||||
const attachment = await loadAttachment(arrayBuffer, fileName);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue