agent-afk 5.295.2 → 5.295.3
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/hooks.d.ts +2 -0
- package/dist/agent/provider.d.ts +3 -0
- package/dist/agent/providers/anthropic-direct/query-runtime.d.ts +4 -0
- package/dist/agent/providers/anthropic-direct/query-turn-driver.d.ts +3 -0
- package/dist/agent/providers/anthropic-direct/request-types.d.ts +3 -0
- package/dist/agent/providers/openai-compatible/query/turn-driver.d.ts +3 -0
- package/dist/agent/providers/openai-compatible/query/turn-driver.progress.d.ts +3 -0
- package/dist/agent/providers/openai-compatible/query.d.ts +7 -0
- package/dist/agent/providers/router/provider-router.d.ts +4 -0
- package/dist/agent/providers/shared/stop-hook-continuation.d.ts +26 -0
- package/dist/agent/session/agent-session.stop-hook-wiring.d.ts +17 -0
- package/dist/agent/session/turn-stream-runner.d.ts +3 -0
- package/dist/agent/spine/spine-hook.annotations.d.ts +1 -0
- package/dist/agent/subagent/fork-types.d.ts +9 -0
- package/dist/agent/subagent.d.ts +1 -1
- package/dist/agent/tools/compose-executor.credential.d.ts +7 -0
- package/dist/agent/trace/events.d.ts +4 -0
- package/dist/agent/trace/events.session-phase.d.ts +4 -0
- package/dist/agent/trace/types.session-phase.d.ts +1 -1
- package/dist/agent/types/session-types.d.ts +1 -0
- package/dist/cli.mjs +324 -324
- package/dist/config/env.d.ts +8 -0
- package/dist/config/env.misc.d.ts +8 -0
- package/dist/index.mjs +135 -135
- package/dist/telegram.mjs +166 -166
- package/package.json +1 -1
package/dist/agent/hooks.d.ts
CHANGED
|
@@ -84,6 +84,8 @@ export interface StopContext {
|
|
|
84
84
|
terminalState?: 'done' | 'blocked' | 'asking' | 'interrupted';
|
|
85
85
|
doneHasCorroboratingEvidence?: boolean;
|
|
86
86
|
doneEvidenceClassification?: 'no-code-changes' | 'verified' | 'unverified';
|
|
87
|
+
stopHookActive?: boolean;
|
|
88
|
+
continuation?: number;
|
|
87
89
|
}
|
|
88
90
|
export interface UserPromptSubmitContext {
|
|
89
91
|
event: 'UserPromptSubmit';
|
package/dist/agent/provider.d.ts
CHANGED
|
@@ -179,6 +179,9 @@ export interface ProviderQuery extends AsyncIterable<ProviderEvent> {
|
|
|
179
179
|
setCwd?(cwd: string): void;
|
|
180
180
|
setSystemPrompt?(basePrompt: string | undefined): boolean;
|
|
181
181
|
setBeforeNextRound?(cb: (() => string | undefined) | undefined): void;
|
|
182
|
+
setBeforeTurnEnd?(cb: ((continuation: number, assistantText?: string) => Promise<{
|
|
183
|
+
continueWith?: string;
|
|
184
|
+
} | undefined>) | undefined): void;
|
|
182
185
|
reauth?(): Promise<{
|
|
183
186
|
accountId: string;
|
|
184
187
|
oldAccountId: string;
|
|
@@ -31,9 +31,13 @@ export declare class AnthropicDirectQuery implements ProviderQuery {
|
|
|
31
31
|
private readonly throttleQueue?;
|
|
32
32
|
private readonly fastModeController?;
|
|
33
33
|
private beforeNextRound?;
|
|
34
|
+
private beforeTurnEnd?;
|
|
34
35
|
constructor(opts: AnthropicDirectQueryOptions);
|
|
35
36
|
private turnDriverContext;
|
|
36
37
|
setBeforeNextRound(cb: (() => string | undefined) | undefined): void;
|
|
38
|
+
setBeforeTurnEnd(cb: ((continuation: number, assistantText?: string) => Promise<{
|
|
39
|
+
continueWith?: string;
|
|
40
|
+
} | undefined>) | undefined): void;
|
|
37
41
|
[Symbol.asyncIterator](): AsyncIterator<ProviderEvent>;
|
|
38
42
|
private composeSystem;
|
|
39
43
|
interrupt(reason?: import('../../abort-reason.js').ProviderAbortReason): Promise<void>;
|
|
@@ -27,6 +27,9 @@ export interface TurnDriverContext {
|
|
|
27
27
|
readonly throttleQueue: import('./throttle-queue.js').ThrottleQueue | undefined;
|
|
28
28
|
readonly fastModeController: import('../../fast-mode.js').FastModeController | undefined;
|
|
29
29
|
readonly beforeNextRound: (() => string | undefined) | undefined;
|
|
30
|
+
readonly beforeTurnEnd: ((continuation: number, assistantText?: string) => Promise<{
|
|
31
|
+
continueWith?: string;
|
|
32
|
+
} | undefined>) | undefined;
|
|
30
33
|
readonly cwd: string;
|
|
31
34
|
composeSystem(): ContentBlockParam[] | null;
|
|
32
35
|
makeInterruptedTurnEvent(): ProviderEvent;
|
|
@@ -27,6 +27,9 @@ export interface RunTurnInput {
|
|
|
27
27
|
onUsageProgress?: (usage: ProviderUsage) => void;
|
|
28
28
|
throttleQueue?: import('./throttle-queue.js').ThrottleQueue;
|
|
29
29
|
beforeNextRound?: () => string | undefined;
|
|
30
|
+
beforeTurnEnd?: (continuation: number, assistantText?: string) => Promise<{
|
|
31
|
+
continueWith?: string;
|
|
32
|
+
} | undefined>;
|
|
30
33
|
journalSync?: import('../../journal/index.js').JournalSync<MessageParam>;
|
|
31
34
|
turnState?: import('./loop/turn-accumulator.js').TurnAccumulator;
|
|
32
35
|
}
|
|
@@ -22,6 +22,9 @@ export interface TurnDriverContext extends IterationContext, FinishTurnContext {
|
|
|
22
22
|
readonly currentPermissionMode: string;
|
|
23
23
|
readonly closed: boolean;
|
|
24
24
|
readonly beforeNextRound: (() => string | undefined) | undefined;
|
|
25
|
+
readonly beforeTurnEnd: ((continuation: number, assistantText?: string) => Promise<{
|
|
26
|
+
continueWith?: string;
|
|
27
|
+
} | undefined>) | undefined;
|
|
25
28
|
}
|
|
26
29
|
export declare function applyBeforeNextRound(priorTurns: OpenAIMessage[], steeringText: string | undefined, traceWriter: TraceSink | undefined, subagentId: string | undefined): void;
|
|
27
30
|
export declare function applyAndSyncSteering(ctx: TurnDriverContext): void;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ProviderEvent, ProviderUsage } from '../../../provider.js';
|
|
2
|
+
import { type StreamState } from '../translate.js';
|
|
3
|
+
export declare function buildRoundProgressEvent(sessionId: string, state: StreamState, taskId: string, round: number, maxIterations: number, accumulatedUsage: ProviderUsage, toolCallCount: number, turnStartTime: number): ProviderEvent;
|
|
@@ -31,6 +31,10 @@ export declare class OpenAICompatibleQuery implements ProviderQuery, TurnDriverC
|
|
|
31
31
|
private readonly _currentBasePromptRef;
|
|
32
32
|
private _beforeNextRound;
|
|
33
33
|
get beforeNextRound(): BeforeNextRoundCallback;
|
|
34
|
+
private _beforeTurnEnd;
|
|
35
|
+
get beforeTurnEnd(): ((continuation: number, assistantText?: string) => Promise<{
|
|
36
|
+
continueWith?: string;
|
|
37
|
+
} | undefined>) | undefined;
|
|
34
38
|
private readonly openAITools;
|
|
35
39
|
readonly wireMode: WireMode;
|
|
36
40
|
readonly useOpenAIPricing: boolean;
|
|
@@ -62,6 +66,9 @@ export declare class OpenAICompatibleQuery implements ProviderQuery, TurnDriverC
|
|
|
62
66
|
setCwd(cwd: string): void;
|
|
63
67
|
setSystemPrompt(basePrompt: string | undefined): boolean;
|
|
64
68
|
setBeforeNextRound(cb: BeforeNextRoundCallback): void;
|
|
69
|
+
setBeforeTurnEnd(cb: ((continuation: number, assistantText?: string) => Promise<{
|
|
70
|
+
continueWith?: string;
|
|
71
|
+
} | undefined>) | undefined): void;
|
|
65
72
|
listRewindTargets(): import('../../provider.js').RewindTarget[];
|
|
66
73
|
rewindConversation(turnIndex: number): Promise<import('../../provider.js').ProviderRewindConversationResult>;
|
|
67
74
|
supportedCommands(): Promise<ProviderCommandInfo[]>;
|
|
@@ -28,6 +28,7 @@ export declare class ProviderRouter implements ProviderQuery {
|
|
|
28
28
|
private pendingAssistantText;
|
|
29
29
|
private lastSessionId;
|
|
30
30
|
private _beforeNextRound;
|
|
31
|
+
private _beforeTurnEnd;
|
|
31
32
|
constructor(args: ProviderRouterArgs, deps: ProviderRouterDeps);
|
|
32
33
|
private resolveInner;
|
|
33
34
|
private buildInner;
|
|
@@ -38,6 +39,9 @@ export declare class ProviderRouter implements ProviderQuery {
|
|
|
38
39
|
private driveUntilInit;
|
|
39
40
|
interrupt(reason?: import('../../abort-reason.js').ProviderAbortReason): Promise<void>;
|
|
40
41
|
setBeforeNextRound(cb: (() => string | undefined) | undefined): void;
|
|
42
|
+
setBeforeTurnEnd(cb: ((continuation: number, assistantText?: string) => Promise<{
|
|
43
|
+
continueWith?: string;
|
|
44
|
+
} | undefined>) | undefined): void;
|
|
41
45
|
setModel(model?: string): Promise<void>;
|
|
42
46
|
setPermissionMode(mode: string): Promise<void>;
|
|
43
47
|
setCwd(cwd: string): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ToolEventMin } from '../../done-evidence.js';
|
|
2
|
+
import type { AgentConfig } from '../../types.js';
|
|
3
|
+
import type { Message } from '../../types.js';
|
|
4
|
+
export declare function resolveMaxContinuations(): number;
|
|
5
|
+
export interface BeforeTurnEndContext {
|
|
6
|
+
readonly config: AgentConfig;
|
|
7
|
+
readonly sessionId: string;
|
|
8
|
+
readonly signal: AbortSignal;
|
|
9
|
+
readonly messages: readonly Message[];
|
|
10
|
+
readonly assistantText?: string;
|
|
11
|
+
readonly toolEvents: readonly ToolEventMin[];
|
|
12
|
+
readonly surface?: string;
|
|
13
|
+
readonly hasNextTurn: boolean;
|
|
14
|
+
readonly wiring: BeforeTurnEndWiring | undefined;
|
|
15
|
+
readonly continuation: number;
|
|
16
|
+
}
|
|
17
|
+
export interface BeforeTurnEndWiring {
|
|
18
|
+
onStopInjectContext?: (text: string) => void;
|
|
19
|
+
onStopBlocked?: (reason: string | undefined) => void;
|
|
20
|
+
onStopTimeout?: () => void;
|
|
21
|
+
}
|
|
22
|
+
export interface BeforeTurnEndResult {
|
|
23
|
+
readonly continueWith?: string;
|
|
24
|
+
readonly nextContinuation: number;
|
|
25
|
+
}
|
|
26
|
+
export declare function runBeforeTurnEnd(ctx: BeforeTurnEndContext): Promise<BeforeTurnEndResult>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ProviderQuery } from '../provider.js';
|
|
2
|
+
import type { AgentConfig } from '../types.js';
|
|
3
|
+
import type { StopWiring } from '../types/session-types.js';
|
|
4
|
+
import type { Message } from '../types.js';
|
|
5
|
+
import type { ToolEventMin } from '../done-evidence.js';
|
|
6
|
+
export interface StopHookWiringDeps {
|
|
7
|
+
readonly getConfig: () => AgentConfig;
|
|
8
|
+
readonly getSessionId: () => string | undefined;
|
|
9
|
+
readonly getSignal: () => AbortSignal;
|
|
10
|
+
readonly getConversationHistory: () => readonly Message[];
|
|
11
|
+
readonly getActiveTurnToolEvents: () => readonly ToolEventMin[];
|
|
12
|
+
readonly getStopWiring: () => StopWiring | undefined;
|
|
13
|
+
}
|
|
14
|
+
export declare function buildBeforeTurnEnd(deps: StopHookWiringDeps): (continuation: number, assistantText?: string) => Promise<{
|
|
15
|
+
continueWith?: string;
|
|
16
|
+
} | undefined>;
|
|
17
|
+
export declare function applyStopHookWiring(wiring: StopWiring, getConfig: () => AgentConfig, getSessionId: () => string | undefined, getSignal: () => AbortSignal, getMessages: () => readonly Message[], getToolEvents: () => readonly ToolEventMin[], providerQuery: ProviderQuery): void;
|
|
@@ -7,6 +7,7 @@ import type { SessionStateManager } from './session-state.js';
|
|
|
7
7
|
import type { AgentConfig, OutputEvent, ResponseMetadata, SessionState } from '../types.js';
|
|
8
8
|
import type { ProviderQuery, ProviderEvent } from '../provider.js';
|
|
9
9
|
import type { Message } from '../types.js';
|
|
10
|
+
import type { ToolEventMin } from '../done-evidence.js';
|
|
10
11
|
import type { StopWiring } from '../types/session-types.js';
|
|
11
12
|
export interface TurnRunnerDeps {
|
|
12
13
|
getConfig: () => AgentConfig;
|
|
@@ -36,7 +37,9 @@ export interface TurnRunnerDeps {
|
|
|
36
37
|
}
|
|
37
38
|
export declare class TurnStreamRunner {
|
|
38
39
|
private readonly deps;
|
|
40
|
+
private _activeDeps;
|
|
39
41
|
constructor(deps: TurnRunnerDeps);
|
|
42
|
+
getActiveTurnToolEvents(): readonly ToolEventMin[];
|
|
40
43
|
assertCanSend(): void;
|
|
41
44
|
summarize(blocks: ContentBlockParam[]): string;
|
|
42
45
|
withPendingContext(content: string | ContentBlockParam[]): string | ContentBlockParam[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare const REINFORCED_LABEL = "reinforced";
|
|
2
2
|
export declare const WEAKENED_LABEL = "partially weakened";
|
|
3
3
|
export declare function stripTrailingAnnotation(description: string, label: typeof REINFORCED_LABEL | typeof WEAKENED_LABEL): string;
|
|
4
|
+
export declare function stripAnnotationLabelPlusSpace(description: string, label: typeof REINFORCED_LABEL | typeof WEAKENED_LABEL): string;
|
|
@@ -30,11 +30,16 @@ export interface ForkSubagentOptions<T = unknown> {
|
|
|
30
30
|
phaseRole?: PhaseRole;
|
|
31
31
|
nestedAgentAllowlist?: readonly string[];
|
|
32
32
|
}
|
|
33
|
+
export interface ParentCredential {
|
|
34
|
+
key: string | (() => string | undefined);
|
|
35
|
+
sourceModel: string;
|
|
36
|
+
}
|
|
33
37
|
export interface SubagentManagerOptions {
|
|
34
38
|
canUseTool?: CanUseTool;
|
|
35
39
|
parentAbortSignal?: AbortSignal;
|
|
36
40
|
hookRegistry?: HookRegistry;
|
|
37
41
|
progressSink?: SubagentProgressSink;
|
|
42
|
+
parentCredential?: ParentCredential;
|
|
38
43
|
apiKey?: string | (() => string | undefined);
|
|
39
44
|
baseUrl?: string;
|
|
40
45
|
parentModel?: string;
|
|
@@ -48,3 +53,7 @@ export interface SubagentManagerOptions {
|
|
|
48
53
|
outputEventSink?: (event: OutputEvent) => void;
|
|
49
54
|
delegationBudget?: import('../tools/delegation-budget.js').DelegationBudget;
|
|
50
55
|
}
|
|
56
|
+
export declare function resolveParentCredential(options: SubagentManagerOptions): {
|
|
57
|
+
effectiveKey: string | (() => string | undefined) | undefined;
|
|
58
|
+
effectiveModel: string | undefined;
|
|
59
|
+
};
|
package/dist/agent/subagent.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { SubagentStatus, SubagentResult, SubagentTrace } from './subagent/r
|
|
|
7
7
|
import { CompletedCache } from './subagent/completed-cache.js';
|
|
8
8
|
export type { SubagentStatus, SubagentResult, SubagentTrace, SubagentHandle };
|
|
9
9
|
import { SUBAGENT_DEFAULT_IDLE_TIMEOUT_MS, SUBAGENT_DRAIN_TIMEOUT_MS, resolveSubagentIdleTimeoutMs } from './subagent/constants.js';
|
|
10
|
-
import type
|
|
10
|
+
import { type ForkParent, type ForkSubagentOptions, type SubagentManagerOptions } from './subagent/fork-types.js';
|
|
11
11
|
export { DENY_ELICITATION, SUBAGENT_DEFAULT_MAX_TOOL_USE_ITERATIONS, SUBAGENT_DEFAULT_TIMEOUT_MS, SUBAGENT_BACKGROUND_TIMEOUT_MS, resolveSubagentTimeoutMs, } from './subagent/constants.js';
|
|
12
12
|
export { SUBAGENT_DEFAULT_IDLE_TIMEOUT_MS, SUBAGENT_DRAIN_TIMEOUT_MS, resolveSubagentIdleTimeoutMs, };
|
|
13
13
|
export type { ForkParent, ForkSubagentOptions, SubagentManagerOptions };
|
|
@@ -769,6 +769,8 @@ export declare const TraceEventInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
769
769
|
usage_notice: "usage_notice";
|
|
770
770
|
tool_degraded: "tool_degraded";
|
|
771
771
|
stop_inject_dropped: "stop_inject_dropped";
|
|
772
|
+
stop_hook_continuation: "stop_hook_continuation";
|
|
773
|
+
stop_hook_cap_reached: "stop_hook_cap_reached";
|
|
772
774
|
}>;
|
|
773
775
|
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
774
776
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
@@ -1174,6 +1176,8 @@ export declare const TraceEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1174
1176
|
usage_notice: "usage_notice";
|
|
1175
1177
|
tool_degraded: "tool_degraded";
|
|
1176
1178
|
stop_inject_dropped: "stop_inject_dropped";
|
|
1179
|
+
stop_hook_continuation: "stop_hook_continuation";
|
|
1180
|
+
stop_hook_cap_reached: "stop_hook_cap_reached";
|
|
1177
1181
|
}>;
|
|
1178
1182
|
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
1179
1183
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
@@ -33,6 +33,8 @@ export declare const SessionPhaseNameSchema: z.ZodEnum<{
|
|
|
33
33
|
usage_notice: "usage_notice";
|
|
34
34
|
tool_degraded: "tool_degraded";
|
|
35
35
|
stop_inject_dropped: "stop_inject_dropped";
|
|
36
|
+
stop_hook_continuation: "stop_hook_continuation";
|
|
37
|
+
stop_hook_cap_reached: "stop_hook_cap_reached";
|
|
36
38
|
}>;
|
|
37
39
|
export declare const SessionPhasePayloadSchema: z.ZodObject<{
|
|
38
40
|
phase: z.ZodEnum<{
|
|
@@ -69,6 +71,8 @@ export declare const SessionPhasePayloadSchema: z.ZodObject<{
|
|
|
69
71
|
usage_notice: "usage_notice";
|
|
70
72
|
tool_degraded: "tool_degraded";
|
|
71
73
|
stop_inject_dropped: "stop_inject_dropped";
|
|
74
|
+
stop_hook_continuation: "stop_hook_continuation";
|
|
75
|
+
stop_hook_cap_reached: "stop_hook_cap_reached";
|
|
72
76
|
}>;
|
|
73
77
|
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
74
78
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
@@ -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' | 'usage_notice' | 'tool_degraded' | 'stop_inject_dropped';
|
|
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' | 'usage_notice' | 'tool_degraded' | 'stop_inject_dropped' | 'stop_hook_continuation' | 'stop_hook_cap_reached';
|
|
2
2
|
export interface SessionPhasePayload {
|
|
3
3
|
phase: SessionPhaseName;
|
|
4
4
|
durationMs?: number;
|