File size: 2,291 Bytes
69b971b
017c628
8bf5d01
b6cd280
69b971b
 
 
 
 
a23bb47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69b971b
 
7e26449
 
 
 
 
69b971b
 
 
 
 
017c628
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69b971b
 
 
 
 
 
 
 
 
 
a23bb47
 
 
 
 
 
 
 
 
 
c01b9cd
 
 
 
 
69b971b
 
 
 
b6cd280
69b971b
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import { Annotation } from "@langchain/langgraph";
import { BaseMessage } from "@langchain/core/messages";
import { VulnerabilityReport } from "./types.js";

export const PoCStateAnnotation = Annotation.Root({
  report: Annotation<VulnerabilityReport>(),

  pocCode: Annotation<string>({
    default: () => "",
    reducer: (_, y) => y,           // overwrite β€” full combined file
  }),

  templateCode: Annotation<string>({
    default: () => "",
    reducer: (_, y) => y,           // overwrite β€” only imports and setUp
  }),

  exploitBody: Annotation<string>({
    default: () => "",
    reducer: (_, y) => y,           // overwrite β€” only the hack logic
  }),

  infrastructurePhase: Annotation<boolean>({
    default: () => true,
    reducer: (_, y) => y,           // overwrite β€” true while fixing imports
  }),

  vulnerabilityAnalysis: Annotation<string>({
    default: () => "",
    reducer: (_, y) => y,           // overwrite
  }),

  executionLogs: Annotation<string[]>({
    default: () => [],
    reducer: (x, y) => x.concat(y), // append β€” never lose previous logs
  }),

  messages: Annotation<BaseMessage[]>({
    default: () => [],
    reducer: (x, y) => x.concat(y),
  }),

  toolCallCount: Annotation<number>({
    default: () => 0,
    reducer: (x, y) => x + y,
  }),

  totalCost: Annotation<number>({
    default: () => 0,
    reducer: (x, y) => x + y,
  }),

  lastError: Annotation<string | null>({
    default: () => null,
    reducer: (_, y) => y,           // overwrite β€” last error analysis
  }),

  iterations: Annotation<number>({
    default: () => 0,
    reducer: (x, y) => x + y,       // additive β€” incremented by +1 per call
  }),

  infraIterations: Annotation<number>({
    default: () => 0,
    reducer: (x, y) => x + y,       // additive
  }),

  exploitIterations: Annotation<number>({
    default: () => 0,
    reducer: (x, y) => x + y,       // additive
  }),

  compileFailures: Annotation<number>({
    default: () => 0,
    reducer: (x, y) => x + y,       // additive β€” incremented on each compile failure
  }),

  status: Annotation<"running" | "success" | "failed" | "timeout">({
    default: () => "running",
    reducer: (_, y) => y,           // overwrite
  }),
});

export type PoCState = typeof PoCStateAnnotation.State;