agent-afk 5.31.2 → 5.33.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 +2 -0
- package/dist/agent/providers/anthropic-direct/compact.d.ts +3 -3
- package/dist/agent/providers/anthropic-direct/resolve-params.d.ts +1 -1
- package/dist/agent/providers/anthropic-direct/types.d.ts +2 -0
- package/dist/agent/providers/openai-compatible/compact.d.ts +19 -0
- package/dist/agent/providers/openai-compatible/oneshot.d.ts +1 -0
- package/dist/agent/providers/openai-compatible/query.d.ts +4 -1
- package/dist/agent/providers/shared/auto-compact.d.ts +3 -0
- package/dist/agent/providers/shared/compaction.d.ts +36 -0
- package/dist/agent/release-boundary-detect.d.ts +4 -0
- package/dist/agent/trace/events.d.ts +8 -0
- package/dist/agent/trace/types.d.ts +2 -0
- package/dist/agent/types/message-types.d.ts +2 -0
- package/dist/cli/commands/interactive/tool-lane-format.d.ts +1 -0
- package/dist/cli.mjs +429 -424
- package/dist/index.mjs +162 -157
- package/dist/telegram.mjs +225 -220
- package/package.json +1 -1
package/dist/agent/provider.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { MessageParam } from '@anthropic-ai/sdk/resources';
|
|
2
2
|
import type { AnthropicMessagesCreateParams } from './types.js';
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
export declare const COMPACT_ACK_TEXT = "Acknowledged. Continuing from the summary above.";
|
|
3
|
+
import { COMPACT_ACK_TEXT, COMPACT_SUMMARY_HEADER, COMPACT_SYSTEM_PROMPT, type CompactionOps } from '../shared/compaction.js';
|
|
4
|
+
export { COMPACT_ACK_TEXT, COMPACT_SUMMARY_HEADER, COMPACT_SYSTEM_PROMPT };
|
|
6
5
|
export declare function isFreshUserTurn(msg: MessageParam): boolean;
|
|
6
|
+
export declare const anthropicCompactionOps: CompactionOps<MessageParam>;
|
|
7
7
|
export declare function findCompactionBoundary(messages: ReadonlyArray<MessageParam>, keepLastN: number): number;
|
|
8
8
|
export declare function buildSummarizationRequest(olderMessages: ReadonlyArray<MessageParam>, model: string, maxTokens: number): AnthropicMessagesCreateParams;
|
|
9
9
|
export declare function applyCompaction(messages: ReadonlyArray<MessageParam>, boundary: number, summaryText: string): MessageParam[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MessageParam, ThinkingConfigParam } from '@anthropic-ai/sdk/resources';
|
|
2
2
|
import type { AgentConfig, ResumeHistoryTurn } from '../../types/config-types.js';
|
|
3
3
|
import type { EffortLevel, ThinkingConfig } from '../../types/sdk-types.js';
|
|
4
|
-
export
|
|
4
|
+
export { resolveAutoCompactThreshold } from '../shared/auto-compact.js';
|
|
5
5
|
export declare function resolveMaxTokens(config: AgentConfig, model: string): number;
|
|
6
6
|
export declare function resumeHistoryToMessages(history: ResumeHistoryTurn[] | undefined): MessageParam[] | undefined;
|
|
7
7
|
export declare function resolveThinkingParam(tc: ThinkingConfig, maxTokens: number, model?: string): ThinkingConfigParam;
|
|
@@ -17,6 +17,8 @@ export interface ToolResult {
|
|
|
17
17
|
truncated?: boolean;
|
|
18
18
|
circuitBreaker?: boolean;
|
|
19
19
|
failureClass?: ToolFailureClass;
|
|
20
|
+
batchIndex?: number;
|
|
21
|
+
batchSize?: number;
|
|
20
22
|
render?: RenderHints;
|
|
21
23
|
testResult?: import('../../tools/handlers/test-runner-detector.js').TestResult;
|
|
22
24
|
image?: {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ProviderCompactResult } from '../../provider.js';
|
|
2
|
+
import type { TraceWriter } from '../../trace/index.js';
|
|
3
|
+
import type { CompactionTrigger } from '../../trace/types.js';
|
|
4
|
+
import { type CompactionOps } from '../shared/compaction.js';
|
|
5
|
+
import type { OpenAIMessage } from './messages.js';
|
|
6
|
+
export declare function isFreshUserTurn(msg: OpenAIMessage): boolean;
|
|
7
|
+
export declare const openaiCompactionOps: CompactionOps<OpenAIMessage>;
|
|
8
|
+
export declare function readKeepLastN(): number;
|
|
9
|
+
export interface CompactOpenAIHistoryDeps {
|
|
10
|
+
priorTurns: OpenAIMessage[];
|
|
11
|
+
summarize: (transcript: string, signal: AbortSignal) => Promise<string>;
|
|
12
|
+
isClosed: boolean;
|
|
13
|
+
isIdle: boolean;
|
|
14
|
+
beginAbort: () => AbortController;
|
|
15
|
+
clearAbort: (controller: AbortController) => void;
|
|
16
|
+
trigger?: CompactionTrigger;
|
|
17
|
+
traceWriter?: TraceWriter;
|
|
18
|
+
}
|
|
19
|
+
export declare function compactOpenAIHistory(deps: CompactOpenAIHistoryDeps): Promise<ProviderCompactResult>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AgentConfig } from '../../types/config-types.js';
|
|
2
2
|
import type { TraceWriter } from '../../trace/index.js';
|
|
3
|
-
import type { ProviderQuery, ProviderEvent, ProviderUserTurn, ProviderContextUsage, ProviderRewindResult, ProviderModelInfo, ProviderCommandInfo, ProviderAgentInfo, ProviderMcpServerStatus, ProviderAccountInfo } from '../../provider.js';
|
|
3
|
+
import type { ProviderQuery, ProviderEvent, ProviderUserTurn, ProviderContextUsage, ProviderRewindResult, ProviderModelInfo, ProviderCommandInfo, ProviderAgentInfo, ProviderMcpServerStatus, ProviderAccountInfo, ProviderCompactResult } from '../../provider.js';
|
|
4
4
|
import { type OpenAIAuthResolution, type AuthResolverDeps } from './auth.js';
|
|
5
5
|
import type { ToolDispatcher } from '../anthropic-direct/tool-dispatcher.js';
|
|
6
6
|
import { resolveReasoningEffort } from './query/model-params.js';
|
|
@@ -40,6 +40,7 @@ export declare class OpenAICompatibleQuery implements ProviderQuery {
|
|
|
40
40
|
private closeResolve;
|
|
41
41
|
private readonly closedPromise;
|
|
42
42
|
private lastUsage;
|
|
43
|
+
private readonly autoCompactThreshold;
|
|
43
44
|
constructor(opts: OpenAICompatibleQueryOptions);
|
|
44
45
|
private activeOpenAITools;
|
|
45
46
|
[Symbol.asyncIterator](): AsyncIterator<ProviderEvent>;
|
|
@@ -50,6 +51,8 @@ export declare class OpenAICompatibleQuery implements ProviderQuery {
|
|
|
50
51
|
private runIteration;
|
|
51
52
|
private dispatchAndAppend;
|
|
52
53
|
interrupt(): Promise<void>;
|
|
54
|
+
compact(): Promise<ProviderCompactResult>;
|
|
55
|
+
private compactHistory;
|
|
53
56
|
setModel(model?: string): Promise<void>;
|
|
54
57
|
setPermissionMode(mode: string): Promise<void>;
|
|
55
58
|
setCwd(cwd: string): void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ProviderUsage } from '../../provider.js';
|
|
2
|
+
import type { AgentConfig } from '../../types/config-types.js';
|
|
2
3
|
export declare function computeUsedTokens(usage: Partial<ProviderUsage>): number;
|
|
3
4
|
export declare function contextWindowTokensUsed(usage: Partial<ProviderUsage>): number;
|
|
4
5
|
export type ContextUsageApiBreakdown = {
|
|
@@ -13,3 +14,5 @@ export interface ContextUsageFields {
|
|
|
13
14
|
}
|
|
14
15
|
export declare function buildContextUsageFields(last: ProviderUsage | null | undefined): ContextUsageFields;
|
|
15
16
|
export declare function shouldAutoCompact(usedTokens: number, contextLimit: number, threshold: number): boolean;
|
|
17
|
+
export declare const DEFAULT_AUTO_COMPACT_THRESHOLD = 0.9;
|
|
18
|
+
export declare function resolveAutoCompactThreshold(autoCompact: AgentConfig['autoCompact']): number | undefined;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ProviderCompactResult } from '../../provider.js';
|
|
2
|
+
export declare const COMPACT_SYSTEM_PROMPT: string;
|
|
3
|
+
export declare const COMPACT_SUMMARY_HEADER = "[Compacted summary of earlier conversation]";
|
|
4
|
+
export declare const COMPACT_ACK_TEXT = "Acknowledged. Continuing from the summary above.";
|
|
5
|
+
export declare function wrapTranscriptForSummary(transcript: string): string;
|
|
6
|
+
export declare const DEFAULT_COMPACT_TIMEOUT_MS = 60000;
|
|
7
|
+
export interface CompactionOps<M> {
|
|
8
|
+
isFreshUserTurn(msg: M): boolean;
|
|
9
|
+
renderMessage(msg: M): string;
|
|
10
|
+
buildPreamble(summaryText: string): [userSummary: M, assistantAck: M];
|
|
11
|
+
countChars(msg: M): number;
|
|
12
|
+
}
|
|
13
|
+
export declare function findCompactionBoundary<M>(messages: ReadonlyArray<M>, keepLastN: number, ops: CompactionOps<M>): number;
|
|
14
|
+
export declare function renderTranscript<M>(messages: ReadonlyArray<M>, ops: CompactionOps<M>): string;
|
|
15
|
+
export declare function applyCompaction<M>(messages: ReadonlyArray<M>, boundary: number, summaryText: string, ops: CompactionOps<M>): M[];
|
|
16
|
+
export declare function estimateTokensSaved<M>(before: ReadonlyArray<M>, boundary: number, summaryText: string, ops: CompactionOps<M>): number;
|
|
17
|
+
export interface CompactionSuccess<M> {
|
|
18
|
+
olderSlice: M[];
|
|
19
|
+
summary: string;
|
|
20
|
+
keptTailCount: number;
|
|
21
|
+
keepLastN: number;
|
|
22
|
+
messagesBefore: number;
|
|
23
|
+
messagesAfter: number;
|
|
24
|
+
tokensSavedEstimate: number;
|
|
25
|
+
}
|
|
26
|
+
export interface CompactionCoreDeps<M> {
|
|
27
|
+
messages: M[];
|
|
28
|
+
ops: CompactionOps<M>;
|
|
29
|
+
keepLastN: number;
|
|
30
|
+
summarize(transcript: string): Promise<string>;
|
|
31
|
+
isAborted(): boolean;
|
|
32
|
+
abortInFlight?(): void;
|
|
33
|
+
timeoutMs?: number;
|
|
34
|
+
onSuccess?(info: CompactionSuccess<M>): void;
|
|
35
|
+
}
|
|
36
|
+
export declare function runCompactionCore<M>(deps: CompactionCoreDeps<M>): Promise<ProviderCompactResult>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { HookContext, HookDecision } from './hooks.js';
|
|
2
|
+
export declare const RELEASE_BOUNDARY_DETECT_REASON_PREFIX = "release-boundary observe-only: publish/deploy/sync-boundary command";
|
|
3
|
+
export declare function detectReleaseBoundaryCommands(command: string): string[];
|
|
4
|
+
export declare function createReleaseBoundaryDetect(): (context: HookContext) => HookDecision;
|
|
@@ -31,6 +31,8 @@ export declare const ToolCallCompletedPayloadSchema: z.ZodObject<{
|
|
|
31
31
|
"hook-block": "hook-block";
|
|
32
32
|
"elicitation-declined": "elicitation-declined";
|
|
33
33
|
}>>;
|
|
34
|
+
batchIndex: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
batchSize: z.ZodOptional<z.ZodNumber>;
|
|
34
36
|
subagentId: z.ZodOptional<z.ZodString>;
|
|
35
37
|
}, z.core.$strip>;
|
|
36
38
|
export declare const ToolCallPayloadSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -56,6 +58,8 @@ export declare const ToolCallPayloadSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
56
58
|
"hook-block": "hook-block";
|
|
57
59
|
"elicitation-declined": "elicitation-declined";
|
|
58
60
|
}>>;
|
|
61
|
+
batchIndex: z.ZodOptional<z.ZodNumber>;
|
|
62
|
+
batchSize: z.ZodOptional<z.ZodNumber>;
|
|
59
63
|
subagentId: z.ZodOptional<z.ZodString>;
|
|
60
64
|
}, z.core.$strip>], "phase">;
|
|
61
65
|
export declare const HookEventNameSchema: z.ZodEnum<{
|
|
@@ -524,6 +528,8 @@ export declare const TraceEventInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
524
528
|
"hook-block": "hook-block";
|
|
525
529
|
"elicitation-declined": "elicitation-declined";
|
|
526
530
|
}>>;
|
|
531
|
+
batchIndex: z.ZodOptional<z.ZodNumber>;
|
|
532
|
+
batchSize: z.ZodOptional<z.ZodNumber>;
|
|
527
533
|
subagentId: z.ZodOptional<z.ZodString>;
|
|
528
534
|
}, z.core.$strip>], "phase">;
|
|
529
535
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -813,6 +819,8 @@ export declare const TraceEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
813
819
|
"hook-block": "hook-block";
|
|
814
820
|
"elicitation-declined": "elicitation-declined";
|
|
815
821
|
}>>;
|
|
822
|
+
batchIndex: z.ZodOptional<z.ZodNumber>;
|
|
823
|
+
batchSize: z.ZodOptional<z.ZodNumber>;
|
|
816
824
|
subagentId: z.ZodOptional<z.ZodString>;
|
|
817
825
|
}, z.core.$strip>], "phase">;
|
|
818
826
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -18,6 +18,8 @@ export interface ToolCallCompletedPayload {
|
|
|
18
18
|
durationMs: number;
|
|
19
19
|
circuitBreaker?: boolean;
|
|
20
20
|
failureClass?: ToolFailureClass;
|
|
21
|
+
batchIndex?: number;
|
|
22
|
+
batchSize?: number;
|
|
21
23
|
subagentId?: string;
|
|
22
24
|
}
|
|
23
25
|
export type ToolCallPayload = ToolCallStartedPayload | ToolCallCompletedPayload;
|
|
@@ -11,4 +11,5 @@ export declare const GROUP_THRESHOLD_DISPATCH = 2;
|
|
|
11
11
|
export declare const GROUP_THRESHOLD_LEAF = 3;
|
|
12
12
|
export declare function inProgressVerb(toolName: string): string;
|
|
13
13
|
export declare function formatOutcome(chunk: ToolResultChunk, homeDir?: string, maxPreview?: number, toolName?: string): string;
|
|
14
|
+
export declare function batchBadge(chunk: ToolResultChunk | undefined): string;
|
|
14
15
|
export declare function formatToolResultLine(chunk: ToolResultChunk, toolPrefix?: string, homeDir?: string, toolName?: string): string;
|