agent-afk 5.219.4 → 5.220.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/daemon/scheduler.d.ts +0 -1
- package/dist/agent/daemon/scheduler.pull-tick.d.ts +16 -0
- package/dist/agent/facets/schema.d.ts +1 -1
- package/dist/agent/session/accounting-accumulator.d.ts +42 -0
- package/dist/agent/session/agent-session.d.ts +7 -22
- package/dist/agent/session/provider-lifecycle.d.ts +16 -0
- package/dist/agent/session/provider-passthrough.d.ts +19 -0
- package/dist/agent/session/session-reset.d.ts +18 -0
- package/dist/agent/session/session-send.d.ts +25 -0
- package/dist/agent/session/session-shutdown.d.ts +21 -0
- package/dist/agent/session/turn-stream-runner.d.ts +49 -0
- package/dist/agent/tools/dispatcher.core-exec.d.ts +34 -0
- package/dist/agent/tools/dispatcher.d.ts +5 -20
- package/dist/agent/tools/dispatcher.pre-dispatch-gates.d.ts +38 -0
- package/dist/agent/trace/events.d.ts +3 -3
- package/dist/cli/commands/daemon-session-factory.d.ts +10 -0
- package/dist/cli/commands/daemon.d.ts +2 -10
- package/dist/cli/markdown-stream-inline-close.d.ts +1 -0
- package/dist/cli.mjs +715 -715
- package/dist/index.mjs +310 -310
- package/dist/telegram.mjs +325 -325
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ScheduledTask } from './triggers.js';
|
|
2
|
+
import type { TelemetryRecord, TelemetryTrigger, TaskCompletionDetails } from './scheduler.js';
|
|
3
|
+
export interface PullTickContext {
|
|
4
|
+
queueDir: string;
|
|
5
|
+
isIdle: () => boolean;
|
|
6
|
+
getIsDequeuing: () => boolean;
|
|
7
|
+
setIsDequeuing: (v: boolean) => void;
|
|
8
|
+
runOnce: (task: ScheduledTask, trigger: 'pull') => Promise<TelemetryRecord>;
|
|
9
|
+
}
|
|
10
|
+
export declare function sweepAnsweredHandoffs(queueDir: string): void;
|
|
11
|
+
export declare function executePullTick(ctx: PullTickContext): Promise<void>;
|
|
12
|
+
export interface FireOnTaskCompleteOptions {
|
|
13
|
+
onTaskComplete?: (record: TelemetryRecord, details?: TaskCompletionDetails) => void | Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export declare function fireOnTaskComplete(record: TelemetryRecord, options: FireOnTaskCompleteOptions, task?: ScheduledTask, details?: TaskCompletionDetails): void;
|
|
16
|
+
export type { TelemetryTrigger };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ClosureSignals } from './closure-emitter.js';
|
|
2
|
+
import type { ResponseMetadata } from '../types.js';
|
|
3
|
+
interface TokenCounters {
|
|
4
|
+
input: number;
|
|
5
|
+
output: number;
|
|
6
|
+
cacheRead: number;
|
|
7
|
+
cacheCreation: number;
|
|
8
|
+
}
|
|
9
|
+
export interface AccountingSnapshot {
|
|
10
|
+
sessionRunningCostUsd: number;
|
|
11
|
+
sessionRunningTokens: Readonly<TokenCounters>;
|
|
12
|
+
subagentCompletedCount: number;
|
|
13
|
+
subagentRunningTokens: Readonly<TokenCounters>;
|
|
14
|
+
subagentRunningCostUsd: number;
|
|
15
|
+
}
|
|
16
|
+
export declare class AccountingAccumulator {
|
|
17
|
+
private sessionRunningCostUsd;
|
|
18
|
+
private sessionRunningTokens;
|
|
19
|
+
private lastStopReason;
|
|
20
|
+
private maxTurnsHit;
|
|
21
|
+
private hookBlocked;
|
|
22
|
+
private sawProviderError;
|
|
23
|
+
readonly sessionStartedAt: number;
|
|
24
|
+
private subagentCompletedCount;
|
|
25
|
+
private subagentRunningTokens;
|
|
26
|
+
private subagentRunningCostUsd;
|
|
27
|
+
reset(): void;
|
|
28
|
+
recordTurnMetadata(m: ResponseMetadata): void;
|
|
29
|
+
markHookBlocked(): void;
|
|
30
|
+
markMaxTurnsHit(): void;
|
|
31
|
+
markProviderError(): void;
|
|
32
|
+
clearProviderError(): void;
|
|
33
|
+
recordSubagentCompletion(usage?: {
|
|
34
|
+
inputTokens?: number;
|
|
35
|
+
outputTokens?: number;
|
|
36
|
+
cacheReadTokens?: number;
|
|
37
|
+
cacheCreationTokens?: number;
|
|
38
|
+
}, costUsd?: number): void;
|
|
39
|
+
closureSignals(signal: AbortSignal, dispatchReason: string): ClosureSignals;
|
|
40
|
+
snapshot(): AccountingSnapshot;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -2,8 +2,8 @@ import type { ContentBlockParam } from '@anthropic-ai/sdk/resources';
|
|
|
2
2
|
import type { TraceWriter } from '../trace/writer.js';
|
|
3
3
|
import type { HookRegistry } from '../hooks.js';
|
|
4
4
|
import type { ProviderCommandInfo, ProviderCompactResult, ProviderQuery, ProviderRewindConversationResult, RewindTarget } from '../provider.js';
|
|
5
|
-
import { type ZodType } from 'zod';
|
|
6
5
|
import type { AccountInfo, AgentConfig, AgentInfo, AgentModelInput, IAgentSession, InputStreamRef, McpServerStatus, Message, ModelInfo, OutputEvent, PermissionMode, ResponseMetadata, RewindFilesResult, SDKControlGetContextUsageResponse, SendMessageOptions, SessionIdentity, SessionMetadata, SessionState, StructuredMessageOptions } from '../types.js';
|
|
6
|
+
import type { ZodType } from 'zod';
|
|
7
7
|
import type { ElicitationRequest } from '../types/sdk-types.js';
|
|
8
8
|
export declare class AgentSession implements IAgentSession {
|
|
9
9
|
private readonly ownedTraceWriter;
|
|
@@ -22,38 +22,25 @@ export declare class AgentSession implements IAgentSession {
|
|
|
22
22
|
private inputStream;
|
|
23
23
|
private readonly abortController;
|
|
24
24
|
private readonly _hookRegistry;
|
|
25
|
-
private sessionEndDispatched;
|
|
26
25
|
private readonly ownsTraceSeal;
|
|
27
26
|
private stateManager;
|
|
28
|
-
private
|
|
29
|
-
private sessionRunningTokens;
|
|
30
|
-
private lastStopReason;
|
|
31
|
-
private maxTurnsHit;
|
|
32
|
-
private hookBlocked;
|
|
33
|
-
private sawProviderError;
|
|
34
|
-
private readonly sessionStartedAt;
|
|
35
|
-
private subagentCompletedCount;
|
|
36
|
-
private subagentRunningTokens;
|
|
37
|
-
private subagentRunningCostUsd;
|
|
27
|
+
private readonly accounting;
|
|
38
28
|
private readonly ledger;
|
|
39
29
|
private readonly outputBroadcast;
|
|
30
|
+
private readonly shutdown;
|
|
31
|
+
private runner;
|
|
40
32
|
constructor(config: AgentConfig, ownedTraceWriter?: TraceWriter);
|
|
41
33
|
private initSdkLifecycle;
|
|
42
|
-
private pullInitialization;
|
|
43
|
-
private buildTransformDeps;
|
|
44
34
|
get state(): SessionState;
|
|
45
35
|
get sessionId(): string | undefined;
|
|
46
36
|
get cwd(): string | undefined;
|
|
47
37
|
get abortSignal(): AbortSignal;
|
|
48
38
|
get hookRegistry(): HookRegistry | undefined;
|
|
49
39
|
abort(reason: string): void;
|
|
40
|
+
private makeSendDeps;
|
|
50
41
|
sendMessage(content: string, options?: SendMessageOptions): Promise<Message>;
|
|
51
42
|
sendMessageStructured<T>(content: string, schema: ZodType<T>, options?: StructuredMessageOptions): Promise<T>;
|
|
52
43
|
sendMessageStream(content: string | ContentBlockParam[]): AsyncIterableIterator<OutputEvent>;
|
|
53
|
-
private sendMessageStreamInternal;
|
|
54
|
-
private ensureLedger;
|
|
55
|
-
recordLedgerElicitation(reqId: string, request: ElicitationRequest): void;
|
|
56
|
-
private summarizeContentBlocks;
|
|
57
44
|
interrupt(): Promise<void>;
|
|
58
45
|
setBeforeNextRound(cb: (() => string | undefined) | undefined): void;
|
|
59
46
|
reset(): Promise<void>;
|
|
@@ -88,16 +75,14 @@ export declare class AgentSession implements IAgentSession {
|
|
|
88
75
|
compact(): Promise<ProviderCompactResult>;
|
|
89
76
|
listRewindTargets(): RewindTarget[];
|
|
90
77
|
rewindConversation(turnIndex: number): Promise<ProviderRewindConversationResult>;
|
|
78
|
+
private makePassthroughDeps;
|
|
91
79
|
getLastResponseMetadata(): ResponseMetadata | null;
|
|
92
80
|
getOutputStream(): AsyncIterable<OutputEvent>;
|
|
93
81
|
queueFrameworkContext(text: string): void;
|
|
94
|
-
private withPendingFrameworkContext;
|
|
95
82
|
getInputStreamRef(): Pick<InputStreamRef, 'pushUserMessage' | 'queueFrameworkContext'>;
|
|
96
83
|
getHistory(): readonly Message[];
|
|
97
84
|
getTurnCount(): number;
|
|
98
85
|
close(): Promise<void>;
|
|
99
|
-
private dispatchSessionEndOnce;
|
|
100
|
-
private closureSignals;
|
|
101
86
|
recordSubagentCompletion(usage?: {
|
|
102
87
|
inputTokens?: number;
|
|
103
88
|
outputTokens?: number;
|
|
@@ -105,5 +90,5 @@ export declare class AgentSession implements IAgentSession {
|
|
|
105
90
|
cacheCreationTokens?: number;
|
|
106
91
|
}, costUsd?: number): void;
|
|
107
92
|
pushSidebandEvent(event: OutputEvent): void;
|
|
108
|
-
|
|
93
|
+
recordLedgerElicitation(reqId: string, request: ElicitationRequest): void;
|
|
109
94
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SessionStateManager } from './session-state.js';
|
|
2
|
+
import { QueryInputStream } from './input-iterable.js';
|
|
3
|
+
import type { AccountingAccumulator } from './accounting-accumulator.js';
|
|
4
|
+
import type { SessionShutdown } from './session-shutdown.js';
|
|
5
|
+
import type { AgentConfig } from '../types.js';
|
|
6
|
+
import type { ProviderQuery, ProviderEvent } from '../provider.js';
|
|
7
|
+
import type { HookRegistry } from '../hooks.js';
|
|
8
|
+
import type { TransformDeps } from './stream-consumer.js';
|
|
9
|
+
export interface ProviderLifecycleResult {
|
|
10
|
+
stateManager: SessionStateManager;
|
|
11
|
+
inputStream: QueryInputStream;
|
|
12
|
+
providerQuery: ProviderQuery;
|
|
13
|
+
providerIterator: AsyncIterator<ProviderEvent>;
|
|
14
|
+
}
|
|
15
|
+
export declare function buildProviderLifecycle(config: AgentConfig): ProviderLifecycleResult;
|
|
16
|
+
export declare function runInitialization(config: AgentConfig, providerIterator: AsyncIterator<ProviderEvent>, abortSignal: AbortSignal, stateManager: SessionStateManager, accounting: AccountingAccumulator, shutdown: SessionShutdown, hookRegistry: HookRegistry | undefined, queueFrameworkContext: (text: string) => void, buildTransformDeps: () => TransformDeps): Promise<void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AccountInfo, AgentInfo, McpServerStatus, ModelInfo, RewindFilesResult, SDKControlGetContextUsageResponse, SessionState } from '../types.js';
|
|
2
|
+
import type { ProviderCommandInfo, ProviderCompactResult, ProviderQuery, ProviderRewindConversationResult, RewindTarget } from '../provider.js';
|
|
3
|
+
export interface PassthroughDeps {
|
|
4
|
+
getState: () => SessionState;
|
|
5
|
+
setState: (s: SessionState) => void;
|
|
6
|
+
getProviderQuery: () => ProviderQuery;
|
|
7
|
+
}
|
|
8
|
+
export declare function supportedCommands(deps: PassthroughDeps): Promise<ProviderCommandInfo[]>;
|
|
9
|
+
export declare function supportedModels(deps: PassthroughDeps): Promise<ModelInfo[]>;
|
|
10
|
+
export declare function supportedAgents(deps: PassthroughDeps): Promise<AgentInfo[]>;
|
|
11
|
+
export declare function getContextUsage(deps: PassthroughDeps): Promise<SDKControlGetContextUsageResponse>;
|
|
12
|
+
export declare function mcpServerStatus(deps: PassthroughDeps): Promise<McpServerStatus[]>;
|
|
13
|
+
export declare function accountInfo(deps: PassthroughDeps): Promise<AccountInfo>;
|
|
14
|
+
export declare function rewindFiles(userMessageId: string, options: {
|
|
15
|
+
dryRun?: boolean;
|
|
16
|
+
} | undefined, deps: PassthroughDeps): Promise<RewindFilesResult>;
|
|
17
|
+
export declare function compact(deps: PassthroughDeps): Promise<ProviderCompactResult>;
|
|
18
|
+
export declare function listRewindTargets(deps: PassthroughDeps): RewindTarget[];
|
|
19
|
+
export declare function rewindConversation(turnIndex: number, deps: PassthroughDeps): Promise<ProviderRewindConversationResult>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AgentConfig, SessionState } from '../types.js';
|
|
2
|
+
import type { ProviderQuery, ProviderEvent } from '../provider.js';
|
|
3
|
+
import type { SessionStateManager } from './session-state.js';
|
|
4
|
+
import type { SessionShutdown } from './session-shutdown.js';
|
|
5
|
+
import type { LedgerLifecycle } from './ledger-lifecycle.js';
|
|
6
|
+
export interface ResetDeps {
|
|
7
|
+
getState: () => SessionState;
|
|
8
|
+
setState: (s: SessionState) => void;
|
|
9
|
+
getAbortController: () => AbortController;
|
|
10
|
+
getProviderQuery: () => ProviderQuery;
|
|
11
|
+
getProviderIterator: () => AsyncIterator<ProviderEvent>;
|
|
12
|
+
getInitPromise: () => Promise<void> | null;
|
|
13
|
+
getShutdown: () => SessionShutdown;
|
|
14
|
+
getLedger: () => LedgerLifecycle;
|
|
15
|
+
getStateManager: () => SessionStateManager;
|
|
16
|
+
reinitialize: (patchConfig: (prev: AgentConfig) => AgentConfig) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare function resetSession(deps: ResetDeps): Promise<void>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ContentBlockParam } from '@anthropic-ai/sdk/resources';
|
|
2
|
+
import { type ZodType } from 'zod';
|
|
3
|
+
import type { Message, OutputEvent, SendMessageOptions, SessionState, StructuredMessageOptions } from '../types.js';
|
|
4
|
+
import type { ProviderQuery } from '../provider.js';
|
|
5
|
+
import type { AgentConfig } from '../types.js';
|
|
6
|
+
import type { TurnStreamRunner } from './turn-stream-runner.js';
|
|
7
|
+
import type { QueryInputStream } from './input-iterable.js';
|
|
8
|
+
import type { PlanExitBridge } from './plan-exit-bridge.js';
|
|
9
|
+
export interface SendDeps {
|
|
10
|
+
getConfig: () => AgentConfig;
|
|
11
|
+
getAbortController: () => AbortController;
|
|
12
|
+
getState: () => SessionState;
|
|
13
|
+
setState: (s: SessionState) => void;
|
|
14
|
+
getSessionId: () => string | undefined;
|
|
15
|
+
runner: TurnStreamRunner;
|
|
16
|
+
getInputStream: () => QueryInputStream;
|
|
17
|
+
getProviderQuery: () => ProviderQuery;
|
|
18
|
+
planExit: PlanExitBridge;
|
|
19
|
+
}
|
|
20
|
+
export declare function sendMessage(content: string, options: SendMessageOptions | undefined, deps: SendDeps): Promise<Message>;
|
|
21
|
+
export declare function sendMessageStructured<T>(content: string, schema: ZodType<T>, options: StructuredMessageOptions | undefined, deps: SendDeps): Promise<T>;
|
|
22
|
+
export declare function sendMessageStream(content: string | ContentBlockParam[], deps: SendDeps): AsyncIterableIterator<OutputEvent>;
|
|
23
|
+
export declare function sendMessageStreamInternal(content: string | ContentBlockParam[], deps: SendDeps): AsyncIterableIterator<OutputEvent>;
|
|
24
|
+
export declare function interrupt(deps: Pick<SendDeps, 'getState' | 'setState' | 'getProviderQuery'>): Promise<void>;
|
|
25
|
+
export declare function setBeforeNextRound(cb: (() => string | undefined) | undefined, deps: Pick<SendDeps, 'getProviderQuery'>): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TraceWriter } from '../trace/writer.js';
|
|
2
|
+
import type { AccountingAccumulator } from './accounting-accumulator.js';
|
|
3
|
+
import type { HookRegistry } from '../hooks.js';
|
|
4
|
+
import type { AgentConfig } from '../types.js';
|
|
5
|
+
export interface ShutdownDeps {
|
|
6
|
+
getConfig: () => AgentConfig;
|
|
7
|
+
getAbortController: () => AbortController;
|
|
8
|
+
getHookRegistry: () => HookRegistry | undefined;
|
|
9
|
+
accounting: AccountingAccumulator;
|
|
10
|
+
getTurnCount: () => number;
|
|
11
|
+
getSessionId: () => string | undefined;
|
|
12
|
+
ownedTraceWriter: TraceWriter | undefined;
|
|
13
|
+
ownsTraceSeal: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare class SessionShutdown {
|
|
16
|
+
private dispatched;
|
|
17
|
+
private readonly deps;
|
|
18
|
+
constructor(deps: ShutdownDeps);
|
|
19
|
+
reset(): void;
|
|
20
|
+
dispatchOnce(reason: string): Promise<void>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ContentBlockParam } from '@anthropic-ai/sdk/resources';
|
|
2
|
+
import { type SubagentOutputRecorder } from './subagent-output-capture.js';
|
|
3
|
+
import { type TransformDeps } from './stream-consumer.js';
|
|
4
|
+
import type { AccountingAccumulator } from './accounting-accumulator.js';
|
|
5
|
+
import type { LedgerLifecycle } from './ledger-lifecycle.js';
|
|
6
|
+
import type { OutputBroadcast } from './output-broadcast.js';
|
|
7
|
+
import type { SessionStateManager } from './session-state.js';
|
|
8
|
+
import type { AgentConfig, OutputEvent, ResponseMetadata, SessionState } from '../types.js';
|
|
9
|
+
import type { ProviderQuery, ProviderEvent } from '../provider.js';
|
|
10
|
+
import type { Message } from '../types.js';
|
|
11
|
+
export interface TurnRunnerDeps {
|
|
12
|
+
getConfig: () => AgentConfig;
|
|
13
|
+
getAbortController: () => AbortController;
|
|
14
|
+
getProviderIterator: () => AsyncIterator<ProviderEvent>;
|
|
15
|
+
stateManager: SessionStateManager;
|
|
16
|
+
accounting: AccountingAccumulator;
|
|
17
|
+
ledger: LedgerLifecycle;
|
|
18
|
+
outputBroadcast: OutputBroadcast;
|
|
19
|
+
conversationHistory: Message[];
|
|
20
|
+
getInitPromise: () => Promise<void> | null;
|
|
21
|
+
getSessionId: () => string | undefined;
|
|
22
|
+
getState: () => SessionState;
|
|
23
|
+
setState: (s: SessionState) => void;
|
|
24
|
+
getLastResponseMetadata: () => ResponseMetadata | null;
|
|
25
|
+
setLastResponseMetadata: (m: ResponseMetadata) => void;
|
|
26
|
+
getPendingFrameworkContext: () => string[];
|
|
27
|
+
setPendingFrameworkContext: (v: string[]) => void;
|
|
28
|
+
getInboundMessageCount: () => number;
|
|
29
|
+
incInboundMessageCount: () => number;
|
|
30
|
+
getTurnCount: () => number;
|
|
31
|
+
incTurnCount: () => void;
|
|
32
|
+
getSubagentOutputRecorder: () => SubagentOutputRecorder | null | undefined;
|
|
33
|
+
setSubagentOutputRecorder: (r: SubagentOutputRecorder | null) => void;
|
|
34
|
+
getProviderQuery: () => ProviderQuery;
|
|
35
|
+
getLedgerMetadata: () => ReturnType<SessionStateManager['getSessionMetadata']>;
|
|
36
|
+
}
|
|
37
|
+
export declare class TurnStreamRunner {
|
|
38
|
+
private readonly deps;
|
|
39
|
+
constructor(deps: TurnRunnerDeps);
|
|
40
|
+
assertCanSend(): void;
|
|
41
|
+
summarize(blocks: ContentBlockParam[]): string;
|
|
42
|
+
withPendingContext(content: string | ContentBlockParam[]): string | ContentBlockParam[];
|
|
43
|
+
ensureLedger(): void;
|
|
44
|
+
buildTransformDeps(): TransformDeps;
|
|
45
|
+
runStream(content: string | ContentBlockParam[], inputStream: {
|
|
46
|
+
pushUserMessage: (c: string | ContentBlockParam[]) => void;
|
|
47
|
+
}): AsyncIterableIterator<OutputEvent>;
|
|
48
|
+
queueFrameworkContext(text: string): void;
|
|
49
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { HookRegistry } from '../hooks.js';
|
|
2
|
+
import type { AnthropicToolDef } from '../providers/anthropic-direct/types.js';
|
|
3
|
+
import type { ToolCall, ToolResult } from '../providers/anthropic-direct/types.js';
|
|
4
|
+
import type { SubagentExecutor } from './subagent-executor.js';
|
|
5
|
+
import type { SkillExecutor } from './skill-executor.js';
|
|
6
|
+
import type { ComposeExecutor } from './compose-executor.js';
|
|
7
|
+
import type { ToolHandler, ToolHandlerContext } from './types.js';
|
|
8
|
+
import type { TraceSink } from '../trace/index.js';
|
|
9
|
+
import type { GrantManager } from '../../cli/slash/commands/allow-dir.js';
|
|
10
|
+
import type { PreDispatchGateDeps } from './dispatcher.pre-dispatch-gates.js';
|
|
11
|
+
export interface CoreExecDeps {
|
|
12
|
+
handlers: Map<string, ToolHandler>;
|
|
13
|
+
hookRegistry: HookRegistry | undefined;
|
|
14
|
+
sessionId: string | undefined;
|
|
15
|
+
parentSessionId: string | undefined;
|
|
16
|
+
sessionGrantManager: GrantManager | undefined;
|
|
17
|
+
traceWriter: TraceSink | undefined;
|
|
18
|
+
maxOutputBytes: number | undefined;
|
|
19
|
+
subagentExecutor: SubagentExecutor | undefined;
|
|
20
|
+
skillExecutor: SkillExecutor | undefined;
|
|
21
|
+
composeExecutor: ComposeExecutor | undefined;
|
|
22
|
+
callHandlerContext: (call: ToolCall) => ToolHandlerContext;
|
|
23
|
+
gateDeps: () => PreDispatchGateDeps;
|
|
24
|
+
toolDefs: readonly AnthropicToolDef[];
|
|
25
|
+
}
|
|
26
|
+
export declare function isRegisteredTool(toolName: string, deps: CoreExecDeps): boolean;
|
|
27
|
+
export declare function unknownToolMessage(toolName: string, deps: CoreExecDeps): string;
|
|
28
|
+
export declare function denialReason(toolName: string, permissionReason: string | undefined, deps: CoreExecDeps): string;
|
|
29
|
+
export declare function firePostToolUse(toolName: string, output: string, signal: AbortSignal, deps: CoreExecDeps, input?: unknown, resultFlags?: Pick<ToolResult, 'incomplete' | 'incompleteReason' | 'isError'>): void;
|
|
30
|
+
export declare function firePostToolUseFailure(toolName: string, errorMessage: string, signal: AbortSignal, deps: CoreExecDeps, input?: unknown): void;
|
|
31
|
+
export declare function applyOutputCap(result: ToolResult, deps: CoreExecDeps): ToolResult;
|
|
32
|
+
export declare function executeCompose(call: ToolCall, deps: CoreExecDeps): Promise<ToolResult>;
|
|
33
|
+
export declare function executeCoreInner(call: ToolCall, deps: CoreExecDeps): Promise<ToolResult>;
|
|
34
|
+
export declare function executeCore(call: ToolCall, deps: CoreExecDeps): Promise<ToolResult>;
|
|
@@ -9,7 +9,7 @@ import type { ComposeExecutor } from './compose-executor.js';
|
|
|
9
9
|
import type { ToolHandler, ConcurrencyClassifier } from './types.js';
|
|
10
10
|
import type { ToolActivityReporter } from '../providers/shared/tool-activity.js';
|
|
11
11
|
import type { SpawnedPidRegistry } from './handlers/pid-registry.js';
|
|
12
|
-
import {
|
|
12
|
+
import type { ToolPermissionConfig } from './permissions.js';
|
|
13
13
|
import type { CanUseTool } from '../types/sdk-types.js';
|
|
14
14
|
import { type GrantSnapshot } from './grant-manager.js';
|
|
15
15
|
import type { GrantManager } from '../../cli/slash/commands/allow-dir.js';
|
|
@@ -68,10 +68,8 @@ export declare class SessionToolDispatcher implements ToolDispatcher {
|
|
|
68
68
|
private readonly maxOutputBytes;
|
|
69
69
|
private readonly spawnedPidRegistry;
|
|
70
70
|
private readonly bashOutputTailReporter;
|
|
71
|
-
private
|
|
71
|
+
private readonly gateState;
|
|
72
72
|
private readonly repeatFailureGuard;
|
|
73
|
-
private denialBreaker;
|
|
74
|
-
private suspectedLoopWindow;
|
|
75
73
|
private readonly grantManager;
|
|
76
74
|
constructor(opts: SessionToolDispatcherOptions);
|
|
77
75
|
private get handlerContext();
|
|
@@ -83,24 +81,11 @@ export declare class SessionToolDispatcher implements ToolDispatcher {
|
|
|
83
81
|
setAllowAll(allow: boolean): void;
|
|
84
82
|
setResolveBase(newCwd: string): void;
|
|
85
83
|
get toolDefs(): readonly AnthropicToolDef[];
|
|
86
|
-
private
|
|
87
|
-
private
|
|
88
|
-
private unknownToolMessage;
|
|
89
|
-
private checkReadOnlyBash;
|
|
90
|
-
private emitPreToolUseBlock;
|
|
91
|
-
private checkRepeatCircuitBreaker;
|
|
92
|
-
private checkRepeatFailureGuard;
|
|
93
|
-
private observeSuspectedLoop;
|
|
94
|
-
private recordForkReadDenial;
|
|
95
|
-
private resetDenialBreaker;
|
|
96
|
-
private runCanUseTool;
|
|
84
|
+
private gateDeps;
|
|
85
|
+
private coreExecDeps;
|
|
97
86
|
private runPreDispatchGates;
|
|
87
|
+
private resetDenialBreaker;
|
|
98
88
|
execute(call: ToolCall): Promise<ToolResult>;
|
|
99
89
|
executeBatch(calls: ToolCall[], onActivity?: ToolActivityReporter): Promise<ToolResult[]>;
|
|
100
90
|
private executeCore;
|
|
101
|
-
private applyOutputCap;
|
|
102
|
-
private executeCoreInner;
|
|
103
|
-
private executeCompose;
|
|
104
|
-
private firePostToolUse;
|
|
105
|
-
private firePostToolUseFailure;
|
|
106
91
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type ToolPermissionConfig } from './permissions.js';
|
|
2
|
+
import { type SuspectedLoopWindow } from './suspected-loop-detector.js';
|
|
3
|
+
import { RepeatFailureGuard } from './repeat-failure-guard.js';
|
|
4
|
+
import type { HookRegistry } from '../hooks.js';
|
|
5
|
+
import type { ToolCall, ToolResult } from '../providers/anthropic-direct/types.js';
|
|
6
|
+
import type { CanUseTool } from '../types/sdk-types.js';
|
|
7
|
+
import type { TraceSink } from '../trace/index.js';
|
|
8
|
+
import type { GrantManager } from '../../cli/slash/commands/allow-dir.js';
|
|
9
|
+
export interface PreDispatchGateMutableState {
|
|
10
|
+
repeatBreaker: {
|
|
11
|
+
fingerprint: string;
|
|
12
|
+
count: number;
|
|
13
|
+
} | null;
|
|
14
|
+
suspectedLoopWindow: SuspectedLoopWindow | null;
|
|
15
|
+
denialBreaker: {
|
|
16
|
+
count: number;
|
|
17
|
+
deniedPaths: string[];
|
|
18
|
+
} | null;
|
|
19
|
+
}
|
|
20
|
+
export interface PreDispatchGateDeps {
|
|
21
|
+
state: PreDispatchGateMutableState;
|
|
22
|
+
hookRegistry: HookRegistry | undefined;
|
|
23
|
+
permissions: ToolPermissionConfig | undefined;
|
|
24
|
+
canUseTool: CanUseTool | undefined;
|
|
25
|
+
readOnlyBash: boolean;
|
|
26
|
+
repeatFailureGuard: RepeatFailureGuard;
|
|
27
|
+
sessionId: string | undefined;
|
|
28
|
+
parentSessionId: string | undefined;
|
|
29
|
+
subagentId: string | undefined;
|
|
30
|
+
sessionGrantManager: GrantManager | undefined;
|
|
31
|
+
resolveBase: string | undefined;
|
|
32
|
+
traceWriter: TraceSink | undefined;
|
|
33
|
+
isRegisteredTool: (toolName: string) => boolean;
|
|
34
|
+
denialReason: (toolName: string, permissionReason: string | undefined) => string;
|
|
35
|
+
}
|
|
36
|
+
export declare function emitPreToolUseBlock(blockedTool: string, reason: string, deps: PreDispatchGateDeps): Promise<void>;
|
|
37
|
+
export declare function resetDenialBreaker(state: PreDispatchGateMutableState): void;
|
|
38
|
+
export declare function runPreDispatchGates(call: ToolCall, deps: PreDispatchGateDeps, repeatBreakerExemptTools: ReadonlySet<string>, repeatCircuitBreakerThreshold: number): Promise<ToolResult | null>;
|
|
@@ -558,8 +558,8 @@ export declare const SessionPhasePayloadSchema: z.ZodObject<{
|
|
|
558
558
|
telegram: "telegram";
|
|
559
559
|
daemon: "daemon";
|
|
560
560
|
cli: "cli";
|
|
561
|
-
unknown: "unknown";
|
|
562
561
|
web: "web";
|
|
562
|
+
unknown: "unknown";
|
|
563
563
|
}>>;
|
|
564
564
|
actor: z.ZodOptional<z.ZodEnum<{
|
|
565
565
|
main: "main";
|
|
@@ -918,8 +918,8 @@ export declare const TraceEventInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
918
918
|
telegram: "telegram";
|
|
919
919
|
daemon: "daemon";
|
|
920
920
|
cli: "cli";
|
|
921
|
-
unknown: "unknown";
|
|
922
921
|
web: "web";
|
|
922
|
+
unknown: "unknown";
|
|
923
923
|
}>>;
|
|
924
924
|
actor: z.ZodOptional<z.ZodEnum<{
|
|
925
925
|
main: "main";
|
|
@@ -1288,8 +1288,8 @@ export declare const TraceEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1288
1288
|
telegram: "telegram";
|
|
1289
1289
|
daemon: "daemon";
|
|
1290
1290
|
cli: "cli";
|
|
1291
|
-
unknown: "unknown";
|
|
1292
1291
|
web: "web";
|
|
1292
|
+
unknown: "unknown";
|
|
1293
1293
|
}>>;
|
|
1294
1294
|
actor: z.ZodOptional<z.ZodEnum<{
|
|
1295
1295
|
main: "main";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AgentConfig, AgentModelInput } from '../../agent/types.js';
|
|
2
|
+
import { AgentSession } from '../../agent/session.js';
|
|
3
|
+
export interface BuildDaemonSessionFactoryOpts {
|
|
4
|
+
model: AgentModelInput;
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
openaiBaseUrl?: string;
|
|
8
|
+
cwd?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function buildDaemonSessionFactory(opts: BuildDaemonSessionFactoryOpts): (config: AgentConfig, ownedTraceWriter?: import('../../agent/trace/index.js').TraceWriter) => AgentSession;
|
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import type { TaskCompletionDetails, TelemetryRecord } from '../../agent/daemon/scheduler.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export interface BuildDaemonSessionFactoryOpts {
|
|
6
|
-
model: AgentModelInput;
|
|
7
|
-
apiKey?: string;
|
|
8
|
-
baseUrl?: string;
|
|
9
|
-
openaiBaseUrl?: string;
|
|
10
|
-
cwd?: string;
|
|
11
|
-
}
|
|
12
|
-
export declare function buildDaemonSessionFactory(opts: BuildDaemonSessionFactoryOpts): (config: AgentConfig, ownedTraceWriter?: import('../../agent/trace/index.js').TraceWriter) => AgentSession;
|
|
3
|
+
export type { BuildDaemonSessionFactoryOpts } from './daemon-session-factory.js';
|
|
4
|
+
export { buildDaemonSessionFactory } from './daemon-session-factory.js';
|
|
13
5
|
export declare function resolveNotifyChatTarget(notifyChat: number | string | undefined, taskId: string): number | undefined;
|
|
14
6
|
export declare function formatTaskCompletion(record: TelemetryRecord, details?: TaskCompletionDetails, verifyDone?: boolean): string;
|
|
15
7
|
export declare function registerDaemonCommand(program: Command): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function closePendingInlineSyntax(text: string): string;
|