agent-afk 5.256.0 → 5.257.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.
Files changed (47) hide show
  1. package/dist/cli/commands/whatif.d.ts +2 -0
  2. package/dist/cli/slash/commands/whatif.d.ts +2 -0
  3. package/dist/cli.mjs +699 -364
  4. package/dist/index.mjs +112 -112
  5. package/dist/telegram.mjs +131 -131
  6. package/dist/whatif/args.d.ts +28 -0
  7. package/dist/whatif/args.usage.d.ts +1 -0
  8. package/dist/whatif/compile.d.ts +6 -0
  9. package/dist/whatif/complete.d.ts +2 -0
  10. package/dist/whatif/complete.retry.d.ts +8 -0
  11. package/dist/whatif/cost.d.ts +27 -0
  12. package/dist/whatif/discover.d.ts +15 -0
  13. package/dist/whatif/episodes.d.ts +12 -0
  14. package/dist/whatif/index.d.ts +11 -0
  15. package/dist/whatif/json-extract.d.ts +3 -0
  16. package/dist/whatif/judge/claude.d.ts +2 -0
  17. package/dist/whatif/judge/index.d.ts +8 -0
  18. package/dist/whatif/judge/jev-connect.d.ts +5 -0
  19. package/dist/whatif/judge/jev.d.ts +9 -0
  20. package/dist/whatif/ledger.d.ts +10 -0
  21. package/dist/whatif/observe.d.ts +6 -0
  22. package/dist/whatif/operators/content-ops.d.ts +4 -0
  23. package/dist/whatif/operators/index.d.ts +6 -0
  24. package/dist/whatif/operators/launch-ops.d.ts +4 -0
  25. package/dist/whatif/operators/memory-ops.d.ts +3 -0
  26. package/dist/whatif/operators/sandbox-guard.d.ts +2 -0
  27. package/dist/whatif/operators/skill-plugin-ops.d.ts +3 -0
  28. package/dist/whatif/predict.d.ts +11 -0
  29. package/dist/whatif/report.d.ts +9 -0
  30. package/dist/whatif/run.d.ts +9 -0
  31. package/dist/whatif/run.limits.d.ts +2 -0
  32. package/dist/whatif/run.persist.d.ts +2 -0
  33. package/dist/whatif/run.verify.d.ts +30 -0
  34. package/dist/whatif/runner/afk-runner.d.ts +10 -0
  35. package/dist/whatif/runner/afk-runner.run.d.ts +16 -0
  36. package/dist/whatif/runner/afk-runner.snapshot.d.ts +4 -0
  37. package/dist/whatif/runner/capture-server.d.ts +9 -0
  38. package/dist/whatif/runner/child-env.d.ts +2 -0
  39. package/dist/whatif/runner/tool-log.d.ts +2 -0
  40. package/dist/whatif/sandbox.d.ts +14 -0
  41. package/dist/whatif/sandbox.home.d.ts +3 -0
  42. package/dist/whatif/stats.d.ts +7 -0
  43. package/dist/whatif/structural.d.ts +2 -0
  44. package/dist/whatif/structural.normalize.d.ts +5 -0
  45. package/dist/whatif/surface.d.ts +18 -0
  46. package/dist/whatif/types.d.ts +260 -0
  47. package/package.json +1 -1
