agent-afk 5.23.2 → 5.25.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/providers/anthropic-direct/loop.d.ts +1 -1
- package/dist/agent/providers/anthropic-direct/query/cwd-dependents.d.ts +37 -0
- package/dist/agent/providers/anthropic-direct/query/presence-lifecycle.d.ts +13 -0
- package/dist/agent/providers/anthropic-direct/query/token-resolution.d.ts +6 -0
- package/dist/agent/providers/openai-compatible/query/dispatch-append.d.ts +15 -0
- package/dist/agent/providers/shared/tool-loop-cap.d.ts +5 -0
- package/dist/agent/shadow-verify-nudge.d.ts +1 -0
- package/dist/agent/tools/subagent/background-branch.d.ts +13 -0
- package/dist/agent/tools/subagent/child-config.d.ts +39 -0
- package/dist/agent/tools/subagent/failure-payload.d.ts +18 -0
- package/dist/agent/tools/subagent/foreground-promotion.d.ts +31 -0
- package/dist/agent/tools/subagent/input-parse.d.ts +14 -0
- package/dist/agent/tools/subagent-executor.d.ts +2 -1
- package/dist/agent/types/sdk-types.d.ts +1 -0
- package/dist/cli/commands/interactive/bootstrap.d.ts +1 -0
- package/dist/cli/commands/interactive/shared.d.ts +1 -1
- package/dist/cli/commands/interactive.d.ts +2 -1
- package/dist/cli/config.d.ts +1 -0
- package/dist/cli/elicitation/field-validation.d.ts +35 -0
- package/dist/cli/shared-helpers.d.ts +2 -0
- package/dist/cli.mjs +507 -507
- package/dist/config/env.d.ts +2 -0
- package/dist/index.mjs +178 -178
- package/dist/telegram.mjs +248 -248
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ProviderEvent } from '../../provider.js';
|
|
2
2
|
import type { AnthropicToolDef, RunTurnInput, WireToolDef } from './types.js';
|
|
3
|
-
export
|
|
3
|
+
export { DEFAULT_MAX_TOOL_USE_ITERATIONS } from '../shared/tool-loop-cap.js';
|
|
4
4
|
export declare function toWireTool(tool: AnthropicToolDef): WireToolDef;
|
|
5
5
|
export declare const OVERLOAD_MAX_RETRIES = 3;
|
|
6
6
|
export declare function isTransientServerError(err: Error): boolean;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { AgentConfig } from '../../../types/config-types.js';
|
|
2
|
+
import type { SubagentExecutor } from '../../../tools/subagent-executor.js';
|
|
3
|
+
import type { SkillExecutor } from '../../../tools/skill-executor.js';
|
|
4
|
+
import type { ComposeExecutor } from '../../../tools/compose-executor.js';
|
|
5
|
+
import type { ToolDispatcher } from '../tool-dispatcher.js';
|
|
6
|
+
import { type RuntimeStateSource } from '../../../awareness/index.js';
|
|
7
|
+
export type CwdDependentsFactory = (newCwd: string) => {
|
|
8
|
+
userSystem: string;
|
|
9
|
+
dispatcher: ToolDispatcher;
|
|
10
|
+
};
|
|
11
|
+
export interface CwdDependentsFactoryArgs {
|
|
12
|
+
stableSystemPrefix: string[];
|
|
13
|
+
config: AgentConfig;
|
|
14
|
+
surface: string;
|
|
15
|
+
runtimeStateSource: RuntimeStateSource;
|
|
16
|
+
getCurrentCwd: () => string | undefined;
|
|
17
|
+
setCurrentCwd: (cwd: string) => void;
|
|
18
|
+
getCurrentPermissionMode: () => string;
|
|
19
|
+
sharedReadRoots: string[] | undefined;
|
|
20
|
+
sharedWriteRoots: string[] | undefined;
|
|
21
|
+
subagentExecutor: SubagentExecutor | undefined;
|
|
22
|
+
skillExecutor: SkillExecutor | undefined;
|
|
23
|
+
composeExecutor: ComposeExecutor | undefined;
|
|
24
|
+
buildDispatcher: (permissionMode: string, opts: {
|
|
25
|
+
cwd?: string;
|
|
26
|
+
env?: Record<string, string>;
|
|
27
|
+
readRoots?: string[];
|
|
28
|
+
writeRoots?: string[];
|
|
29
|
+
sessionId?: string;
|
|
30
|
+
parentSessionId?: string;
|
|
31
|
+
traceWriter?: AgentConfig['traceWriter'];
|
|
32
|
+
runtimeStateSource?: RuntimeStateSource;
|
|
33
|
+
hookRegistry?: AgentConfig['hookRegistry'];
|
|
34
|
+
planExitControls?: AgentConfig['planExitControls'];
|
|
35
|
+
}) => ToolDispatcher;
|
|
36
|
+
}
|
|
37
|
+
export declare function createCwdDependentsFactory(args: CwdDependentsFactoryArgs): CwdDependentsFactory;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type RuntimeStateSource } from '../../../awareness/index.js';
|
|
2
|
+
export interface PresenceLifecycleArgs {
|
|
3
|
+
depth: number | undefined;
|
|
4
|
+
parentSessionId: string | undefined;
|
|
5
|
+
sessionId: string | undefined;
|
|
6
|
+
currentPresenceSessionId: string | null;
|
|
7
|
+
runtimeStateSource: RuntimeStateSource;
|
|
8
|
+
surface: string;
|
|
9
|
+
cwd: string | undefined;
|
|
10
|
+
providerName: string;
|
|
11
|
+
model: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function registerPresenceLifecycle(args: PresenceLifecycleArgs): string | null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TraceWriter } from '../../../trace/index.js';
|
|
2
|
+
import type { ProviderEvent } from '../../../provider.js';
|
|
3
|
+
import type { ToolDispatcher } from '../../anthropic-direct/tool-dispatcher.js';
|
|
4
|
+
import type { OpenAIMessage } from '../messages.js';
|
|
5
|
+
import type { StreamState } from '../translate.js';
|
|
6
|
+
export interface DispatchAndAppendInput {
|
|
7
|
+
state: StreamState;
|
|
8
|
+
signal: AbortSignal;
|
|
9
|
+
vision: boolean;
|
|
10
|
+
toolDispatcher: ToolDispatcher | undefined;
|
|
11
|
+
traceWriter: TraceWriter | undefined;
|
|
12
|
+
priorTurns: OpenAIMessage[];
|
|
13
|
+
sessionId: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function dispatchAndAppendToolCalls({ state, signal, vision, toolDispatcher, traceWriter, priorTurns, sessionId, }: DispatchAndAppendInput): AsyncGenerator<ProviderEvent>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const TOOL_USE_LOOP_CAPPED = "tool_use_loop_capped";
|
|
2
|
+
export declare const DEFAULT_MAX_TOOL_USE_ITERATIONS = 0;
|
|
3
|
+
export declare const WIND_DOWN_NOTE: string;
|
|
4
|
+
export declare function resolveMaxToolIterations(configured: number | undefined): number;
|
|
5
|
+
export declare function shouldWindDown(completedRounds: number, maxIterations: number): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type BackgroundAgentRegistry } from '../../background-registry.js';
|
|
2
|
+
import type { SubagentManager } from '../../subagent.js';
|
|
3
|
+
import type { ToolResult } from '../types.js';
|
|
4
|
+
type ForkedHandle = Awaited<ReturnType<SubagentManager['forkSubagent']>>;
|
|
5
|
+
export interface RunBackgroundBranchArgs {
|
|
6
|
+
handle: ForkedHandle;
|
|
7
|
+
registry: BackgroundAgentRegistry | undefined;
|
|
8
|
+
prompt: string;
|
|
9
|
+
model: string | undefined;
|
|
10
|
+
parentSessionId: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare function runBackgroundBranch(args: RunBackgroundBranchArgs): Promise<ToolResult>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { SubagentManager } from '../../subagent.js';
|
|
2
|
+
import type { ModelProvider } from '../../provider.js';
|
|
3
|
+
import type { AgentModelInput } from '../../types.js';
|
|
4
|
+
import type { AgentConfig } from '../../types/config-types.js';
|
|
5
|
+
import { createStubParentSession, type ChildProviderFactoryArgs } from '../nesting.js';
|
|
6
|
+
import type { RegisteredAgent } from '../../agents/index.js';
|
|
7
|
+
import type { AgentRegistry } from '../../agents/index.js';
|
|
8
|
+
import type { SkillExecutor } from '../skill-executor.js';
|
|
9
|
+
import type { Surface } from '../../awareness/types.js';
|
|
10
|
+
import type { SubagentExecutor, SubagentExecutorContext } from '../subagent-executor.js';
|
|
11
|
+
import type { AgentInput } from './input-parse.js';
|
|
12
|
+
export type ChildParentSession = ReturnType<typeof createStubParentSession> & {
|
|
13
|
+
sessionId: string | undefined;
|
|
14
|
+
};
|
|
15
|
+
export interface BuildChildConfigArgs {
|
|
16
|
+
parsed: AgentInput;
|
|
17
|
+
namedAgent: RegisteredAgent | undefined;
|
|
18
|
+
depth: number;
|
|
19
|
+
maxDepth: number;
|
|
20
|
+
currentCwd: string | undefined;
|
|
21
|
+
signal: AbortSignal;
|
|
22
|
+
defaultConfig: Pick<AgentConfig, 'apiKey' | 'systemPrompt' | 'baseUrl' | 'openaiBaseUrl'>;
|
|
23
|
+
resolveApiKeyForModel?: (model: string) => string | undefined;
|
|
24
|
+
defaultSubagentModel?: AgentModelInput;
|
|
25
|
+
childProviderFactory?: (args: ChildProviderFactoryArgs) => ModelProvider;
|
|
26
|
+
childSkillExecutorFactory?: (depth: number, maxDepth: number, signal: AbortSignal, inheritedCwd?: string) => SkillExecutor;
|
|
27
|
+
surface?: Surface;
|
|
28
|
+
allowedTools?: string[];
|
|
29
|
+
readOnlyBash?: boolean;
|
|
30
|
+
agentRegistry?: AgentRegistry;
|
|
31
|
+
parentModel?: AgentModelInput;
|
|
32
|
+
createChildExecutor: (ctx: SubagentExecutorContext) => SubagentExecutor;
|
|
33
|
+
}
|
|
34
|
+
export interface BuildChildConfigResult {
|
|
35
|
+
childConfig: AgentConfig;
|
|
36
|
+
childParentSession: ChildParentSession | undefined;
|
|
37
|
+
childManager: SubagentManager | undefined;
|
|
38
|
+
}
|
|
39
|
+
export declare function buildChildConfig(args: BuildChildConfigArgs): BuildChildConfigResult;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { appendRoutingDecision } from '../../routing-telemetry.js';
|
|
2
|
+
export declare function emitTelemetry(entry: Parameters<typeof appendRoutingDecision>[0]): Promise<void>;
|
|
3
|
+
export declare function truncate(s: string, max?: number): string;
|
|
4
|
+
export declare function measurePartial(partial: unknown): number | undefined;
|
|
5
|
+
export interface StructuredFailurePayload {
|
|
6
|
+
status: string;
|
|
7
|
+
error: string;
|
|
8
|
+
schemaError?: string;
|
|
9
|
+
partialOutput?: unknown;
|
|
10
|
+
subagent_id: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function buildFailurePayload(args: {
|
|
13
|
+
status: string;
|
|
14
|
+
errorMessage: string;
|
|
15
|
+
schemaErrorMessage?: string;
|
|
16
|
+
partialOutput?: unknown;
|
|
17
|
+
subagentId: string;
|
|
18
|
+
}): StructuredFailurePayload;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { BackgroundAgentRegistry } from '../../background-registry.js';
|
|
2
|
+
import type { SubagentManager } from '../../subagent.js';
|
|
3
|
+
import type { TraceOrigin, TraceActor } from '../../session/session-identity.js';
|
|
4
|
+
import type { ToolResult } from '../types.js';
|
|
5
|
+
import type { PromotedSubagentInfo } from '../subagent-executor.js';
|
|
6
|
+
type ForkedHandle = Awaited<ReturnType<SubagentManager['forkSubagent']>>;
|
|
7
|
+
export interface PromotionTrigger {
|
|
8
|
+
fire: () => void;
|
|
9
|
+
ready: Promise<PromotedSubagentInfo | null>;
|
|
10
|
+
}
|
|
11
|
+
export interface RunForegroundArgs {
|
|
12
|
+
handle: ForkedHandle;
|
|
13
|
+
signal: AbortSignal;
|
|
14
|
+
prompt: string;
|
|
15
|
+
idPrefix: string | undefined;
|
|
16
|
+
model: string | undefined;
|
|
17
|
+
childManager: SubagentManager | undefined;
|
|
18
|
+
identity: {
|
|
19
|
+
origin?: TraceOrigin;
|
|
20
|
+
actor?: TraceActor;
|
|
21
|
+
};
|
|
22
|
+
depth: number;
|
|
23
|
+
parentSessionId: string | undefined;
|
|
24
|
+
registry: BackgroundAgentRegistry | undefined;
|
|
25
|
+
promotionTriggers: Map<string, PromotionTrigger>;
|
|
26
|
+
activeForegroundHandles: Map<string, {
|
|
27
|
+
cancel: () => Promise<void>;
|
|
28
|
+
}>;
|
|
29
|
+
}
|
|
30
|
+
export declare function runForegroundWithPromotion(args: RunForegroundArgs): Promise<ToolResult>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type AgentExecutionMode = 'foreground' | 'background';
|
|
2
|
+
export interface AgentInput {
|
|
3
|
+
prompt: string;
|
|
4
|
+
model?: string;
|
|
5
|
+
max_turns?: number;
|
|
6
|
+
max_turns_explicit: boolean;
|
|
7
|
+
max_tool_use_iterations?: number;
|
|
8
|
+
max_tool_use_iterations_explicit: boolean;
|
|
9
|
+
id_prefix?: string;
|
|
10
|
+
agent_type?: string;
|
|
11
|
+
mode: AgentExecutionMode;
|
|
12
|
+
cwd?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function parseAgentInput(input: unknown): AgentInput;
|
|
@@ -8,7 +8,9 @@ import { type ChildProviderFactoryArgs } from './nesting.js';
|
|
|
8
8
|
import type { AgentRegistry } from '../agents/index.js';
|
|
9
9
|
import type { SkillExecutor } from './skill-executor.js';
|
|
10
10
|
import type { Surface } from '../awareness/types.js';
|
|
11
|
+
import { type AgentExecutionMode } from './subagent/input-parse.js';
|
|
11
12
|
export { DEFAULT_MAX_NESTING_DEPTH, type ChildProviderFactoryArgs } from './nesting.js';
|
|
13
|
+
export type { AgentExecutionMode };
|
|
12
14
|
export interface SubagentExecutorContext {
|
|
13
15
|
subagentManager: SubagentManager;
|
|
14
16
|
parentSession: Pick<IAgentSession, 'sessionId' | 'getInputStreamRef' | 'abortSignal'> & Partial<Pick<IAgentSession, 'hookRegistry'>>;
|
|
@@ -28,7 +30,6 @@ export interface SubagentExecutorContext {
|
|
|
28
30
|
agentRegistry?: AgentRegistry;
|
|
29
31
|
parentModel?: AgentModelInput;
|
|
30
32
|
}
|
|
31
|
-
export type AgentExecutionMode = 'foreground' | 'background';
|
|
32
33
|
export interface PromotedSubagentInfo {
|
|
33
34
|
jobId: string;
|
|
34
35
|
label: string;
|
|
@@ -14,6 +14,7 @@ interface BuildAgentSessionDeps {
|
|
|
14
14
|
thinking: ThinkingConfig | undefined;
|
|
15
15
|
effort: EffortLevel | undefined;
|
|
16
16
|
maxOutputTokens: number | undefined;
|
|
17
|
+
maxToolUseIterations: number | undefined;
|
|
17
18
|
providerFactory: (model: string | undefined) => ModelProvider;
|
|
18
19
|
hookRegistry: HookRegistry;
|
|
19
20
|
traceWriter: TraceWriter | undefined;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { type SkipReason } from './interactive/worktree-autoname.js';
|
|
3
3
|
import { type CliConfig } from '../config.js';
|
|
4
|
-
import type { CliOptions } from './interactive/shared.js';
|
|
4
|
+
import type { CliOptions, ThinkingUiMode } from './interactive/shared.js';
|
|
5
5
|
import { type UpdateInfo } from '../update-checker.js';
|
|
6
6
|
export { formatToolResultLine } from './interactive/tool-lane.js';
|
|
7
7
|
export declare function setInteractiveUpdateNotices(updateInfo: UpdateInfo | null, pendingMessage: string | null): void;
|
|
8
8
|
export declare function formatAutonameSkipReason(reason: SkipReason | 'create-failed' | 'unknown', detail: string | undefined): string | undefined;
|
|
9
9
|
export declare function isAutonameEnabled(options: CliOptions, config: CliConfig): boolean;
|
|
10
|
+
export declare function resolveThinkingUi(options: CliOptions, config: CliConfig): ThinkingUiMode;
|
|
10
11
|
export declare function startupHintLine(): string;
|
|
11
12
|
export declare function registerInteractiveCommand(program: Command): void;
|
package/dist/cli/config.d.ts
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface NumberValidationOptions {
|
|
2
|
+
allowSkip: boolean;
|
|
3
|
+
min?: number;
|
|
4
|
+
max?: number;
|
|
5
|
+
emptyError: string;
|
|
6
|
+
}
|
|
7
|
+
export type NumberValidationOutcome = {
|
|
8
|
+
ok: true;
|
|
9
|
+
skip: true;
|
|
10
|
+
} | {
|
|
11
|
+
ok: true;
|
|
12
|
+
skip: false;
|
|
13
|
+
value: number;
|
|
14
|
+
} | {
|
|
15
|
+
ok: false;
|
|
16
|
+
error: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function validateNumberField(input: string, opts: NumberValidationOptions): NumberValidationOutcome;
|
|
19
|
+
export interface TextValidationOptions {
|
|
20
|
+
allowSkip: boolean;
|
|
21
|
+
minLength?: number;
|
|
22
|
+
maxLength?: number;
|
|
23
|
+
emptyError: string;
|
|
24
|
+
}
|
|
25
|
+
export type TextValidationOutcome = {
|
|
26
|
+
ok: true;
|
|
27
|
+
skip: true;
|
|
28
|
+
} | {
|
|
29
|
+
ok: true;
|
|
30
|
+
skip: false;
|
|
31
|
+
} | {
|
|
32
|
+
ok: false;
|
|
33
|
+
error: string;
|
|
34
|
+
};
|
|
35
|
+
export declare function validateTextField(input: string, opts: TextValidationOptions): TextValidationOutcome;
|
|
@@ -23,6 +23,8 @@ export declare function getMaxBudgetUsd(): number | undefined;
|
|
|
23
23
|
export declare function getTaskBudget(): number | undefined;
|
|
24
24
|
export declare function parseMaxOutputTokens(raw: string | undefined): number | undefined;
|
|
25
25
|
export declare function getMaxOutputTokens(): number | undefined;
|
|
26
|
+
export declare function parseMaxToolUseIterations(raw: string | undefined): number | undefined;
|
|
27
|
+
export declare function getMaxToolUseIterations(): number | undefined;
|
|
26
28
|
export declare function parseProvider(raw: string | undefined, opts?: {
|
|
27
29
|
subagentExecutor?: import('../agent/tools/subagent-executor.js').SubagentExecutor;
|
|
28
30
|
skillExecutor?: import('../agent/tools/skill-executor.js').SkillExecutor;
|