agent-afk 5.156.0 → 5.157.1

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.
@@ -20,4 +20,5 @@ export declare function createSessionState(opts: {
20
20
  toolDispatcher: ToolDispatcher;
21
21
  initialMessages?: MessageParam[];
22
22
  autoCompactThreshold?: number;
23
+ initialUsageInputTokens?: number;
23
24
  }): SessionState;
@@ -11,6 +11,7 @@ export interface AnthropicDirectQueryOptions {
11
11
  toolDispatcher: ToolDispatcher;
12
12
  sessionId?: string;
13
13
  initialMessages?: MessageParam[];
14
+ initialUsageInputTokens?: number;
14
15
  model: string;
15
16
  requestedModel?: string;
16
17
  permissionMode?: string;
@@ -27,6 +27,7 @@ export interface WireExecutorsOptions {
27
27
  backgroundRegistry?: BackgroundAgentRegistry;
28
28
  agentRegistryWarn?: (message: string) => void;
29
29
  workspaceStore?: WorkspaceStore;
30
+ sessionLabel?: string;
30
31
  }
31
32
  export interface WiredExecutors {
32
33
  rootManager: SubagentManager;
@@ -0,0 +1,19 @@
1
+ import type { SubagentHandle } from './handle.js';
2
+ import type { SubagentResult } from './result.js';
3
+ export interface CompletedEntry<T = unknown> {
4
+ readonly handle: SubagentHandle<T>;
5
+ readonly result: Pick<SubagentResult, 'id' | 'status'>;
6
+ readonly completedAt: number;
7
+ }
8
+ export declare class CompletedCache {
9
+ private readonly entries;
10
+ private readonly capacity;
11
+ constructor(capacity?: number);
12
+ add(id: string, handle: SubagentHandle, result: Pick<SubagentResult, 'id' | 'status'>): void;
13
+ get(id: string): CompletedEntry | undefined;
14
+ list(): readonly CompletedEntry[];
15
+ get size(): number;
16
+ delete(id: string): boolean;
17
+ clear(): void;
18
+ private evictIfNeeded;
19
+ }
@@ -37,4 +37,5 @@ export interface SubagentManagerOptions {
37
37
  surface?: Surface;
38
38
  onSubagentSucceeded?: (usage: import('./result.js').SubagentTrace['usage'], costUsd: number | undefined) => void;
39
39
  workspaceStore?: WorkspaceStore;
40
+ sessionLabel?: string;
40
41
  }
@@ -3,9 +3,11 @@ import type { ContentBlockParam } from '@anthropic-ai/sdk/resources';
3
3
  import { AbortGraph } from '../abort-graph.js';
4
4
  import type { HookRegistry } from '../hooks.js';
5
5
  import type { IAgentSession, Message } from '../types.js';
6
- import type { OutputEvent, SubagentProgressSink } from '../types/session-types.js';
6
+ import type { OutputEvent, SubagentProgressSink, SubagentProgressMeta } from '../types/session-types.js';
7
7
  import type { TraceSink } from '../trace/index.js';
8
+ import { PauseAwareCeiling } from './pause-ceiling.js';
8
9
  import { type SubagentResult, type SubagentStatus, type SubagentTrace } from './result.js';
10
+ export type { SubagentProgressMeta };
9
11
  export interface SubagentHandle<T = unknown> {
10
12
  readonly id: string;
11
13
  readonly status: SubagentStatus;
@@ -22,35 +24,38 @@ export interface SubagentHandle<T = unknown> {
22
24
  export declare class SubagentHandleImpl<T> implements SubagentHandle<T> {
23
25
  readonly id: string;
24
26
  readonly session: IAgentSession;
25
- private readonly controller;
27
+ readonly _controller: AbortController;
26
28
  private readonly abortGraph;
27
- private readonly outputSchema;
29
+ readonly _outputSchema: ZodType<T> | undefined;
28
30
  private readonly timeoutMs;
29
- private readonly hookRegistry;
30
- private readonly onTerminal;
31
- private readonly parentInputStreamRef?;
32
- private readonly parentAbortSignal?;
33
- private readonly agentType?;
34
- private readonly traceWriter?;
31
+ readonly _hookRegistry: HookRegistry | undefined;
32
+ readonly _onTerminal: () => void;
33
+ readonly _parentInputStreamRef?: ReturnType<IAgentSession["getInputStreamRef"]> | undefined;
34
+ readonly _parentAbortSignal?: AbortSignal | undefined;
35
+ readonly _agentType?: string | undefined;
36
+ readonly _traceWriter?: TraceSink | undefined;
35
37
  private readonly onSubagentSucceeded?;
36
- private readonly idleTimeoutMs;
37
- private currentStatus;
38
+ readonly _idleTimeoutMs: number;
39
+ _currentStatus: SubagentStatus;
38
40
  private inFlight;
39
- private lastMessage;
40
- private lastDurationMs;
41
+ _lastMessage: string | undefined;
42
+ _lastDurationMs: number | undefined;
41
43
  private latestTerminalStatus;
42
- private stopDispatched;
43
- private lastStopInjectContext;
44
- private readonly progressSink;
45
- private parentId;
46
- private currentTrace;
47
- private lastStreamedContent;
48
- private pauseCeiling;
49
- private lastStopReason;
50
- constructor(id: string, session: IAgentSession, controller: AbortController, abortGraph: AbortGraph, outputSchema: ZodType<T> | undefined, timeoutMs: number, hookRegistry: HookRegistry | undefined, onTerminal: () => void, parentInputStreamRef?: ReturnType<IAgentSession["getInputStreamRef"]> | undefined, parentAbortSignal?: AbortSignal | undefined, agentType?: string | undefined, progressSink?: SubagentProgressSink, parentId?: string, traceWriter?: TraceSink | undefined, onSubagentSucceeded?: ((usage: SubagentTrace["usage"], costUsd: number | undefined) => void) | undefined, idleTimeoutMs?: number);
44
+ _stopDispatched: boolean;
45
+ _lastStopInjectContext: string | undefined;
46
+ readonly _progressSink: SubagentProgressSink | undefined;
47
+ _parentId: string | undefined;
48
+ _currentTrace: SubagentTrace;
49
+ _lastStreamedContent: string;
50
+ _pauseCeiling: PauseAwareCeiling | undefined;
51
+ _lastStopReason: string | undefined;
52
+ _logWriter?: {
53
+ write(event: OutputEvent): void;
54
+ close(): Promise<void>;
55
+ };
56
+ constructor(id: string, session: IAgentSession, _controller: AbortController, abortGraph: AbortGraph, _outputSchema: ZodType<T> | undefined, timeoutMs: number, _hookRegistry: HookRegistry | undefined, _onTerminal: () => void, _parentInputStreamRef?: ReturnType<IAgentSession["getInputStreamRef"]> | undefined, _parentAbortSignal?: AbortSignal | undefined, _agentType?: string | undefined, progressSink?: SubagentProgressSink, parentId?: string, _traceWriter?: TraceSink | undefined, onSubagentSucceeded?: ((usage: SubagentTrace["usage"], costUsd: number | undefined) => void) | undefined, _idleTimeoutMs?: number);
51
57
  get status(): SubagentStatus;
52
58
  run(prompt: string | ContentBlockParam[], sinkOverride?: SubagentProgressSink): Promise<Message>;
53
- private streamToFinalMessage;
54
59
  runToResult(prompt: string | ContentBlockParam[], sinkOverride?: SubagentProgressSink): Promise<SubagentResult<T>>;
55
60
  runInBackground(prompt: string, onResult?: (result: SubagentResult<T>) => void, onProgress?: (event: OutputEvent) => void): void;
56
61
  cancel(): Promise<void>;
@@ -58,5 +63,4 @@ export declare class SubagentHandleImpl<T> implements SubagentHandle<T> {
58
63
  deferInjectContextToCaller?: boolean;
59
64
  }): Promise<void>;
60
65
  getLastStopInjectContext(): string | undefined;
61
- private dispatchStopAndRelease;
62
66
  }
@@ -0,0 +1,11 @@
1
+ import type { ContentBlockParam } from '@anthropic-ai/sdk/resources';
2
+ import type { OutputEvent, SubagentProgressSink } from '../types/session-types.js';
3
+ import type { Message } from '../types.js';
4
+ import { type SubagentResult, type SubagentStatus } from './result.js';
5
+ import type { SubagentHandleImpl } from './handle.js';
6
+ export declare function streamToFinalMessage<T>(handle: SubagentHandleImpl<T>, prompt: string | ContentBlockParam[], sinkOverride?: SubagentProgressSink): Promise<Message>;
7
+ export declare function runToResult<T>(handle: SubagentHandleImpl<T>, prompt: string | ContentBlockParam[], sinkOverride?: SubagentProgressSink): Promise<SubagentResult<T>>;
8
+ export declare function runInBackground<T>(handle: SubagentHandleImpl<T>, prompt: string, onResult?: (result: SubagentResult<T>) => void, onProgress?: (event: OutputEvent) => void): void;
9
+ export declare function dispatchStopAndRelease<T>(handle: SubagentHandleImpl<T>, reportedStatus: SubagentStatus, options?: {
10
+ deferInjectContextToCaller?: boolean;
11
+ }): Promise<void>;
@@ -0,0 +1,24 @@
1
+ import type { OutputEvent } from '../types/session-types.js';
2
+ export declare class SubagentLogWriter {
3
+ readonly sessionLabel: string;
4
+ readonly subagentId: string;
5
+ readonly logPath: string;
6
+ private stream;
7
+ private errored;
8
+ private closed;
9
+ private streamReady;
10
+ private pendingLines;
11
+ private readyPromise;
12
+ private readyResolve;
13
+ private bytesWritten;
14
+ constructor(sessionLabel: string, subagentId: string);
15
+ static isEnabled(): boolean;
16
+ write(event: OutputEvent): void;
17
+ close(): Promise<void>;
18
+ private openStream;
19
+ private writeLine;
20
+ }
21
+ export declare class SubagentLogReader {
22
+ static readEvents(sessionLabel: string, subagentId: string): AsyncGenerator<OutputEvent>;
23
+ static list(sessionLabel: string): Promise<string[]>;
24
+ }
@@ -3,6 +3,7 @@ import type { AbortOrigin, TraceSink } from './trace/index.js';
3
3
  import { type ReadScopeInputs } from './subagent-read-scope.js';
4
4
  import { type SubagentHandle } from './subagent/handle.js';
5
5
  import type { SubagentStatus, SubagentResult, SubagentTrace } from './subagent/result.js';
6
+ import { CompletedCache } from './subagent/completed-cache.js';
6
7
  export type { SubagentStatus, SubagentResult, SubagentTrace, SubagentHandle };
7
8
  import { DENY_ELICITATION, SUBAGENT_DEFAULT_MAX_TOOL_USE_ITERATIONS, SUBAGENT_DEFAULT_TIMEOUT_MS, SUBAGENT_DEFAULT_IDLE_TIMEOUT_MS, SUBAGENT_BACKGROUND_TIMEOUT_MS, SUBAGENT_DRAIN_TIMEOUT_MS, resolveSubagentTimeoutMs, resolveSubagentIdleTimeoutMs } from './subagent/constants.js';
8
9
  import type { ForkParent, ForkSubagentOptions, SubagentManagerOptions } from './subagent/fork-types.js';
@@ -10,6 +11,7 @@ export { DENY_ELICITATION, SUBAGENT_DEFAULT_MAX_TOOL_USE_ITERATIONS, SUBAGENT_DE
10
11
  export type { ForkParent, ForkSubagentOptions, SubagentManagerOptions };
11
12
  export declare class SubagentManager {
12
13
  private readonly active;
14
+ readonly completed: CompletedCache;
13
15
  private readonly parentCanUseTool;
14
16
  private readonly hookRegistry;
15
17
  private readonly progressSink;
@@ -24,6 +26,7 @@ export declare class SubagentManager {
24
26
  private readonly parentSurface;
25
27
  private readonly parentAbortSignal;
26
28
  private readonly workspaceStore;
29
+ private readonly sessionLabel;
27
30
  private readonly abortGraph;
28
31
  private readonly rootId;
29
32
  private rootController;
@@ -13,6 +13,7 @@ export interface ToolConfig {
13
13
  export interface ResumeHistoryTurn {
14
14
  user: string;
15
15
  assistant: string;
16
+ inputTokens?: number;
16
17
  }
17
18
  export interface PlanExitControls {
18
19
  setPermissionMode(mode: PermissionMode): Promise<void>;
@@ -129,6 +129,7 @@ export interface IAgentSession {
129
129
  getQuery(): ProviderQuery;
130
130
  getLastResponseMetadata(): ResponseMetadata | null;
131
131
  getOutputStream(): AsyncIterable<OutputEvent>;
132
+ getHistory?(): readonly Message[];
132
133
  getInputStreamRef(): Pick<InputStreamRef, 'pushUserMessage' | 'queueFrameworkContext'>;
133
134
  supportedCommands(): Promise<SlashCommand[]>;
134
135
  supportedModels(): Promise<ModelInfo[]>;
@@ -0,0 +1,3 @@
1
+ import type { OutputEvent } from '../agent/types/session-types.js';
2
+ export declare function formatOutputEvent(event: OutputEvent): string | null;
3
+ export declare const formatDiskEvent: typeof formatOutputEvent;
@@ -0,0 +1,8 @@
1
+ import type { SlashCommand } from '../types.js';
2
+ import type { SubagentManager } from '../../../agent/subagent.js';
3
+ export declare function setTasksRegistry(manager: SubagentManager, sessionLabel: string): void;
4
+ export declare function resetTasksRegistry(): void;
5
+ export declare const tasksCmd: SlashCommand;
6
+ export declare const tasksViewCmd: SlashCommand;
7
+ export declare const tasksCancelCmd: SlashCommand;
8
+ export declare const tasksCommands: readonly SlashCommand[];
@@ -1,3 +1,8 @@
1
+ export interface PluginSkillHarvest {
2
+ flags: Map<string, string[]>;
3
+ categories: Map<string, string>;
4
+ }
1
5
  export declare function harvestPluginSkillFlags(cacheRoot?: string): Map<string, string[]>;
6
+ export declare function harvestPluginSkillMetadata(cacheRoot?: string): PluginSkillHarvest;
2
7
  export declare function harvestAllPluginSkillFlags(): Map<string, string[]>;
3
8
  export declare function extractHintFromDescription(description: string): string | undefined;
@@ -4,6 +4,7 @@ export interface DiscoveredSkill {
4
4
  description: string;
5
5
  argumentHint?: string;
6
6
  source?: SkillManifestEntry['source'];
7
+ category?: string;
7
8
  }
8
9
  export interface PluginCollision {
9
10
  bare: string;
@@ -1,4 +1,4 @@
1
- export { harvestPluginSkillFlags, extractHintFromDescription, } from './plugin-skills/flags.js';
1
+ export { harvestPluginSkillFlags, harvestPluginSkillMetadata, extractHintFromDescription, type PluginSkillHarvest, } from './plugin-skills/flags.js';
2
2
  export { initialSkillsCmd } from './plugin-skills/listing.js';
3
3
  export { makeForwardHandler, registerPluginSkills, getPluginShadowingNoticeLines, autoRegisterPluginPassthroughs, } from './plugin-skills/dispatch.js';
4
4
  export { buildSourceBreakdown, computeSkillDelta, formatSkillDelta, buildPluginRows, reloadPluginsCmd, } from './plugin-skills/reload.js';