agent-afk 5.32.0 → 5.33.1
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/hooks.d.ts +3 -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/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/tools/dispatcher.d.ts +3 -0
- package/dist/cli.mjs +429 -424
- package/dist/index.mjs +155 -150
- package/dist/telegram.mjs +217 -212
- package/package.json +1 -1
package/dist/agent/hooks.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SubagentTrace } from './subagent/result.js';
|
|
2
|
+
import type { GrantManager } from '../cli/slash/commands/allow-dir.js';
|
|
2
3
|
export type HarnessHookEvent = 'SessionStart' | 'SessionEnd' | 'SubagentStart' | 'SubagentStop' | 'PreToolUse' | 'PostToolUse' | 'PreCompact' | 'PostToolUseFailure' | 'Stop' | 'UserPromptSubmit';
|
|
3
4
|
export interface HookDecision {
|
|
4
5
|
continue?: boolean;
|
|
@@ -41,6 +42,7 @@ export interface PreToolUseContext {
|
|
|
41
42
|
cwd?: string;
|
|
42
43
|
toolName: string;
|
|
43
44
|
input?: unknown;
|
|
45
|
+
grantManager?: GrantManager;
|
|
44
46
|
}
|
|
45
47
|
export interface PostToolUseContext {
|
|
46
48
|
event: 'PostToolUse';
|
|
@@ -50,6 +52,7 @@ export interface PostToolUseContext {
|
|
|
50
52
|
toolName: string;
|
|
51
53
|
input?: unknown;
|
|
52
54
|
output?: unknown;
|
|
55
|
+
grantManager?: GrantManager;
|
|
53
56
|
}
|
|
54
57
|
export interface PreCompactContext {
|
|
55
58
|
event: 'PreCompact';
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -9,6 +9,7 @@ import type { ToolHandler, ConcurrencyClassifier } from './types.js';
|
|
|
9
9
|
import { type ToolPermissionConfig } from './permissions.js';
|
|
10
10
|
import type { CanUseTool } from '../types/sdk-types.js';
|
|
11
11
|
import { type GrantSnapshot } from './grant-manager.js';
|
|
12
|
+
import type { GrantManager } from '../../cli/slash/commands/allow-dir.js';
|
|
12
13
|
import type { TraceWriter } from '../trace/index.js';
|
|
13
14
|
export { defaultConcurrencyClassifier } from './dispatch-batching.js';
|
|
14
15
|
export declare const REPEAT_CIRCUIT_BREAKER_THRESHOLD = 8;
|
|
@@ -31,6 +32,7 @@ export interface SessionToolDispatcherOptions {
|
|
|
31
32
|
env?: Record<string, string>;
|
|
32
33
|
sessionId?: string;
|
|
33
34
|
parentSessionId?: string;
|
|
35
|
+
sessionGrantManager?: GrantManager;
|
|
34
36
|
traceWriter?: TraceWriter;
|
|
35
37
|
readOnlyBash?: boolean;
|
|
36
38
|
}
|
|
@@ -52,6 +54,7 @@ export declare class SessionToolDispatcher implements ToolDispatcher {
|
|
|
52
54
|
private readonly _env;
|
|
53
55
|
private readonly sessionId;
|
|
54
56
|
private readonly parentSessionId;
|
|
57
|
+
private readonly sessionGrantManager;
|
|
55
58
|
private readonly traceWriter;
|
|
56
59
|
private readonly readOnlyBash;
|
|
57
60
|
private repeatBreaker;
|