@tangle-network/agent-eval 0.109.1 → 0.110.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.
Files changed (177) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/analyst/index.d.ts +10 -12
  3. package/dist/analyst/index.js +8 -11
  4. package/dist/analyst/index.js.map +1 -1
  5. package/dist/{analyze-runs-DJYpep3L.d.ts → analyze-runs-Dmz6LA9e.d.ts} +4 -4
  6. package/dist/{baseline-Bbid3WoO.d.ts → baseline-DsNteOgR.d.ts} +32 -2
  7. package/dist/belief-state/index.d.ts +6 -6
  8. package/dist/benchmarks/index.d.ts +4 -4
  9. package/dist/benchmarks/index.js +7 -8
  10. package/dist/builder-eval/index.d.ts +4 -4
  11. package/dist/builder-eval/index.js +1 -2
  12. package/dist/builder-eval/index.js.map +1 -1
  13. package/dist/{calibration-BPmzuVPk.d.ts → calibration-Dz8TQV4y.d.ts} +2 -2
  14. package/dist/campaign/index.d.ts +62 -20
  15. package/dist/campaign/index.js +9 -8
  16. package/dist/{chunk-LOJ2QVCE.js → chunk-2IY4ILP4.js} +2 -2
  17. package/dist/{chunk-LIEJUH2I.js → chunk-6PL5MGDL.js} +9 -9
  18. package/dist/{chunk-2OGPXHOB.js → chunk-7NX6ZSBG.js} +36 -7
  19. package/dist/chunk-7NX6ZSBG.js.map +1 -0
  20. package/dist/{chunk-R6D7NEYJ.js → chunk-GBI5J5DB.js} +81 -11
  21. package/dist/chunk-GBI5J5DB.js.map +1 -0
  22. package/dist/{chunk-YEHAEDUD.js → chunk-IMWDSFUM.js} +604 -2
  23. package/dist/chunk-IMWDSFUM.js.map +1 -0
  24. package/dist/{chunk-OVPVM4JC.js → chunk-J4AKLZEV.js} +15 -4
  25. package/dist/{chunk-OVPVM4JC.js.map → chunk-J4AKLZEV.js.map} +1 -1
  26. package/dist/{chunk-JZXGWLK5.js → chunk-MHNQWM4I.js} +62 -6
  27. package/dist/chunk-MHNQWM4I.js.map +1 -0
  28. package/dist/{chunk-QRVS7MX4.js → chunk-OW47B5WA.js} +3 -5
  29. package/dist/{chunk-QRVS7MX4.js.map → chunk-OW47B5WA.js.map} +1 -1
  30. package/dist/{chunk-DBDRR6GF.js → chunk-PLOMR3HP.js} +48 -2
  31. package/dist/chunk-PLOMR3HP.js.map +1 -0
  32. package/dist/{chunk-GDZAWO2I.js → chunk-QFGTU7MT.js} +2 -2
  33. package/dist/{chunk-V7HNA47Z.js → chunk-RSVSSZKF.js} +5 -5
  34. package/dist/{chunk-5PK3626Q.js → chunk-XRGOKCMO.js} +88 -17
  35. package/dist/chunk-XRGOKCMO.js.map +1 -0
  36. package/dist/{code-agent-session-rnJKlqmT.d.ts → code-agent-session-yitf9I-F.d.ts} +1 -1
  37. package/dist/contract/index.d.ts +26 -28
  38. package/dist/contract/index.js +11 -13
  39. package/dist/contract/index.js.map +1 -1
  40. package/dist/{control-B8UthSBL.d.ts → control-U8LBKUES.d.ts} +5 -6
  41. package/dist/control.d.ts +8 -9
  42. package/dist/control.js +6 -8
  43. package/dist/{dataset-DS7ytHZU.d.ts → dataset-NENEzRgk.d.ts} +1 -1
  44. package/dist/{default-registry-BswHCXnU.d.ts → default-registry-Bcf1uKVI.d.ts} +1 -2
  45. package/dist/{emitter-C2rqGH_l.d.ts → emitter-BRchAAAx.d.ts} +2 -2
  46. package/dist/{failure-cluster-DH9Flgcf.d.ts → failure-cluster-C48PiReX.d.ts} +2 -2
  47. package/dist/feedback-trajectory-pDcz1lQ1.d.ts +348 -0
  48. package/dist/{gepa-B3x5Ulcv.d.ts → gepa-T8T215nw.d.ts} +149 -6
  49. package/dist/hosted/index.d.ts +7 -7
  50. package/dist/{index-pPtfoIJO.d.ts → index-Dc3VLGhp.d.ts} +2 -2
  51. package/dist/index.d.ts +645 -61
  52. package/dist/index.js +1282 -190
  53. package/dist/index.js.map +1 -1
  54. package/dist/{insight-report-B4xrdwEK.d.ts → insight-report-D4cXFsLt.d.ts} +1 -1
  55. package/dist/{integrity-DqGZg3st.d.ts → integrity-qemeBAyx.d.ts} +1 -1
  56. package/dist/{types-D1ytG0Yg.d.ts → kind-factory-20hcaYpf.d.ts} +169 -2
  57. package/dist/meta-eval/index.d.ts +5 -5
  58. package/dist/meta-eval/index.js +1 -2
  59. package/dist/meta-eval/index.js.map +1 -1
  60. package/dist/{multi-layer-verifier-CI4jdX-q.d.ts → multi-layer-verifier-BsqKuLyN.d.ts} +1 -1
  61. package/dist/multishot/index.d.ts +3 -3
  62. package/dist/openapi.json +1 -1
  63. package/dist/pipelines/index.d.ts +6 -7
  64. package/dist/pipelines/index.js +3 -6
  65. package/dist/pipelines/index.js.map +1 -1
  66. package/dist/{policy-edit-DQUXYMDm.d.ts → policy-edit-D2bBDZDf.d.ts} +2 -2
  67. package/dist/{pre-registration-BUhVPzE7.d.ts → pre-registration-BepVVa6P.d.ts} +3 -3
  68. package/dist/{provenance-DdDhf6cg.d.ts → provenance-CyxkvEi9.d.ts} +3 -5
  69. package/dist/{query-0aTmbmQe.d.ts → query-Ck190MOd.d.ts} +2 -2
  70. package/dist/{release-report-DeJpsBiA.d.ts → release-report-oBfOz8ku.d.ts} +3 -3
  71. package/dist/reporting.d.ts +8 -8
  72. package/dist/{researcher-Wc7dx6GM.d.ts → researcher-CaH0CwFC.d.ts} +6 -6
  73. package/dist/rl.d.ts +568 -15
  74. package/dist/rl.js +4 -4
  75. package/dist/{rubric-predictive-validity-DPnyG-CE.d.ts → rubric-predictive-validity-C-fMteAW.d.ts} +1 -1
  76. package/dist/{run-record-I-Z3JNvO.d.ts → run-record-DksGsfgv.d.ts} +1 -1
  77. package/dist/{runtime-trajectory-iW9IhV3e.d.ts → runtime-trajectory-h5i0SZUj.d.ts} +1 -1
  78. package/dist/{schema-m0gsnbt3.d.ts → schema-SGWcK9wa.d.ts} +1 -1
  79. package/dist/{semantic-concept-judge-BmNZPB_j.d.ts → semantic-concept-judge-D7z6JCLZ.d.ts} +57 -4
  80. package/dist/{store-BcFXE6LG.d.ts → store-BsVi7ncX.d.ts} +1 -1
  81. package/dist/storyboard/index.d.ts +1 -1
  82. package/dist/{summary-report-QMZVe3P-.d.ts → summary-report-Bz-0-t8v.d.ts} +2 -2
  83. package/dist/{test-graded-scenario-DeODGLra.d.ts → test-graded-scenario-mzYBKspu.d.ts} +3 -3
  84. package/dist/traces.d.ts +54 -11
  85. package/dist/traces.js +25 -27
  86. package/dist/{types-BdIv5dvA.d.ts → types-v--ctu-b.d.ts} +2 -2
  87. package/dist/wire/index.d.ts +5 -6
  88. package/docs/improvement-glossary.md +14 -13
  89. package/package.json +1 -71
  90. package/dist/adapters/http.d.ts +0 -142
  91. package/dist/adapters/http.js +0 -203
  92. package/dist/adapters/http.js.map +0 -1
  93. package/dist/adapters/langchain.d.ts +0 -95
  94. package/dist/adapters/langchain.js +0 -34
  95. package/dist/adapters/langchain.js.map +0 -1
  96. package/dist/adapters/otel.d.ts +0 -112
  97. package/dist/adapters/otel.js +0 -110
  98. package/dist/adapters/otel.js.map +0 -1
  99. package/dist/chunk-2OGPXHOB.js.map +0 -1
  100. package/dist/chunk-45EEMHTC.js +0 -35
  101. package/dist/chunk-45EEMHTC.js.map +0 -1
  102. package/dist/chunk-5BKGXME7.js +0 -65
  103. package/dist/chunk-5BKGXME7.js.map +0 -1
  104. package/dist/chunk-5PK3626Q.js.map +0 -1
  105. package/dist/chunk-6SK5VFYK.js +0 -100
  106. package/dist/chunk-6SK5VFYK.js.map +0 -1
  107. package/dist/chunk-DBDRR6GF.js.map +0 -1
  108. package/dist/chunk-DJWX3GVS.js +0 -81
  109. package/dist/chunk-DJWX3GVS.js.map +0 -1
  110. package/dist/chunk-FOUG2VVS.js +0 -855
  111. package/dist/chunk-FOUG2VVS.js.map +0 -1
  112. package/dist/chunk-JZXGWLK5.js.map +0 -1
  113. package/dist/chunk-K7QEIHHJ.js +0 -613
  114. package/dist/chunk-K7QEIHHJ.js.map +0 -1
  115. package/dist/chunk-KKHDIONI.js +0 -414
  116. package/dist/chunk-KKHDIONI.js.map +0 -1
  117. package/dist/chunk-KMPRBJK4.js +0 -74
  118. package/dist/chunk-KMPRBJK4.js.map +0 -1
  119. package/dist/chunk-Q2JRAWRI.js +0 -196
  120. package/dist/chunk-Q2JRAWRI.js.map +0 -1
  121. package/dist/chunk-R6D7NEYJ.js.map +0 -1
  122. package/dist/chunk-RZTMDUO7.js +0 -49
  123. package/dist/chunk-RZTMDUO7.js.map +0 -1
  124. package/dist/chunk-STGVSCDH.js +0 -202
  125. package/dist/chunk-STGVSCDH.js.map +0 -1
  126. package/dist/chunk-YEHAEDUD.js.map +0 -1
  127. package/dist/control-runtime-Acf9CGhw.d.ts +0 -182
  128. package/dist/corpus-eBVwhCp1.d.ts +0 -560
  129. package/dist/counterfactual-DlOz8PBx.d.ts +0 -85
  130. package/dist/diagnose.d.ts +0 -252
  131. package/dist/diagnose.js +0 -382
  132. package/dist/diagnose.js.map +0 -1
  133. package/dist/feedback-trajectory-C9KCo8ag.d.ts +0 -169
  134. package/dist/governance/index.d.ts +0 -135
  135. package/dist/governance/index.js +0 -18
  136. package/dist/governance/index.js.map +0 -1
  137. package/dist/groundedness/index.d.ts +0 -112
  138. package/dist/groundedness/index.js +0 -77
  139. package/dist/groundedness/index.js.map +0 -1
  140. package/dist/harness-optimizer-mOl9XX_O.d.ts +0 -106
  141. package/dist/kind-factory-DvIGo_cP.d.ts +0 -171
  142. package/dist/knowledge/index.d.ts +0 -103
  143. package/dist/knowledge/index.js +0 -18
  144. package/dist/knowledge/index.js.map +0 -1
  145. package/dist/pareto-E-pembql.d.ts +0 -81
  146. package/dist/perf/index.d.ts +0 -123
  147. package/dist/perf/index.js +0 -18
  148. package/dist/perf/index.js.map +0 -1
  149. package/dist/prm/index.d.ts +0 -104
  150. package/dist/prm/index.js +0 -265
  151. package/dist/prm/index.js.map +0 -1
  152. package/dist/product-benchmark/index.d.ts +0 -247
  153. package/dist/product-benchmark/index.js +0 -37
  154. package/dist/product-benchmark/index.js.map +0 -1
  155. package/dist/red-team-KmmiqBlY.d.ts +0 -63
  156. package/dist/redact-B40YG2M_.d.ts +0 -45
  157. package/dist/rubric-Cc6UHvUb.d.ts +0 -73
  158. package/dist/run-critic-CmMf05uV.d.ts +0 -56
  159. package/dist/sink-fetch-B1Yg4Til.d.ts +0 -101
  160. package/dist/telemetry/file.d.ts +0 -19
  161. package/dist/telemetry/file.js +0 -45
  162. package/dist/telemetry/file.js.map +0 -1
  163. package/dist/telemetry/index.d.ts +0 -38
  164. package/dist/telemetry/index.js +0 -130
  165. package/dist/telemetry/index.js.map +0 -1
  166. package/dist/testing-C21CHsq2.d.ts +0 -20
  167. package/dist/testing.d.ts +0 -1
  168. package/dist/testing.js +0 -8
  169. package/dist/testing.js.map +0 -1
  170. package/dist/trajectory-2TkpSEVh.d.ts +0 -33
  171. package/dist/workflow/index.d.ts +0 -496
  172. package/dist/workflow/index.js +0 -2178
  173. package/dist/workflow/index.js.map +0 -1
  174. /package/dist/{chunk-LOJ2QVCE.js.map → chunk-2IY4ILP4.js.map} +0 -0
  175. /package/dist/{chunk-LIEJUH2I.js.map → chunk-6PL5MGDL.js.map} +0 -0
  176. /package/dist/{chunk-GDZAWO2I.js.map → chunk-QFGTU7MT.js.map} +0 -0
  177. /package/dist/{chunk-V7HNA47Z.js.map → chunk-RSVSSZKF.js.map} +0 -0
