agent-afk 5.317.1 → 5.318.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/tools/dispatcher.hook-block-repeat-gate.d.ts +4 -0
- package/dist/agent/tools/dispatcher.pre-dispatch-gates.d.ts +4 -0
- package/dist/agent/tools/hook-block-repeat-breaker.d.ts +16 -0
- package/dist/agent/trace/events.d.ts +8 -0
- package/dist/agent/trace/events.session-phase.d.ts +2 -0
- package/dist/agent/trace/events.subagent-lifecycle.d.ts +3 -0
- package/dist/agent/trace/types.d.ts +1 -1
- package/dist/agent/trace/types.session-phase.d.ts +1 -1
- package/dist/browser/playwright/egress-proxy.d.ts +3 -1
- package/dist/browser/playwright/egress-proxy.race.d.ts +8 -0
- package/dist/cli.mjs +370 -368
- package/dist/index.mjs +179 -177
- package/dist/telegram.mjs +190 -188
- package/package.json +1 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PreDispatchGateDeps, PreDispatchGateMutableState } from './dispatcher.pre-dispatch-gates.js';
|
|
2
|
+
import type { ToolCall, ToolResult } from '../providers/anthropic-direct/types.js';
|
|
3
|
+
export declare function resetHookBlockRepeatBreaker(state: PreDispatchGateMutableState): void;
|
|
4
|
+
export declare function applyHookBlockRepeatGate(call: ToolCall, blockResult: ToolResult, deps: PreDispatchGateDeps, rawReason?: string): ToolResult;
|
|
@@ -6,6 +6,7 @@ import type { ToolCall, ToolResult } from '../providers/anthropic-direct/types.j
|
|
|
6
6
|
import type { CanUseTool } from '../types/sdk-types.js';
|
|
7
7
|
import type { TraceSink } from '../trace/index.js';
|
|
8
8
|
import type { GrantManager } from './grant-manager.js';
|
|
9
|
+
import type { HookBlockRepeatState } from './hook-block-repeat-breaker.js';
|
|
9
10
|
export interface PreDispatchGateMutableState {
|
|
10
11
|
repeatBreaker: {
|
|
11
12
|
fingerprint: string;
|
|
@@ -16,6 +17,7 @@ export interface PreDispatchGateMutableState {
|
|
|
16
17
|
count: number;
|
|
17
18
|
deniedPaths: string[];
|
|
18
19
|
} | null;
|
|
20
|
+
hookBlockRepeat: HookBlockRepeatState | null;
|
|
19
21
|
}
|
|
20
22
|
export interface PreDispatchGateDeps {
|
|
21
23
|
state: PreDispatchGateMutableState;
|
|
@@ -37,6 +39,8 @@ export interface PreDispatchGateDeps {
|
|
|
37
39
|
}
|
|
38
40
|
export declare function emitPreToolUseBlock(blockedTool: string, reason: string, deps: PreDispatchGateDeps): Promise<void>;
|
|
39
41
|
export declare function resetDenialBreaker(state: PreDispatchGateMutableState): void;
|
|
42
|
+
export { applyHookBlockRepeatGate as applyHookBlockRepeat } from './dispatcher.hook-block-repeat-gate.js';
|
|
43
|
+
export declare function resetProgressBreakers(state: PreDispatchGateMutableState): void;
|
|
40
44
|
export declare function accountDenialBreakerPostGate(call: ToolCall, blockReason: string | undefined, blockResult: ToolResult, deps: PreDispatchGateDeps): ToolResult;
|
|
41
45
|
export declare function replayObserveSuspectedLoopPostGate(call: ToolCall, deps: PreDispatchGateDeps): void;
|
|
42
46
|
export interface RunPreDispatchGatesOpts {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ToolFailureClass } from '../trace/types.js';
|
|
2
|
+
export declare const HOOK_BLOCK_REPEAT_THRESHOLD = 3;
|
|
3
|
+
export declare const HOOK_BLOCK_REPEAT_FAILURE_CLASS: ToolFailureClass;
|
|
4
|
+
export declare function gateKey(toolName: string): string;
|
|
5
|
+
export interface HookBlockRepeatState {
|
|
6
|
+
key: string;
|
|
7
|
+
count: number;
|
|
8
|
+
escalated: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function recordHookBlock(state: HookBlockRepeatState | null, toolName: string): {
|
|
11
|
+
state: HookBlockRepeatState;
|
|
12
|
+
count: number;
|
|
13
|
+
};
|
|
14
|
+
export declare function resetHookBlockRepeat(): null;
|
|
15
|
+
export declare function buildHookBlockRepeatMessage(toolName: string, count: number): string;
|
|
16
|
+
export declare function buildHookBlockRepeatEscalation(toolName: string, count: number): string;
|
|
@@ -35,6 +35,7 @@ export declare const ToolCallCompletedPayloadSchema: z.ZodObject<{
|
|
|
35
35
|
"denial-breaker": "denial-breaker";
|
|
36
36
|
"repeat-failure": "repeat-failure";
|
|
37
37
|
"no-such-target": "no-such-target";
|
|
38
|
+
"hook-block-repeat": "hook-block-repeat";
|
|
38
39
|
}>>;
|
|
39
40
|
batchIndex: z.ZodOptional<z.ZodNumber>;
|
|
40
41
|
batchSize: z.ZodOptional<z.ZodNumber>;
|
|
@@ -71,6 +72,7 @@ export declare const ToolCallPayloadSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
71
72
|
"denial-breaker": "denial-breaker";
|
|
72
73
|
"repeat-failure": "repeat-failure";
|
|
73
74
|
"no-such-target": "no-such-target";
|
|
75
|
+
"hook-block-repeat": "hook-block-repeat";
|
|
74
76
|
}>>;
|
|
75
77
|
batchIndex: z.ZodOptional<z.ZodNumber>;
|
|
76
78
|
batchSize: z.ZodOptional<z.ZodNumber>;
|
|
@@ -305,6 +307,7 @@ export declare const TraceEventInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
305
307
|
"denial-breaker": "denial-breaker";
|
|
306
308
|
"repeat-failure": "repeat-failure";
|
|
307
309
|
"no-such-target": "no-such-target";
|
|
310
|
+
"hook-block-repeat": "hook-block-repeat";
|
|
308
311
|
}>>;
|
|
309
312
|
batchIndex: z.ZodOptional<z.ZodNumber>;
|
|
310
313
|
batchSize: z.ZodOptional<z.ZodNumber>;
|
|
@@ -387,6 +390,7 @@ export declare const TraceEventInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
387
390
|
"denial-breaker": "denial-breaker";
|
|
388
391
|
"repeat-failure": "repeat-failure";
|
|
389
392
|
"no-such-target": "no-such-target";
|
|
393
|
+
"hook-block-repeat": "hook-block-repeat";
|
|
390
394
|
}>>;
|
|
391
395
|
}, z.core.$strip>, z.ZodObject<{
|
|
392
396
|
transition: z.ZodLiteral<"cancelled">;
|
|
@@ -652,6 +656,7 @@ export declare const TraceEventInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
652
656
|
background_process_settled: "background_process_settled";
|
|
653
657
|
compose_recovery_decision: "compose_recovery_decision";
|
|
654
658
|
compose_leaf_tools_stripped: "compose_leaf_tools_stripped";
|
|
659
|
+
hook_block_repeat_tripped: "hook_block_repeat_tripped";
|
|
655
660
|
}>;
|
|
656
661
|
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
657
662
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
@@ -706,6 +711,7 @@ export declare const TraceEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
706
711
|
"denial-breaker": "denial-breaker";
|
|
707
712
|
"repeat-failure": "repeat-failure";
|
|
708
713
|
"no-such-target": "no-such-target";
|
|
714
|
+
"hook-block-repeat": "hook-block-repeat";
|
|
709
715
|
}>>;
|
|
710
716
|
batchIndex: z.ZodOptional<z.ZodNumber>;
|
|
711
717
|
batchSize: z.ZodOptional<z.ZodNumber>;
|
|
@@ -794,6 +800,7 @@ export declare const TraceEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
794
800
|
"denial-breaker": "denial-breaker";
|
|
795
801
|
"repeat-failure": "repeat-failure";
|
|
796
802
|
"no-such-target": "no-such-target";
|
|
803
|
+
"hook-block-repeat": "hook-block-repeat";
|
|
797
804
|
}>>;
|
|
798
805
|
}, z.core.$strip>, z.ZodObject<{
|
|
799
806
|
transition: z.ZodLiteral<"cancelled">;
|
|
@@ -1083,6 +1090,7 @@ export declare const TraceEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1083
1090
|
background_process_settled: "background_process_settled";
|
|
1084
1091
|
compose_recovery_decision: "compose_recovery_decision";
|
|
1085
1092
|
compose_leaf_tools_stripped: "compose_leaf_tools_stripped";
|
|
1093
|
+
hook_block_repeat_tripped: "hook_block_repeat_tripped";
|
|
1086
1094
|
}>;
|
|
1087
1095
|
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
1088
1096
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
@@ -48,6 +48,7 @@ export declare const SessionPhaseNameSchema: z.ZodEnum<{
|
|
|
48
48
|
background_process_settled: "background_process_settled";
|
|
49
49
|
compose_recovery_decision: "compose_recovery_decision";
|
|
50
50
|
compose_leaf_tools_stripped: "compose_leaf_tools_stripped";
|
|
51
|
+
hook_block_repeat_tripped: "hook_block_repeat_tripped";
|
|
51
52
|
}>;
|
|
52
53
|
export declare const SessionPhasePayloadSchema: z.ZodObject<{
|
|
53
54
|
phase: z.ZodEnum<{
|
|
@@ -99,6 +100,7 @@ export declare const SessionPhasePayloadSchema: z.ZodObject<{
|
|
|
99
100
|
background_process_settled: "background_process_settled";
|
|
100
101
|
compose_recovery_decision: "compose_recovery_decision";
|
|
101
102
|
compose_leaf_tools_stripped: "compose_leaf_tools_stripped";
|
|
103
|
+
hook_block_repeat_tripped: "hook_block_repeat_tripped";
|
|
102
104
|
}>;
|
|
103
105
|
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
104
106
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
@@ -10,6 +10,7 @@ export declare const ToolFailureClassSchema: z.ZodEnum<{
|
|
|
10
10
|
"denial-breaker": "denial-breaker";
|
|
11
11
|
"repeat-failure": "repeat-failure";
|
|
12
12
|
"no-such-target": "no-such-target";
|
|
13
|
+
"hook-block-repeat": "hook-block-repeat";
|
|
13
14
|
}>;
|
|
14
15
|
export declare const SubagentStartedPayloadSchema: z.ZodObject<{
|
|
15
16
|
transition: z.ZodLiteral<"started">;
|
|
@@ -49,6 +50,7 @@ export declare const SubagentFailedPayloadSchema: z.ZodObject<{
|
|
|
49
50
|
"denial-breaker": "denial-breaker";
|
|
50
51
|
"repeat-failure": "repeat-failure";
|
|
51
52
|
"no-such-target": "no-such-target";
|
|
53
|
+
"hook-block-repeat": "hook-block-repeat";
|
|
52
54
|
}>>;
|
|
53
55
|
}, z.core.$strip>;
|
|
54
56
|
export declare const SubagentCancelledPayloadSchema: z.ZodObject<{
|
|
@@ -96,6 +98,7 @@ export declare const SubagentLifecyclePayloadSchema: z.ZodDiscriminatedUnion<[z.
|
|
|
96
98
|
"denial-breaker": "denial-breaker";
|
|
97
99
|
"repeat-failure": "repeat-failure";
|
|
98
100
|
"no-such-target": "no-such-target";
|
|
101
|
+
"hook-block-repeat": "hook-block-repeat";
|
|
99
102
|
}>>;
|
|
100
103
|
}, z.core.$strip>, z.ZodObject<{
|
|
101
104
|
transition: z.ZodLiteral<"cancelled">;
|
|
@@ -8,7 +8,7 @@ export interface ToolCallStartedPayload {
|
|
|
8
8
|
resourceFingerprint?: string;
|
|
9
9
|
subagentId?: string;
|
|
10
10
|
}
|
|
11
|
-
export declare const TOOL_FAILURE_CLASSES: readonly ["policy-refusal", "timeout", "budget", "permission-denied", "hook-block", "abort", "elicitation-declined", "denial-breaker", "repeat-failure", "no-such-target"];
|
|
11
|
+
export declare const TOOL_FAILURE_CLASSES: readonly ["policy-refusal", "timeout", "budget", "permission-denied", "hook-block", "abort", "elicitation-declined", "denial-breaker", "repeat-failure", "no-such-target", "hook-block-repeat"];
|
|
12
12
|
export type ToolFailureClass = (typeof TOOL_FAILURE_CLASSES)[number];
|
|
13
13
|
export declare const BENIGN_FAILURE_CLASSES: ReadonlySet<ToolFailureClass>;
|
|
14
14
|
export interface ToolCallCompletedPayload {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
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' | 'context_pressure_wind_down' | 'catalog_model_upgrade' | 'interrupt_halt' | 'rate_limit' | 'ttfb_timeout' | 'usage_limit_pause' | 'usage_limit_resume' | 'overload_pause' | 'overload_resume' | 'idle_watchdog_fired' | 'pause_extension_granted' | 'suspected_loop' | 'compaction_disabled' | 'boot_warning' | 'workspace_subscribed' | 'workspace_delivery' | 'gate_shape' | 'session_id_assigned' | 'many_image_degraded' | 'stream_accepted_after_drop' | 'connection_retry' | 'connection_retry_exhausted' | 'connection_failure' | 'connection_recovered' | 'connection_budget_exhausted' | 'usage_notice' | 'tool_degraded' | 'strategy_nudge_fired' | 'stop_inject_dropped' | 'stop_hook_continuation' | 'stop_hook_cap_reached' | 'orphan_repair' | 'thinking_block_dropped' | 'background_process_started' | 'background_process_settled' | 'compose_recovery_decision' | 'compose_leaf_tools_stripped';
|
|
1
|
+
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' | 'context_pressure_wind_down' | 'catalog_model_upgrade' | 'interrupt_halt' | 'rate_limit' | 'ttfb_timeout' | 'usage_limit_pause' | 'usage_limit_resume' | 'overload_pause' | 'overload_resume' | 'idle_watchdog_fired' | 'pause_extension_granted' | 'suspected_loop' | 'compaction_disabled' | 'boot_warning' | 'workspace_subscribed' | 'workspace_delivery' | 'gate_shape' | 'session_id_assigned' | 'many_image_degraded' | 'stream_accepted_after_drop' | 'connection_retry' | 'connection_retry_exhausted' | 'connection_failure' | 'connection_recovered' | 'connection_budget_exhausted' | 'usage_notice' | 'tool_degraded' | 'strategy_nudge_fired' | 'stop_inject_dropped' | 'stop_hook_continuation' | 'stop_hook_cap_reached' | 'orphan_repair' | 'thinking_block_dropped' | 'background_process_started' | 'background_process_settled' | 'compose_recovery_decision' | 'compose_leaf_tools_stripped' | 'hook_block_repeat_tripped';
|
|
2
2
|
export interface SessionPhasePayload {
|
|
3
3
|
phase: SessionPhaseName;
|
|
4
4
|
durationMs?: number;
|
|
@@ -10,6 +10,7 @@ export interface EgressProxyDeps {
|
|
|
10
10
|
}[]>;
|
|
11
11
|
isBlocked?: (ip: string, port: number) => boolean;
|
|
12
12
|
connectTimeoutMs?: number;
|
|
13
|
+
responseInactivityMs?: number;
|
|
13
14
|
drainTimeoutMs?: number;
|
|
14
15
|
}
|
|
15
16
|
export declare function targetKey(host: string, port: number | string): string;
|
|
@@ -23,6 +24,7 @@ export declare class EgressProxy {
|
|
|
23
24
|
private readonly lookupFn;
|
|
24
25
|
private readonly isBlocked;
|
|
25
26
|
private readonly connectTimeoutMs;
|
|
27
|
+
private readonly responseInactivityMs;
|
|
26
28
|
private readonly drainTimeoutMs;
|
|
27
29
|
constructor(deps?: EgressProxyDeps);
|
|
28
30
|
listen(): Promise<number>;
|
|
@@ -32,8 +34,8 @@ export declare class EgressProxy {
|
|
|
32
34
|
private lookupGuarded;
|
|
33
35
|
private record;
|
|
34
36
|
private track;
|
|
35
|
-
private dial;
|
|
36
37
|
private openUpstream;
|
|
38
|
+
private raceAddresses;
|
|
37
39
|
private onForward;
|
|
38
40
|
private relayResponse;
|
|
39
41
|
private onTunnel;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import net from 'node:net';
|
|
2
|
+
export interface RaceAddressesDeps {
|
|
3
|
+
port: number;
|
|
4
|
+
connectTimeoutMs: number;
|
|
5
|
+
track: (s: net.Socket) => void;
|
|
6
|
+
gone: () => boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function raceAddresses(addresses: string[], deps: RaceAddressesDeps): Promise<net.Socket>;
|