agent-afk 5.310.5 → 5.310.7

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.
Files changed (29) hide show
  1. package/dist/agent/file-checkpoint/file-checkpoint.d.ts +15 -0
  2. package/dist/agent/file-checkpoint/rewind-files.d.ts +11 -0
  3. package/dist/agent/file-checkpoint/rewind-staging.d.ts +2 -0
  4. package/dist/agent/file-checkpoint/write-policy.d.ts +3 -0
  5. package/dist/agent/provider.d.ts +2 -0
  6. package/dist/agent/providers/anthropic-direct/query/session-state.d.ts +3 -0
  7. package/dist/agent/providers/anthropic-direct/query-options.d.ts +1 -0
  8. package/dist/agent/providers/anthropic-direct/query-runtime.d.ts +1 -1
  9. package/dist/agent/providers/openai-compatible/query.d.ts +2 -1
  10. package/dist/agent/providers/openai-compatible/query.file-checkpoint.d.ts +14 -0
  11. package/dist/agent/providers/shared/chain-provider-close.d.ts +2 -0
  12. package/dist/agent/session/stream-consumer.d.ts +1 -1
  13. package/dist/agent/tools/compose-agent-resolve.d.ts +6 -0
  14. package/dist/agent/tools/compose-node-provider.d.ts +1 -0
  15. package/dist/agent/tools/dispatcher.d.ts +2 -0
  16. package/dist/agent/tools/dispatcher.file-checkpoint.d.ts +9 -0
  17. package/dist/agent/tools/nesting.d.ts +2 -0
  18. package/dist/agent/tools/types.d.ts +2 -0
  19. package/dist/agent/types/message-types.d.ts +1 -0
  20. package/dist/cli/first-run.d.ts +4 -0
  21. package/dist/cli/index.d.ts +1 -2
  22. package/dist/cli/provider-selection.d.ts +7 -0
  23. package/dist/cli.mjs +483 -476
  24. package/dist/index.mjs +209 -202
  25. package/dist/paths.checkpoint.d.ts +3 -0
  26. package/dist/paths.d.ts +2 -1
  27. package/dist/paths.whatif.d.ts +1 -0
  28. package/dist/telegram.mjs +242 -235
  29. package/package.json +1 -1
