- Add OpenClawProcessOwner class to manage the lifecycle of the OpenClaw process. - Introduce utility functions for managing OpenClaw runtime paths. - Update session store to normalize agent session keys and migrate existing keys. - Refactor main process to handle local provider API routing through a new dispatch function. - Enhance token usage writer to utilize a new session key parsing function. - Create agents management store to handle agent data and interactions. - Update chat store to integrate agent selection and session management. - Introduce AgentsSection component for displaying agent information in the UI. - Refactor HomePage to support agent selection and display current agent. - Update routing to reflect new agents page structure.
24 lines
865 B
TypeScript
24 lines
865 B
TypeScript
import { app } from 'electron';
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
import { parseSessionKey } from '@runtime/lib/agents';
|
|
|
|
export function getTranscriptFilePath(sessionKey: string): string {
|
|
const parsed = parseSessionKey(sessionKey);
|
|
let agentId = parsed.isAgentSession ? parsed.agentId : 'default';
|
|
let sessionId = parsed.isAgentSession ? parsed.sessionId : sessionKey;
|
|
|
|
if (!sessionId) {
|
|
sessionId = 'unknown';
|
|
}
|
|
|
|
const baseDir = path.join(app.getPath('userData'), 'agents', agentId, 'sessions');
|
|
return path.join(baseDir, `${sessionId}.jsonl`);
|
|
}
|
|
|
|
export function appendTranscriptLine(sessionKey: string, lineObject: any): void {
|
|
const filePath = getTranscriptFilePath(sessionKey);
|
|
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
fs.appendFileSync(filePath, JSON.stringify(lineObject) + '\n', 'utf-8');
|
|
}
|