agent-afk 5.67.0 → 5.68.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/subagent/handle.d.ts +2 -1
- package/dist/agent/subagent/idle-watchdog.d.ts +24 -0
- package/dist/agent/subagent.d.ts +2 -0
- package/dist/agent/tools/dispatcher.d.ts +2 -0
- package/dist/agent/tools/suspected-loop-detector.d.ts +15 -0
- package/dist/agent/trace/events.d.ts +8 -0
- package/dist/agent/trace/types.d.ts +1 -1
- package/dist/agent/types/config-types.d.ts +1 -0
- package/dist/cli.mjs +436 -436
- package/dist/config/env.d.ts +1 -0
- package/dist/index.mjs +155 -155
- package/dist/telegram.mjs +202 -202
- package/dist/utils/errors.d.ts +3 -0
- package/package.json +1 -1
|
@@ -32,6 +32,7 @@ export declare class SubagentHandleImpl<T> implements SubagentHandle<T> {
|
|
|
32
32
|
private readonly agentType?;
|
|
33
33
|
private readonly traceWriter?;
|
|
34
34
|
private readonly onSubagentSucceeded?;
|
|
35
|
+
private readonly idleTimeoutMs;
|
|
35
36
|
private currentStatus;
|
|
36
37
|
private inFlight;
|
|
37
38
|
private lastMessage;
|
|
@@ -44,7 +45,7 @@ export declare class SubagentHandleImpl<T> implements SubagentHandle<T> {
|
|
|
44
45
|
private currentTrace;
|
|
45
46
|
private lastStreamedContent;
|
|
46
47
|
private lastStopReason;
|
|
47
|
-
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?: TraceWriter | undefined, onSubagentSucceeded?: ((usage: SubagentTrace["usage"], costUsd: number | undefined) => void) | undefined);
|
|
48
|
+
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?: TraceWriter | undefined, onSubagentSucceeded?: ((usage: SubagentTrace["usage"], costUsd: number | undefined) => void) | undefined, idleTimeoutMs?: number);
|
|
48
49
|
get status(): SubagentStatus;
|
|
49
50
|
run(prompt: string, sinkOverride?: SubagentProgressSink): Promise<Message>;
|
|
50
51
|
private streamToFinalMessage;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { OutputEvent } from '../types/session-types.js';
|
|
2
|
+
export declare const IDLE_WATCHDOG_PAUSE_SLACK_MS = 30000;
|
|
3
|
+
export declare class IdleWatchdog {
|
|
4
|
+
private readonly controller;
|
|
5
|
+
private readonly idleTimeoutMs;
|
|
6
|
+
private readonly label;
|
|
7
|
+
private readonly onFire?;
|
|
8
|
+
private timer;
|
|
9
|
+
private disposed;
|
|
10
|
+
private fired;
|
|
11
|
+
private readonly inFlightTools;
|
|
12
|
+
constructor(controller: AbortController, idleTimeoutMs: number, label: string, onFire?: ((info: {
|
|
13
|
+
idleTimeoutMs: number;
|
|
14
|
+
elapsedSinceLastProgressMs: number;
|
|
15
|
+
lastEventType: string;
|
|
16
|
+
}) => void) | undefined);
|
|
17
|
+
private isEnabled;
|
|
18
|
+
onEvent(event: OutputEvent): void;
|
|
19
|
+
private pausedWindowMs;
|
|
20
|
+
private arm;
|
|
21
|
+
private clearTimer;
|
|
22
|
+
private fire;
|
|
23
|
+
dispose(): void;
|
|
24
|
+
}
|
package/dist/agent/subagent.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export declare const DENY_ELICITATION: NonNullable<AgentConfig['onElicitation']>
|
|
|
15
15
|
export declare const SUBAGENT_DEFAULT_MAX_TOOL_USE_ITERATIONS = 50;
|
|
16
16
|
export declare const SUBAGENT_DEFAULT_TIMEOUT_MS: number;
|
|
17
17
|
export declare function resolveSubagentTimeoutMs(): number;
|
|
18
|
+
export declare const SUBAGENT_DEFAULT_IDLE_TIMEOUT_MS: number;
|
|
19
|
+
export declare function resolveSubagentIdleTimeoutMs(): number;
|
|
18
20
|
export declare const SUBAGENT_BACKGROUND_TIMEOUT_MS: number;
|
|
19
21
|
export interface ForkParent {
|
|
20
22
|
sessionId?: string;
|
|
@@ -61,6 +61,7 @@ export declare class SessionToolDispatcher implements ToolDispatcher {
|
|
|
61
61
|
private readonly maxOutputBytes;
|
|
62
62
|
private repeatBreaker;
|
|
63
63
|
private denialBreaker;
|
|
64
|
+
private suspectedLoopWindow;
|
|
64
65
|
private readonly grantManager;
|
|
65
66
|
constructor(opts: SessionToolDispatcherOptions);
|
|
66
67
|
private get handlerContext();
|
|
@@ -74,6 +75,7 @@ export declare class SessionToolDispatcher implements ToolDispatcher {
|
|
|
74
75
|
get toolDefs(): readonly AnthropicToolDef[];
|
|
75
76
|
private checkReadOnlyBash;
|
|
76
77
|
private checkRepeatCircuitBreaker;
|
|
78
|
+
private observeSuspectedLoop;
|
|
77
79
|
private recordForkReadDenial;
|
|
78
80
|
private resetDenialBreaker;
|
|
79
81
|
private runCanUseTool;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ToolCall } from '../providers/anthropic-direct/types.js';
|
|
2
|
+
export declare const SUSPECTED_LOOP_THRESHOLD = 5;
|
|
3
|
+
export declare const SUSPECTED_LOOP_WINDOW_SIZE = 20;
|
|
4
|
+
export interface SuspectedLoopWindow {
|
|
5
|
+
recent: string[];
|
|
6
|
+
firedFingerprints: Set<string>;
|
|
7
|
+
}
|
|
8
|
+
export declare function createSuspectedLoopWindow(): SuspectedLoopWindow;
|
|
9
|
+
export declare function fingerprintToolCall(call: ToolCall): string;
|
|
10
|
+
export interface SuspectedLoopObservation {
|
|
11
|
+
fired: boolean;
|
|
12
|
+
count: number;
|
|
13
|
+
}
|
|
14
|
+
export declare function countInWindow(recent: readonly string[], fingerprint: string): number;
|
|
15
|
+
export declare function observeToolCall(window: SuspectedLoopWindow, fingerprint: string): SuspectedLoopObservation;
|
|
@@ -483,6 +483,8 @@ export declare const SessionPhaseNameSchema: z.ZodEnum<{
|
|
|
483
483
|
rate_limit: "rate_limit";
|
|
484
484
|
usage_limit_pause: "usage_limit_pause";
|
|
485
485
|
usage_limit_resume: "usage_limit_resume";
|
|
486
|
+
idle_watchdog_fired: "idle_watchdog_fired";
|
|
487
|
+
suspected_loop: "suspected_loop";
|
|
486
488
|
}>;
|
|
487
489
|
export declare const SessionPhasePayloadSchema: z.ZodObject<{
|
|
488
490
|
phase: z.ZodEnum<{
|
|
@@ -500,6 +502,8 @@ export declare const SessionPhasePayloadSchema: z.ZodObject<{
|
|
|
500
502
|
rate_limit: "rate_limit";
|
|
501
503
|
usage_limit_pause: "usage_limit_pause";
|
|
502
504
|
usage_limit_resume: "usage_limit_resume";
|
|
505
|
+
idle_watchdog_fired: "idle_watchdog_fired";
|
|
506
|
+
suspected_loop: "suspected_loop";
|
|
503
507
|
}>;
|
|
504
508
|
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
505
509
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
@@ -823,6 +827,8 @@ export declare const TraceEventInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
823
827
|
rate_limit: "rate_limit";
|
|
824
828
|
usage_limit_pause: "usage_limit_pause";
|
|
825
829
|
usage_limit_resume: "usage_limit_resume";
|
|
830
|
+
idle_watchdog_fired: "idle_watchdog_fired";
|
|
831
|
+
suspected_loop: "suspected_loop";
|
|
826
832
|
}>;
|
|
827
833
|
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
828
834
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
@@ -1154,6 +1160,8 @@ export declare const TraceEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1154
1160
|
rate_limit: "rate_limit";
|
|
1155
1161
|
usage_limit_pause: "usage_limit_pause";
|
|
1156
1162
|
usage_limit_resume: "usage_limit_resume";
|
|
1163
|
+
idle_watchdog_fired: "idle_watchdog_fired";
|
|
1164
|
+
suspected_loop: "suspected_loop";
|
|
1157
1165
|
}>;
|
|
1158
1166
|
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
1159
1167
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
@@ -201,7 +201,7 @@ export interface BrowserEventPayload {
|
|
|
201
201
|
};
|
|
202
202
|
durationMs: number;
|
|
203
203
|
}
|
|
204
|
-
export type SessionPhaseName = 'bootstrap_start' | 'bootstrap_done' | 'session_init_start' | 'session_init_done' | 'mcp_connect_start' | 'mcp_connect_done' | 'mcp_server_start' | 'mcp_server_done' | 'loop_start' | 'loop_end' | 'model_ttfb' | 'rate_limit' | 'usage_limit_pause' | 'usage_limit_resume';
|
|
204
|
+
export type SessionPhaseName = 'bootstrap_start' | 'bootstrap_done' | 'session_init_start' | 'session_init_done' | 'mcp_connect_start' | 'mcp_connect_done' | 'mcp_server_start' | 'mcp_server_done' | 'loop_start' | 'loop_end' | 'model_ttfb' | 'rate_limit' | 'usage_limit_pause' | 'usage_limit_resume' | 'idle_watchdog_fired' | 'suspected_loop';
|
|
205
205
|
export interface SessionPhasePayload {
|
|
206
206
|
phase: SessionPhaseName;
|
|
207
207
|
durationMs?: number;
|