@@ -1,6 +1,5 @@
1
1
  import { AxAIService } from '@ax-llm/ax';
2
- import { T as TraceAnalystKindSpec } from './kind-factory-DvIGo_cP.js';
3
- import { a as Analyst, b as AnalystContext, c as AnalystRunSummary, A as AnalystFinding, d as AnalystRunResult, C as ChatClient, e as AnalystRunInputs, f as AnalystRunEvent } from './types-D1ytG0Yg.js';
2
+ import { a as Analyst, b as AnalystContext, c as AnalystRunSummary, A as AnalystFinding, d as AnalystRunResult, C as ChatClient, e as AnalystRunInputs, f as AnalystRunEvent, T as TraceAnalystKindSpec } from './kind-factory-20hcaYpf.js';
4
3
 
5
4
  /**
6
5
  * AnalystRegistry — orchestrate N analysts against one run.
@@ -1,5 +1,5 @@
1
- import { b as RunOutcome, R as Run, S as Span, c as SpanKind, L as LlmSpan, T as ToolSpan, d as RetrievalSpan, J as JudgeSpan, e as SandboxSpan, E as EventKind, a as TraceEvent, B as BudgetLedgerEntry, A as Artifact, M as Message } from './schema-m0gsnbt3.js';
2
- import { T as TraceStore } from './store-BcFXE6LG.js';
1
+ import { a as RunOutcome, R as Run, S as Span, b as SpanKind, L as LlmSpan, T as ToolSpan, c as RetrievalSpan, J as JudgeSpan, d as SandboxSpan, E as EventKind, e as TraceEvent, B as BudgetLedgerEntry, A as Artifact, M as Message } from './schema-SGWcK9wa.js';
2
+ import { T as TraceStore } from './store-BsVi7ncX.js';
3
3
 
4
4
  /**
5
5
  * TraceEmitter — hierarchical span builder that auto-parents using an
@@ -1,5 +1,5 @@
1
- import { R as Run, S as Span, a as TraceEvent, F as FailureClass } from './schema-m0gsnbt3.js';
2
- import { T as TraceStore } from './store-BcFXE6LG.js';
1
+ import { R as Run, S as Span, e as TraceEvent, F as FailureClass } from './schema-SGWcK9wa.js';
2
+ import { T as TraceStore } from './store-BsVi7ncX.js';
3
3
 
4
4
  /**
5
5
  * Failure taxonomy — canonical classes + a default classifier.
@@ -0,0 +1,348 @@
1
+ import { T as TraceEmitter } from './emitter-BRchAAAx.js';
2
+ import { F as FailureClass } from './schema-SGWcK9wa.js';
3
+ import { T as TraceStore } from './store-BsVi7ncX.js';
4
+ import { a as DatasetSplit, D as DatasetScenario } from './dataset-NENEzRgk.js';
5
+
6
+ /**
7
+ * Policy-based agent control runtime.
8
+ *
9
+ * This is the minimal reusable loop behind driver-agent patterns:
10
+ *
11
+ * observe state -> validate -> decide next action -> act -> observe -> ...
12
+ *
13
+ * It deliberately does not model named "topologies". Direct execution,
14
+ * critic/revise, driver intervention, specialist calls, and human escalation
15
+ * are all just actions chosen by the control policy.
16
+ */
17
+
18
+ type ControlSeverity = 'info' | 'warning' | 'error' | 'critical';
19
+ type ControlActionFailureMode = 'continue' | 'stop';
20
+ interface ControlEvalResult {
21
+ /** Stable validator or judge id. */
22
+ id: string;
23
+ /** Whether this check passed. */
24
+ passed: boolean;
25
+ /** Optional normalized score. 1 = best, 0 = worst. */
26
+ score?: number;
27
+ /** Objective validators should usually be "error" or "critical" when failed. */
28
+ severity?: ControlSeverity;
29
+ /** Human-readable result. */
30
+ detail?: string;
31
+ /** Small evidence string or pointer. Avoid large payloads. */
32
+ evidence?: string;
33
+ /** True when the result came from deterministic state, not LLM judgment. */
34
+ objective?: boolean;
35
+ /** Structured details for downstream control policies and reports. */
36
+ metadata?: Record<string, unknown>;
37
+ }
38
+ interface ControlBudget {
39
+ maxSteps: number;
40
+ maxWallMs?: number;
41
+ maxCostUsd?: number;
42
+ }
43
+ interface ControlStopPolicies<TState, TAction> {
44
+ /**
45
+ * Stop after N consecutive steps with no state fingerprint change and
46
+ * less than `minScoreDelta` score movement. Disabled when omitted.
47
+ */
48
+ maxNoProgressSteps?: number;
49
+ /**
50
+ * Stop after the same action fingerprint is selected N consecutive
51
+ * times. Disabled when omitted.
52
+ */
53
+ maxRepeatedActions?: number;
54
+ /** Minimum score movement that counts as progress. Default 0.001. */
55
+ minScoreDelta?: number;
56
+ /** Override the default JSON/string fingerprint for state comparisons. */
57
+ stateFingerprint?: (state: TState) => string;
58
+ /** Override the default JSON/string fingerprint for repeated-action checks. */
59
+ actionFingerprint?: (action: TAction) => string;
60
+ }
61
+ interface ControlContext<TState, TAction, TActionResult, TEval extends ControlEvalResult = ControlEvalResult> {
62
+ intent: string;
63
+ state: TState;
64
+ evals: TEval[];
65
+ history: ControlStep<TState, TAction, TActionResult, TEval>[];
66
+ budget: ControlBudget;
67
+ stepIndex: number;
68
+ wallMs: number;
69
+ spentCostUsd: number;
70
+ remainingCostUsd?: number;
71
+ abortSignal: AbortSignal;
72
+ emitter?: TraceEmitter;
73
+ }
74
+ type ControlDecision<TAction> = {
75
+ type: 'continue';
76
+ action: TAction;
77
+ reason?: string;
78
+ } | {
79
+ type: 'stop';
80
+ reason: string;
81
+ pass?: boolean;
82
+ score?: number;
83
+ };
84
+ interface StopDecision {
85
+ stop: boolean;
86
+ pass: boolean;
87
+ reason: string;
88
+ score?: number;
89
+ failureClass?: FailureClass;
90
+ }
91
+ interface ControlActionOutcome<TActionResult> {
92
+ ok: boolean;
93
+ result?: TActionResult;
94
+ error?: string;
95
+ costUsd?: number;
96
+ durationMs: number;
97
+ }
98
+ interface ControlRuntimeError {
99
+ phase: 'observe' | 'validate' | 'decide' | 'act' | 'stop-policy' | 'on-step' | 'trace';
100
+ stepIndex: number;
101
+ message: string;
102
+ }
103
+ interface ControlStep<TState, TAction, TActionResult, TEval extends ControlEvalResult = ControlEvalResult> {
104
+ index: number;
105
+ decision: ControlDecision<TAction>;
106
+ beforeState: TState;
107
+ afterState: TState;
108
+ evalsBefore: TEval[];
109
+ evalsAfter: TEval[];
110
+ actionOutcome?: ControlActionOutcome<TActionResult>;
111
+ startedAt: string;
112
+ endedAt: string;
113
+ }
114
+ interface ControlRunResult<TState, TAction, TActionResult, TEval extends ControlEvalResult = ControlEvalResult> {
115
+ intent: string;
116
+ pass: boolean;
117
+ completed: boolean;
118
+ reason: string;
119
+ score?: number;
120
+ steps: ControlStep<TState, TAction, TActionResult, TEval>[];
121
+ finalState: TState | undefined;
122
+ finalEvals: TEval[];
123
+ wallMs: number;
124
+ spentCostUsd: number;
125
+ /** null when the run executed without a TraceEmitter wired (no run record was persisted). */
126
+ runId: string | null;
127
+ failureClass?: FailureClass;
128
+ runtimeErrors: ControlRuntimeError[];
129
+ stoppedBy: 'policy' | 'stop-policy' | 'budget' | 'abort' | 'runtime-error';
130
+ }
131
+ interface ControlRuntimeConfig<TState, TAction, TActionResult, TEval extends ControlEvalResult = ControlEvalResult> {
132
+ intent: string;
133
+ budget?: Partial<ControlBudget>;
134
+ signal?: AbortSignal;
135
+ /** Defaults to `continue`: action failures are recorded, then the policy gets another chance. */
136
+ actionFailure?: ControlActionFailureMode;
137
+ /**
138
+ * Extract cost from an action result. Used for `maxCostUsd` budget
139
+ * enforcement and trace budget ledger emission.
140
+ */
141
+ getActionCostUsd?: (ctx: {
142
+ action: TAction;
143
+ result: TActionResult;
144
+ state: TState;
145
+ evals: TEval[];
146
+ history: ControlStep<TState, TAction, TActionResult, TEval>[];
147
+ }) => number | undefined;
148
+ /** Read typed task/product state. Prefer structured state over transcript-only context. */
149
+ observe: (ctx: {
150
+ history: ControlStep<TState, TAction, TActionResult, TEval>[];
151
+ abortSignal: AbortSignal;
152
+ }) => Promise<TState> | TState;
153
+ /** Objective validators first, subjective judges only where objective state is insufficient. */
154
+ validate: (ctx: {
155
+ intent: string;
156
+ state: TState;
157
+ history: ControlStep<TState, TAction, TActionResult, TEval>[];
158
+ abortSignal: AbortSignal;
159
+ }) => Promise<TEval[]> | TEval[];
160
+ /** Choose the next control action. Can call a worker, ask user, run critic, inspect state, or stop. */
161
+ decide: (ctx: ControlContext<TState, TAction, TActionResult, TEval>) => Promise<ControlDecision<TAction>> | ControlDecision<TAction>;
162
+ /** Execute the action selected by the policy. */
163
+ act: (action: TAction, ctx: ControlContext<TState, TAction, TActionResult, TEval>) => Promise<TActionResult> | TActionResult;
164
+ /** Final stopping policy. Called before decide and after each action. */
165
+ shouldStop?: (ctx: ControlContext<TState, TAction, TActionResult, TEval>) => Promise<StopDecision> | StopDecision;
166
+ /** Optional hook for tracing or live progress updates. */
167
+ onStep?: (step: ControlStep<TState, TAction, TActionResult, TEval>) => Promise<void> | void;
168
+ /** Optional generic stuck-loop policies. Custom `shouldStop` still runs first. */
169
+ stopPolicies?: ControlStopPolicies<TState, TAction>;
170
+ /** Optional trace sink. Emits one run plus one span per control step. */
171
+ store?: TraceStore;
172
+ scenarioId?: string;
173
+ projectId?: string;
174
+ variantId?: string;
175
+ }
176
+ declare function runAgentControlLoop<TState, TAction, TActionResult, TEval extends ControlEvalResult = ControlEvalResult>(config: ControlRuntimeConfig<TState, TAction, TActionResult, TEval>): Promise<ControlRunResult<TState, TAction, TActionResult, TEval>>;
177
+ declare function stopOnNoProgress<TState, TAction>(maxNoProgressSteps: number, options?: Omit<ControlStopPolicies<TState, TAction>, 'maxNoProgressSteps'>): ControlStopPolicies<TState, TAction>;
178
+ declare function stopOnRepeatedAction<TState, TAction>(maxRepeatedActions: number, options?: Omit<ControlStopPolicies<TState, TAction>, 'maxRepeatedActions'>): ControlStopPolicies<TState, TAction>;
179
+ declare function objectiveEval(input: Omit<ControlEvalResult, 'objective'>): ControlEvalResult;
180
+ declare function subjectiveEval(input: Omit<ControlEvalResult, 'objective'>): ControlEvalResult;
181
+ declare function allCriticalPassed(evals: ControlEvalResult[]): boolean;
182
+
183
+ type FeedbackArtifactType = 'text' | 'code' | 'plan' | 'research' | 'action' | 'ui' | 'decision' | 'data' | 'other';
184
+ type FeedbackLabelSource = 'user' | 'judge' | 'environment' | 'metric' | 'policy' | 'system';
185
+ type FeedbackLabelKind = 'approve' | 'reject' | 'select' | 'edit' | 'rank' | 'rate' | 'comment' | 'metric_outcome' | 'policy_block' | 'revision_request';
186
+ type FeedbackSeverity = 'info' | 'warning' | 'error' | 'critical';
187
+ interface FeedbackTask {
188
+ intent: string;
189
+ context?: unknown;
190
+ }
191
+ interface ProposedSideEffect {
192
+ type: string;
193
+ risk?: 'low' | 'medium' | 'high';
194
+ costUsd?: number;
195
+ externalSideEffect?: boolean;
196
+ requiresApproval?: boolean;
197
+ metadata?: Record<string, unknown>;
198
+ }
199
+ interface FeedbackLabel {
200
+ id?: string;
201
+ source: FeedbackLabelSource;
202
+ kind: FeedbackLabelKind;
203
+ value: unknown;
204
+ reason?: string;
205
+ severity?: FeedbackSeverity;
206
+ createdAt: string;
207
+ metadata?: Record<string, unknown>;
208
+ }
209
+ interface FeedbackAttempt {
210
+ id: string;
211
+ stepIndex: number;
212
+ artifactType: FeedbackArtifactType;
213
+ artifact: unknown;
214
+ options?: unknown[];
215
+ proposedAction?: ProposedSideEffect;
216
+ evals?: ControlEvalResult[];
217
+ feedback?: FeedbackLabel[];
218
+ createdAt: string;
219
+ metadata?: Record<string, unknown>;
220
+ }
221
+ interface FeedbackOutcome {
222
+ success?: boolean;
223
+ score?: number;
224
+ metrics?: Record<string, number>;
225
+ costUsd?: number;
226
+ detail?: string;
227
+ observedAt?: string;
228
+ metadata?: Record<string, unknown>;
229
+ }
230
+ interface FeedbackTrajectory {
231
+ id: string;
232
+ projectId?: string;
233
+ scenarioId?: string;
234
+ task: FeedbackTask;
235
+ attempts: FeedbackAttempt[];
236
+ labels: FeedbackLabel[];
237
+ outcome?: FeedbackOutcome;
238
+ split?: DatasetSplit;
239
+ tags?: Record<string, string>;
240
+ createdAt: string;
241
+ updatedAt?: string;
242
+ metadata?: Record<string, unknown>;
243
+ }
244
+ interface FeedbackTrajectoryStore {
245
+ save(trajectory: FeedbackTrajectory): Promise<void>;
246
+ get(id: string): Promise<FeedbackTrajectory | null>;
247
+ list(filter?: FeedbackTrajectoryFilter): Promise<FeedbackTrajectory[]>;
248
+ appendAttempt(id: string, attempt: FeedbackAttempt): Promise<FeedbackTrajectory>;
249
+ appendLabel(id: string, label: FeedbackLabel, attemptId?: string): Promise<FeedbackTrajectory>;
250
+ }
251
+ interface FeedbackTrajectoryFilter {
252
+ projectId?: string;
253
+ scenarioId?: string;
254
+ split?: DatasetSplit;
255
+ tag?: [string, string];
256
+ }
257
+ interface FeedbackSplitPolicy {
258
+ trainPct?: number;
259
+ devPct?: number;
260
+ testPct?: number;
261
+ holdoutPct?: number;
262
+ }
263
+ interface PreferenceMemoryEntry {
264
+ instruction: string;
265
+ rationale: string;
266
+ weight: number;
267
+ sourceTrajectoryId: string;
268
+ sourceLabelId?: string;
269
+ category?: string;
270
+ }
271
+ interface FeedbackOptimizerRow {
272
+ scenarioId: string;
273
+ trajectoryId: string;
274
+ labelKinds: FeedbackLabelKind[];
275
+ score?: number;
276
+ metadata?: Record<string, unknown>;
277
+ }
278
+ interface FeedbackReplayResult {
279
+ trajectoryId: string;
280
+ pass: boolean;
281
+ score?: number;
282
+ labels: FeedbackLabel[];
283
+ outcome?: FeedbackOutcome;
284
+ metadata?: Record<string, unknown>;
285
+ }
286
+ interface FeedbackReplayAdapter {
287
+ replay(trajectory: FeedbackTrajectory): Promise<Omit<FeedbackReplayResult, 'trajectoryId'>> | Omit<FeedbackReplayResult, 'trajectoryId'>;
288
+ }
289
+ declare class InMemoryFeedbackTrajectoryStore implements FeedbackTrajectoryStore {
290
+ private readonly trajectories;
291
+ save(trajectory: FeedbackTrajectory): Promise<void>;
292
+ get(id: string): Promise<FeedbackTrajectory | null>;
293
+ list(filter?: FeedbackTrajectoryFilter): Promise<FeedbackTrajectory[]>;
294
+ appendAttempt(id: string, attempt: FeedbackAttempt): Promise<FeedbackTrajectory>;
295
+ appendLabel(id: string, label: FeedbackLabel, attemptId?: string): Promise<FeedbackTrajectory>;
296
+ }
297
+ declare class FileSystemFeedbackTrajectoryStore implements FeedbackTrajectoryStore {
298
+ private readonly dir;
299
+ private readonly memory;
300
+ private loaded;
301
+ constructor(options: {
302
+ dir: string;
303
+ });
304
+ save(trajectory: FeedbackTrajectory): Promise<void>;
305
+ get(id: string): Promise<FeedbackTrajectory | null>;
306
+ list(filter?: FeedbackTrajectoryFilter): Promise<FeedbackTrajectory[]>;
307
+ appendAttempt(id: string, attempt: FeedbackAttempt): Promise<FeedbackTrajectory>;
308
+ appendLabel(id: string, label: FeedbackLabel, attemptId?: string): Promise<FeedbackTrajectory>;
309
+ private append;
310
+ private load;
311
+ }
312
+ declare function createFeedbackTrajectory(input: {
313
+ id?: string;
314
+ projectId?: string;
315
+ scenarioId?: string;
316
+ task: FeedbackTask;
317
+ attempts?: FeedbackAttempt[];
318
+ labels?: FeedbackLabel[];
319
+ outcome?: FeedbackOutcome;
320
+ split?: DatasetSplit;
321
+ tags?: Record<string, string>;
322
+ createdAt?: string;
323
+ metadata?: Record<string, unknown>;
324
+ }): FeedbackTrajectory;
325
+ declare function assignFeedbackSplit(trajectory: Pick<FeedbackTrajectory, 'id' | 'projectId' | 'scenarioId' | 'task'>, policy?: FeedbackSplitPolicy): DatasetSplit;
326
+ declare function withAssignedFeedbackSplit(trajectory: FeedbackTrajectory, policy?: FeedbackSplitPolicy): FeedbackTrajectory;
327
+ declare function feedbackTrajectoryToDatasetScenario(trajectory: FeedbackTrajectory): DatasetScenario;
328
+ declare function feedbackTrajectoriesToDatasetScenarios(trajectories: FeedbackTrajectory[]): DatasetScenario[];
329
+ declare function feedbackTrajectoryToOptimizerRow(trajectory: FeedbackTrajectory): FeedbackOptimizerRow;
330
+ declare function feedbackTrajectoriesToOptimizerRows(trajectories: FeedbackTrajectory[]): FeedbackOptimizerRow[];
331
+ declare function replayFeedbackTrajectory(trajectory: FeedbackTrajectory, adapter: FeedbackReplayAdapter): Promise<FeedbackReplayResult>;
332
+ declare function replayFeedbackTrajectories(trajectories: FeedbackTrajectory[], adapter: FeedbackReplayAdapter): Promise<FeedbackReplayResult[]>;
333
+ declare function summarizePreferenceMemory(trajectories: FeedbackTrajectory[], options?: {
334
+ maxEntries?: number;
335
+ }): PreferenceMemoryEntry[];
336
+ declare function renderPreferenceMemoryMarkdown(entries: PreferenceMemoryEntry[]): string;
337
+ declare function serializeFeedbackTrajectoriesJsonl(trajectories: FeedbackTrajectory[]): string;
338
+ declare function parseFeedbackTrajectoriesJsonl(jsonl: string): FeedbackTrajectory[];
339
+ declare function controlRunToFeedbackTrajectory<TState, TAction, TActionResult>(run: ControlRunResult<TState, TAction, TActionResult>, options?: {
340
+ projectId?: string;
341
+ scenarioId?: string;
342
+ artifactType?: FeedbackArtifactType;
343
+ artifactFromStep?: (step: ControlStep<TState, TAction, TActionResult>) => unknown;
344
+ proposedActionFromStep?: (step: ControlStep<TState, TAction, TActionResult>) => ProposedSideEffect | undefined;
345
+ createdAt?: string;
346
+ }): FeedbackTrajectory;
347
+
348
+ export { type ProposedSideEffect as A, allCriticalPassed as B, type ControlSeverity as C, assignFeedbackSplit as D, controlRunToFeedbackTrajectory as E, type FeedbackTrajectoryStore as F, createFeedbackTrajectory as G, feedbackTrajectoriesToDatasetScenarios as H, InMemoryFeedbackTrajectoryStore as I, feedbackTrajectoriesToOptimizerRows as J, feedbackTrajectoryToDatasetScenario as K, feedbackTrajectoryToOptimizerRow as L, objectiveEval as M, parseFeedbackTrajectoriesJsonl as N, renderPreferenceMemoryMarkdown as O, type PreferenceMemoryEntry as P, replayFeedbackTrajectories as Q, replayFeedbackTrajectory as R, type StopDecision as S, runAgentControlLoop as T, serializeFeedbackTrajectoriesJsonl as U, stopOnNoProgress as V, stopOnRepeatedAction as W, subjectiveEval as X, summarizePreferenceMemory as Y, withAssignedFeedbackSplit as Z, type ControlEvalResult as a, type FeedbackLabel as b, type FeedbackTrajectory as c, type ControlActionFailureMode as d, type ControlActionOutcome as e, type ControlBudget as f, type ControlContext as g, type ControlDecision as h, type ControlRunResult as i, type ControlRuntimeConfig as j, type ControlRuntimeError as k, type ControlStep as l, type ControlStopPolicies as m, type FeedbackArtifactType as n, type FeedbackAttempt as o, type FeedbackLabelKind as p, type FeedbackLabelSource as q, type FeedbackOptimizerRow as r, type FeedbackOutcome as s, type FeedbackReplayAdapter as t, type FeedbackReplayResult as u, type FeedbackSeverity as v, type FeedbackSplitPolicy as w, type FeedbackTask as x, type FeedbackTrajectoryFilter as y, FileSystemFeedbackTrajectoryStore as z };
@@ -1,7 +1,148 @@
1
- import { S as Scenario, C as CampaignResult, G as GateResult, D as DispatchFn, a as JudgeConfig, L as LabeledScenarioStore, c as CampaignTraceWriter, d as GenerationRecord, M as MutableSurface, P as ParetoParent, e as SurfaceProposer, f as Gate } from './types-BdIv5dvA.js';
1
+ import { D as DatasetScenario, c as Dataset } from './dataset-NENEzRgk.js';
2
+ import { T as TraceStore } from './store-BsVi7ncX.js';
3
+ import { S as Scenario, C as CampaignResult, G as GateResult, c as DispatchFn, b as JudgeConfig, L as LabeledScenarioStore, d as CampaignTraceWriter, e as GenerationRecord, M as MutableSurface, P as ParetoParent, f as SurfaceProposer, g as Gate } from './types-v--ctu-b.js';
2
4
  import { C as CampaignStorage } from './storage-Dw_f7WMt.js';
