mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 19:05:11 +00:00
Consolidate session events: remove session_before_new/session_new, add reason field to switch events
- Remove session_before_new and session_new hook events - Add reason: 'new' | 'resume' to session_before_switch and session_switch events - Remove 'new' reason from custom tool onSession (use 'switch' for both /new and /resume) - Rename reset() to newSession(options?) in AgentSession - Add NewSessionOptions with optional parentSession for lineage tracking - Rename branchedFrom to parentSession in SessionHeader - Rename RPC reset command to new_session with optional parentSession - Update example hooks to use new event structure - Update documentation and changelog Based on discussion in #293
This commit is contained in:
parent
1d9fa13d58
commit
484d7e06bb
19 changed files with 117 additions and 117 deletions
|
|
@ -31,7 +31,11 @@ export interface SessionHeader {
|
|||
id: string;
|
||||
timestamp: string;
|
||||
cwd: string;
|
||||
branchedFrom?: string;
|
||||
parentSession?: string;
|
||||
}
|
||||
|
||||
export interface NewSessionOptions {
|
||||
parentSession?: string;
|
||||
}
|
||||
|
||||
export interface SessionEntryBase {
|
||||
|
|
@ -508,7 +512,7 @@ export class SessionManager {
|
|||
}
|
||||
}
|
||||
|
||||
newSession(): string | undefined {
|
||||
newSession(options?: NewSessionOptions): string | undefined {
|
||||
this.sessionId = randomUUID();
|
||||
const timestamp = new Date().toISOString();
|
||||
const header: SessionHeader = {
|
||||
|
|
@ -517,11 +521,13 @@ export class SessionManager {
|
|||
id: this.sessionId,
|
||||
timestamp,
|
||||
cwd: this.cwd,
|
||||
parentSession: options?.parentSession,
|
||||
};
|
||||
this.fileEntries = [header];
|
||||
this.byId.clear();
|
||||
this.leafId = null;
|
||||
this.flushed = false;
|
||||
|
||||
// Only generate filename if persisting and not already set (e.g., via --session flag)
|
||||
if (this.persist && !this.sessionFile) {
|
||||
const fileTimestamp = timestamp.replace(/[:.]/g, "-");
|
||||
|
|
@ -929,7 +935,7 @@ export class SessionManager {
|
|||
id: newSessionId,
|
||||
timestamp,
|
||||
cwd: this.cwd,
|
||||
branchedFrom: this.persist ? this.sessionFile : undefined,
|
||||
parentSession: this.persist ? this.sessionFile : undefined,
|
||||
};
|
||||
|
||||
// Collect labels for entries in the path
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue