agent-afk 5.312.5 → 5.312.7

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.
@@ -0,0 +1,18 @@
1
+ import type { Telegraf } from 'telegraf';
2
+ import type { ElicitationRequest, ElicitationResult } from '../agent/types/sdk-types.js';
3
+ export interface ChoiceResolver {
4
+ chatId: number;
5
+ resolve: (choiceIndex: number) => void;
6
+ }
7
+ export interface ChoiceElicitationCtx {
8
+ chatId: number;
9
+ threadOpts: object;
10
+ request: ElicitationRequest;
11
+ signal: AbortSignal;
12
+ bot: Telegraf;
13
+ elicitId: string;
14
+ pendingChoiceElicitations: Map<string, ChoiceResolver>;
15
+ setPending: (resolver: (text: string) => void) => void;
16
+ deletePending: () => void;
17
+ }
18
+ export declare function handleChoiceElicitation(ctx: ChoiceElicitationCtx, qType: string, displayText: string): Promise<ElicitationResult>;
@@ -0,0 +1,6 @@
1
+ import { Markup } from 'telegraf';
2
+ import { type ChoiceMessages } from './elicitation-choice-list.js';
3
+ export declare function prepareChoiceRender(choices: readonly string[], displayText: string, buildCallback: (i: number) => string): {
4
+ choiceMsg: ChoiceMessages;
5
+ buttons: ReturnType<typeof Markup.button.callback>[][];
6
+ };
@@ -0,0 +1,3 @@
1
+ import type { ElicitationCtx } from './elicitation-handler.types.js';
2
+ export declare function buildTextPrompt(displayText: string, request: ElicitationCtx['request'], qType: string, isFirstPrompt: boolean): string;
3
+ export declare function handleTextElicitation(ctx: ElicitationCtx, qType: string, displayText: string): Promise<import('../agent/types/sdk-types.js').ElicitationResult>;
@@ -0,0 +1,19 @@
1
+ import type { Telegraf } from 'telegraf';
2
+ import type { ElicitationRequest, ElicitationResult } from '../agent/types/sdk-types.js';
3
+ import type { MessageHandler } from './handlers/message.js';
4
+ export declare const CUSTOM_ENTRY_SENTINEL_INDEX = -1;
5
+ export interface ElicitationCtx {
6
+ chatId: number;
7
+ threadOpts: object;
8
+ request: ElicitationRequest;
9
+ signal: AbortSignal;
10
+ bot: Telegraf;
11
+ setPending: (resolver: (text: string) => void) => void;
12
+ deletePending: () => void;
13
+ key: string;
14
+ messageHandler: Pick<MessageHandler, 'pendingElicitations'>;
15
+ }
16
+ export interface ResolveGuard {
17
+ resolved: boolean;
18
+ }
19
+ export type Resolve = (result: ElicitationResult) => void;
@@ -0,0 +1,39 @@
1
+ import type { Context } from 'telegraf';
2
+ import type { ContentBlockParam } from '@anthropic-ai/sdk/resources';
3
+ import type { IAgentSession, OutputEvent } from '../agent/types.js';
4
+ import type { StreamState } from './streaming.handlers.js';
5
+ import { type HandlerParams } from './streaming.handlers.js';
6
+ import type { WatchdogState } from './streaming.watchdog.js';
7
+ export interface ContentRunState {
8
+ contentRunStartAccumulated: number;
9
+ contentRunStartAnswer: number;
10
+ inContentRun: boolean;
11
+ }
12
+ export declare function buildStream(session: IAgentSession, content: string | ContentBlockParam[]): AsyncIterable<OutputEvent>;
13
+ export declare function updateWatchdogForChunk(event: OutputEvent & {
14
+ type: 'chunk';
15
+ }, watchdog: WatchdogState): void;
16
+ export declare function processChunkContent(event: OutputEvent & {
17
+ type: 'chunk';
18
+ chunk: {
19
+ type: 'content';
20
+ content: string;
21
+ };
22
+ }, state: StreamState, run: ContentRunState, ctx: Context, chatId: number, livePreview: () => string): Promise<void>;
23
+ export declare function processInlineEvent(event: OutputEvent, state: StreamState, run: ContentRunState, ctx: Context, chatId: number, livePreview: () => string): Promise<boolean>;
24
+ export declare function runStreamLoop(params: {
25
+ nextWithTimeout: () => Promise<IteratorResult<OutputEvent>>;
26
+ state: StreamState;
27
+ watchdog: WatchdogState;
28
+ run: ContentRunState;
29
+ ctx: Context;
30
+ chatId: number;
31
+ livePreview: () => string;
32
+ finalBody: () => string;
33
+ progressGateOpen: boolean;
34
+ progressDelayMs: number;
35
+ setProgressGateOpen: (v: boolean) => void;
36
+ clearProgressTimer: () => void;
37
+ handlerParams: HandlerParams;
38
+ logger?: (...args: unknown[]) => void;
39
+ }): Promise<void>;