agent-afk 5.61.0 → 5.63.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.
- package/dist/agent/provider.d.ts +17 -0
- package/dist/agent/providers/anthropic-direct/compact.d.ts +3 -1
- package/dist/agent/providers/anthropic-direct/query/rewind-conversation.d.ts +10 -0
- package/dist/agent/providers/anthropic-direct/query.d.ts +3 -1
- package/dist/agent/providers/openai-compatible/compact.d.ts +3 -1
- package/dist/agent/providers/router/provider-router.d.ts +3 -1
- package/dist/agent/providers/shared/compaction.d.ts +25 -0
- package/dist/agent/session/agent-session.d.ts +3 -1
- package/dist/agent/types/session-types.d.ts +3 -1
- package/dist/cli/input/input-surface.d.ts +2 -0
- package/dist/cli/slash/types.d.ts +3 -0
- package/dist/cli/terminal-compositor.d.ts +4 -0
- package/dist/cli/terminal-compositor.input-dispatch.d.ts +2 -0
- package/dist/cli.mjs +482 -482
- package/dist/config/env.d.ts +2 -0
- package/dist/index.mjs +170 -170
- package/dist/telegram/formatter.d.ts +4 -0
- package/dist/telegram.mjs +213 -213
- package/package.json +1 -1
package/dist/agent/provider.d.ts
CHANGED
|
@@ -151,6 +151,8 @@ export interface ProviderQuery extends AsyncIterable<ProviderEvent> {
|
|
|
151
151
|
dryRun?: boolean;
|
|
152
152
|
}): Promise<ProviderRewindResult>;
|
|
153
153
|
compact?(): Promise<ProviderCompactResult>;
|
|
154
|
+
listRewindTargets?(): RewindTarget[];
|
|
155
|
+
rewindConversation?(turnIndex: number): Promise<ProviderRewindConversationResult>;
|
|
154
156
|
setCwd?(cwd: string): void;
|
|
155
157
|
reauth?(): Promise<{
|
|
156
158
|
accountId: string;
|
|
@@ -202,6 +204,21 @@ export interface ProviderCompactResult {
|
|
|
202
204
|
messagesBefore: number;
|
|
203
205
|
messagesAfter: number;
|
|
204
206
|
tokensSavedEstimate?: number;
|
|
207
|
+
microcompaction?: {
|
|
208
|
+
blocksCleared: number;
|
|
209
|
+
bytesReclaimed: number;
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
export interface RewindTarget {
|
|
213
|
+
turnIndex: number;
|
|
214
|
+
preview: string;
|
|
215
|
+
}
|
|
216
|
+
export interface ProviderRewindConversationResult {
|
|
217
|
+
rewound: boolean;
|
|
218
|
+
reason?: string;
|
|
219
|
+
reloadText?: string;
|
|
220
|
+
messagesBefore: number;
|
|
221
|
+
messagesAfter: number;
|
|
205
222
|
}
|
|
206
223
|
export interface ProviderCompleteArgs {
|
|
207
224
|
system: string;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { MessageParam } from '@anthropic-ai/sdk/resources';
|
|
2
2
|
import type { AnthropicMessagesCreateParams } from './types.js';
|
|
3
|
-
import { COMPACT_ACK_TEXT, COMPACT_SUMMARY_HEADER, COMPACT_SYSTEM_PROMPT, type CompactionOps } from '../shared/compaction.js';
|
|
3
|
+
import { COMPACT_ACK_TEXT, COMPACT_SUMMARY_HEADER, COMPACT_SYSTEM_PROMPT, type CompactionOps, type MicrocompactOps, type MicrocompactOptions, type MicrocompactResult } from '../shared/compaction.js';
|
|
4
4
|
export { COMPACT_ACK_TEXT, COMPACT_SUMMARY_HEADER, COMPACT_SYSTEM_PROMPT };
|
|
5
5
|
export declare function isFreshUserTurn(msg: MessageParam): boolean;
|
|
6
6
|
export declare const anthropicCompactionOps: CompactionOps<MessageParam>;
|
|
7
|
+
export declare const anthropicMicrocompactOps: MicrocompactOps<MessageParam>;
|
|
8
|
+
export declare function microcompactToolResults(messages: ReadonlyArray<MessageParam>, opts?: MicrocompactOptions): MicrocompactResult;
|
|
7
9
|
export declare function findCompactionBoundary(messages: ReadonlyArray<MessageParam>, keepLastN: number): number;
|
|
8
10
|
export declare function findCompactionBoundaryAdaptive(messages: ReadonlyArray<MessageParam>, keepLastN: number, usedFraction: number, shrinkAtFraction: number): number;
|
|
9
11
|
export declare function buildSummarizationRequest(olderMessages: ReadonlyArray<MessageParam>, model: string, maxTokens: number): AnthropicMessagesCreateParams;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MessageParam } from '@anthropic-ai/sdk/resources';
|
|
2
|
+
import type { ProviderRewindConversationResult, RewindTarget } from '../../../provider.js';
|
|
3
|
+
import type { SessionState } from './session-state.js';
|
|
4
|
+
import type { AbortCoordinator } from './abort-coordinator.js';
|
|
5
|
+
export declare function listUserTurns(messages: readonly MessageParam[]): RewindTarget[];
|
|
6
|
+
export interface RewindHandlerDeps {
|
|
7
|
+
state: SessionState;
|
|
8
|
+
abort: AbortCoordinator;
|
|
9
|
+
}
|
|
10
|
+
export declare function rewindConversationHistory(deps: RewindHandlerDeps, turnIndex: number): ProviderRewindConversationResult;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type Anthropic from '@anthropic-ai/sdk';
|
|
2
2
|
import type { ContentBlockParam, MessageParam } from '@anthropic-ai/sdk/resources';
|
|
3
|
-
import type { ProviderAccountInfo, ProviderAgentInfo, ProviderCommandInfo, ProviderCompactResult, ProviderContextUsage, ProviderEvent, ProviderMcpServerStatus, ProviderModelInfo, ProviderQuery, ProviderRewindResult, ProviderUserTurn } from '../../provider.js';
|
|
3
|
+
import type { ProviderAccountInfo, ProviderAgentInfo, ProviderCommandInfo, ProviderCompactResult, ProviderContextUsage, ProviderEvent, ProviderMcpServerStatus, ProviderModelInfo, ProviderQuery, ProviderRewindConversationResult, ProviderRewindResult, ProviderUserTurn, RewindTarget } from '../../provider.js';
|
|
4
4
|
import type { ToolDispatcher } from './tool-dispatcher.js';
|
|
5
5
|
import type { AnthropicToolDef, AuthMode } from './types.js';
|
|
6
6
|
import type { HookRegistry } from '../../hooks.js';
|
|
@@ -78,5 +78,7 @@ export declare class AnthropicDirectQuery implements ProviderQuery {
|
|
|
78
78
|
dryRun?: boolean;
|
|
79
79
|
}): Promise<ProviderRewindResult>;
|
|
80
80
|
compact(): Promise<ProviderCompactResult>;
|
|
81
|
+
listRewindTargets(): RewindTarget[];
|
|
82
|
+
rewindConversation(turnIndex: number): Promise<ProviderRewindConversationResult>;
|
|
81
83
|
close(): void;
|
|
82
84
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { ProviderCompactResult } from '../../provider.js';
|
|
2
2
|
import type { TraceWriter } from '../../trace/index.js';
|
|
3
3
|
import type { CompactionTrigger } from '../../trace/types.js';
|
|
4
|
-
import { type CompactionOps } from '../shared/compaction.js';
|
|
4
|
+
import { type CompactionOps, type MicrocompactOps, type MicrocompactOptions, type MicrocompactResult } from '../shared/compaction.js';
|
|
5
5
|
import type { OpenAIMessage } from './messages.js';
|
|
6
6
|
export declare function isFreshUserTurn(msg: OpenAIMessage): boolean;
|
|
7
|
+
export declare const openaiMicrocompactOps: MicrocompactOps<OpenAIMessage>;
|
|
8
|
+
export declare function microcompactToolResults(messages: ReadonlyArray<OpenAIMessage>, opts?: MicrocompactOptions): MicrocompactResult;
|
|
7
9
|
export declare const openaiCompactionOps: CompactionOps<OpenAIMessage>;
|
|
8
10
|
export declare function readKeepLastN(): number;
|
|
9
11
|
export declare function readShrinkFraction(): number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ModelProvider, ProviderQuery, ProviderEvent, ProviderUserTurn, ProviderCommandInfo, ProviderModelInfo, ProviderAgentInfo, ProviderContextUsage, ProviderMcpServerStatus, ProviderAccountInfo, ProviderRewindResult, ProviderCompactResult } from '../../provider.js';
|
|
1
|
+
import type { ModelProvider, ProviderQuery, ProviderEvent, ProviderUserTurn, ProviderCommandInfo, ProviderModelInfo, ProviderAgentInfo, ProviderContextUsage, ProviderMcpServerStatus, ProviderAccountInfo, ProviderRewindResult, ProviderRewindConversationResult, ProviderCompactResult, RewindTarget } from '../../provider.js';
|
|
2
2
|
import type { AgentConfig } from '../../types/config-types.js';
|
|
3
3
|
export interface ProviderRouterDeps {
|
|
4
4
|
resolveProvider: (model: string | undefined) => ModelProvider;
|
|
@@ -50,6 +50,8 @@ export declare class ProviderRouter implements ProviderQuery {
|
|
|
50
50
|
dryRun?: boolean;
|
|
51
51
|
}): Promise<ProviderRewindResult>;
|
|
52
52
|
compact(): Promise<ProviderCompactResult>;
|
|
53
|
+
listRewindTargets(): RewindTarget[];
|
|
54
|
+
rewindConversation(turnIndex: number): Promise<ProviderRewindConversationResult>;
|
|
53
55
|
reloadPlugins(...args: unknown[]): Promise<unknown>;
|
|
54
56
|
close(): Promise<void>;
|
|
55
57
|
}
|
|
@@ -5,6 +5,31 @@ export declare const COMPACT_ACK_TEXT = "Acknowledged. Continuing from the summa
|
|
|
5
5
|
export declare function wrapTranscriptForSummary(transcript: string): string;
|
|
6
6
|
export declare const DEFAULT_COMPACT_TIMEOUT_MS = 60000;
|
|
7
7
|
export declare const DEFAULT_COMPACT_SHRINK_THRESHOLD = 0.7;
|
|
8
|
+
export declare const DEFAULT_MICROCOMPACT_TOOL_RESULT_BYTES = 2048;
|
|
9
|
+
export declare const DEFAULT_MICROCOMPACT_KEEP_LAST = 4;
|
|
10
|
+
export declare const MICROCOMPACT_PLACEHOLDER_SENTINEL = "[tool result cleared to reclaim context";
|
|
11
|
+
export declare function buildMicrocompactPlaceholder(bytes: number): string;
|
|
12
|
+
export declare function isMicrocompactPlaceholder(text: string): boolean;
|
|
13
|
+
export interface ToolResultRef {
|
|
14
|
+
byteLength: number;
|
|
15
|
+
isPlaceholder: boolean;
|
|
16
|
+
clear(placeholder: string): void;
|
|
17
|
+
}
|
|
18
|
+
export interface MicrocompactOps<M> {
|
|
19
|
+
listToolResults(messages: ReadonlyArray<M>): ToolResultRef[];
|
|
20
|
+
}
|
|
21
|
+
export interface MicrocompactOptions {
|
|
22
|
+
thresholdBytes?: number;
|
|
23
|
+
keepLast?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface MicrocompactResult {
|
|
26
|
+
blocksCleared: number;
|
|
27
|
+
bytesReclaimed: number;
|
|
28
|
+
blocksScanned: number;
|
|
29
|
+
}
|
|
30
|
+
export declare function microcompactToolResults<M>(messages: ReadonlyArray<M>, ops: MicrocompactOps<M>, opts?: MicrocompactOptions): MicrocompactResult;
|
|
31
|
+
export declare function byteLengthOf(text: string): number;
|
|
32
|
+
export declare function resolveMicrocompactOptions(rawBytes: string | undefined, rawKeepLast: string | undefined): Required<MicrocompactOptions>;
|
|
8
33
|
export interface CompactionOps<M> {
|
|
9
34
|
isFreshUserTurn(msg: M): boolean;
|
|
10
35
|
renderMessage(msg: M): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ContentBlockParam } from '@anthropic-ai/sdk/resources';
|
|
2
2
|
import type { HookRegistry } from '../hooks.js';
|
|
3
|
-
import type { ProviderCompactResult, ProviderQuery } from '../provider.js';
|
|
3
|
+
import type { ProviderCompactResult, ProviderQuery, ProviderRewindConversationResult, RewindTarget } from '../provider.js';
|
|
4
4
|
import { type ZodType } from 'zod';
|
|
5
5
|
import type { AccountInfo, AgentConfig, AgentInfo, AgentModelInput, IAgentSession, InputStreamRef, McpServerStatus, Message, ModelInfo, OutputEvent, PermissionMode, ResponseMetadata, RewindFilesResult, SDKControlGetContextUsageResponse, SendMessageOptions, SessionIdentity, SessionMetadata, SessionState, SlashCommand, StructuredMessageOptions } from '../types.js';
|
|
6
6
|
import type { ElicitationRequest } from '../types/sdk-types.js';
|
|
@@ -77,6 +77,8 @@ export declare class AgentSession implements IAgentSession {
|
|
|
77
77
|
dryRun?: boolean;
|
|
78
78
|
}): Promise<RewindFilesResult>;
|
|
79
79
|
compact(): Promise<ProviderCompactResult>;
|
|
80
|
+
listRewindTargets(): RewindTarget[];
|
|
81
|
+
rewindConversation(turnIndex: number): Promise<ProviderRewindConversationResult>;
|
|
80
82
|
getLastResponseMetadata(): ResponseMetadata | null;
|
|
81
83
|
getOutputStream(): AsyncIterable<OutputEvent>;
|
|
82
84
|
queueFrameworkContext(text: string): void;
|
|
@@ -3,7 +3,7 @@ import type { ContentBlockParam } from '@anthropic-ai/sdk/resources';
|
|
|
3
3
|
import type { AgentModelInput } from './model-types.js';
|
|
4
4
|
import type { InputStreamRef } from './permission-types.js';
|
|
5
5
|
import type { Message, MessageChunk, ResponseMetadata, SendMessageOptions, StructuredMessageOptions } from './message-types.js';
|
|
6
|
-
import type { ProviderCompactResult, ProviderQuery } from '../provider.js';
|
|
6
|
+
import type { ProviderCompactResult, ProviderQuery, ProviderRewindConversationResult, RewindTarget } from '../provider.js';
|
|
7
7
|
import type { HookRegistry } from '../hooks.js';
|
|
8
8
|
import type { ZodType } from 'zod';
|
|
9
9
|
export type SessionState = 'idle' | 'processing' | 'streaming' | 'compacting' | 'closed';
|
|
@@ -136,5 +136,7 @@ export interface IAgentSession {
|
|
|
136
136
|
dryRun?: boolean;
|
|
137
137
|
}): Promise<RewindFilesResult>;
|
|
138
138
|
compact(): Promise<ProviderCompactResult>;
|
|
139
|
+
listRewindTargets(): RewindTarget[];
|
|
140
|
+
rewindConversation(turnIndex: number): Promise<ProviderRewindConversationResult>;
|
|
139
141
|
close(): Promise<void>;
|
|
140
142
|
}
|
|
@@ -16,6 +16,7 @@ export interface InputSurfaceReadOpts {
|
|
|
16
16
|
promptFn: () => string;
|
|
17
17
|
onSigint?: () => void;
|
|
18
18
|
onShiftTab?: () => void;
|
|
19
|
+
initialBuffer?: string;
|
|
19
20
|
compositor?: TerminalCompositor;
|
|
20
21
|
}
|
|
21
22
|
export interface InputSurfaceRefs {
|
|
@@ -64,5 +65,6 @@ export declare class InputSurface {
|
|
|
64
65
|
isAwaitingInput(): boolean;
|
|
65
66
|
bufferIsEmpty(): boolean;
|
|
66
67
|
abortPendingRead(): void;
|
|
68
|
+
requestRewind(): boolean;
|
|
67
69
|
toRunTurnRefs(promptText: string): InputSurfaceRefs;
|
|
68
70
|
}
|
|
@@ -17,6 +17,8 @@ export declare class TerminalCompositor {
|
|
|
17
17
|
postEscCoalesce: boolean;
|
|
18
18
|
postEscPayload: SubmissionPayload | null;
|
|
19
19
|
onBackground?: () => void;
|
|
20
|
+
onRewindRequest?: () => void;
|
|
21
|
+
lastIdleEscAt: number;
|
|
20
22
|
onPauseInterrupt?: () => void;
|
|
21
23
|
onShiftTab?: () => void;
|
|
22
24
|
onOpenEditor?: () => void;
|
|
@@ -88,6 +90,7 @@ export declare class TerminalCompositor {
|
|
|
88
90
|
getOnCancel(): (() => void) | undefined;
|
|
89
91
|
setOnSoftStop(handler: (() => void) | null): void;
|
|
90
92
|
setOnBackground(handler: (() => void) | null): void;
|
|
93
|
+
setOnRewindRequest(handler: (() => void) | null): void;
|
|
91
94
|
setOnShiftTab(handler: (() => void) | null): void;
|
|
92
95
|
setOnOpenEditor(handler: (() => void) | null): void;
|
|
93
96
|
enterPickerMode(controller: PickerController): void;
|
|
@@ -125,6 +128,7 @@ export declare class TerminalCompositor {
|
|
|
125
128
|
clearScreen(): void;
|
|
126
129
|
resetState(): void;
|
|
127
130
|
applyEdit(next: InputCoreState): boolean;
|
|
131
|
+
prefillInput(text: string): void;
|
|
128
132
|
applyDropdownSelection(): boolean;
|
|
129
133
|
applyGhostAccept(): boolean;
|
|
130
134
|
}
|
|
@@ -29,6 +29,7 @@ export interface KeyDispatchHost {
|
|
|
29
29
|
readonly activeGhost: string | null;
|
|
30
30
|
readonly history?: IHistoryRing;
|
|
31
31
|
softStopped: boolean;
|
|
32
|
+
lastIdleEscAt: number;
|
|
32
33
|
postEscCoalesce: boolean;
|
|
33
34
|
postEscPayload: SubmissionPayload | null;
|
|
34
35
|
canceled: boolean;
|
|
@@ -37,6 +38,7 @@ export interface KeyDispatchHost {
|
|
|
37
38
|
readonly onCancel?: () => void;
|
|
38
39
|
readonly onSoftStop?: () => void;
|
|
39
40
|
readonly onBackground?: () => void;
|
|
41
|
+
readonly onRewindRequest?: () => void;
|
|
40
42
|
readonly onPauseInterrupt?: () => void;
|
|
41
43
|
readonly onShiftTab?: () => void;
|
|
42
44
|
readonly onOpenEditor?: () => void;
|