3
5
  import { L as LlmClientOptions } from './llm-client-DyqEH4jH.js';
4
6
 
7
+ /**
8
+ * Pareto frontier — multi-objective optimization over candidate runs.
9
+ *
10
+ * Lifted from ADC pareto.ts and blueprint-agent frontier.ts. When you're
11
+ * trading off (cost, latency, quality) or (passRate, tokenBudget,
12
+ * ttfb), you rarely have a single "winner" — you have a set of
13
+ * non-dominated candidates. This module exposes:
14
+ *
15
+ * - `paretoFrontier`: filter a set of candidates to the non-dominated ones
16
+ * - `dominates`: does A dominate B across all objectives?
17
+ *
18
+ * Each objective is declared with a direction: 'maximize' (higher=better)
19
+ * or 'minimize' (lower=better). Candidates are any object; pass an
20
+ * `objective(candidate)` accessor.
21
+ */
22
+ type Direction = 'maximize' | 'minimize';
23
+ interface Objective<T> {
24
+ /** Stable label used in reports. */
25
+ name: string;
26
+ direction: Direction;
27
+ value: (candidate: T) => number;
28
+ }
29
+ interface ParetoResult<T> {
30
+ frontier: T[];
31
+ dominated: T[];
32
+ /** Index map: frontier[i] dominates each of dominatedBy[i]. */
33
+ dominanceMap: Array<{
34
+ dominator: T;
35
+ dominated: T[];
36
+ }>;
37
+ }
38
+ /** Does candidate A weakly dominate B — strictly better on at least one objective and no worse on any? */
39
+ declare function dominates<T>(a: T, b: T, objectives: Objective<T>[]): boolean;
40
+ /**
41
+ * Compute the non-dominated frontier. Candidates with NaN/Infinity on any
42
+ * objective are excluded (can't rank them). A candidate enters the frontier
43
+ * iff no other candidate dominates it.
44
+ */
45
+ declare function paretoFrontier<T>(candidates: T[], objectives: Objective<T>[]): ParetoResult<T>;
46
+ /**
47
+ * Weighted-sum scalarisation. Use as a tie-break / single-winner selector
48
+ * when callers don't want to consume a frontier. Each objective contributes
49
+ * its normalised value (0..1 via min-max across the candidate pool) times
50
+ * its weight; missing weights default to 1/N.
51
+ *
52
+ * Direction is honoured automatically — `minimize` axes have their values
53
+ * inverted before scaling so "higher scalar = better" always holds.
54
+ */
55
+ declare function scalarScore<T>(candidates: T[], objectives: Objective<T>[], options?: {
56
+ weights?: Partial<Record<string, number>>;
57
+ }): Array<{
58
+ candidate: T;
59
+ score: number;
60
+ }>;
61
+ /**
62
+ * NSGA-II crowding distance — secondary sort for ties on the frontier.
63
+ *
64
+ * When the Pareto front collapses to a single point (or many candidates tie
65
+ * on dominance), naive selection picks arbitrarily and the population
66
+ * degenerates over generations. NSGA-II preserves diversity by preferring
67
+ * candidates with more empty space around them on the frontier.
68
+ *
69
+ * Returns an array of `{ candidate, distance }` in the SAME order as the
70
+ * input. Higher distance = more isolated = should be preferred when
71
+ * preserving diversity.
72
+ */
73
+ declare function crowdingDistance<T>(candidates: T[], objectives: Objective<T>[]): Array<{
74
+ candidate: T;
75
+ distance: number;
76
+ }>;
77
+ /**
78
+ * Pareto frontier with tie-break by crowding distance — the canonical
79
+ * NSGA-II selection step. Returns the frontier sorted by descending crowding
80
+ * distance so callers can `.slice(0, k)` to pick K diverse winners.
81
+ */
82
+ declare function paretoFrontierWithCrowding<T>(candidates: T[], objectives: Objective<T>[]): Array<{
83
+ candidate: T;
84
+ distance: number;
85
+ }>;
86
+
87
+ /**
88
+ * Red-team battery — adversarial scenario corpus with per-category
89
+ * scorers.
90
+ *
91
+ * Every scenario is a `DatasetScenario` with a `redTeam: {...}` payload
92
+ * that declares: category, expected refusal, attack surface. Scorers
93
+ * inspect the agent's output + trajectory and return a PASS/FAIL per
94
+ * category. Aggregated via `redTeamReport`.
95
+ *
96
+ * The built-in corpus is intentionally conservative — 40 cases
97
+ * covering the most-seen attack patterns. Extend via `extendCorpus`.
98
+ */
99
+
100
+ type RedTeamCategory = 'prompt_injection_direct' | 'prompt_injection_indirect' | 'jailbreak_persona' | 'jailbreak_dan' | 'pii_leak' | 'permission_escalation' | 'data_exfil' | 'policy_override';
101
+ interface RedTeamPayload {
102
+ category: RedTeamCategory;
103
+ /** The hostile input the agent sees. */
104
+ input: string;
105
+ /**
106
+ * What a safe agent should do: "refuse" means explicit refusal,
107
+ * "ignore" means process benignly without executing the attack.
108
+ */
109
+ expected: 'refuse' | 'ignore';
110
+ /** Substring(s) that MUST NOT appear in output. */
111
+ forbiddenStrings?: string[];
112
+ /** Tool names the agent MUST NOT call for this scenario. */
113
+ forbiddenTools?: string[];
114
+ }
115
+ interface RedTeamCase extends DatasetScenario {
116
+ payload: RedTeamPayload;
117
+ }
118
+ interface RedTeamFinding {
119
+ scenarioId: string;
120
+ category: RedTeamCategory;
121
+ passed: boolean;
122
+ reason: string;
123
+ evidence?: string;
124
+ }
125
+ interface RedTeamReport {
126
+ findings: RedTeamFinding[];
127
+ passRateByCategory: Record<RedTeamCategory, number>;
128
+ overallPassRate: number;
129
+ }
130
+ /** Ship a canonical, small corpus. Consumers extend via `extendCorpus`. */
131
+ declare const DEFAULT_RED_TEAM_CORPUS: RedTeamCase[];
132
+ declare function redTeamDataset(extraCases?: RedTeamCase[]): Dataset;
133
+ /**
134
+ * Score a single agent response against the red-team case.
135
+ * `toolCalls` should be the names of tools the agent invoked during the run.
136
+ */
137
+ declare function scoreRedTeamOutput(output: string, toolCalls: string[], rtCase: RedTeamCase): RedTeamFinding;
138
+ /** Aggregate red-team findings into per-category pass rates. */
139
+ declare function redTeamReport(findings: RedTeamFinding[]): RedTeamReport;
140
+ /**
141
+ * Extract the tool-call names from a corpus run — convenience for the
142
+ * common pipeline (run the scenario → score the run).
143
+ */
144
+ declare function toolNamesForRun(store: TraceStore, runId: string): Promise<string[]>;
145
+
5
146
  /**
6
147
  * `openAutoPr` — thin shell-out helper for the `runImprovementLoop` preset's
7
148
  * `autoOnPromote: 'pr'` mode. Substitutes for the per-product PR-opening
@@ -229,10 +370,12 @@ interface RunOptimizationBaseOptions<TScenario extends Scenario, TArtifact> exte
229
370
  * generation's traces; findings-grounded proposers consume them. Opaque here;
230
371
  * the proposer types its `TFindings`. Empty when no producer is wired. */
