agent-afk 5.320.5 → 5.321.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/provider.d.ts +8 -0
- package/dist/agent/session/accounting-accumulator.d.ts +6 -6
- package/dist/agent/session/agent-session.d.ts +1 -6
- package/dist/agent/session/agent-session.executors.d.ts +1 -0
- package/dist/agent/session/billing-rollup.d.ts +18 -0
- package/dist/agent/session/closure-emitter.d.ts +3 -0
- package/dist/agent/session/manager-shutdown-config.d.ts +7 -0
- package/dist/agent/session/session-executors.d.ts +2 -6
- package/dist/agent/subagent/capped-handoff.d.ts +2 -1
- package/dist/agent/subagent/handle.billing.d.ts +13 -0
- package/dist/agent/subagent/handle.d.ts +8 -0
- package/dist/agent/subagent/handle.run-success.d.ts +2 -1
- package/dist/agent/subagent/handle.streaming.d.ts +2 -1
- package/dist/agent/subagent/result.d.ts +3 -0
- package/dist/agent/subagent.d.ts +3 -0
- package/dist/agent/tools/compose-executor.d.ts +5 -0
- package/dist/agent/trace/events.billing.d.ts +66 -0
- package/dist/agent/trace/events.browser.d.ts +1 -1
- package/dist/agent/trace/events.d.ts +110 -8
- package/dist/agent/trace/events.subagent-lifecycle.d.ts +45 -3
- package/dist/agent/trace/pending-writes.d.ts +1 -1
- package/dist/agent/trace/types.d.ts +9 -3
- package/dist/agent/types/config-types.d.ts +1 -0
- package/dist/agent/usage.billing.d.ts +27 -0
- package/dist/cli/commands/interactive/bootstrap-session-builder.d.ts +2 -0
- package/dist/cli/commands/trace-lifecycle-render.d.ts +2 -0
- package/dist/cli.mjs +399 -399
- package/dist/index.mjs +193 -193
- package/dist/telegram/wire-telegram-executors.d.ts +1 -0
- package/dist/telegram.mjs +208 -208
- package/dist/web-server/session-owner.wiring.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const ToolFailureClassSchema: z.ZodEnum<{
|
|
3
|
-
budget: "budget";
|
|
4
3
|
abort: "abort";
|
|
4
|
+
budget: "budget";
|
|
5
5
|
"policy-refusal": "policy-refusal";
|
|
6
6
|
timeout: "timeout";
|
|
7
7
|
"permission-denied": "permission-denied";
|
|
@@ -25,6 +25,13 @@ export declare const SubagentStartedPayloadSchema: z.ZodObject<{
|
|
|
25
25
|
maxToolUseIterations: z.ZodOptional<z.ZodNumber>;
|
|
26
26
|
}, z.core.$strip>;
|
|
27
27
|
export declare const SubagentSucceededPayloadSchema: z.ZodObject<{
|
|
28
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
29
|
+
tokens: z.ZodOptional<z.ZodObject<{
|
|
30
|
+
uncachedInput: z.ZodNumber;
|
|
31
|
+
cacheRead: z.ZodNumber;
|
|
32
|
+
cacheWrite: z.ZodNumber;
|
|
33
|
+
output: z.ZodNumber;
|
|
34
|
+
}, z.core.$strip>>;
|
|
28
35
|
transition: z.ZodLiteral<"succeeded">;
|
|
29
36
|
subagentId: z.ZodString;
|
|
30
37
|
durationMs: z.ZodNumber;
|
|
@@ -34,14 +41,21 @@ export declare const SubagentSucceededPayloadSchema: z.ZodObject<{
|
|
|
34
41
|
stopReason: z.ZodOptional<z.ZodString>;
|
|
35
42
|
}, z.core.$strip>;
|
|
36
43
|
export declare const SubagentFailedPayloadSchema: z.ZodObject<{
|
|
44
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
45
|
+
tokens: z.ZodOptional<z.ZodObject<{
|
|
46
|
+
uncachedInput: z.ZodNumber;
|
|
47
|
+
cacheRead: z.ZodNumber;
|
|
48
|
+
cacheWrite: z.ZodNumber;
|
|
49
|
+
output: z.ZodNumber;
|
|
50
|
+
}, z.core.$strip>>;
|
|
37
51
|
transition: z.ZodLiteral<"failed">;
|
|
38
52
|
subagentId: z.ZodString;
|
|
39
53
|
errorClass: z.ZodString;
|
|
40
54
|
errorMessage: z.ZodString;
|
|
41
55
|
partialOutputBytes: z.ZodNumber;
|
|
42
56
|
failureClass: z.ZodOptional<z.ZodEnum<{
|
|
43
|
-
budget: "budget";
|
|
44
57
|
abort: "abort";
|
|
58
|
+
budget: "budget";
|
|
45
59
|
"policy-refusal": "policy-refusal";
|
|
46
60
|
timeout: "timeout";
|
|
47
61
|
"permission-denied": "permission-denied";
|
|
@@ -54,6 +68,13 @@ export declare const SubagentFailedPayloadSchema: z.ZodObject<{
|
|
|
54
68
|
}>>;
|
|
55
69
|
}, z.core.$strip>;
|
|
56
70
|
export declare const SubagentCancelledPayloadSchema: z.ZodObject<{
|
|
71
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
72
|
+
tokens: z.ZodOptional<z.ZodObject<{
|
|
73
|
+
uncachedInput: z.ZodNumber;
|
|
74
|
+
cacheRead: z.ZodNumber;
|
|
75
|
+
cacheWrite: z.ZodNumber;
|
|
76
|
+
output: z.ZodNumber;
|
|
77
|
+
}, z.core.$strip>>;
|
|
57
78
|
transition: z.ZodLiteral<"cancelled">;
|
|
58
79
|
subagentId: z.ZodString;
|
|
59
80
|
source: z.ZodEnum<{
|
|
@@ -74,6 +95,13 @@ export declare const SubagentLifecyclePayloadSchema: z.ZodDiscriminatedUnion<[z.
|
|
|
74
95
|
resolvedAgentType: z.ZodOptional<z.ZodString>;
|
|
75
96
|
maxToolUseIterations: z.ZodOptional<z.ZodNumber>;
|
|
76
97
|
}, z.core.$strip>, z.ZodObject<{
|
|
98
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
99
|
+
tokens: z.ZodOptional<z.ZodObject<{
|
|
100
|
+
uncachedInput: z.ZodNumber;
|
|
101
|
+
cacheRead: z.ZodNumber;
|
|
102
|
+
cacheWrite: z.ZodNumber;
|
|
103
|
+
output: z.ZodNumber;
|
|
104
|
+
}, z.core.$strip>>;
|
|
77
105
|
transition: z.ZodLiteral<"succeeded">;
|
|
78
106
|
subagentId: z.ZodString;
|
|
79
107
|
durationMs: z.ZodNumber;
|
|
@@ -82,14 +110,21 @@ export declare const SubagentLifecyclePayloadSchema: z.ZodDiscriminatedUnion<[z.
|
|
|
82
110
|
outputBytes: z.ZodNumber;
|
|
83
111
|
stopReason: z.ZodOptional<z.ZodString>;
|
|
84
112
|
}, z.core.$strip>, z.ZodObject<{
|
|
113
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
114
|
+
tokens: z.ZodOptional<z.ZodObject<{
|
|
115
|
+
uncachedInput: z.ZodNumber;
|
|
116
|
+
cacheRead: z.ZodNumber;
|
|
117
|
+
cacheWrite: z.ZodNumber;
|
|
118
|
+
output: z.ZodNumber;
|
|
119
|
+
}, z.core.$strip>>;
|
|
85
120
|
transition: z.ZodLiteral<"failed">;
|
|
86
121
|
subagentId: z.ZodString;
|
|
87
122
|
errorClass: z.ZodString;
|
|
88
123
|
errorMessage: z.ZodString;
|
|
89
124
|
partialOutputBytes: z.ZodNumber;
|
|
90
125
|
failureClass: z.ZodOptional<z.ZodEnum<{
|
|
91
|
-
budget: "budget";
|
|
92
126
|
abort: "abort";
|
|
127
|
+
budget: "budget";
|
|
93
128
|
"policy-refusal": "policy-refusal";
|
|
94
129
|
timeout: "timeout";
|
|
95
130
|
"permission-denied": "permission-denied";
|
|
@@ -101,6 +136,13 @@ export declare const SubagentLifecyclePayloadSchema: z.ZodDiscriminatedUnion<[z.
|
|
|
101
136
|
"hook-block-repeat": "hook-block-repeat";
|
|
102
137
|
}>>;
|
|
103
138
|
}, z.core.$strip>, z.ZodObject<{
|
|
139
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
140
|
+
tokens: z.ZodOptional<z.ZodObject<{
|
|
141
|
+
uncachedInput: z.ZodNumber;
|
|
142
|
+
cacheRead: z.ZodNumber;
|
|
143
|
+
cacheWrite: z.ZodNumber;
|
|
144
|
+
output: z.ZodNumber;
|
|
145
|
+
}, z.core.$strip>>;
|
|
104
146
|
transition: z.ZodLiteral<"cancelled">;
|
|
105
147
|
subagentId: z.ZodString;
|
|
106
148
|
source: z.ZodEnum<{
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const SEAL_PENDING_WRITES_TIMEOUT_MS = 5000;
|
|
2
|
-
export declare function awaitPendingWritesBounded(pending: readonly Promise<void>[], timeoutMs: number, label: string): Promise<void>;
|
|
2
|
+
export declare function awaitPendingWritesBounded(pending: readonly Promise<void>[], timeoutMs: number, label: string, describeTimeout?: (unsettled: number, total: number) => string): Promise<void>;
|
|
@@ -60,7 +60,7 @@ export interface SubagentStartedPayload {
|
|
|
60
60
|
resolvedAgentType?: string;
|
|
61
61
|
maxToolUseIterations?: number;
|
|
62
62
|
}
|
|
63
|
-
export interface SubagentSucceededPayload {
|
|
63
|
+
export interface SubagentSucceededPayload extends SubagentBillingFields {
|
|
64
64
|
incomplete?: true;
|
|
65
65
|
incompleteReason?: string;
|
|
66
66
|
roundsUsed?: number;
|
|
@@ -75,7 +75,7 @@ export interface SubagentSucceededPayload {
|
|
|
75
75
|
outputBytes: number;
|
|
76
76
|
stopReason?: string;
|
|
77
77
|
}
|
|
78
|
-
export interface SubagentFailedPayload {
|
|
78
|
+
export interface SubagentFailedPayload extends SubagentBillingFields {
|
|
79
79
|
transition: 'failed';
|
|
80
80
|
subagentId: string;
|
|
81
81
|
errorClass: string;
|
|
@@ -83,7 +83,7 @@ export interface SubagentFailedPayload {
|
|
|
83
83
|
partialOutputBytes: number;
|
|
84
84
|
failureClass?: ToolFailureClass;
|
|
85
85
|
}
|
|
86
|
-
export interface SubagentCancelledPayload {
|
|
86
|
+
export interface SubagentCancelledPayload extends SubagentBillingFields {
|
|
87
87
|
transition: 'cancelled';
|
|
88
88
|
subagentId: string;
|
|
89
89
|
source: 'cascade' | 'explicit';
|
|
@@ -215,7 +215,13 @@ export interface SessionSealedPayload {
|
|
|
215
215
|
cacheCreation?: number;
|
|
216
216
|
};
|
|
217
217
|
subagentCostUsd?: number;
|
|
218
|
+
billing?: {
|
|
219
|
+
root?: BillingRollupSnapshot;
|
|
220
|
+
subagents?: BillingRollupSnapshot;
|
|
221
|
+
};
|
|
218
222
|
}
|
|
223
|
+
import type { BillingRollupSnapshot, SubagentBillingFields } from './events.billing.js';
|
|
224
|
+
export type { BillingCounters as SessionBillingCounters, BillingRollupSnapshot as SessionBillingRollup, SubagentBillingFields, } from './events.billing.js';
|
|
219
225
|
export type TraceEventInput = {
|
|
220
226
|
kind: 'tool_call';
|
|
221
227
|
payload: ToolCallPayload;
|
|
@@ -87,6 +87,7 @@ export interface AgentConfig {
|
|
|
87
87
|
processJobs?: import('../shell-jobs/process-jobs.js').ProcessJobRegistry;
|
|
88
88
|
drainSubagents?: (reason: string) => Promise<unknown>;
|
|
89
89
|
getPendingChildTerminalWrites?: () => readonly Promise<void>[];
|
|
90
|
+
getPendingChildBillingStreams?: () => readonly Promise<void>[];
|
|
90
91
|
isSubagentFork?: true;
|
|
91
92
|
provider?: ModelProvider;
|
|
92
93
|
executors?: import('../session/session-executors.js').SessionExecutors;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { BillingUsage } from './provider.js';
|
|
2
|
+
export declare const BILLING_USAGE_KEYS: {
|
|
3
|
+
readonly provider: "billing_provider";
|
|
4
|
+
readonly uncachedInput: "billing_uncached_input_tokens";
|
|
5
|
+
readonly cacheRead: "billing_cache_read_tokens";
|
|
6
|
+
readonly cacheWrite: "billing_cache_write_tokens";
|
|
7
|
+
readonly output: "billing_output_tokens";
|
|
8
|
+
};
|
|
9
|
+
export declare function anthropicBilling(u: {
|
|
10
|
+
input_tokens?: number | null;
|
|
11
|
+
output_tokens?: number | null;
|
|
12
|
+
cache_read_input_tokens?: number | null;
|
|
13
|
+
cache_creation_input_tokens?: number | null;
|
|
14
|
+
}): BillingUsage;
|
|
15
|
+
export declare function openAICompatibleBilling(promptTokens: number, cachedTokens: number, completionTokens: number): BillingUsage;
|
|
16
|
+
export declare function sumBillingUsage(a: BillingUsage | undefined, b: BillingUsage | undefined): BillingUsage | undefined;
|
|
17
|
+
export declare function billingToUsageFields(b: BillingUsage | undefined): Record<string, unknown>;
|
|
18
|
+
export declare function billingFromUsageRecord(u: Record<string, unknown> | undefined): BillingUsage | undefined;
|
|
19
|
+
export declare function billingLifecycleFields(b: BillingUsage | undefined): {
|
|
20
|
+
provider?: string;
|
|
21
|
+
tokens?: {
|
|
22
|
+
uncachedInput: number;
|
|
23
|
+
cacheRead: number;
|
|
24
|
+
cacheWrite: number;
|
|
25
|
+
output: number;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
@@ -24,6 +24,7 @@ export interface BuildAgentSessionDeps {
|
|
|
24
24
|
traceWriter: TraceWriter | undefined;
|
|
25
25
|
drainSubagents?: ((reason: string) => Promise<unknown>) | undefined;
|
|
26
26
|
getPendingChildTerminalWrites?: (() => readonly Promise<void>[]) | undefined;
|
|
27
|
+
getPendingChildBillingStreams?: (() => readonly Promise<void>[]) | undefined;
|
|
27
28
|
bashOutputTailReporter?: (toolUseId: string) => (tail: string | undefined) => void;
|
|
28
29
|
detachRegistry?: import('../../../agent/tools/detach-registry.js').DetachableToolRegistry;
|
|
29
30
|
processJobs?: import('../../../agent/shell-jobs/process-jobs.js').ProcessJobRegistry;
|
|
@@ -52,6 +53,7 @@ export declare function buildSharedDeps(a: {
|
|
|
52
53
|
traceWriter: TraceWriter | undefined;
|
|
53
54
|
drainSubagents?: ((reason: string) => Promise<unknown>) | undefined;
|
|
54
55
|
getPendingChildTerminalWrites?: (() => readonly Promise<void>[]) | undefined;
|
|
56
|
+
getPendingChildBillingStreams?: (() => readonly Promise<void>[]) | undefined;
|
|
55
57
|
bashOutputTailReporter?: (toolUseId: string) => (tail: string | undefined) => void;
|
|
56
58
|
detachRegistry?: import('../../../agent/tools/detach-registry.js').DetachableToolRegistry;
|
|
57
59
|
processJobs?: import('../../../agent/shell-jobs/process-jobs.js').ProcessJobRegistry;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { SubagentLifecyclePayload, BackgroundAgentPayload } from '../../agent/trace/index.js';
|
|
2
|
+
import type { SubagentBillingFields } from '../../agent/trace/events.billing.js';
|
|
3
|
+
export declare function fmtBillingSuffix(p: SubagentBillingFields): string;
|
|
2
4
|
export declare function renderSubagentLifecycle(p: SubagentLifecyclePayload, line: (kind: string, detail: string) => string): string | null;
|
|
3
5
|
export declare function renderBackgroundAgent(p: BackgroundAgentPayload, line: (kind: string, detail: string) => string): string | null;
|