agent-afk 5.353.0 → 5.353.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.
@@ -1,9 +1,14 @@
1
1
  import { type ProviderRouteHints } from '../providers/index.js';
2
2
  export declare function loadAnthropicCredential(): string | undefined;
3
+ export type CredentialSourceId = 'ANTHROPIC_API_KEY' | 'CLAUDE_CODE_OAUTH_TOKEN' | 'claude-code-keychain' | 'claude-code-session-refresh';
4
+ export interface AnthropicCredential {
5
+ token: string;
6
+ source: CredentialSourceId;
7
+ }
8
+ export declare function resolveAnthropicCredential(): AnthropicCredential | undefined;
3
9
  export declare function preloadClaudeKeychainOAuth(provider: string): Promise<string | undefined>;
4
10
  export declare function _resetRefreshedClaudeCodeOauthToken(): void;
5
11
  export declare function setRefreshedClaudeCodeOauthToken(token: string): void;
6
- export declare function hasProcessLocalRefreshedToken(): boolean;
7
12
  export declare function loadOpenAICredential(): string | undefined;
8
13
  export declare function loadXaiApiKey(): string | undefined;
9
14
  export declare function resolveCredentialForModel(model: string | undefined, hints?: ProviderRouteHints): string | undefined;
@@ -22,6 +22,8 @@ export declare function classifyEntry(e: RawEntry): Classified;
22
22
  export declare function parseCatFileBatch(buf: Buffer, count: number): Buffer[] | null;
23
23
  export declare const MAX_BLOB_BYTES: number;
24
24
  export declare function _setMaxBlobBytesForTests(value: number | undefined): void;
25
+ export declare const MAX_AGGREGATE_BLOB_BYTES: number;
26
+ export declare function _setMaxAggregateBlobBytesForTests(value: number | undefined): void;
25
27
  export declare function parseBatchCheck(buf: Buffer, count: number): number[] | null;
26
28
  export declare function diffWithCtx(options: DiffOptions, ctx: GitCtx): Promise<DiffResult>;
27
29
  export {};
@@ -13,6 +13,7 @@ import type { CustomToolDef } from '../../tools/custom-tool.js';
13
13
  import type { GrantManager } from '../../tools/grant-manager.js';
14
14
  import type { RuntimeStateSource } from '../../awareness/index.js';
15
15
  import type { SpawnedPidRegistry } from '../../tools/handlers/pid-registry.js';
16
+ import type { ToolCallLedgerWiring } from '../../tools/dispatcher.ledger.js';
16
17
  import { SessionToolDispatcher } from '../../tools/dispatcher.js';
17
18
  import type { ToolPermissionConfig } from '../../tools/permissions.js';
