agent-afk 5.296.2 → 5.296.3
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.
- package/dist/cli.mjs +320 -320
- package/dist/index.mjs +143 -143
- package/dist/telegram/handlers/farm-callbacks.open-pr.d.ts +7 -0
- package/dist/telegram/handlers/farm-callbacks.respawn.d.ts +6 -0
- package/dist/telegram/handlers/message.compact-handler.d.ts +14 -0
- package/dist/telegram/handlers/message.media-helpers.d.ts +13 -0
- package/dist/telegram/handlers/message.photo-handler.d.ts +22 -0
- package/dist/telegram/session-manager.d.ts +0 -1
- package/dist/telegram/session-manager.disk-io.d.ts +5 -0
- package/dist/telegram/session-manager.session-builder.d.ts +20 -0
- package/dist/telegram/session-manager.switcher.d.ts +21 -0
- package/dist/telegram.mjs +172 -172
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Context } from 'telegraf';
|
|
2
|
+
import { type CreatePrOpts, type ExecFn } from '../../agent/gh.js';
|
|
3
|
+
import { type FarmManifest } from '../../agent/worktree.js';
|
|
4
|
+
import type { FarmCallbackDeps } from './farm-callbacks.js';
|
|
5
|
+
type LogFn = (...args: unknown[]) => void;
|
|
6
|
+
export declare function handleOpenPr(ctx: Context, manifest: FarmManifest, deps: FarmCallbackDeps, log: LogFn): Promise<void>;
|
|
7
|
+
export type { CreatePrOpts, ExecFn };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Context } from 'telegraf';
|
|
2
|
+
import { type FarmManifest } from '../../agent/worktree.js';
|
|
3
|
+
import type { FarmCallbackDeps } from './farm-callbacks.js';
|
|
4
|
+
type LogFn = (...args: unknown[]) => void;
|
|
5
|
+
export declare function handleRespawn(ctx: Context, manifest: FarmManifest, deps: FarmCallbackDeps, log: LogFn): Promise<void>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Context } from 'telegraf';
|
|
2
|
+
import { type TelegramRoute } from '../route.js';
|
|
3
|
+
import type { SessionManager } from '../session-manager.js';
|
|
4
|
+
type LogFn = (...args: unknown[]) => void;
|
|
5
|
+
export interface CompactHandlerContext {
|
|
6
|
+
sessionManager: SessionManager;
|
|
7
|
+
log: LogFn;
|
|
8
|
+
reserveClaim(key: string): void;
|
|
9
|
+
releaseClaim(key: string): void;
|
|
10
|
+
enqueueCompact(route: TelegramRoute, ctx: Context): void;
|
|
11
|
+
drainQueue(route: TelegramRoute): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export declare function processCompactDirectImpl(route: TelegramRoute, ctx: Context, hc: CompactHandlerContext): Promise<void>;
|
|
14
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Context } from 'telegraf';
|
|
1
2
|
export declare function sniffMimeType(bytes: Buffer): 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp' | null;
|
|
2
3
|
export type LimitedReadResult = {
|
|
3
4
|
status: 'ok';
|
|
@@ -9,3 +10,15 @@ export type LimitedReadResult = {
|
|
|
9
10
|
status: 'missing-body';
|
|
10
11
|
};
|
|
11
12
|
export declare function readResponseBytesWithLimit(response: Response, maxBytes: number): Promise<LimitedReadResult>;
|
|
13
|
+
export declare const ALLOWED_PHOTO_MIME: readonly ["image/jpeg", "image/png", "image/gif", "image/webp"];
|
|
14
|
+
export type AllowedPhotoMime = typeof ALLOWED_PHOTO_MIME[number];
|
|
15
|
+
export type FetchPhotoResult = {
|
|
16
|
+
ok: true;
|
|
17
|
+
bytes: Buffer;
|
|
18
|
+
media_type: AllowedPhotoMime;
|
|
19
|
+
} | {
|
|
20
|
+
ok: false;
|
|
21
|
+
};
|
|
22
|
+
type LogFn = (...args: unknown[]) => void;
|
|
23
|
+
export declare function fetchAndClassifyPhoto(ctx: Context, fileId: string, chatId: number, log: LogFn): Promise<FetchPhotoResult>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Context } from 'telegraf';
|
|
2
|
+
import type { ContentBlockParam } from '@anthropic-ai/sdk/resources';
|
|
3
|
+
import { type TelegramRoute } from '../route.js';
|
|
4
|
+
import type { SessionManager } from '../session-manager.js';
|
|
5
|
+
import type { Telegraf } from 'telegraf';
|
|
6
|
+
type LogFn = (...args: unknown[]) => void;
|
|
7
|
+
export interface PhotoHandlerContext {
|
|
8
|
+
bot: Telegraf;
|
|
9
|
+
sessionManager: SessionManager;
|
|
10
|
+
registeredCommandChats: Set<number>;
|
|
11
|
+
tagOnlyChats: Set<number>;
|
|
12
|
+
log: LogFn;
|
|
13
|
+
isClaimed(key: string): boolean;
|
|
14
|
+
reserveClaim(key: string): void;
|
|
15
|
+
releaseClaim(key: string): void;
|
|
16
|
+
enqueuePhoto(route: TelegramRoute, ctx: Context, content: ContentBlockParam[]): number | false;
|
|
17
|
+
processOne(route: TelegramRoute, ctx: Context, content: ContentBlockParam[]): Promise<void>;
|
|
18
|
+
MAX_QUEUE_DEPTH: number;
|
|
19
|
+
messageQueues: Map<string, unknown[]>;
|
|
20
|
+
}
|
|
21
|
+
export declare function handlePhotoImpl(ctx: Context, hc: PhotoHandlerContext): Promise<void>;
|
|
22
|
+
export {};
|
|
@@ -70,7 +70,6 @@ export declare class SessionManager {
|
|
|
70
70
|
reason: 'not-found' | 'already-active';
|
|
71
71
|
}>;
|
|
72
72
|
newSession(target: RouteTarget): Promise<void>;
|
|
73
|
-
private sidecarFileName;
|
|
74
73
|
loadSessions(): Promise<void>;
|
|
75
74
|
saveSessions(): Promise<void>;
|
|
76
75
|
private _evictStaleSessionData;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type TelegramRoute } from './route.js';
|
|
2
|
+
import type { SessionData } from './session-manager.js';
|
|
3
|
+
export declare function sidecarFileName(data: SessionData): string;
|
|
4
|
+
export declare function loadSessionsFromDisk(dataDir: string, sessionData: Map<string, SessionData>, onEachRoute: (route: TelegramRoute, data: SessionData) => void): Promise<void>;
|
|
5
|
+
export declare function saveSessionsToDisk(dataDir: string, sessionData: Map<string, SessionData>): Promise<void>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IAgentSession, AgentConfig, AgentModelInput, ThinkingConfig, EffortLevel } from '../agent/types.js';
|
|
2
|
+
import { type TelegramRoute } from './route.js';
|
|
3
|
+
import type { SessionData } from './session-manager.js';
|
|
4
|
+
export interface SessionBuilderOptions {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
settingSources?: ('user' | 'project')[];
|
|
7
|
+
thinking?: ThinkingConfig;
|
|
8
|
+
effort?: EffortLevel;
|
|
9
|
+
botCwd?: string;
|
|
10
|
+
createSession: (config: AgentConfig) => Promise<IAgentSession>;
|
|
11
|
+
onResumptionOffer?: (route: TelegramRoute, text: string) => void | Promise<boolean>;
|
|
12
|
+
defaultModel: AgentModelInput;
|
|
13
|
+
}
|
|
14
|
+
export interface SessionBuilderContext {
|
|
15
|
+
sessions: Map<string, IAgentSession>;
|
|
16
|
+
sessionData: Map<string, SessionData>;
|
|
17
|
+
pendingResume: Map<string, string>;
|
|
18
|
+
ensureRegistryHandle(route: TelegramRoute, data: SessionData): void;
|
|
19
|
+
}
|
|
20
|
+
export declare function buildAndRegisterSession(route: TelegramRoute, key: string, data: SessionData, opts: SessionBuilderOptions, sc: SessionBuilderContext): Promise<IAgentSession>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { IAgentSession } from '../agent/types.js';
|
|
2
|
+
import { type TelegramRoute } from './route.js';
|
|
3
|
+
import type { SessionData, ChatSessionInfo, RouteTarget } from './session-manager.js';
|
|
4
|
+
import type { SessionStats } from '../cli/slash/types.js';
|
|
5
|
+
export declare function listChatSessionsImpl(target: RouteTarget, sessionData: Map<string, SessionData>): ChatSessionInfo[];
|
|
6
|
+
export interface SwitcherContext {
|
|
7
|
+
sessions: Map<string, IAgentSession>;
|
|
8
|
+
pendingSessions: Map<string, Promise<IAgentSession>>;
|
|
9
|
+
sessionData: Map<string, SessionData>;
|
|
10
|
+
sessionStats: Map<string, SessionStats>;
|
|
11
|
+
autosaveFailureLogged: Set<string>;
|
|
12
|
+
pendingResume: Map<string, string>;
|
|
13
|
+
newData(route: TelegramRoute): SessionData;
|
|
14
|
+
}
|
|
15
|
+
export declare function switchToSessionImpl(target: RouteTarget, targetSessionId: string, sc: SwitcherContext): Promise<{
|
|
16
|
+
ok: true;
|
|
17
|
+
name?: string;
|
|
18
|
+
} | {
|
|
19
|
+
ok: false;
|
|
20
|
+
reason: 'not-found' | 'already-active';
|
|
21
|
+
}>;
|