agent-afk 5.313.15 → 5.314.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/handlers/witness.query.d.ts +8 -0
- package/dist/agent/tools/handlers/witness.query.where.d.ts +26 -0
- package/dist/agent/trace/emit.d.ts +2 -1
- package/dist/agent/trace/events.d.ts +24 -0
- package/dist/agent/trace/hook-tally.d.ts +8 -0
- package/dist/agent/trace/types.d.ts +15 -1
- package/dist/cli.mjs +406 -404
- package/dist/index.mjs +192 -190
- package/dist/telegram.mjs +207 -205
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TraceEvent } from '../../trace/index.js';
|
|
2
|
+
import { type CurrentSessionRef, type WhereClause } from './witness.query.where.js';
|
|
2
3
|
export declare const MAX_LIMIT = 200;
|
|
3
4
|
export declare const MAX_SEARCH_MATCHES = 200;
|
|
4
5
|
export declare function clampLimit(raw: unknown): number;
|
|
@@ -9,6 +10,7 @@ export interface ReadWitnessParams {
|
|
|
9
10
|
toolName?: string;
|
|
10
11
|
errorsOnly?: boolean;
|
|
11
12
|
limit?: number;
|
|
13
|
+
where?: WhereClause;
|
|
12
14
|
}
|
|
13
15
|
export interface ReadWitnessResult {
|
|
14
16
|
sessionId: string;
|
|
@@ -24,6 +26,9 @@ export interface SearchWitnessParams {
|
|
|
24
26
|
kinds?: string[];
|
|
25
27
|
since?: string;
|
|
26
28
|
toolName?: string;
|
|
29
|
+
where?: WhereClause;
|
|
30
|
+
currentSession?: CurrentSessionRef;
|
|
31
|
+
includeCurrentSession?: boolean;
|
|
27
32
|
}
|
|
28
33
|
export interface SearchMatch {
|
|
29
34
|
sessionId: string;
|
|
@@ -37,5 +42,8 @@ export interface SearchWitnessResult {
|
|
|
37
42
|
sessionsScanned: number;
|
|
38
43
|
matches: SearchMatch[];
|
|
39
44
|
truncatedSessions?: string[];
|
|
45
|
+
matchLimitReached?: true;
|
|
46
|
+
hint?: string;
|
|
47
|
+
excludedCurrentSession?: true;
|
|
40
48
|
}
|
|
41
49
|
export declare function searchAcrossSessions(params: SearchWitnessParams): Promise<SearchWitnessResult>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type WhereScalar = string | number | boolean | null;
|
|
2
|
+
export type WhereClause = ReadonlyArray<{
|
|
3
|
+
path: string;
|
|
4
|
+
segments: string[];
|
|
5
|
+
value: WhereScalar;
|
|
6
|
+
}>;
|
|
7
|
+
export declare class WitnessWhereError extends Error {
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
export declare function parseWhere(raw: unknown): WhereClause | undefined;
|
|
11
|
+
export declare function matchesWhere(event: unknown, where: WhereClause | undefined): boolean;
|
|
12
|
+
export interface CurrentSessionRef {
|
|
13
|
+
tracePath?: string;
|
|
14
|
+
sessionId?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function isCurrentSession(entry: {
|
|
17
|
+
sessionId: string;
|
|
18
|
+
tracePath: string;
|
|
19
|
+
}, current: CurrentSessionRef | undefined): boolean;
|
|
20
|
+
export declare function currentSessionRef(ctx: {
|
|
21
|
+
traceWriter?: {
|
|
22
|
+
getTracePath(): string;
|
|
23
|
+
};
|
|
24
|
+
sessionId?: string;
|
|
25
|
+
}): CurrentSessionRef | undefined;
|
|
26
|
+
export declare const MATCH_LIMIT_HINT: string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { AbortPayload, BackgroundAgentPayload, BrowserEventPayload, BudgetPayload, ClaimPayload, ClosurePayload, CompactionPayloadInput, HookDecisionPayload, PeerMessagePayload, QueuedUserMessagePayload, SessionPhasePayload, SubagentLifecyclePayload, ToolCallPayload } from './types.js';
|
|
1
|
+
import type { AbortPayload, BackgroundAgentPayload, BrowserEventPayload, BudgetPayload, ClaimPayload, ClosurePayload, CompactionPayloadInput, HookDecisionPayload, HookSummaryPayload, PeerMessagePayload, QueuedUserMessagePayload, SessionPhasePayload, SubagentLifecyclePayload, ToolCallPayload } from './types.js';
|
|
2
2
|
import type { TraceSink } from './writer.js';
|
|
3
3
|
export declare const emitToolCall: (w: TraceSink | undefined, p: ToolCallPayload) => Promise<void>;
|
|
4
4
|
export declare const emitHookDecision: (w: TraceSink | undefined, p: HookDecisionPayload) => Promise<void>;
|
|
5
|
+
export declare const emitHookSummary: (w: TraceSink | undefined, p: HookSummaryPayload) => Promise<void>;
|
|
5
6
|
export declare const emitSubagentLifecycle: (w: TraceSink | undefined, p: SubagentLifecyclePayload) => Promise<void>;
|
|
6
7
|
export declare const emitBackgroundAgent: (w: TraceSink | undefined, p: BackgroundAgentPayload) => Promise<void>;
|
|
7
8
|
export declare const emitBudget: (w: TraceSink | undefined, p: BudgetPayload) => Promise<void>;
|
|
@@ -115,6 +115,12 @@ export declare const HookDecisionPayloadSchema: z.ZodObject<{
|
|
|
115
115
|
"hard-block": "hard-block";
|
|
116
116
|
}>>;
|
|
117
117
|
}, z.core.$strip>;
|
|
118
|
+
export declare const HookSummaryPayloadSchema: z.ZodObject<{
|
|
119
|
+
scope: z.ZodLiteral<"root-session-including-subagents">;
|
|
120
|
+
counts: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
121
|
+
written: z.ZodNumber;
|
|
122
|
+
suppressed: z.ZodNumber;
|
|
123
|
+
}, z.core.$strip>;
|
|
118
124
|
export declare const BackgroundAgentPayloadSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
119
125
|
transition: z.ZodLiteral<"started">;
|
|
120
126
|
jobId: z.ZodString;
|
|
@@ -335,6 +341,14 @@ export declare const TraceEventInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
335
341
|
"hard-block": "hard-block";
|
|
336
342
|
}>>;
|
|
337
343
|
}, z.core.$strip>;
|
|
344
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
345
|
+
kind: z.ZodLiteral<"hook_summary">;
|
|
346
|
+
payload: z.ZodObject<{
|
|
347
|
+
scope: z.ZodLiteral<"root-session-including-subagents">;
|
|
348
|
+
counts: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
349
|
+
written: z.ZodNumber;
|
|
350
|
+
suppressed: z.ZodNumber;
|
|
351
|
+
}, z.core.$strip>;
|
|
338
352
|
}, z.core.$strip>, z.ZodObject<{
|
|
339
353
|
kind: z.ZodLiteral<"subagent_lifecycle">;
|
|
340
354
|
payload: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -730,6 +744,16 @@ export declare const TraceEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
730
744
|
"hard-block": "hard-block";
|
|
731
745
|
}>>;
|
|
732
746
|
}, z.core.$strip>;
|
|
747
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
748
|
+
ts: z.ZodString;
|
|
749
|
+
seq: z.ZodNumber;
|
|
750
|
+
kind: z.ZodLiteral<"hook_summary">;
|
|
751
|
+
payload: z.ZodObject<{
|
|
752
|
+
scope: z.ZodLiteral<"root-session-including-subagents">;
|
|
753
|
+
counts: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
754
|
+
written: z.ZodNumber;
|
|
755
|
+
suppressed: z.ZodNumber;
|
|
756
|
+
}, z.core.$strip>;
|
|
733
757
|
}, z.core.$strip>, z.ZodObject<{
|
|
734
758
|
ts: z.ZodString;
|
|
735
759
|
seq: z.ZodNumber;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { HookDecisionPayload, HookSummaryPayload } from './types.js';
|
|
2
|
+
import type { TraceSink } from './writer.js';
|
|
3
|
+
export interface HookTallyAliasedSink extends TraceSink {
|
|
4
|
+
readonly hookTallyKey: TraceSink;
|
|
5
|
+
}
|
|
6
|
+
export declare function isInformativeHookDecision(p: HookDecisionPayload): boolean;
|
|
7
|
+
export declare function recordHookDecision(writer: TraceSink, p: HookDecisionPayload, written: boolean): void;
|
|
8
|
+
export declare function takeHookSummary(writer: TraceSink): HookSummaryPayload | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type TraceEventKind = 'tool_call' | 'hook_decision' | 'subagent_lifecycle' | 'background_agent' | 'budget' | 'abort' | 'compaction' | 'closure' | 'claim' | 'browser_event' | 'queued_user_message' | 'peer_message' | 'session_phase' | 'session_sealed';
|
|
1
|
+
export type TraceEventKind = 'tool_call' | 'hook_decision' | 'hook_summary' | 'subagent_lifecycle' | 'background_agent' | 'budget' | 'abort' | 'compaction' | 'closure' | 'claim' | 'browser_event' | 'queued_user_message' | 'peer_message' | 'session_phase' | 'session_sealed';
|
|
2
2
|
export interface ToolCallStartedPayload {
|
|
3
3
|
phase: 'started';
|
|
4
4
|
toolUseId: string;
|
|
@@ -42,6 +42,12 @@ export interface HookDecisionPayload {
|
|
|
42
42
|
durationMs?: number;
|
|
43
43
|
approvalOutcome?: AfkApprovalOutcome;
|
|
44
44
|
}
|
|
45
|
+
export interface HookSummaryPayload {
|
|
46
|
+
scope: 'root-session-including-subagents';
|
|
47
|
+
counts: Record<string, Record<string, number>>;
|
|
48
|
+
written: number;
|
|
49
|
+
suppressed: number;
|
|
50
|
+
}
|
|
45
51
|
export interface SubagentStartedPayload {
|
|
46
52
|
transition: 'started';
|
|
47
53
|
subagentId: string;
|
|
@@ -216,6 +222,9 @@ export type TraceEventInput = {
|
|
|
216
222
|
} | {
|
|
217
223
|
kind: 'hook_decision';
|
|
218
224
|
payload: HookDecisionPayload;
|
|
225
|
+
} | {
|
|
226
|
+
kind: 'hook_summary';
|
|
227
|
+
payload: HookSummaryPayload;
|
|
219
228
|
} | {
|
|
220
229
|
kind: 'subagent_lifecycle';
|
|
221
230
|
payload: SubagentLifecyclePayload;
|
|
@@ -260,6 +269,11 @@ export type TraceEvent = {
|
|
|
260
269
|
seq: number;
|
|
261
270
|
kind: 'hook_decision';
|
|
262
271
|
payload: HookDecisionPayload;
|
|
272
|
+
} | {
|
|
273
|
+
ts: string;
|
|
274
|
+
seq: number;
|
|
275
|
+
kind: 'hook_summary';
|
|
276
|
+
payload: HookSummaryPayload;
|
|
263
277
|
} | {
|
|
264
278
|
ts: string;
|
|
265
279
|
seq: number;
|