agent-afk 5.177.2 → 5.181.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.
Files changed (32) hide show
  1. package/dist/agent/daemon/handoff-store.d.ts +27 -0
  2. package/dist/agent/daemon/task-lifecycle.d.ts +1 -1
  3. package/dist/agent/effect-ledger/classifier.d.ts +5 -0
  4. package/dist/agent/effect-ledger/hook.d.ts +4 -0
  5. package/dist/agent/effect-ledger/idempotency.d.ts +1 -0
  6. package/dist/agent/effect-ledger/index.d.ts +6 -0
  7. package/dist/agent/effect-ledger/store.d.ts +13 -0
  8. package/dist/agent/effect-ledger/types.d.ts +32 -0
  9. package/dist/agent/facets/schema.d.ts +9 -9
  10. package/dist/agent/hooks.d.ts +1 -0
  11. package/dist/agent/mcp/client.d.ts +3 -1
  12. package/dist/agent/provider.d.ts +5 -0
  13. package/dist/agent/providers/anthropic-direct/types.d.ts +1 -1
  14. package/dist/agent/providers/shared/event-relay.d.ts +1 -0
  15. package/dist/agent/providers/shared/tool-activity.d.ts +1 -0
  16. package/dist/agent/tools/dispatcher.batch-process.d.ts +1 -0
  17. package/dist/agent/tools/dispatcher.d.ts +2 -1
  18. package/dist/agent/tools/handlers/index.d.ts +2 -1
  19. package/dist/agent/tools/handlers/json-query.d.ts +3 -0
  20. package/dist/agent/tools/schemas.d.ts +1 -0
  21. package/dist/agent/tools/schemas.json-query.d.ts +2 -0
  22. package/dist/agent/types/session-types.d.ts +4 -0
  23. package/dist/cli/commands/interactive/tool-lane-format.d.ts +4 -0
  24. package/dist/cli/commands/interactive/tool-lane.d.ts +2 -0
  25. package/dist/cli/display.d.ts +1 -0
  26. package/dist/cli/terminal-compositor.d.ts +1 -0
  27. package/dist/cli/terminal-compositor.lifecycle.d.ts +3 -0
  28. package/dist/cli.mjs +668 -663
  29. package/dist/index.mjs +241 -240
  30. package/dist/paths.d.ts +2 -0
  31. package/dist/telegram.mjs +308 -305
  32. package/package.json +1 -1