@@ -0,0 +1,15 @@
1
+ export interface FileCheckpointRegistry {
2
+ snapshotFile(absPath: string): Promise<void>;
3
+ readonly turnId: string;
4
+ }
5
+ export interface FileSnapshot {
6
+ absPath: string;
7
+ snapshotPath: string;
8
+ isNewFile: boolean;
9
+ mode?: number;
10
+ }
11
+ export declare function decodePathKey(key: string): string;
12
+ export declare const NEW_FILE_SENTINEL = "__afk_new_file__\n";
13
+ export declare function createFileCheckpointRegistry(sessionId: string, turnId: string, _stateDir?: string): FileCheckpointRegistry;
14
+ export declare function hasTurnCheckpoint(sessionId: string, turnId: string, _stateDir?: string): boolean;
15
+ export declare function listTurnSnapshots(sessionId: string, turnId: string, _stateDir?: string): FileSnapshot[];
@@ -0,0 +1,11 @@
1
+ import type { ProviderRewindResult } from '../provider.js';
2
+ import type { ToolHandlerContext } from '../tools/types.js';
3
+ export interface RewindFilesDeps {
4
+ sessionId: string;
5
+ enableFileCheckpointing: boolean;
6
+ writePolicy?: ToolHandlerContext;
7
+ _stateDir?: string;
8
+ }
9
+ export declare function rewindFiles(deps: RewindFilesDeps, turnId: string, options?: {
10
+ dryRun?: boolean;
11
+ }): Promise<ProviderRewindResult>;
@@ -0,0 +1,2 @@
1
+ export declare function pinRewindParent(target: string): () => void;
2
+ export declare function stageRewindFile(target: string, content: Buffer, validate: () => void, mode?: number): void;
@@ -0,0 +1,3 @@
1
+ import type { ToolHandlerContext } from '../tools/types.js';
2
+ export declare function validatedWriteTarget(path: string, context: ToolHandlerContext | undefined, cwd?: string): Promise<string>;
3
+ export declare function currentWritePolicy(dispatcher: object | undefined, fallback: ToolHandlerContext): ToolHandlerContext;
@@ -118,6 +118,7 @@ export type ProviderEvent = {
118
118
  sessionId?: string;
119
119
  } | {
120
120
  type: 'turn.completed';
121
+ userMessageId?: string;
121
122
  usage: ProviderUsage;
122
123
  sessionId?: string;
123
124
  } | {
@@ -156,6 +157,7 @@ export type ProviderEvent = {
156
157
  };
157
158
  export interface ProviderUserTurn {
158
159
  content: string | ContentBlockParam[];
160
+ userMessageId?: string;
159
161
  sessionId?: string;
160
162
  }
161
163
  export interface ProviderQueryArgs {
@@ -14,6 +14,8 @@ export interface SessionState {
14
14
  autoCompactThreshold: number | undefined;
15
15
  readonly journalSync: JournalSync<MessageParam>;
16
16
  readonly messageJournal: MessageJournal | undefined;
17
+ enableFileCheckpointing: boolean;
18
+ currentTurnId: string | undefined;
17
19
  }
18
20
  export declare function createSessionState(opts: {
19
21
  model: string;
@@ -25,4 +27,5 @@ export declare function createSessionState(opts: {
25
27
  autoCompactThreshold?: number;
26
28
  initialUsageInputTokens?: number;
27
29
  messageJournal?: MessageJournal;
30
+ enableFileCheckpointing?: boolean;
28
31
  }): SessionState;
@@ -46,5 +46,6 @@ export interface AnthropicDirectQueryOptions {
46
46
  throttleQueue?: import('./throttle-queue.js').ThrottleQueue;
47
47
  fastModeController?: import('../../fast-mode.js').FastModeController;
48
48
  beforeNextRound?: () => string | undefined;
49
+ enableFileCheckpointing?: boolean;
49
50
  }
50
51
  export declare function starterModels(): ProviderModelInfo[];
@@ -57,7 +57,7 @@ export declare class AnthropicDirectQuery implements ProviderQuery {
57
57
  oldAccountId: string;
58
58
  swapped: boolean;
59
59
  } | null>;
60
- rewindFiles(_userMessageId: string, _options?: {
60
+ rewindFiles(userMessageId: string, options?: {
61
61
  dryRun?: boolean;
62
62
  }): Promise<ProviderRewindResult>;
63
63
  compact(): Promise<ProviderCompactResult>;
@@ -56,6 +56,7 @@ export declare class OpenAICompatibleQuery implements ProviderQuery, TurnDriverC
56
56
  get closed(): boolean;
57
57
  lastUsage: ProviderUsage | null;
58
58
  private readonly autoCompactThreshold;
59
+ private readonly checkpoint;
59
60
  constructor(opts: OpenAICompatibleQueryOptions);
60
61
  activeOpenAITools(): OpenAIFunctionTool[] | undefined;
61
62
  [Symbol.asyncIterator](): AsyncIterator<ProviderEvent>;
@@ -81,7 +82,7 @@ export declare class OpenAICompatibleQuery implements ProviderQuery, TurnDriverC
81
82
  getContextUsage(): Promise<ProviderContextUsage>;
82
83
  mcpServerStatus(): Promise<ProviderMcpServerStatus[]>;
83
84
  accountInfo(): Promise<ProviderAccountInfo>;
84
- rewindFiles(_userMessageId: string, _options?: {
85
+ rewindFiles(userMessageId: string, options?: {
85
86
  dryRun?: boolean;
86
87
  }): Promise<ProviderRewindResult>;
87
88
  journalSnapshot(): ReturnType<OpenAIJournalWiring['snapshot']>;
@@ -0,0 +1,14 @@
1
+ import type { ToolHandlerContext } from '../../tools/types.js';
2
+ import type { ProviderEvent, ProviderRewindResult } from '../../provider.js';
3
+ export declare class FileCheckpointState {
4
+ private readonly enabled;
5
+ private readonly sessionId;
6
+ private currentTurnId;
7
+ constructor(enabled: boolean, sessionId: string);
8
+ begin(dispatcher: object | undefined, userMessageId?: string): string | undefined;
9
+ end(dispatcher: object | undefined): void;
10
+ events(events: AsyncIterable<ProviderEvent>, dispatcher: object | undefined, checkpointId: string | undefined): AsyncGenerator<ProviderEvent>;
11
+ rewind(userMessageId: string, options?: {
12
+ dryRun?: boolean;
13
+ }, writePolicy?: ToolHandlerContext): Promise<ProviderRewindResult>;
14
+ }
@@ -0,0 +1,2 @@
1
+ import type { ProviderQuery } from '../../provider.js';
2
+ export declare function chainProviderClose<Q extends ProviderQuery>(query: Q, closeProvider: () => void): Q;
@@ -20,5 +20,5 @@ export declare function parsePersistedOutput(content: string): {
20
20
  sizeBytes: number;
21
21
  absolutePath: string;
22
22
  } | null;
23
- export declare function usageToMetadata(usage: ProviderUsage, sessionId: string | undefined): ResponseMetadata;
23
+ export declare function usageToMetadata(usage: ProviderUsage, sessionId: string | undefined, userMessageId?: string): ResponseMetadata;
24
24
  export declare function transformProviderEvent(event: ProviderEvent, deps: TransformDeps): OutputEvent | null;
@@ -1,11 +1,17 @@
1
1
  import type { AgentRegistry } from '../agents/index.js';
2
2
  import type { CanUseTool } from '../types.js';
3
+ export { COMPOSE_LEAF_STRIPPED_TOOLS } from './nesting.js';
4
+ export declare const COMPOSE_LEAF_NOTICE: string;
3
5
  export interface ResolvedComposeAgent {
4
6
  replaySafe?: boolean;
5
7
  systemPrompt?: string;
8
+ leafNotice?: string;
6
9
  namedAgentModel?: string;
7
10
  canUseTool?: CanUseTool;
11
+ namedAgentAllowedTools?: string[];
8
12
  readOnlyBash?: true;
9
13
  }
10
14
  export declare function buildAllowlistCanUseTool(allowed: string[]): CanUseTool;
11
15
  export declare function resolveComposeNodeAgent(agentType: string | undefined, agentRegistry: AgentRegistry | undefined): ResolvedComposeAgent;
16
+ export declare function resolveComposeAgentPrompt(agent: ResolvedComposeAgent, basePrompt: string): string;
17
+ export declare function resolvedAgentToolRestriction(agent: ResolvedComposeAgent): Pick<ResolvedComposeAgent, 'canUseTool' | 'namedAgentAllowedTools'> | Record<string, never>;
@@ -4,6 +4,7 @@ import type { CanUseTool } from '../types.js';
4
4
  import type { AgentModelInput } from '../types/model-types.js';
5
5
  export interface ComposeNodeRestrictions {
6
6
  canUseTool?: CanUseTool;
7
+ namedAgentAllowedTools?: string[];
7
8
  readOnlyBash?: true;
8
9
  }
9
10
  export declare function resolveComposeNodeProvider(nodeModel: AgentModelInput, workspaceStore: WorkspaceStore | undefined, openaiBaseUrl: string | undefined, restrictions?: ComposeNodeRestrictions): {
@@ -16,6 +16,7 @@ import type { TraceSink } from '../trace/index.js';
16
16
  import { type UserAttention } from './user-yield.js';
17
17
  import { type DetachableToolRegistry } from './detach-bash.js';
18
18
  import type { ProcessJobRegistry } from '../shell-jobs/process-jobs.js';
19
+ import { FileCheckpointWiring } from './dispatcher.file-checkpoint.js';
19
20
  export { defaultConcurrencyClassifier } from './dispatch-batching.js';
20
21
  export declare const REPEAT_CIRCUIT_BREAKER_THRESHOLD = 8;
21
22
  export { DEFAULT_MAX_CONCURRENT_SAFE_TOOL_CALLS, resolveMaxConcurrentSafeToolCalls };
@@ -79,6 +80,7 @@ export declare class SessionToolDispatcher implements ToolDispatcher {
79
80
  private readonly userAttention;
80
81
  private readonly detachRegistry;
81
82
  private readonly processJobs;
83
+ readonly fileCheckpointWiring: FileCheckpointWiring;
82
84
  private readonly bashOutputTailReporter;
83
85
  private readonly gateState;
84
86
  private readonly repeatFailureGuard;
@@ -0,0 +1,9 @@
1
+ import type { FileCheckpointRegistry } from '../file-checkpoint/file-checkpoint.js';
2
+ export type { FileCheckpointRegistry };
3
+ export declare class FileCheckpointWiring {
4
+ private _registry;
5
+ set(registry: FileCheckpointRegistry | undefined): void;
6
+ contextSpread(): {
7
+ fileCheckpoint: FileCheckpointRegistry;
8
+ } | Record<never, never>;
9
+ }
@@ -35,10 +35,12 @@ export interface CreateChildProviderFactoryOptions {
35
35
  }
36
36
  export declare function createChildProviderFactory(opts?: CreateChildProviderFactoryOptions): (args: ChildProviderFactoryArgs) => ModelProvider;
37
37
  export declare function buildReadOnlyReconProvider(model: AgentModelInput | undefined, openaiBaseUrl?: string, allowedTools?: readonly string[]): ModelProvider;
38
+ export declare const COMPOSE_LEAF_STRIPPED_TOOLS: ReadonlySet<string>;
38
39
  export interface BuildComposeNodeProviderOpts {
39
40
  openaiBaseUrl?: string;
40
41
  readOnlyBash?: true;
41
42
  canUseTool?: CanUseTool;
43
+ namedAgentAllowedTools?: string[];
42
44
  }
43
45
  export declare function buildComposeNodeProvider(model: AgentModelInput | undefined, workspaceStore: WorkspaceStore | undefined, opts?: BuildComposeNodeProviderOpts): ModelProvider;
44
46
  export declare function createChildSkillExecutorFactory(defaultModel: AgentModelInput, apiKey: string | undefined, childProviderFactory: (args: ChildProviderFactoryArgs) => ModelProvider, baseUrl?: string, traceWriter?: TraceSink, backgroundRegistry?: BackgroundAgentRegistry, cwd?: string, resolveApiKeyForModel?: (model: string) => string | undefined, surface?: Surface, defaultSubagentModel?: AgentModelInput, agentRegistry?: AgentRegistry, openaiBaseUrl?: string, xaiBaseUrl?: string, workspaceStore?: WorkspaceStore, delegationBudget?: import('./delegation-budget.js').DelegationBudget, pluginConfigs?: SdkPluginConfig[], skillAllowlist?: readonly string[], hookRegistry?: HookRegistry): (depth: number, maxDepth: number, signal: AbortSignal, inheritedCwd?: string, inheritedReadScope?: ReadScopeInputs, skillDispatchName?: string, journalParent?: JournalParent, rootSessionId?: string) => SkillExecutor;
@@ -8,6 +8,7 @@ import type { SpawnedPidRegistry } from './handlers/pid-registry.js';
8
8
  import type { UserAttention } from './user-yield.js';
9
9
  import type { DetachableToolRegistry } from './detach-registry.js';
10
10
  import type { ProcessJobRegistry } from '../shell-jobs/process-jobs.js';
11
+ import type { FileCheckpointRegistry } from '../file-checkpoint/file-checkpoint.js';
11
12
  export interface ToolHandlerContext {
12
13
  resolveBase?: string;
13
14
  cwd?: string;
@@ -23,6 +24,7 @@ export interface ToolHandlerContext {
23
24
  userAttention?: UserAttention;
24
25
  detachRegistry?: DetachableToolRegistry;
25
26
  processJobs?: ProcessJobRegistry;
27
+ fileCheckpoint?: FileCheckpointRegistry;
26
28
  }
27
29
  export type ToolHandler = (input: unknown, signal: AbortSignal, context?: ToolHandlerContext) => Promise<ToolResult>;
28
30
  export type ConcurrencyClassifier = (toolName: string, input?: unknown) => boolean;
@@ -2,6 +2,7 @@ import type { DiffPayload } from '../../utils/diff.js';
2
2
  import type { ToolFailureClass } from '../trace/types.js';
3
3
  export type MessageRole = 'user' | 'assistant';
4
4
  export interface ResponseMetadata extends Record<string, unknown> {
5
+ userMessageId?: string;
5
6
  sessionId?: string;
6
7
  stopReason?: string | null;
7
8
  resultSubtype?: string;
@@ -0,0 +1,4 @@
1
+ import type { Command } from 'commander';
2
+ export declare function needsCredentialGate(command: Command): boolean;
3
+ export declare function runFirstRunDetector(command: Command): Promise<void>;
4
+ export declare function installCredentialGate(program: Command): void;
@@ -1,4 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  export { parseThinking, parseEffort, parseBudget, parseMaxOutputTokens, getMaxBudgetUsd, getTaskBudget, getMaxOutputTokens, } from './shared-helpers.js';
3
- export declare function needsCredentialGate(argv: string[]): boolean;
4
- export declare function runFirstRunDetector(argv?: string[]): Promise<void>;
3
+ export { needsCredentialGate, runFirstRunDetector } from './first-run.js';
@@ -0,0 +1,7 @@
1
+ import { type BundledProviderName } from '../agent/providers/index.js';
2
+ export interface CliProviderContext {
3
+ model?: string;
4
+ openaiBaseUrl?: string;
5
+ }
6
+ export declare function selectCliProvider(raw: string | undefined, opts?: CliProviderContext): string | undefined;
7
+ export declare function cliProviderFamily(raw: string | undefined, opts?: CliProviderContext): BundledProviderName;