18
19
  export interface BuildDispatcherOptions {
@@ -31,6 +32,7 @@ export interface BuildDispatcherOptions {
31
32
  hookRegistry?: HookRegistry;
32
33
  planExitControls?: PlanExitControls;
33
34
  spawnedPidRegistry?: SpawnedPidRegistry;
35
+ toolCallLedger?: ToolCallLedgerWiring;
34
36
  bashOutputTailReporter?: (toolUseId: string) => (tail: string | undefined) => void;
35
37
  detachRegistry?: import('../../tools/detach-registry.js').DetachableToolRegistry;
36
38
  processJobs?: import('../../shell-jobs/process-jobs.js').ProcessJobRegistry;
@@ -33,6 +33,7 @@ export declare class AnthropicDirectProvider implements ModelProvider {
33
33
  private _presenceSessionId;
34
34
  private _mintedSessionId;
35
35
  private readonly _spawnedPidRegistry;
36
+ private readonly _toolCallLedger;
36
37
  private get memoryStore();
37
38
  private get stateStore();
38
39
  private readonly _injectedMemoryStore;
@@ -18,6 +18,7 @@ export declare class OpenAICompatibleProvider implements ModelProvider {
18
18
  private _presenceSessionId;
19
19
  private _mintedSessionId;
20
20
  private readonly _spawnedPidRegistry;
21
+ private readonly _toolCallLedger;
21
22
  constructor(opts?: OpenAICompatibleProviderOptions);
22
23
  setEndpointDefaults(defaults: {
23
24
  baseURL?: string;
@@ -26,7 +26,7 @@ export interface SystemPromptWiringResult {
26
26
  goalPrompt: string;
27
27
  manifest: string;
28
28
  agentTypeListing: string;
29
- episodeRecall: string | undefined;
29
+ episodeRecall: string;
30
30
  };
31
31
  }
32
32
  export declare function buildSystemPromptWiring(args: SystemPromptWiringArgs): SystemPromptWiringResult;
@@ -1,4 +1,5 @@
1
1
  import type { RepeatFailureGuard } from './repeat-failure-guard.js';
2
+ import { type ToolCallLedgerWiring } from './dispatcher.ledger.js';
2
3
  import type { ToolCall, ToolResult } from '../providers/anthropic-direct/types.js';
3
4
  import type { SubagentExecutor } from './subagent-executor.js';
4
5
  import type { Batch } from './dispatch-batching.js';
@@ -11,6 +12,7 @@ export interface IndexedCall {
11
12
  }
12
13
  export interface BatchExecDeps {
13
14
  repeatFailureGuard: RepeatFailureGuard;
15
+ toolCallLedger: ToolCallLedgerWiring;
14
16
  repeatBreakerExemptTools: ReadonlySet<string>;
15
17
  executeCore: (call: ToolCall) => Promise<ToolResult>;
16
18
  subagentExecutor: SubagentExecutor | undefined;
@@ -1,58 +1,16 @@
1
1
  import { DEFAULT_MAX_CONCURRENT_SAFE_TOOL_CALLS, resolveMaxConcurrentSafeToolCalls } from '../../config/concurrency.js';
2
- import type { HookRegistry } from '../hooks.js';
3
2
  import type { AnthropicToolDef } from '../providers/anthropic-direct/types.js';
4
3
  import type { ToolDispatcher } from '../providers/anthropic-direct/tool-dispatcher.js';
5
4
  import type { ToolCall, ToolResult } from '../providers/anthropic-direct/types.js';
6
- import type { SubagentExecutor } from './subagent-executor.js';
7
- import type { SkillExecutor } from './skill-executor.js';
8
- import type { ComposeExecutor } from './compose-executor.js';
9
- import type { ToolHandler, ConcurrencyClassifier } from './types.js';
10
5
  import type { ToolActivityReporter } from '../providers/shared/tool-activity.js';
11
- import type { SpawnedPidRegistry } from './handlers/pid-registry.js';
12
- import { type ToolPermissionConfig } from './permissions.js';
13
- import type { CanUseTool } from '../types/sdk-types.js';
14
- import { type GrantSnapshot, type GrantManager } from './grant-manager.js';
15
- import type { TraceSink } from '../trace/index.js';
16
- import { type GetMcpServerStates } from './dispatcher.mcp-states.js';
17
- import { type UserAttention } from './user-yield.js';
18
- import { type DetachableToolRegistry } from './detach-bash.js';
19
- import type { ProcessJobRegistry } from '../shell-jobs/process-jobs.js';
6
+ import { type GrantSnapshot } from './grant-manager.js';
7
+ import { ToolCallLedgerWiring } from './dispatcher.ledger.js';
20
8
  import { FileCheckpointWiring } from './dispatcher.file-checkpoint.js';
21
9
  export { defaultConcurrencyClassifier } from './dispatch-batching.js';
22
10
  export declare const REPEAT_CIRCUIT_BREAKER_THRESHOLD = 8;
23
11
  export { DEFAULT_MAX_CONCURRENT_SAFE_TOOL_CALLS, resolveMaxConcurrentSafeToolCalls };
24
- export interface SessionToolDispatcherOptions {
25
- handlers: Map<string, ToolHandler>;
26
- schemas: AnthropicToolDef[];
27
- hookRegistry: HookRegistry | undefined;
28
- permissions?: ToolPermissionConfig;
29
- canUseTool?: CanUseTool;
30
- subagentExecutor?: SubagentExecutor;
31
- skillExecutor?: SkillExecutor;
32
- composeExecutor?: ComposeExecutor;
33
- concurrencyClassifier?: ConcurrencyClassifier;
34
- maxConcurrentSafeCalls?: number;
35
- cwd?: string;
36
- readRoots?: string[];
37
- writeRoots?: string[];
38
- allowAll?: boolean;
39
- env?: Record<string, string>;
40
- getMcpServerStates?: GetMcpServerStates;
41
- sessionId?: string;
42
- parentSessionId?: string;
43
- rootSessionId?: string;
44
- subagentId?: string;
45
- sessionGrantManager?: GrantManager;
46
- isNonInteractive?: boolean;
47
- traceWriter?: TraceSink;
48
- readOnlyBash?: boolean;
49
- maxOutputBytes?: number;
50
- spawnedPidRegistry?: SpawnedPidRegistry;
51
- userAttention?: UserAttention;
52
- bashOutputTailReporter?: (toolUseId: string) => (tail: string | undefined) => void;
53
- detachRegistry?: DetachableToolRegistry;
54
- processJobs?: ProcessJobRegistry;
55
- }
12
+ import type { SessionToolDispatcherOptions } from './dispatcher.options.js';
13
+ export type { SessionToolDispatcherOptions } from './dispatcher.options.js';
56
14
  export declare class SessionToolDispatcher implements ToolDispatcher {
57
15
  private readonly handlers;
58
16
  private readonly schemas;
@@ -88,6 +46,7 @@ export declare class SessionToolDispatcher implements ToolDispatcher {
88
46
  private readonly repeatFailureGuard;
89
47
  private readonly toolHealthMonitor;
90
48
  private readonly strategyNudger;
49
+ readonly toolCallLedger: ToolCallLedgerWiring;
91
50
  private readonly _getMcpServerStates;
92
51
  private readonly grantManager;
93
52
  constructor(opts: SessionToolDispatcherOptions);
@@ -3,6 +3,7 @@ import type { TraceSink } from '../trace/index.js';
3
3
  import type { ToolCall, ToolResult } from '../providers/anthropic-direct/types.js';
4
4
  import type { ToolActivityReporter } from '../providers/shared/tool-activity.js';
5
5
  import type { RepeatFailureGuard } from './repeat-failure-guard.js';
6
+ import type { ToolCallLedgerWiring } from './dispatcher.ledger.js';
6
7
  import type { SubagentExecutor } from './subagent-executor.js';
7
8
  import type { ConcurrencyClassifier } from './types.js';
8
9
  import type { ToolHealthMonitor } from './tool-health-monitor.js';
@@ -13,6 +14,7 @@ export interface ExecuteBatchDeps {
13
14
  runPreDispatchGates: (call: ToolCall, opts?: RunPreDispatchGatesOpts) => Promise<ToolResult | null>;
14
15
  resetDenialBreaker: () => void;
15
16
  repeatFailureGuard: RepeatFailureGuard;
17
+ toolCallLedger: ToolCallLedgerWiring;
16
18
  repeatBreakerExemptTools: ReadonlySet<string>;
17
19
  executeCore: (call: ToolCall) => Promise<ToolResult>;
18
20
  subagentExecutor: SubagentExecutor | undefined;
@@ -0,0 +1,13 @@
1
+ import type { ToolCall, ToolResult } from '../providers/anthropic-direct/types.js';
2
+ import { type RepeatFailureGuard } from './repeat-failure-guard.js';
3
+ import { ToolCallLedger, type LedgerHistory } from './tool-call-ledger.js';
4
+ export declare class ToolCallLedgerWiring {
5
+ readonly ledger: ToolCallLedger;
6
+ private round;
7
+ constructor(ledger?: ToolCallLedger);
8
+ get currentRound(): number;
9
+ beginRound(): void;
10
+ record(toolName: string, inputHash: string, result: ToolResult): void;
11
+ lookup(call: ToolCall): LedgerHistory;
12
+ }
13
+ export declare function noteSettledOutcome(guard: RepeatFailureGuard, wiring: ToolCallLedgerWiring, call: ToolCall, result: ToolResult): void;
@@ -0,0 +1,49 @@
1
+ import type { HookRegistry } from '../hooks.js';
2
+ import type { AnthropicToolDef } from '../providers/anthropic-direct/types.js';
3
+ import type { SubagentExecutor } from './subagent-executor.js';
4
+ import type { SkillExecutor } from './skill-executor.js';
5
+ import type { ComposeExecutor } from './compose-executor.js';
6
+ import type { ToolHandler, ConcurrencyClassifier } from './types.js';
7
+ import type { SpawnedPidRegistry } from './handlers/pid-registry.js';
8
+ import type { ToolPermissionConfig } from './permissions.js';
9
+ import type { CanUseTool } from '../types/sdk-types.js';
10
+ import type { GrantManager } from './grant-manager.js';
11
+ import type { TraceSink } from '../trace/index.js';
12
+ import type { GetMcpServerStates } from './dispatcher.mcp-states.js';
13
+ import type { UserAttention } from './user-yield.js';
14
+ import type { DetachableToolRegistry } from './detach-bash.js';
15
+ import type { ProcessJobRegistry } from '../shell-jobs/process-jobs.js';
16
+ import type { ToolCallLedgerWiring } from './dispatcher.ledger.js';
17
+ export interface SessionToolDispatcherOptions {
18
+ handlers: Map<string, ToolHandler>;
19
+ schemas: AnthropicToolDef[];
20
+ hookRegistry: HookRegistry | undefined;
21
+ permissions?: ToolPermissionConfig;
22
+ canUseTool?: CanUseTool;
23
+ subagentExecutor?: SubagentExecutor;
24
+ skillExecutor?: SkillExecutor;
25
+ composeExecutor?: ComposeExecutor;
26
+ concurrencyClassifier?: ConcurrencyClassifier;
27
+ maxConcurrentSafeCalls?: number;
28
+ cwd?: string;
29
+ readRoots?: string[];
30
+ writeRoots?: string[];
31
+ allowAll?: boolean;
32
+ env?: Record<string, string>;
33
+ getMcpServerStates?: GetMcpServerStates;
34
+ sessionId?: string;
35
+ parentSessionId?: string;
36
+ rootSessionId?: string;
37
+ subagentId?: string;
38
+ sessionGrantManager?: GrantManager;
39
+ isNonInteractive?: boolean;
40
+ traceWriter?: TraceSink;
41
+ readOnlyBash?: boolean;
42
+ maxOutputBytes?: number;
43
+ spawnedPidRegistry?: SpawnedPidRegistry;
44
+ userAttention?: UserAttention;
45
+ bashOutputTailReporter?: (toolUseId: string) => (tail: string | undefined) => void;
46
+ detachRegistry?: DetachableToolRegistry;
47
+ processJobs?: ProcessJobRegistry;
48
+ toolCallLedger?: ToolCallLedgerWiring;
49
+ }
@@ -9,6 +9,6 @@ export declare function repeatFailureFingerprint(call: ToolCall): string;
9
9
  export declare class RepeatFailureGuard {
10
10
  private readonly streaks;
11
11
  check(call: ToolCall): RepeatFailureVerdict | null;
12
- note(call: ToolCall, result: ToolResult): void;
12
+ note(call: ToolCall, result: ToolResult): string;
13
13
  streakFor(call: ToolCall): number;
14
14
  }
@@ -12,7 +12,7 @@ export declare function anthropicBilling(u: {
12
12
  cache_read_input_tokens?: number | null;
13
13
  cache_creation_input_tokens?: number | null;
14
14
  }): BillingUsage;
15
- export declare function openAICompatibleBilling(promptTokens: number, cachedTokens: number, completionTokens: number): BillingUsage;
15
+ export declare function openAICompatibleBilling(promptTokens: number, cachedTokens: number, completionTokens: number, cacheWriteTokens?: number): BillingUsage;
16
16
  export declare function sumBillingUsage(a: BillingUsage | undefined, b: BillingUsage | undefined): BillingUsage | undefined;
17
17
  export declare function billingToUsageFields(b: BillingUsage | undefined): Record<string, unknown>;
18
18
  export declare function billingFromUsageRecord(u: Record<string, unknown> | undefined): BillingUsage | undefined;
@@ -1,3 +1,4 @@
1
- export declare function describeCredentialSource(): string;
2
- export type CredentialSourceId = 'ANTHROPIC_API_KEY' | 'CLAUDE_CODE_OAUTH_TOKEN' | 'claude-code-keychain' | 'claude-code-session-refresh';
1
+ import { type CredentialSourceId } from '../agent/auth/credential-resolver.js';
2
+ export type { CredentialSourceId };
3
+ export declare function describeCredentialSource(source?: CredentialSourceId | null): string;
3
4
  export declare function credentialSourceId(): CredentialSourceId | null;