231
372
  findings?: unknown[];
232
- /** Per-generation findings producer. After each
233
- * generation's candidates are scored, this is called with that generation's
234
- * results; whatever it returns REPLACES `ctx.findings` for the NEXT
235
- * generation's `propose()`, so the diagnosis is refreshed each round instead
373
+ /** Per-generation findings producer. Runs once on the BASELINE campaign
374
+ * (as `generation: -1`, the baseline convention) before generation 0
375
+ * proposes so even a single-generation run proposes with trace context —
376
+ * and then after each generation's candidates are scored with that
377
+ * generation's results; whatever it returns REPLACES `ctx.findings` for the
378
+ * NEXT `propose()`, so the diagnosis is refreshed each round instead
236
379
  * of being a static one-shot. Generic by design: the substrate does not
237
380
  * import an analyst — the consumer plugs its trace-analyst registry / HALO
238
381
  * here (reading the per-candidate `runDir` traces). When absent, findings
@@ -448,4 +591,4 @@ declare function extractH2Sections(text: string): string[];
448
591
  * whitespace as identical. Exported for tests + consumer-side validators. */
449
592
  declare function countSentenceEdits(baseline: string, candidate: string): number;
450
593
 
451
- export { type CampaignRunPlan as C, type GepaProposerOptions as G, type OpenAutoPrOptions as O, type PlanCampaignRunOptions as P, type RunOptimizationOptions as R, type RunImprovementLoopResult as a, type RunCampaignOptions as b, type RunImprovementLoopOptions as c, runImprovementLoop as d, type CampaignRunPlanCell as e, type GepaProposerConstraints as f, gepaProposer as g, type OpenAutoPrResult as h, type RunOptimizationResult as i, countSentenceEdits as j, defaultRenderDiff as k, extractH2Sections as l, runOptimization as m, openAutoPr as o, planCampaignRun as p, runCampaign as r, surfaceHash as s };
594
+ export { dominates as A, paretoFrontier as B, type CampaignRunPlan as C, type Direction as D, paretoFrontierWithCrowding as E, redTeamDataset as F, type GepaProposerOptions as G, redTeamReport as H, scalarScore as I, scoreRedTeamOutput as J, toolNamesForRun as K, type OpenAutoPrOptions as O, type PlanCampaignRunOptions as P, type RunOptimizationOptions as R, type RunImprovementLoopResult as a, type RunCampaignOptions as b, type RunImprovementLoopOptions as c, runImprovementLoop as d, type RedTeamCase as e, type CampaignRunPlanCell as f, gepaProposer as g, type GepaProposerConstraints as h, type OpenAutoPrResult as i, type RunOptimizationResult as j, countSentenceEdits as k, defaultRenderDiff as l, extractH2Sections as m, runOptimization as n, openAutoPr as o, planCampaignRun as p, type Objective as q, runCampaign as r, surfaceHash as s, type ParetoResult as t, DEFAULT_RED_TEAM_CORPUS as u, type RedTeamCategory as v, type RedTeamFinding as w, type RedTeamPayload as x, type RedTeamReport as y, crowdingDistance as z };
@@ -1,12 +1,12 @@
1
- import { M as MutableSurface, h as GateDecision } from '../types-BdIv5dvA.js';
2
- import { I as InsightReport } from '../insight-report-B4xrdwEK.js';
3
- import '../run-record-I-Z3JNvO.js';
1
+ import { M as MutableSurface, h as GateDecision } from '../types-v--ctu-b.js';
2
+ import { I as InsightReport } from '../insight-report-D4cXFsLt.js';
3
+ import '../run-record-DksGsfgv.js';
4
4
  import '@tangle-network/agent-interface';
5
5
  import '../errors-oeQrLqXC.js';
6
- import '../schema-m0gsnbt3.js';
7
- import '../summary-report-QMZVe3P-.js';
8
- import '../failure-cluster-DH9Flgcf.js';
9
- import '../store-BcFXE6LG.js';
6
+ import '../schema-SGWcK9wa.js';
7
+ import '../summary-report-Bz-0-t8v.js';
8
+ import '../failure-cluster-C48PiReX.js';
9
+ import '../store-BsVi7ncX.js';
10
10
  import '../judge-calibration-7C-IDmKr.js';
11
11
 
12
12
  /**
@@ -1,5 +1,5 @@
1
- import { S as Scenario, b as DispatchContext, C as CampaignResult } from './types-BdIv5dvA.js';
2
- import { b as RunSplitTag } from './run-record-I-Z3JNvO.js';
1
+ import { S as Scenario, D as DispatchContext, C as CampaignResult } from './types-v--ctu-b.js';
2
+ import { b as RunSplitTag } from './run-record-DksGsfgv.js';
3
3
  import { C as CampaignStorage } from './storage-Dw_f7WMt.js';
4
4
 
5
5
  /**