agent-afk 5.281.0 → 5.282.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.
@@ -0,0 +1,26 @@
1
+ import type { DetachableToolRegistry, DetachToken, DetachedToolResult } from './detach-registry.js';
2
+ export declare function bashDetachLabel(command: string): string;
3
+ export declare function buildBashDelivery(toolUseId: string, label: string, output: string, closeCode: number | null, closeSignal: string | null, startedAt: number): DetachedToolResult;
4
+ export declare function applyBashDetach(registry: DetachableToolRegistry, toolUseId: string, command: string, onDetach: (token: DetachToken, label: string) => void): DetachToken;
5
+ export interface OnDetachParams {
6
+ resolvedRef: {
7
+ value: boolean;
8
+ };
9
+ timeoutHandle: ReturnType<typeof setTimeout>;
10
+ signal: AbortSignal;
11
+ abortHandler: () => void;
12
+ deregisterOnCloseRef: {
13
+ value: (() => void) | undefined;
14
+ };
15
+ clearTail: (() => void) | undefined;
16
+ getOutput: () => string;
17
+ proc: import('child_process').ChildProcess;
18
+ startedAt: number;
19
+ resolve: (result: {
20
+ content: string;
21
+ }) => void;
22
+ }
23
+ export declare function execOnDetach(token: DetachToken, label: string, toolUseId: string, p: OnDetachParams): void;
24
+ export declare const DETACHABLE_TOOLS: ReadonlySet<string>;
25
+ export declare function isDetachableTool(name: string): boolean;
26
+ export type { DetachableToolRegistry };
@@ -0,0 +1,28 @@
1
+ import { EventEmitter } from 'node:events';
2
+ export interface DetachedToolResult {
3
+ readonly toolUseId: string;
4
+ readonly label: string;
5
+ readonly status: 'completed' | 'failed';
6
+ readonly output: string;
7
+ readonly exitCode?: number;
8
+ readonly durationMs: number;
9
+ }
10
+ export interface DetachToken {
11
+ readonly toolUseId: string;
12
+ readonly detachSignal: AbortSignal;
13
+ shouldDetach(): boolean;
14
+ detachResult(label: string): {
15
+ content: string;
16
+ };
17
+ notifyDetached(): void;
18
+ deliver(result: DetachedToolResult): void;
19
+ }
20
+ export declare class DetachableToolRegistry extends EventEmitter {
21
+ private readonly tokens;
22
+ register(toolUseId: string): DetachToken;
23
+ hasDetachable(): boolean;
24
+ deregister(toolUseId: string): void;
25
+ detachAll(): void;
26
+ cancelAll(): void;
27
+ listRunning(): string[];
28
+ }
@@ -14,6 +14,7 @@ import type { CanUseTool } from '../types/sdk-types.js';
14
14
  import { type GrantSnapshot, type GrantManager } from './grant-manager.js';
15
15
  import type { TraceSink } from '../trace/index.js';
16
16
  import { type UserAttention } from './user-yield.js';
17
+ import { type DetachableToolRegistry } from './detach-bash.js';
17
18
  export { defaultConcurrencyClassifier } from './dispatch-batching.js';
18
19
  export declare const REPEAT_CIRCUIT_BREAKER_THRESHOLD = 8;
19
20
  export { DEFAULT_MAX_CONCURRENT_SAFE_TOOL_CALLS, resolveMaxConcurrentSafeToolCalls };
@@ -43,6 +44,7 @@ export interface SessionToolDispatcherOptions {
43
44
  spawnedPidRegistry?: SpawnedPidRegistry;
44
45
  userAttention?: UserAttention;
45
46
  bashOutputTailReporter?: (toolUseId: string) => (tail: string | undefined) => void;
47
+ detachRegistry?: DetachableToolRegistry;
46
48
  }
47
49
  export declare class SessionToolDispatcher implements ToolDispatcher {
48
50
  private readonly handlers;
@@ -69,6 +71,7 @@ export declare class SessionToolDispatcher implements ToolDispatcher {
69
71
  private readonly maxOutputBytes;
70
72
  private readonly spawnedPidRegistry;
71
73
  private readonly userAttention;
74
+ private readonly detachRegistry;
72
75
  private readonly bashOutputTailReporter;
73
76
  private readonly gateState;
74
77
  private readonly repeatFailureGuard;
@@ -6,6 +6,7 @@ import type { ToolResult } from '../providers/shared/tool-result.js';
6
6
  import type { TraceSink } from '../trace/index.js';
7
7
  import type { SpawnedPidRegistry } from './handlers/pid-registry.js';
8
8
  import type { UserAttention } from './user-yield.js';
9
+ import type { DetachableToolRegistry } from './detach-registry.js';
9
10
  export interface ToolHandlerContext {
10
11
  cwd?: string;
11
12
  resolveBase?: string;
@@ -19,6 +20,7 @@ export interface ToolHandlerContext {
19
20
  spawnedPidRegistry?: SpawnedPidRegistry;
20
21
  onBashOutputTail?: (tail: string | undefined) => void;
21
22
  userAttention?: UserAttention;
23
+ detachRegistry?: DetachableToolRegistry;
22
24
  }
23
25
  export type ToolHandler = (input: unknown, signal: AbortSignal, context?: ToolHandlerContext) => Promise<ToolResult>;
24
26
  export type ConcurrencyClassifier = (toolName: string, input?: unknown) => boolean;
@@ -8,6 +8,7 @@ import type { AgentModelInput } from '../../../agent/types.js';
8
8
  import type { BackgroundAgentRegistry } from '../../../agent/background-registry.js';
9
9
  import type { BackgroundSummarizer } from '../../../agent/background-summarizer.js';
10
10
  import type { SubagentControl } from '../../../agent/tools/subagent-executor.js';
11
+ import type { DetachableToolRegistry } from '../../../agent/tools/detach-registry.js';
11
12
  import type { SubagentManager } from '../../../agent/subagent.js';
12
13
  import type { SlashContext, SessionStats, ResumeSwapResult, ThinkingUiMode } from '../../slash/types.js';
13
14
  import type { StoredSession } from '../../session-store.js';
@@ -117,6 +118,7 @@ export interface TurnHandles {
117
118
  getCompositor?(): import('../../terminal-compositor.js').TerminalCompositor | null;
118
119
  setBackgroundHandler?(handler: (() => void) | null): void;
119
120
  subagentControl?: SubagentControl;
121
+ detachRegistry?: DetachableToolRegistry;
120
122
  setSoftStopHandler?(handler: (() => void) | null): void;
121
123
  setTaskViewHandler?(handler: (() => boolean) | null): void;
122
124
  setPausedState?(paused: boolean): void;