agent-afk 5.140.0 → 5.141.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.
- package/dist/agent/background-registry.cap.d.ts +4 -0
- package/dist/agent/background-registry.d.ts +6 -15
- package/dist/agent/background-registry.telemetry.d.ts +2 -0
- package/dist/agent/background-registry.transcript.d.ts +2 -0
- package/dist/agent/background-registry.types.d.ts +14 -0
- package/dist/agent/tools/dispatcher.subagent-tools.d.ts +8 -0
- package/dist/agent/tools/schemas.background-cancel.d.ts +2 -0
- package/dist/agent/tools/schemas.orchestration.d.ts +1 -0
- package/dist/agent/tools/subagent/background-cancel.d.ts +3 -0
- package/dist/agent/tools/subagent-executor.d.ts +2 -0
- package/dist/agent/trace/background-agent-payloads.d.ts +43 -0
- package/dist/agent/trace/background-agent-schema.d.ts +12 -0
- package/dist/agent/trace/events.d.ts +20 -22
- package/dist/agent/trace/types.d.ts +2 -41
- package/dist/cli.mjs +541 -541
- package/dist/index.mjs +188 -188
- package/dist/telegram.mjs +259 -259
- package/package.json +1 -1
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
import { EventEmitter } from 'node:events';
|
|
2
2
|
import type { SubagentHandle, SubagentResult } from './subagent.js';
|
|
3
3
|
import type { TraceSink } from './trace/index.js';
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
readonly label: string;
|
|
9
|
-
readonly model: string;
|
|
10
|
-
readonly startedAt: number;
|
|
11
|
-
readonly status: BackgroundJobStatus;
|
|
12
|
-
readonly result?: SubagentResult;
|
|
13
|
-
readonly endedAt?: number;
|
|
14
|
-
}
|
|
15
|
-
export declare const MAX_TRANSCRIPT_TAIL_BYTES = 4096;
|
|
4
|
+
import type { BackgroundJob, BackgroundJobProvenance } from './background-registry.types.js';
|
|
5
|
+
export { BackgroundJobCapError } from './background-registry.cap.js';
|
|
6
|
+
export { MAX_TRANSCRIPT_TAIL_BYTES } from './background-registry.transcript.js';
|
|
7
|
+
export type { BackgroundJob, BackgroundJobProvenance, BackgroundJobStatus } from './background-registry.types.js';
|
|
16
8
|
export interface BackgroundRegistryOptions {
|
|
17
9
|
traceWriter?: TraceSink | undefined;
|
|
18
10
|
maxConcurrentJobs?: number;
|
|
@@ -21,12 +13,10 @@ export interface RegisterArgs {
|
|
|
21
13
|
handle: SubagentHandle;
|
|
22
14
|
prompt: string;
|
|
23
15
|
model: string;
|
|
16
|
+
provenance?: BackgroundJobProvenance;
|
|
24
17
|
parentSessionId?: string | undefined;
|
|
25
18
|
onCleanup?: () => Promise<void>;
|
|
26
19
|
}
|
|
27
|
-
export declare class BackgroundJobCapError extends Error {
|
|
28
|
-
constructor(running: number, cap: number);
|
|
29
|
-
}
|
|
30
20
|
export interface BackgroundRegistryEvents {
|
|
31
21
|
started: [job: BackgroundJob];
|
|
32
22
|
settled: [job: BackgroundJob];
|
|
@@ -49,6 +39,7 @@ export declare class BackgroundAgentRegistry extends EventEmitter<BackgroundRegi
|
|
|
49
39
|
join(jobId: string): Promise<SubagentResult>;
|
|
50
40
|
markDelivered(jobId: string): void;
|
|
51
41
|
cancelJob(jobId: string): Promise<boolean>;
|
|
42
|
+
cancelModelJob(jobId: string, reason: string): Promise<boolean>;
|
|
52
43
|
cancelAll(): Promise<void>;
|
|
53
44
|
appendTranscript(jobId: string, chunk: string): void;
|
|
54
45
|
getTranscript(jobId: string): string | undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SubagentResult } from './subagent.js';
|
|
2
|
+
export type BackgroundJobStatus = 'running' | 'completed' | 'failed' | 'cancelled';
|
|
3
|
+
export type BackgroundJobProvenance = 'model' | 'user';
|
|
4
|
+
export interface BackgroundJob {
|
|
5
|
+
readonly jobId: string;
|
|
6
|
+
readonly provenance: BackgroundJobProvenance;
|
|
7
|
+
readonly subagentId: string;
|
|
8
|
+
readonly label: string;
|
|
9
|
+
readonly model: string;
|
|
10
|
+
readonly startedAt: number;
|
|
11
|
+
readonly status: BackgroundJobStatus;
|
|
12
|
+
readonly result?: SubagentResult;
|
|
13
|
+
readonly endedAt?: number;
|
|
14
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SubagentExecutor } from './subagent-executor.js';
|
|
2
|
+
import type { ToolCall, ToolResult } from './types.js';
|
|
3
|
+
export declare function isSubagentProviderTool(name: string): boolean;
|
|
4
|
+
export interface SubagentProviderToolOutcome {
|
|
5
|
+
result: ToolResult;
|
|
6
|
+
thrownMessage?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function executeSubagentProviderTool(executor: SubagentExecutor | undefined, call: ToolCall): Promise<SubagentProviderToolOutcome>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { cancelBackgroundJobTool } from './schemas.background-cancel.js';
|
|
@@ -62,7 +62,9 @@ export declare class SubagentExecutor implements SubagentControl {
|
|
|
62
62
|
notifyWaveStart(calls: ReadonlyArray<ToolCall>, sessionId: string, traceLabel: string | null): void;
|
|
63
63
|
notifyWaveEnd(): void;
|
|
64
64
|
private updateCurrentWaveUnit;
|
|
65
|
+
supportsBackgroundJobs(): boolean;
|
|
65
66
|
hasPromotableForeground(): boolean;
|
|
67
|
+
cancelBackgroundJob(call: ToolCall): Promise<ToolResult>;
|
|
66
68
|
hasActiveForeground(): boolean;
|
|
67
69
|
private cancelGeneration;
|
|
68
70
|
cancelActiveForeground(): Promise<number>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface BackgroundAgentStartedPayload {
|
|
2
|
+
transition: 'started';
|
|
3
|
+
jobId: string;
|
|
4
|
+
subagentId: string;
|
|
5
|
+
label: string;
|
|
6
|
+
model: string;
|
|
7
|
+
}
|
|
8
|
+
export interface BackgroundAgentCompletedPayload {
|
|
9
|
+
transition: 'completed';
|
|
10
|
+
jobId: string;
|
|
11
|
+
subagentId: string;
|
|
12
|
+
durationMs: number;
|
|
13
|
+
outputBytes: number;
|
|
14
|
+
}
|
|
15
|
+
export interface BackgroundAgentFailedPayload {
|
|
16
|
+
transition: 'failed';
|
|
17
|
+
jobId: string;
|
|
18
|
+
subagentId: string;
|
|
19
|
+
durationMs: number;
|
|
20
|
+
errorClass: string;
|
|
21
|
+
errorMessage: string;
|
|
22
|
+
}
|
|
23
|
+
export interface BackgroundAgentCancelledPayload {
|
|
24
|
+
transition: 'cancelled';
|
|
25
|
+
jobId: string;
|
|
26
|
+
subagentId: string;
|
|
27
|
+
source: 'explicit' | 'cascade';
|
|
28
|
+
cancelledBy?: 'model';
|
|
29
|
+
reason?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface BackgroundAgentJoinedPayload {
|
|
32
|
+
transition: 'joined';
|
|
33
|
+
jobId: string;
|
|
34
|
+
subagentId: string;
|
|
35
|
+
jobStatus: 'completed' | 'failed' | 'cancelled';
|
|
36
|
+
}
|
|
37
|
+
export interface BackgroundAgentDeliveredPayload {
|
|
38
|
+
transition: 'delivered';
|
|
39
|
+
jobId: string;
|
|
40
|
+
subagentId: string;
|
|
41
|
+
jobStatus: 'completed' | 'failed' | 'cancelled';
|
|
42
|
+
}
|
|
43
|
+
export type BackgroundAgentPayload = BackgroundAgentStartedPayload | BackgroundAgentCompletedPayload | BackgroundAgentFailedPayload | BackgroundAgentCancelledPayload | BackgroundAgentJoinedPayload | BackgroundAgentDeliveredPayload;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const BackgroundAgentCancelledPayloadSchema: z.ZodObject<{
|
|
3
|
+
transition: z.ZodLiteral<"cancelled">;
|
|
4
|
+
jobId: z.ZodString;
|
|
5
|
+
subagentId: z.ZodString;
|
|
6
|
+
source: z.ZodEnum<{
|
|
7
|
+
explicit: "explicit";
|
|
8
|
+
cascade: "cascade";
|
|
9
|
+
}>;
|
|
10
|
+
cancelledBy: z.ZodOptional<z.ZodLiteral<"model">>;
|
|
11
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, z.core.$strip>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
export { BackgroundAgentCancelledPayloadSchema } from './background-agent-schema.js';
|
|
2
3
|
export declare const ToolCallStartedPayloadSchema: z.ZodObject<{
|
|
3
4
|
phase: z.ZodLiteral<"started">;
|
|
4
5
|
toolUseId: z.ZodString;
|
|
@@ -159,8 +160,8 @@ export declare const SubagentCancelledPayloadSchema: z.ZodObject<{
|
|
|
159
160
|
transition: z.ZodLiteral<"cancelled">;
|
|
160
161
|
subagentId: z.ZodString;
|
|
161
162
|
source: z.ZodEnum<{
|
|
162
|
-
cascade: "cascade";
|
|
163
163
|
explicit: "explicit";
|
|
164
|
+
cascade: "cascade";
|
|
164
165
|
}>;
|
|
165
166
|
timeout: z.ZodOptional<z.ZodBoolean>;
|
|
166
167
|
}, z.core.$strip>;
|
|
@@ -204,8 +205,8 @@ export declare const SubagentLifecyclePayloadSchema: z.ZodDiscriminatedUnion<[z.
|
|
|
204
205
|
transition: z.ZodLiteral<"cancelled">;
|
|
205
206
|
subagentId: z.ZodString;
|
|
206
207
|
source: z.ZodEnum<{
|
|
207
|
-
cascade: "cascade";
|
|
208
208
|
explicit: "explicit";
|
|
209
|
+
cascade: "cascade";
|
|
209
210
|
}>;
|
|
210
211
|
timeout: z.ZodOptional<z.ZodBoolean>;
|
|
211
212
|
}, z.core.$strip>], "transition">;
|
|
@@ -231,15 +232,6 @@ export declare const BackgroundAgentFailedPayloadSchema: z.ZodObject<{
|
|
|
231
232
|
errorClass: z.ZodString;
|
|
232
233
|
errorMessage: z.ZodString;
|
|
233
234
|
}, z.core.$strip>;
|
|
234
|
-
export declare const BackgroundAgentCancelledPayloadSchema: z.ZodObject<{
|
|
235
|
-
transition: z.ZodLiteral<"cancelled">;
|
|
236
|
-
jobId: z.ZodString;
|
|
237
|
-
subagentId: z.ZodString;
|
|
238
|
-
source: z.ZodEnum<{
|
|
239
|
-
cascade: "cascade";
|
|
240
|
-
explicit: "explicit";
|
|
241
|
-
}>;
|
|
242
|
-
}, z.core.$strip>;
|
|
243
235
|
export declare const BackgroundAgentJoinedPayloadSchema: z.ZodObject<{
|
|
244
236
|
transition: z.ZodLiteral<"joined">;
|
|
245
237
|
jobId: z.ZodString;
|
|
@@ -284,9 +276,11 @@ export declare const BackgroundAgentPayloadSchema: z.ZodDiscriminatedUnion<[z.Zo
|
|
|
284
276
|
jobId: z.ZodString;
|
|
285
277
|
subagentId: z.ZodString;
|
|
286
278
|
source: z.ZodEnum<{
|
|
287
|
-
cascade: "cascade";
|
|
288
279
|
explicit: "explicit";
|
|
280
|
+
cascade: "cascade";
|
|
289
281
|
}>;
|
|
282
|
+
cancelledBy: z.ZodOptional<z.ZodLiteral<"model">>;
|
|
283
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
290
284
|
}, z.core.$strip>, z.ZodObject<{
|
|
291
285
|
transition: z.ZodLiteral<"joined">;
|
|
292
286
|
jobId: z.ZodString;
|
|
@@ -313,17 +307,17 @@ export declare const BudgetPayloadSchema: z.ZodObject<{
|
|
|
313
307
|
lastTurnCostUsd: z.ZodNumber;
|
|
314
308
|
}, z.core.$strip>;
|
|
315
309
|
export declare const AbortOriginSchema: z.ZodEnum<{
|
|
310
|
+
cascade: "cascade";
|
|
316
311
|
budget: "budget";
|
|
317
312
|
timeout: "timeout";
|
|
318
|
-
cascade: "cascade";
|
|
319
313
|
user_signal: "user_signal";
|
|
320
314
|
hook_block: "hook_block";
|
|
321
315
|
}>;
|
|
322
316
|
export declare const AbortPayloadSchema: z.ZodObject<{
|
|
323
317
|
origin: z.ZodEnum<{
|
|
318
|
+
cascade: "cascade";
|
|
324
319
|
budget: "budget";
|
|
325
320
|
timeout: "timeout";
|
|
326
|
-
cascade: "cascade";
|
|
327
321
|
user_signal: "user_signal";
|
|
328
322
|
hook_block: "hook_block";
|
|
329
323
|
}>;
|
|
@@ -568,8 +562,8 @@ export declare const SessionPhasePayloadSchema: z.ZodObject<{
|
|
|
568
562
|
export declare const SessionSealedPayloadSchema: z.ZodObject<{
|
|
569
563
|
status: z.ZodEnum<{
|
|
570
564
|
failed: "failed";
|
|
571
|
-
succeeded: "succeeded";
|
|
572
565
|
cancelled: "cancelled";
|
|
566
|
+
succeeded: "succeeded";
|
|
573
567
|
}>;
|
|
574
568
|
finalCostUsd: z.ZodNumber;
|
|
575
569
|
finalTurnCount: z.ZodNumber;
|
|
@@ -691,8 +685,8 @@ export declare const TraceEventInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
691
685
|
transition: z.ZodLiteral<"cancelled">;
|
|
692
686
|
subagentId: z.ZodString;
|
|
693
687
|
source: z.ZodEnum<{
|
|
694
|
-
cascade: "cascade";
|
|
695
688
|
explicit: "explicit";
|
|
689
|
+
cascade: "cascade";
|
|
696
690
|
}>;
|
|
697
691
|
timeout: z.ZodOptional<z.ZodBoolean>;
|
|
698
692
|
}, z.core.$strip>], "transition">;
|
|
@@ -722,9 +716,11 @@ export declare const TraceEventInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
722
716
|
jobId: z.ZodString;
|
|
723
717
|
subagentId: z.ZodString;
|
|
724
718
|
source: z.ZodEnum<{
|
|
725
|
-
cascade: "cascade";
|
|
726
719
|
explicit: "explicit";
|
|
720
|
+
cascade: "cascade";
|
|
727
721
|
}>;
|
|
722
|
+
cancelledBy: z.ZodOptional<z.ZodLiteral<"model">>;
|
|
723
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
728
724
|
}, z.core.$strip>, z.ZodObject<{
|
|
729
725
|
transition: z.ZodLiteral<"joined">;
|
|
730
726
|
jobId: z.ZodString;
|
|
@@ -756,9 +752,9 @@ export declare const TraceEventInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
756
752
|
kind: z.ZodLiteral<"abort">;
|
|
757
753
|
payload: z.ZodObject<{
|
|
758
754
|
origin: z.ZodEnum<{
|
|
755
|
+
cascade: "cascade";
|
|
759
756
|
budget: "budget";
|
|
760
757
|
timeout: "timeout";
|
|
761
|
-
cascade: "cascade";
|
|
762
758
|
user_signal: "user_signal";
|
|
763
759
|
hook_block: "hook_block";
|
|
764
760
|
}>;
|
|
@@ -1031,8 +1027,8 @@ export declare const TraceEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1031
1027
|
transition: z.ZodLiteral<"cancelled">;
|
|
1032
1028
|
subagentId: z.ZodString;
|
|
1033
1029
|
source: z.ZodEnum<{
|
|
1034
|
-
cascade: "cascade";
|
|
1035
1030
|
explicit: "explicit";
|
|
1031
|
+
cascade: "cascade";
|
|
1036
1032
|
}>;
|
|
1037
1033
|
timeout: z.ZodOptional<z.ZodBoolean>;
|
|
1038
1034
|
}, z.core.$strip>], "transition">;
|
|
@@ -1064,9 +1060,11 @@ export declare const TraceEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1064
1060
|
jobId: z.ZodString;
|
|
1065
1061
|
subagentId: z.ZodString;
|
|
1066
1062
|
source: z.ZodEnum<{
|
|
1067
|
-
cascade: "cascade";
|
|
1068
1063
|
explicit: "explicit";
|
|
1064
|
+
cascade: "cascade";
|
|
1069
1065
|
}>;
|
|
1066
|
+
cancelledBy: z.ZodOptional<z.ZodLiteral<"model">>;
|
|
1067
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
1070
1068
|
}, z.core.$strip>, z.ZodObject<{
|
|
1071
1069
|
transition: z.ZodLiteral<"joined">;
|
|
1072
1070
|
jobId: z.ZodString;
|
|
@@ -1102,9 +1100,9 @@ export declare const TraceEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1102
1100
|
kind: z.ZodLiteral<"abort">;
|
|
1103
1101
|
payload: z.ZodObject<{
|
|
1104
1102
|
origin: z.ZodEnum<{
|
|
1103
|
+
cascade: "cascade";
|
|
1105
1104
|
budget: "budget";
|
|
1106
1105
|
timeout: "timeout";
|
|
1107
|
-
cascade: "cascade";
|
|
1108
1106
|
user_signal: "user_signal";
|
|
1109
1107
|
hook_block: "hook_block";
|
|
1110
1108
|
}>;
|
|
@@ -1286,8 +1284,8 @@ export declare const TraceEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1286
1284
|
payload: z.ZodObject<{
|
|
1287
1285
|
status: z.ZodEnum<{
|
|
1288
1286
|
failed: "failed";
|
|
1289
|
-
succeeded: "succeeded";
|
|
1290
1287
|
cancelled: "cancelled";
|
|
1288
|
+
succeeded: "succeeded";
|
|
1291
1289
|
}>;
|
|
1292
1290
|
finalCostUsd: z.ZodNumber;
|
|
1293
1291
|
finalTurnCount: z.ZodNumber;
|
|
@@ -74,47 +74,8 @@ export interface SubagentCancelledPayload {
|
|
|
74
74
|
timeout?: boolean;
|
|
75
75
|
}
|
|
76
76
|
export type SubagentLifecyclePayload = SubagentStartedPayload | SubagentSucceededPayload | SubagentFailedPayload | SubagentCancelledPayload;
|
|
77
|
-
export
|
|
78
|
-
|
|
79
|
-
jobId: string;
|
|
80
|
-
subagentId: string;
|
|
81
|
-
label: string;
|
|
82
|
-
model: string;
|
|
83
|
-
}
|
|
84
|
-
export interface BackgroundAgentCompletedPayload {
|
|
85
|
-
transition: 'completed';
|
|
86
|
-
jobId: string;
|
|
87
|
-
subagentId: string;
|
|
88
|
-
durationMs: number;
|
|
89
|
-
outputBytes: number;
|
|
90
|
-
}
|
|
91
|
-
export interface BackgroundAgentFailedPayload {
|
|
92
|
-
transition: 'failed';
|
|
93
|
-
jobId: string;
|
|
94
|
-
subagentId: string;
|
|
95
|
-
durationMs: number;
|
|
96
|
-
errorClass: string;
|
|
97
|
-
errorMessage: string;
|
|
98
|
-
}
|
|
99
|
-
export interface BackgroundAgentCancelledPayload {
|
|
100
|
-
transition: 'cancelled';
|
|
101
|
-
jobId: string;
|
|
102
|
-
subagentId: string;
|
|
103
|
-
source: 'explicit' | 'cascade';
|
|
104
|
-
}
|
|
105
|
-
export interface BackgroundAgentJoinedPayload {
|
|
106
|
-
transition: 'joined';
|
|
107
|
-
jobId: string;
|
|
108
|
-
subagentId: string;
|
|
109
|
-
jobStatus: 'completed' | 'failed' | 'cancelled';
|
|
110
|
-
}
|
|
111
|
-
export interface BackgroundAgentDeliveredPayload {
|
|
112
|
-
transition: 'delivered';
|
|
113
|
-
jobId: string;
|
|
114
|
-
subagentId: string;
|
|
115
|
-
jobStatus: 'completed' | 'failed' | 'cancelled';
|
|
116
|
-
}
|
|
117
|
-
export type BackgroundAgentPayload = BackgroundAgentStartedPayload | BackgroundAgentCompletedPayload | BackgroundAgentFailedPayload | BackgroundAgentCancelledPayload | BackgroundAgentJoinedPayload | BackgroundAgentDeliveredPayload;
|
|
77
|
+
export type { BackgroundAgentStartedPayload, BackgroundAgentCompletedPayload, BackgroundAgentFailedPayload, BackgroundAgentCancelledPayload, BackgroundAgentJoinedPayload, BackgroundAgentDeliveredPayload, BackgroundAgentPayload, } from './background-agent-payloads.js';
|
|
78
|
+
import type { BackgroundAgentPayload } from './background-agent-payloads.js';
|
|
118
79
|
export interface BudgetPayload {
|
|
119
80
|
kind: 'monetary';
|
|
120
81
|
runningCostUsd: number;
|