@@ -0,0 +1,260 @@
1
+ export type Change = {
2
+ kind: 'append';
3
+ target: 'user-afk-md' | 'project-afk-md';
4
+ text: string;
5
+ } | {
6
+ kind: 'file';
7
+ path: string;
8
+ content: string;
9
+ } | {
10
+ kind: 'hot';
11
+ content: string;
12
+ } | {
13
+ kind: 'memory-add';
14
+ content: string;
15
+ category: 'preference' | 'convention' | 'decision' | 'learning';
16
+ } | {
17
+ kind: 'memory-remove';
18
+ id: number;
19
+ } | {
20
+ kind: 'disable-skill';
21
+ name: string;
22
+ } | {
23
+ kind: 'disable-plugin';
24
+ name: string;
25
+ } | {
26
+ kind: 'model';
27
+ model: string;
28
+ } | {
29
+ kind: 'effort';
30
+ effort: string;
31
+ } | {
32
+ kind: 'env';
33
+ key: string;
34
+ value: string;
35
+ };
36
+ export type ChangeKind = Change['kind'];
37
+ export interface ChangeSpec {
38
+ title: string;
39
+ changes: Change[];
40
+ }
41
+ export interface LaunchSettings {
42
+ model?: string;
43
+ effort?: string;
44
+ env: Record<string, string>;
45
+ unset?: string[];
46
+ }
47
+ export interface Environment {
48
+ label: 'baseline' | 'candidate';
49
+ home: string;
50
+ cwd: string;
51
+ launch: LaunchSettings;
52
+ }
53
+ export interface OperatorContext {
54
+ realHome: string;
55
+ realCwd: string;
56
+ }
57
+ export interface ChangeOperator<K extends ChangeKind = ChangeKind> {
58
+ kind: K;
59
+ touchesProject(change: Extract<Change, {
60
+ kind: K;
61
+ }>): boolean;
62
+ homePathsToCopy(change: Extract<Change, {
63
+ kind: K;
64
+ }>): string[];
65
+ apply(change: Extract<Change, {
66
+ kind: K;
67
+ }>, env: Environment, ctx: OperatorContext): Promise<void>;
68
+ describe(change: Extract<Change, {
69
+ kind: K;
70
+ }>): string;
71
+ }
72
+ export interface RequestSnapshot {
73
+ model: string;
74
+ system: string;
75
+ tools: {
76
+ name: string;
77
+ description: string;
78
+ }[];
79
+ firstUserMessage: string;
80
+ }
81
+ export interface StructuralImpact {
82
+ baseline: RequestSnapshot;
83
+ candidate: RequestSnapshot;
84
+ systemDiff: string;
85
+ toolsAdded: string[];
86
+ toolsRemoved: string[];
87
+ toolsChanged: string[];
88
+ userMessageDiff: string;
89
+ tokens: {
90
+ baseline: number;
91
+ candidate: number;
92
+ };
93
+ perTurnCostDeltaUsd?: number;
94
+ modelChanged: boolean;
95
+ }
96
+ export type PredictionDirection = 'added' | 'removed' | 'strengthened' | 'weakened';
97
+ export type Confidence = 'high' | 'medium' | 'low';
98
+ export interface Prediction {
99
+ id: string;
100
+ behavior: string;
101
+ direction: PredictionDirection;
102
+ confidence: Confidence;
103
+ reason: string;
104
+ testQuestion: string;
105
+ probes: string[];
106
+ }
107
+ export interface Episode {
108
+ id: string;
109
+ source: 'real' | 'synthetic' | 'suite';
110
+ prompt: string;
111
+ targets?: string;
112
+ }
113
+ export interface ToolRequest {
114
+ tool: string;
115
+ input: unknown;
116
+ verdict: 'executed' | 'recorded';
117
+ }
118
+ export interface EpisodeTrace {
119
+ episodeId: string;
120
+ env: 'baseline' | 'candidate';
121
+ sample: number;
122
+ text: string;
123
+ tools: ToolRequest[];
124
+ costUsd: number;
125
+ inputTokens: number;
126
+ outputTokens: number;
127
+ durationMs: number;
128
+ error?: string;
129
+ }
130
+ export interface RunnerOptions {
131
+ timeoutMs: number;
132
+ maxTurns: number;
133
+ signal?: AbortSignal;
134
+ }
135
+ export interface AgentRunner {
136
+ name: string;
137
+ run(env: Environment, episode: Episode, sample: number, opts: RunnerOptions): Promise<EpisodeTrace>;
138
+ snapshot(env: Environment, probePrompt: string, opts: RunnerOptions): Promise<RequestSnapshot>;
139
+ }
140
+ export interface EpisodeFeatures {
141
+ firstAction: 'answer' | 'read' | 'side-effect' | 'ask' | 'delegate' | 'none';
142
+ askedBeforeActing: boolean;
143
+ delegated: boolean;
144
+ usedTools: string[];
145
+ usedSkills: string[];
146
+ searchedMemory: boolean;
147
+ toolCalls: number;
148
+ responseChars: number;
149
+ errored: boolean;
150
+ }
151
+ export interface JudgeQuestion {
152
+ id: string;
153
+ question: string;
154
+ }
155
+ export interface JudgeInput {
156
+ prompt: string;
157
+ output: string;
158
+ questions: JudgeQuestion[];
159
+ }
160
+ export type JudgeResult = Record<string, number>;
161
+ export interface Judge {
162
+ name: 'jev' | 'claude';
163
+ external: boolean;
164
+ grade(input: JudgeInput, signal?: AbortSignal): Promise<JudgeResult>;
165
+ close?(): Promise<void>;
166
+ }
167
+ export interface RateComparison {
168
+ baseline: number;
169
+ candidate: number;
170
+ delta: number;
171
+ ci: [number, number];
172
+ n: {
173
+ baseline: number;
174
+ candidate: number;
175
+ };
176
+ }
177
+ export type Verdict = 'confirmed' | 'refuted' | 'unclear';
178
+ export interface VerifiedPrediction {
179
+ prediction: Prediction;
180
+ rates: RateComparison;
181
+ verdict: Verdict;
182
+ }
183
+ export interface DiscoveredDifference {
184
+ id: string;
185
+ description: string;
186
+ question: string;
187
+ rates: RateComparison;
188
+ }
189
+ export interface FeatureDelta {
190
+ label: string;
191
+ rates: RateComparison;
192
+ }
193
+ export interface VerifyResult {
194
+ predictions: VerifiedPrediction[];
195
+ discovered: DiscoveredDifference[];
196
+ features: FeatureDelta[];
197
+ episodes: number;
198
+ samples: number;
199
+ judge: {
200
+ name: 'jev' | 'claude';
201
+ external: boolean;
202
+ crossCheckAgreement?: number;
203
+ };
204
+ predictionAccuracy?: number;
205
+ truncatedByBudget: boolean;
206
+ failedEpisodes: number;
207
+ judgeFailures?: number;
208
+ }
209
+ export interface WhatifReport {
210
+ spec: ChangeSpec;
211
+ structural: StructuralImpact;
212
+ predictions: Prediction[];
213
+ verify?: VerifyResult;
214
+ costUsd: number;
215
+ runDir: string;
216
+ limits: string[];
217
+ headline: string;
218
+ }
219
+ export type WhatifStage = 'compile' | 'sandbox' | 'snapshot' | 'predict' | 'episodes' | 'run' | 'judge' | 'discover' | 'report';
220
+ export interface WhatifProgress {
221
+ stage: WhatifStage;
222
+ message: string;
223
+ done?: number;
224
+ total?: number;
225
+ }
226
+ export type CompleteFn = (req: {
227
+ system: string;
228
+ user: string;
229
+ maxTokens: number;
230
+ model: string;
231
+ signal?: AbortSignal;
232
+ }) => Promise<{
233
+ text: string;
234
+ costUsd: number;
235
+ }>;
236
+ export interface WhatifOptions {
237
+ spec: ChangeSpec;
238
+ realHome: string;
239
+ realCwd: string;
240
+ agentModel: string;
241
+ analystModel: string;
242
+ verify: boolean;
243
+ turns: number;
244
+ samples: number;
245
+ maxUsd: number;
246
+ judge: 'auto' | 'jev' | 'claude';
247
+ concurrency: number;
248
+ maxTurns: number;
249
+ episodeTimeoutMs: number;
250
+ keepSandboxes: boolean;
251
+ }
252
+ export interface WhatifDeps {
253
+ runner: AgentRunner;
254
+ complete: CompleteFn;
255
+ makeJudge(choice: WhatifOptions['judge']): Promise<Judge>;
256
+ makeCrossCheckJudge(): Promise<Judge | undefined>;
257
+ onProgress?: (p: WhatifProgress) => void;
258
+ signal?: AbortSignal;
259
+ now?: () => Date;
260
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-afk",
3
- "version": "5.256.0",
3
+ "version": "5.257.0",
4
4
  "description": "Open-source coding-agent harness you can actually change — own the loop (prompts, gates, routing, skills, terminal states), use any model, run long tasks while you're away.",
5
5
  "main": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",