agent-afk 5.38.7 → 5.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,3 +22,17 @@ export declare function formatCompact(opts?: {
22
22
  tokensSavedEstimate?: number;
23
23
  }): string;
24
24
  export declare function formatCompactNoop(reason: string): string;
25
+ export declare function formatSessionsList(sessions: ReadonlyArray<{
26
+ name?: string;
27
+ model: string;
28
+ turns: number;
29
+ active: boolean;
30
+ }>): string;
31
+ export declare function formatNoSessions(): string;
32
+ export declare function formatSwitched(session: {
33
+ name?: string;
34
+ }): string;
35
+ export declare function formatNewSession(): string;
36
+ export declare function formatSessionBusy(): string;
37
+ export declare function formatSwitchNotFound(): string;
38
+ export declare function formatAlreadyActive(): string;
@@ -0,0 +1,8 @@
1
+ import { Context } from 'telegraf';
2
+ import { SessionManager } from '../session-manager.js';
3
+ type LogFn = (...args: unknown[]) => void;
4
+ export declare const SWITCH_CALLBACK_PREFIX = "afk:sw:";
5
+ export declare function handleSessions(ctx: Context, sessionManager: SessionManager, _log: LogFn): Promise<void>;
6
+ export declare function handleNew(ctx: Context, sessionManager: SessionManager, registeredCommandChats: Set<number>, log: LogFn): Promise<void>;
7
+ export declare function handleSwitchCallback(ctx: Context, sessionManager: SessionManager, log: LogFn): Promise<void>;
8
+ export {};
@@ -0,0 +1,13 @@
1
+ import type { Context } from 'telegraf';
2
+ export declare const GENERAL_TOPIC_ID = 1;
3
+ export interface TelegramRoute {
4
+ chatId: number;
5
+ threadId?: number;
6
+ isTopicMessage?: boolean;
7
+ }
8
+ export declare function routeFromCtx(ctx: Context): TelegramRoute | undefined;
9
+ export declare function isGeneral(route: TelegramRoute): boolean;
10
+ export declare function routeKey(route: TelegramRoute): string;
11
+ export declare function sendOptions(route: TelegramRoute): {
12
+ message_thread_id?: number;
13
+ };
@@ -1,4 +1,12 @@
1
1
  import type { IAgentSession, AgentConfig, AgentModelInput, ThinkingConfig, EffortLevel, ResponseMetadata } from '../agent/types.js';
2
+ export interface ChatSessionInfo {
3
+ sessionId: string;
4
+ name?: string;
5
+ model: AgentModelInput;
6
+ turns: number;
7
+ lastActive: number;
8
+ active: boolean;
9
+ }
2
10
  export interface SessionManagerOptions {
3
11
  dataDir?: string;
4
12
  defaultModel?: AgentModelInput;
@@ -15,6 +23,7 @@ export declare class SessionManager {
15
23
  private sessionData;
16
24
  private sessionStats;
17
25
  private autosaveFailureLogged;
26
+ private pendingResume;
18
27
  private options;
19
28
  constructor(options: SessionManagerOptions);
20
29
  getSessionIfExists(chatId: number): IAgentSession | undefined;
@@ -33,6 +42,15 @@ export declare class SessionManager {
33
42
  getModel(chatId: number): AgentModelInput;
34
43
  setCwd(chatId: number, cwd: string): Promise<void>;
35
44
  getCwd(chatId: number): string | undefined;
45
+ listChatSessions(chatId: number): ChatSessionInfo[];
46
+ switchToSession(chatId: number, targetSessionId: string): Promise<{
47
+ ok: true;
48
+ name?: string;
49
+ } | {
50
+ ok: false;
51
+ reason: 'not-found' | 'already-active';
52
+ }>;
53
+ newSession(chatId: number): Promise<void>;
36
54
  loadSessions(): Promise<void>;
37
55
  saveSessions(): Promise<void>;
38
56
  closeAll(): Promise<void>;