@@ -0,0 +1,27 @@
1
+ export type HandoffRequestType = 'ask_question' | 'mcp' | 'path_approval';
2
+ export interface HandoffRoute {
3
+ chatId: number;
4
+ threadId?: number;
5
+ }
6
+ export interface UpdateHandoffResult {
7
+ won: boolean;
8
+ }
9
+ export interface HandoffRecord {
10
+ taskId: string;
11
+ sessionId: string;
12
+ question: Record<string, unknown>;
13
+ requestType: HandoffRequestType;
14
+ route?: HandoffRoute;
15
+ elicitId?: string;
16
+ createdAt: string;
17
+ status: 'pending' | 'answered' | 'expired' | 'cancelled';
18
+ answer?: unknown;
19
+ answeredAt?: string;
20
+ answerSource?: string;
21
+ originalCommand: string;
22
+ }
23
+ export declare function writeHandoff(record: HandoffRecord, handoffsDir?: string): Promise<void>;
24
+ export declare function readHandoff(taskId: string, handoffsDir?: string): Promise<HandoffRecord | null>;
25
+ export declare function deleteHandoff(taskId: string, handoffsDir?: string): Promise<void>;
26
+ export declare function listPendingHandoffs(handoffsDir?: string): Promise<HandoffRecord[]>;
27
+ export declare function updateHandoffAnswer(taskId: string, answer: unknown, source: string, handoffsDir?: string): Promise<UpdateHandoffResult>;
@@ -1,4 +1,4 @@
1
- export type TaskState = 'queued' | 'leased' | 'running' | 'succeeded' | 'failed' | 'retrying' | 'dead-letter';
1
+ export type TaskState = 'queued' | 'leased' | 'running' | 'waiting_human_input' | 'succeeded' | 'failed' | 'retrying' | 'dead-letter';
2
2
  export interface TaskRecord {
3
3
  id: string;
4
4
  command: string;
@@ -0,0 +1,5 @@
1
+ export interface Classification {
2
+ isExternal: boolean;
3
+ operationType: string;
4
+ }
5
+ export declare function classifyToolCall(toolName: string, input: unknown): Classification;
@@ -0,0 +1,4 @@
1
+ import { EffectStore } from './store.js';
2
+ import type { HookHandler } from '../hooks.js';
3
+ export declare function createEffectLedgerPostHook(store?: EffectStore): HookHandler;
4
+ export declare function createEffectLedgerPreHook(pendingIds: Map<string, string>, store?: EffectStore): HookHandler;
@@ -0,0 +1 @@
1
+ export declare function computeIdempotencyKey(operationType: string, args: unknown): string;
@@ -0,0 +1,6 @@
1
+ export { EffectStore } from './store.js';
2
+ export { classifyToolCall } from './classifier.js';
3
+ export { computeIdempotencyKey } from './idempotency.js';
4
+ export { createEffectLedgerPostHook, createEffectLedgerPreHook } from './hook.js';
5
+ export type { EffectRecord, EffectStatus, EffectQuery, PendingEffectInput, ExecuteEffectInput, } from './types.js';
6
+ export type { Classification } from './classifier.js';
@@ -0,0 +1,13 @@
1
+ import type { EffectRecord, EffectQuery, PendingEffectInput, ExecuteEffectInput } from './types.js';
2
+ export declare class EffectStore {
3
+ private readonly path;
4
+ private cachedRecords;
5
+ constructor(path?: string);
6
+ private readCached;
7
+ private invalidateCache;
8
+ writePending(input: PendingEffectInput): EffectRecord;
9
+ updateStatus(input: ExecuteEffectInput): Promise<EffectRecord>;
10
+ findByIdempotencyKey(key: string, sessionId?: string): Promise<EffectRecord | null>;
11
+ query(filters?: EffectQuery): Promise<EffectRecord[]>;
12
+ all(): Promise<EffectRecord[]>;
13
+ }
@@ -0,0 +1,32 @@
1
+ export type EffectStatus = 'pending' | 'executed' | 'confirmed' | 'failed' | 'ambiguous';
2
+ export interface EffectRecord {
3
+ v: 1;
4
+ id: string;
5
+ idempotencyKey: string;
6
+ operationType: string;
7
+ args: unknown;
8
+ status: EffectStatus;
9
+ sessionId?: string;
10
+ taskId?: string;
11
+ timestamp: number;
12
+ result?: unknown;
13
+ reconciledAt?: number;
14
+ }
15
+ export interface EffectQuery {
16
+ sessionId?: string;
17
+ operationType?: string;
18
+ status?: EffectStatus;
19
+ idempotencyKey?: string;
20
+ }
21
+ export interface PendingEffectInput {
22
+ idempotencyKey: string;
23
+ operationType: string;
24
+ args: unknown;
25
+ sessionId?: string;
26
+ taskId?: string;
27
+ }
28
+ export interface ExecuteEffectInput {
29
+ id: string;
30
+ status: Exclude<EffectStatus, 'pending'>;
31
+ result?: unknown;
32
+ }
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- export declare const FACET_VERSION = 2;
2
+ export declare const FACET_VERSION = 3;
3
3
  export declare const ToolEventInputSchema: z.ZodObject<{
4
4
  toolName: z.ZodString;
5
5
  toolUseId: z.ZodOptional<z.ZodString>;
@@ -79,10 +79,10 @@ export declare const WorldChangesSchema: z.ZodObject<{
79
79
  mutated: z.ZodBoolean;
80
80
  }, z.core.$strip>;
81
81
  export declare const TokenBreakdownSchema: z.ZodObject<{
82
- input: z.ZodNumber;
83
- output: z.ZodNumber;
84
- cache_read: z.ZodNumber;
85
- cache_creation: z.ZodNumber;
82
+ input: z.ZodOptional<z.ZodNumber>;
83
+ output: z.ZodOptional<z.ZodNumber>;
84
+ cache_read: z.ZodOptional<z.ZodNumber>;
85
+ cache_creation: z.ZodOptional<z.ZodNumber>;
86
86
  cost_usd: z.ZodNumber;
87
87
  }, z.core.$strip>;
88
88
  export type TokenBreakdown = z.infer<typeof TokenBreakdownSchema>;
@@ -142,10 +142,10 @@ export declare const SessionFacetSchema: z.ZodObject<{
142
142
  mutated: z.ZodBoolean;
143
143
  }, z.core.$strip>;
144
144
  token_breakdown: z.ZodOptional<z.ZodObject<{
145
- input: z.ZodNumber;
146
- output: z.ZodNumber;
147
- cache_read: z.ZodNumber;
148
- cache_creation: z.ZodNumber;
145
+ input: z.ZodOptional<z.ZodNumber>;
146
+ output: z.ZodOptional<z.ZodNumber>;
147
+ cache_read: z.ZodOptional<z.ZodNumber>;
148
+ cache_creation: z.ZodOptional<z.ZodNumber>;
149
149
  cost_usd: z.ZodNumber;
150
150
  }, z.core.$strip>>;
151
151
  decisions: z.ZodArray<z.ZodString>;
@@ -54,6 +54,7 @@ export interface PostToolUseContext {
54
54
  toolName: string;
55
55
  input?: unknown;
56
56
  output?: unknown;
57
+ isError?: boolean;
57
58
  grantManager?: GrantManager;
58
59
  incomplete?: boolean;
59
60
  incompleteReason?: string;
@@ -1,4 +1,4 @@
1
- import { type Tool as McpTool } from '@modelcontextprotocol/sdk/types.js';
1
+ import { type CallToolResult, type Tool as McpTool } from '@modelcontextprotocol/sdk/types.js';
2
2
  import { UnauthorizedError } from '@modelcontextprotocol/sdk/client/auth.js';
3
3
  import type { ToolResult } from '../tools/types.js';
4
4
  import type { McpServerConfig } from './types.js';
@@ -25,4 +25,6 @@ export declare class McpClient {
25
25
  finishAuth(authorizationCode: string): Promise<void>;
26
26
  disconnect(): Promise<void>;
27
27
  }
28
+ declare function normalizeCallToolResult(result: CallToolResult): ToolResult;
28
29
  export { UnauthorizedError };
30
+ export { normalizeCallToolResult };
@@ -100,6 +100,11 @@ export type ProviderEvent = {
100
100
  incomplete?: boolean;
101
101
  incompleteReason?: string;
102
102
  failureClass?: ToolFailureClass;
103
+ } | {
104
+ type: 'tool.activity';
105
+ activeCount: number;
106
+ activeToolUseIds: string[];
107
+ sessionId?: string;
103
108
  } | {
104
109
  type: 'tool.diff';
105
110
  toolUseId: string;
@@ -46,7 +46,7 @@ export interface AnthropicToolDef {
46
46
  }
47
47
  export interface ToolDispatcherLike {
48
48
  execute(call: ToolCall): Promise<ToolResult>;
49
- executeBatch?(calls: ToolCall[]): Promise<ToolResult[]>;
49
+ executeBatch?(calls: ToolCall[], onActivity?: (activeIds: readonly string[]) => void): Promise<ToolResult[]>;
50
50
  setResolveBase?(cwd: string): void;
51
51
  setAllowAll?(allow: boolean): void;
52
52
  }
@@ -0,0 +1 @@
1
+ export declare function relayWhilePending<E, R>(start: (emit: (event: E) => void) => Promise<R>): AsyncGenerator<E, R, void>;
@@ -0,0 +1 @@
1
+ export type ToolActivityReporter = (activeIds: readonly string[]) => void;
@@ -13,6 +13,7 @@ export interface BatchExecDeps {
13
13
  subagentExecutor: SubagentExecutor | undefined;
14
14
  sessionId: string | undefined;
15
15
  maxConcurrentSafeCalls: number;
16
+ onActivity?: (activeIds: readonly string[]) => void;
16
17
  }
17
18
  export declare function reconcileOutcomes(settled: PromiseSettledResult<{
18
19
  result: ToolResult;
@@ -7,6 +7,7 @@ import type { SubagentExecutor } from './subagent-executor.js';
7
7
  import type { SkillExecutor } from './skill-executor.js';
8
8
  import type { ComposeExecutor } from './compose-executor.js';
9
9
  import type { ToolHandler, ConcurrencyClassifier } from './types.js';
10
+ import type { ToolActivityReporter } from '../providers/shared/tool-activity.js';
10
11
  import type { SpawnedPidRegistry } from './handlers/pid-registry.js';
11
12
  import { type ToolPermissionConfig } from './permissions.js';
12
13
  import type { CanUseTool } from '../types/sdk-types.js';
@@ -93,7 +94,7 @@ export declare class SessionToolDispatcher implements ToolDispatcher {
93
94
  private runCanUseTool;
94
95
  private runPreDispatchGates;
95
96
  execute(call: ToolCall): Promise<ToolResult>;
96
- executeBatch(calls: ToolCall[]): Promise<ToolResult[]>;
97
+ executeBatch(calls: ToolCall[], onActivity?: ToolActivityReporter): Promise<ToolResult[]>;
97
98
  private executeCore;
98
99
  private applyOutputCap;
99
100
  private executeCoreInner;
@@ -24,5 +24,6 @@ import { waitForHandler } from './wait-for.js';
24
24
  import { patchApplyHandler } from './patch-apply.js';
25
25
  import { testRunHandler } from './test-run.js';
26
26
  import { getFacetHandler } from './get-facet.js';
27
+ import { jsonQueryHandler, createJsonQueryHandler } from './json-query.js';
27
28
  export declare function createBuiltinHandlers(permissionMode?: string, cwd?: string): Map<string, ToolHandler>;
28
- export { bashHandler, readFileHandler, extractDocumentHandler, writeFileHandler, editFileHandler, globHandler, grepHandler, listDirectoryHandler, sendTelegramHandler, webScrapeHandler, webRequestHandler, createScheduleHandler, listSchedulesHandler, getScheduleHistoryHandler, cancelScheduleHandler, terminalFontSizeHandler, createWorktreeHandler, configGetHandler, configSetHandler, askQuestionHandler, waitForHandler, patchApplyHandler, browserOpenHandler, browserObserveHandler, browserActHandler, browserScreenshotHandler, browserCloseHandler, testRunHandler, getFacetHandler, };
29
+ export { bashHandler, readFileHandler, extractDocumentHandler, writeFileHandler, editFileHandler, globHandler, grepHandler, listDirectoryHandler, sendTelegramHandler, webScrapeHandler, webRequestHandler, createScheduleHandler, listSchedulesHandler, getScheduleHistoryHandler, cancelScheduleHandler, terminalFontSizeHandler, createWorktreeHandler, configGetHandler, configSetHandler, askQuestionHandler, waitForHandler, patchApplyHandler, browserOpenHandler, browserObserveHandler, browserActHandler, browserScreenshotHandler, browserCloseHandler, testRunHandler, getFacetHandler, jsonQueryHandler, createJsonQueryHandler, };
@@ -0,0 +1,3 @@
1
+ import type { ToolHandler } from '../types.js';
2
+ export declare function createJsonQueryHandler(cwd?: string): ToolHandler;
3
+ export declare const jsonQueryHandler: ToolHandler;
@@ -1,5 +1,6 @@
1
1
  import type { AnthropicToolDef } from './types.js';
2
2
  export { waitForTool } from './schemas.wait-for.js';
3
+ export { jsonQueryTool } from './schemas.json-query.js';
3
4
  export declare const bashTool: AnthropicToolDef;
4
5
  export declare const readFileTool: AnthropicToolDef;
5
6
  export declare const extractDocumentTool: AnthropicToolDef;
@@ -0,0 +1,2 @@
1
+ import type { AnthropicToolDef } from './types.js';
2
+ export declare const jsonQueryTool: AnthropicToolDef;
@@ -72,6 +72,10 @@ export type OutputEvent = {
72
72
  type: 'notice';
73
73
  text: string;
74
74
  kind: 'truncation' | 'refusal';
75
+ } | {
76
+ type: 'tool-activity';
77
+ activeCount: number;
78
+ activeToolUseIds: string[];
75
79
  } | {
76
80
  type: 'paused';
77
81
  reason: 'usage-limit';
@@ -12,4 +12,8 @@ export declare const GROUP_THRESHOLD_LEAF = 3;
12
12
  export declare function inProgressVerb(toolName: string): string;
13
13
  export declare function formatOutcome(chunk: ToolResultChunk, homeDir?: string, maxPreview?: number, toolName?: string): string;
14
14
  export declare function batchBadge(chunk: ToolResultChunk | undefined): string;
15
+ export declare function activeToolBadge(toolUseId: string, activeTools: {
16
+ activeCount: number;
17
+ toolUseIds: Set<string>;
18
+ } | null): string;
15
19
  export declare function formatToolResultLine(chunk: ToolResultChunk, toolPrefix?: string, homeDir?: string, toolName?: string): string;
@@ -9,6 +9,7 @@ export declare class ToolLane {
9
9
  private order;
10
10
  private agentIdStack;
11
11
  private lastElapsedSecond;
12
+ private activeTools;
12
13
  addStart(toolUseId: string, toolName: string, toolInput: string): void;
13
14
  addStartWithAgentContext(toolUseId: string, toolName: string, toolInput: string, agentContext: string | undefined, maxWidth?: number): void;
14
15
  mergeAgentLabel(parentToolUseId: string, label: string, maxWidth?: number): boolean;
@@ -16,6 +17,7 @@ export declare class ToolLane {
16
17
  setAgentResultSummary(toolUseId: string, summary: string): void;
17
18
  setThinkingTail(toolUseId: string, tail: string | undefined): void;
18
19
  addResult(toolUseId: string, chunk: ToolResultChunk): void;
20
+ notifyToolActivity(activeCount: number, activeToolUseIds: string[]): void;
19
21
  addDiff(toolUseId: string, diff: DiffPayload): void;
20
22
  addPreviewDiff(toolUseId: string, diff: DiffPayload): void;
21
23
  upsertTextChild(toolUseId: string, agentContext: string, text: string): void;
@@ -5,6 +5,7 @@ export declare function padDisplayRight(text: string, width: number): string;
5
5
  export declare function padDisplayLeft(text: string, width: number): string;
6
6
  export declare function padDisplay(text: string, width: number, align?: 'left' | 'right' | 'center'): string;
7
7
  export declare function truncateDisplayWidth(text: string, maxWidth: number, ellipsis?: string): string;
8
+ export declare function suffixDisplayWidth(text: string, maxWidth: number, ellipsis?: string): string;
8
9
  export declare function previousGraphemeIndex(text: string, index: number): number;
9
10
  export declare function nextGraphemeIndex(text: string, index: number): number;
10
11
  export interface CursorMetrics {
@@ -105,6 +105,7 @@ export declare class TerminalCompositor {
105
105
  setInputMode(mode: CompositorInputMode): void;
106
106
  getInputMode(): CompositorInputMode;
107
107
  arm(): Promise<void>;
108
+ endTurn(): void;
108
109
  disarm(): void;
109
110
  setOverlay(text: string): void;
110
111
  setSpinner(config: {
@@ -33,10 +33,13 @@ export interface LifecycleHost {
33
33
  readonly committedBand: string[];
34
34
  readonly committedBandMeta: BandRowMeta[];
35
35
  readonly committedBandTopRow: number;
36
+ readonly committedBandBottomRow: number;
36
37
  readonly committedBandPaintedRows: number;
37
38
  bandGeometryStale: boolean;
39
+ clearCommittedBand(): void;
38
40
  }
39
41
  export declare function suspendInput(self: LifecycleHost): void;
40
42
  export declare function resumeInput(self: LifecycleHost): void;
41
43
  export declare function arm(self: LifecycleHost & KeyDispatchHost): Promise<void>;
42
44
  export declare function disarm(self: LifecycleHost): void;
45
+ export declare function endTurnFlush(self: LifecycleHost): void;