agent-afk 5.302.13 → 5.303.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.
@@ -26,6 +26,7 @@ export declare class JournalFileWriter {
26
26
  private len;
27
27
  constructor(shared: JournalSessionShared, subagentId?: string | undefined);
28
28
  get length(): number;
29
+ get path(): string | undefined;
29
30
  get isClosed(): boolean;
30
31
  record(input: JournalRecordInput): void;
31
32
  private recordUnsafe;
@@ -121,6 +121,7 @@ export type JournalRecordInput = Omit<Extract<JournalRecord, {
121
121
  kind: 'mark';
122
122
  }>, 'v' | 'ts'>;
123
123
  export interface MessageJournal {
124
+ readonly path?: string;
124
125
  readonly length: number;
125
126
  append(index: number, message: JournalMessage): void;
126
127
  truncate(length: number, reason?: JournalTruncateReason): void;
@@ -56,9 +56,9 @@ export declare const VerifiedOutcomeSchema: z.ZodObject<{
56
56
  self_report: z.ZodEnum<{
57
57
  done: "done";
58
58
  blocked: "blocked";
59
+ none: "none";
59
60
  asking: "asking";
60
61
  interrupted: "interrupted";
61
- none: "none";
62
62
  }>;
63
63
  artifacts: z.ZodObject<{
64
64
  commits: z.ZodArray<z.ZodString>;
@@ -44,6 +44,8 @@ export interface ProviderProgress {
44
44
  taskId: string;
45
45
  description: string;
46
46
  summary?: string;
47
+ roundsUsed?: number;
48
+ budget?: number;
47
49
  lastToolName?: string;
48
50
  totalTokens: number;
49
51
  toolUses: number;
@@ -0,0 +1,19 @@
1
+ import type { AnthropicMessagesCreateParams } from '../types.js';
2
+ export declare class ConnectionOverloadExhaustedError extends Error {
3
+ constructor();
4
+ }
5
+ export interface ConnectionRetryInfo {
6
+ attempt: number;
7
+ delayMs: number;
8
+ error: Error;
9
+ }
10
+ export interface ConnectionLifecycleInfo {
11
+ phase: 'connection_failure' | 'connection_recovered' | 'connection_budget_exhausted';
12
+ metadata: Record<string, string | number | boolean>;
13
+ }
14
+ export declare function createWithRetry(client: {
15
+ messages: {
16
+ create(params: unknown, opts: unknown): unknown;
17
+ };
18
+ baseURL?: string;
19
+ }, params: AnthropicMessagesCreateParams, headers: Record<string, string>, requestSignal: AbortSignal, turnSignal: AbortSignal, onConnectionRetry?: (info: ConnectionRetryInfo) => void, onLifecycle?: (info: ConnectionLifecycleInfo) => void): Promise<AsyncIterable<unknown>>;
@@ -2,19 +2,10 @@ import type { ProviderEvent } from '../../../provider.js';
2
2
  import type { AnthropicMessagesCreateParams, AnthropicToolDef, RunTurnInput, WireToolDef } from '../types.js';
3
3
  import { type FirstByteTimeoutHandle } from '../../shared/first-byte-timeout.js';
4
4
  import { type StreamStallHandle } from '../../shared/stream-stall-timeout.js';
5
- import { type RoundRetryBudget } from './retry-budget.js';
5
+ import type { RoundRetryBudget } from './retry-budget.js';
6
6
  import type { TurnAccumulator } from './turn-accumulator.js';
7
7
  export declare function toWireTool(tool: AnthropicToolDef): WireToolDef;
8
- export declare function createWithRetry(client: {
9
- messages: {
10
- create(params: unknown, opts: unknown): unknown;
11
- };
12
- }, params: AnthropicMessagesCreateParams, headers: Record<string, string>, requestSignal: AbortSignal, turnSignal: AbortSignal, onConnectionRetry?: (info: ConnectionRetryInfo) => void): Promise<AsyncIterable<unknown>>;
13
- export interface ConnectionRetryInfo {
14
- attempt: number;
15
- delayMs: number;
16
- error: Error;
17
- }
8
+ export { createWithRetry, type ConnectionRetryInfo } from './connection-create.js';
18
9
  export interface OpenRoundTransport {
19
10
  kind: 'opened';
20
11
  events: AsyncIterable<unknown>;
@@ -6,4 +6,4 @@ export type ConnectionOutcome<TEvent> = {
6
6
  ok: false;
7
7
  error: unknown;
8
8
  };
9
- export declare function runConnectionPhase<TEvent>(createStream: (signal: AbortSignal) => Promise<AsyncIterable<TEvent>>, streamSignal: AbortSignal, userSignal: AbortSignal, traceWriter: TraceSink | undefined, resolvedModel: string): Promise<ConnectionOutcome<TEvent>>;
9
+ export declare function runConnectionPhase<TEvent>(createStream: (signal: AbortSignal) => Promise<AsyncIterable<TEvent>>, streamSignal: AbortSignal, userSignal: AbortSignal, traceWriter: TraceSink | undefined, resolvedModel: string, endpoint?: string): Promise<ConnectionOutcome<TEvent>>;
@@ -17,6 +17,7 @@ export interface StreamDriveContext {
17
17
  traceWriter: TraceSink | undefined;
18
18
  initSessionId: string;
19
19
  currentModel: string;
20
+ endpoint?: string;
20
21
  isClosed: () => boolean;
21
22
  ttfbTimeoutMs?: number;
22
23
  stallTimeoutMs?: number;
@@ -0,0 +1,4 @@
1
+ export declare function connectionLoopLag(): {
2
+ loopLagP99Ms: number;
3
+ loopLagMaxMs: number;
4
+ };
@@ -0,0 +1,10 @@
1
+ export declare const CONNECT_WAIT_CAP_MS = 8000;
2
+ export declare function connectRetryBudgetMs(): number | undefined;
3
+ export declare class ConnectionRetryBudget {
4
+ readonly startedAt: number;
5
+ readonly budgetMs: number | undefined;
6
+ elapsedMs(): number;
7
+ canRetry(attempt: number, legacyMax: number): boolean;
8
+ delay(legacyDelay: number, baseMs: number, attempt: number): number;
9
+ }
10
+ export declare function connectionFailureMetadata(error: unknown, budget: ConnectionRetryBudget, endpoint?: string): Record<string, string | number | boolean>;
@@ -4,3 +4,4 @@ export declare const WIND_DOWN_NOTE: string;
4
4
  export declare function resolveMaxToolIterations(configured: number | undefined): number;
5
5
  export declare function shouldWindDown(completedRounds: number, maxIterations: number): boolean;
6
6
  export declare function formatRoundLabel(round: number, maxIterations: number): string;
7
+ export declare function roundDeliveryNotice(completedRounds: number, budget: number): string | null;
@@ -0,0 +1,26 @@
1
+ import type { Message, IAgentSession, OutputEvent } from '../types.js';
2
+ import type { SubagentHandleImpl } from './handle.js';
3
+ import { TOOL_USE_LOOP_CAPPED } from '../providers/shared/tool-loop-cap.js';
4
+ export declare function isNarrationOnly(text: string): boolean;
5
+ export declare class CappedHandoffAccumulator {
6
+ private priorText;
7
+ private roundText;
8
+ private lastMessage;
9
+ private roundsUsed;
10
+ private budget;
11
+ private historyLengthAtStart;
12
+ setHistoryBaseline(length: number): void;
13
+ onEvent(event: OutputEvent): void;
14
+ finish(finalMessage: Message | undefined, session: IAgentSession): Message;
15
+ }
16
+ export declare function emitSuccessfulHandoff<T>(handle: SubagentHandleImpl<T>, message: Message, startTime: number): Promise<void>;
17
+ export interface CappedHandoff {
18
+ incomplete: true;
19
+ incompleteReason: typeof TOOL_USE_LOOP_CAPPED;
20
+ roundsUsed?: number;
21
+ budget?: number;
22
+ journalPath?: string;
23
+ salvaged?: true;
24
+ }
25
+ export declare function cappedHandoffFields(message: Message, stopReason: string | undefined): Partial<CappedHandoff>;
26
+ export declare function salvageCappedMessage(finalMessage: Message | undefined, buffered: string, priorText: string, fields: Omit<CappedHandoff, 'incomplete' | 'incompleteReason'>): Message;
@@ -1,5 +1,6 @@
1
1
  import type { ZodError, ZodType } from 'zod';
2
2
  import type { Message } from '../types.js';
3
+ import { type CappedHandoff } from './capped-handoff.js';
3
4
  import { type Signal } from '../signal-block.js';
4
5
  export type SubagentStatus = 'idle' | 'running' | 'succeeded' | 'failed' | 'cancelled';
5
6
  export declare const STREAM_INCOMPLETE = "stream_incomplete";
@@ -33,7 +34,7 @@ export interface SubagentTrace {
33
34
  };
34
35
  }
35
36
  export declare function createEmptyTrace(): SubagentTrace;
36
- export interface SubagentResult<T = unknown> {
37
+ export interface SubagentResult<T = unknown> extends Partial<CappedHandoff> {
37
38
  id: string;
38
39
  status: SubagentStatus;
39
40
  message?: Message;
@@ -633,6 +633,9 @@ export declare const TraceEventInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject
633
633
  stream_accepted_after_drop: "stream_accepted_after_drop";
634
634
  connection_retry: "connection_retry";
635
635
  connection_retry_exhausted: "connection_retry_exhausted";
636
+ connection_failure: "connection_failure";
637
+ connection_recovered: "connection_recovered";
638
+ connection_budget_exhausted: "connection_budget_exhausted";
636
639
  usage_notice: "usage_notice";
637
640
  tool_degraded: "tool_degraded";
638
641
  strategy_nudge_fired: "strategy_nudge_fired";
@@ -1046,6 +1049,9 @@ export declare const TraceEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1046
1049
  stream_accepted_after_drop: "stream_accepted_after_drop";
1047
1050
  connection_retry: "connection_retry";
1048
1051
  connection_retry_exhausted: "connection_retry_exhausted";
1052
+ connection_failure: "connection_failure";
1053
+ connection_recovered: "connection_recovered";
1054
+ connection_budget_exhausted: "connection_budget_exhausted";
1049
1055
  usage_notice: "usage_notice";
1050
1056
  tool_degraded: "tool_degraded";
1051
1057
  strategy_nudge_fired: "strategy_nudge_fired";
@@ -31,6 +31,9 @@ export declare const SessionPhaseNameSchema: z.ZodEnum<{
31
31
  stream_accepted_after_drop: "stream_accepted_after_drop";
32
32
  connection_retry: "connection_retry";
33
33
  connection_retry_exhausted: "connection_retry_exhausted";
34
+ connection_failure: "connection_failure";
35
+ connection_recovered: "connection_recovered";
36
+ connection_budget_exhausted: "connection_budget_exhausted";
34
37
  usage_notice: "usage_notice";
35
38
  tool_degraded: "tool_degraded";
36
39
  strategy_nudge_fired: "strategy_nudge_fired";
@@ -74,6 +77,9 @@ export declare const SessionPhasePayloadSchema: z.ZodObject<{
74
77
  stream_accepted_after_drop: "stream_accepted_after_drop";
75
78
  connection_retry: "connection_retry";
76
79
  connection_retry_exhausted: "connection_retry_exhausted";
80
+ connection_failure: "connection_failure";
81
+ connection_recovered: "connection_recovered";
82
+ connection_budget_exhausted: "connection_budget_exhausted";
77
83
  usage_notice: "usage_notice";
78
84
  tool_degraded: "tool_degraded";
79
85
  strategy_nudge_fired: "strategy_nudge_fired";
@@ -55,6 +55,12 @@ export interface SubagentStartedPayload {
55
55
  maxToolUseIterations?: number;
56
56
  }
57
57
  export interface SubagentSucceededPayload {
58
+ incomplete?: true;
59
+ incompleteReason?: string;
60
+ roundsUsed?: number;
61
+ budget?: number;
62
+ journalPath?: string;
63
+ salvaged?: true;
58
64
  transition: 'succeeded';
59
65
  subagentId: string;
60
66
  durationMs: number;
@@ -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' | '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' | 'usage_notice' | 'tool_degraded' | 'strategy_nudge_fired' | 'stop_inject_dropped' | 'stop_hook_continuation' | 'stop_hook_cap_reached' | 'orphan_repair' | 'background_process_started' | 'background_process_settled';
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' | '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' | 'background_process_started' | 'background_process_settled';
2
2
  export interface SessionPhasePayload {
3
3
  phase: SessionPhaseName;
4
4
  durationMs?: number;
@@ -120,6 +120,8 @@ export interface ProgressEvent {
120
120
  taskId: string;
121
121
  description: string;
122
122
  summary?: string;
123
+ roundsUsed?: number;
124
+ budget?: number;
123
125
  lastToolName?: string;
124
126
  totalTokens: number;
125
127
  toolUses: number;