@tangle-network/agent-eval 0.37.0 → 0.40.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 (67) hide show
  1. package/dist/campaign/index.d.ts +695 -0
  2. package/dist/campaign/index.js +741 -0
  3. package/dist/campaign/index.js.map +1 -0
  4. package/dist/chunk-5U2DOJU4.js +565 -0
  5. package/dist/chunk-5U2DOJU4.js.map +1 -0
  6. package/dist/{chunk-KE7TDJUO.js → chunk-AU2JLNSZ.js} +2 -2
  7. package/dist/{chunk-TSPOEDM3.js → chunk-BWZEGTES.js} +2 -5
  8. package/dist/chunk-BWZEGTES.js.map +1 -0
  9. package/dist/{chunk-3HYQXPC2.js → chunk-DMW5VENN.js} +3 -3
  10. package/dist/{chunk-TQL7BAOY.js → chunk-EGIPWXHL.js} +2 -2
  11. package/dist/chunk-GGE4NNQT.js +65 -0
  12. package/dist/chunk-GGE4NNQT.js.map +1 -0
  13. package/dist/{chunk-7PR3WPWE.js → chunk-L7XMNXLO.js} +2 -2
  14. package/dist/{chunk-RL6TERL2.js → chunk-LCIDRYGP.js} +3 -3
  15. package/dist/{chunk-L5UNCDAJ.js → chunk-MAOZCN36.js} +2 -64
  16. package/dist/chunk-MAOZCN36.js.map +1 -0
  17. package/dist/{chunk-LGAPK7NA.js → chunk-NKLGKF2Q.js} +2 -2
  18. package/dist/chunk-QWV226SL.js +276 -0
  19. package/dist/chunk-QWV226SL.js.map +1 -0
  20. package/dist/chunk-TMXPFWC7.js +305 -0
  21. package/dist/chunk-TMXPFWC7.js.map +1 -0
  22. package/dist/{chunk-KHZRNY3F.js → chunk-WP7SY7AI.js} +5 -4
  23. package/dist/chunk-WP7SY7AI.js.map +1 -0
  24. package/dist/chunk-YV7J7X5N.js +313 -0
  25. package/dist/chunk-YV7J7X5N.js.map +1 -0
  26. package/dist/{control-DVrmvM_k.d.ts → control-CmLJk3IG.d.ts} +1 -1
  27. package/dist/control.d.ts +3 -3
  28. package/dist/control.js +2 -2
  29. package/dist/{dataset-ueRVTUoY.d.ts → dataset-BlwAtYYf.d.ts} +1 -1
  30. package/dist/{feedback-trajectory-iATEAHmc.d.ts → feedback-trajectory-Dvy-bt7x.d.ts} +1 -1
  31. package/dist/governance/index.d.ts +133 -5
  32. package/dist/index.d.ts +35 -34
  33. package/dist/index.js +97 -630
  34. package/dist/index.js.map +1 -1
  35. package/dist/matrix/index.d.ts +2 -109
  36. package/dist/matrix/index.js +5 -270
  37. package/dist/matrix/index.js.map +1 -1
  38. package/dist/multishot/index.d.ts +276 -0
  39. package/dist/multishot/index.js +516 -0
  40. package/dist/multishot/index.js.map +1 -0
  41. package/dist/openapi.json +1 -1
  42. package/dist/optimization.d.ts +2 -2
  43. package/dist/optimization.js +5 -5
  44. package/dist/pipelines/index.js +2 -2
  45. package/dist/red-team-30II1T4o.d.ts +63 -0
  46. package/dist/{release-report-D2ykiLSe.d.ts → release-report-Di84bXD7.d.ts} +5 -2
  47. package/dist/reporting.d.ts +2 -2
  48. package/dist/reporting.js +3 -3
  49. package/dist/rl.js +15 -315
  50. package/dist/rl.js.map +1 -1
  51. package/dist/run-campaign-JYJXYHHL.js +10 -0
  52. package/dist/run-campaign-JYJXYHHL.js.map +1 -0
  53. package/dist/traces.js +7 -5
  54. package/dist/types-DHqkLwEU.d.ts +110 -0
  55. package/dist/wire/index.d.ts +2 -2
  56. package/docs/design/loop-taxonomy.md +233 -0
  57. package/package.json +38 -24
  58. package/dist/chunk-KHZRNY3F.js.map +0 -1
  59. package/dist/chunk-L5UNCDAJ.js.map +0 -1
  60. package/dist/chunk-TSPOEDM3.js.map +0 -1
  61. package/dist/index-CN2agEaO.d.ts +0 -191
  62. /package/dist/{chunk-KE7TDJUO.js.map → chunk-AU2JLNSZ.js.map} +0 -0
  63. /package/dist/{chunk-3HYQXPC2.js.map → chunk-DMW5VENN.js.map} +0 -0
  64. /package/dist/{chunk-TQL7BAOY.js.map → chunk-EGIPWXHL.js.map} +0 -0
  65. /package/dist/{chunk-7PR3WPWE.js.map → chunk-L7XMNXLO.js.map} +0 -0
  66. /package/dist/{chunk-RL6TERL2.js.map → chunk-LCIDRYGP.js.map} +0 -0
  67. /package/dist/{chunk-LGAPK7NA.js.map → chunk-NKLGKF2Q.js.map} +0 -0
@@ -0,0 +1,276 @@
1
+ import { AgentProfile } from '@tangle-network/sandbox';
2
+ import { M as MatrixResult } from '../types-DHqkLwEU.js';
3
+ import '@tangle-network/agent-runtime/loops';
4
+
5
+ interface MultishotMessage {
6
+ role: 'user' | 'assistant' | 'tool';
7
+ content: string;
8
+ toolCallId?: string;
9
+ toolCalls?: Array<{
10
+ id: string;
11
+ name: string;
12
+ args: Record<string, unknown>;
13
+ }>;
14
+ }
15
+ interface MultishotArtifact {
16
+ type: string;
17
+ turn: number;
18
+ invocation: {
19
+ name: string;
20
+ args: Record<string, unknown>;
21
+ };
22
+ content: string;
23
+ }
24
+ interface MultishotResult {
25
+ transcript: MultishotMessage[];
26
+ artifacts: MultishotArtifact[];
27
+ toolCalls: number;
28
+ durationMs: number;
29
+ costUsd: number;
30
+ }
31
+ interface MultishotToolDefinition {
32
+ type: 'function';
33
+ function: {
34
+ name: string;
35
+ description: string;
36
+ parameters: Record<string, unknown>;
37
+ };
38
+ }
39
+ type MultishotToolExecutor = (args: Record<string, unknown>, ctx: {
40
+ apiKey: string;
41
+ baseUrl: string;
42
+ signal?: AbortSignal;
43
+ }) => Promise<{
44
+ content: string;
45
+ costUsd: number;
46
+ }>;
47
+ interface MultishotPersona {
48
+ /** Stable identifier — used for per-cell artifact paths + matrix axis keys. */
49
+ id: string;
50
+ /** Per-domain payload (income/profile/voice/etc.) shaped by the consumer. */
51
+ [k: string]: unknown;
52
+ }
53
+ interface MultishotShape<TPersona extends MultishotPersona> {
54
+ /** Opening user message (turn 0) — the persona's first ask. */
55
+ buildOpener: (persona: TPersona) => string;
56
+ /** System prompt the driver LLM uses to roleplay the persona. Should set
57
+ * voice, goals, constraints, time-pressure, and the "never go silent" rule. */
58
+ buildDriverSystemPrompt: (persona: TPersona) => string;
59
+ }
60
+ declare class MultishotDriverEmptyError extends Error {
61
+ readonly turn: number;
62
+ constructor(turn: number);
63
+ }
64
+
65
+ interface RouterCompletionRequest {
66
+ apiKey: string;
67
+ baseUrl: string;
68
+ model: string;
69
+ messages: Array<Record<string, unknown>>;
70
+ tools?: MultishotToolDefinition[];
71
+ temperature?: number;
72
+ maxTokens?: number;
73
+ signal?: AbortSignal;
74
+ }
75
+ interface RouterToolCall {
76
+ id: string;
77
+ type: 'function';
78
+ function: {
79
+ name: string;
80
+ arguments: string;
81
+ };
82
+ }
83
+ interface RouterCompletionResponse {
84
+ message: {
85
+ content?: string | null;
86
+ tool_calls?: RouterToolCall[];
87
+ };
88
+ usage?: {
89
+ prompt_tokens?: number;
90
+ completion_tokens?: number;
91
+ };
92
+ }
93
+ declare function routerCompletion(req: RouterCompletionRequest): Promise<RouterCompletionResponse>;
94
+ declare function estimateRouterCost(model: string, usage?: {
95
+ prompt_tokens?: number;
96
+ completion_tokens?: number;
97
+ }): number;
98
+ declare function defaultRouterBaseUrl(): string;
99
+ declare function requireRouterApiKey(): string;
100
+
101
+ declare const DEFAULT_RESEARCHER_MODEL = "openai/gpt-4o-mini";
102
+ declare const DEFAULT_CODER_MODEL = "openai/gpt-4o-mini";
103
+ interface DefaultResearcherConfig {
104
+ /** Replace the system prompt to bias the researcher toward a domain's
105
+ * citation style. Defaults to a generic "cite sources by name" prompt. */
106
+ systemPrompt?: string;
107
+ model?: string;
108
+ }
109
+ interface DefaultCoderConfig {
110
+ /** Replace the system prompt to bias the coder toward a language /
111
+ * framework / artifact style. */
112
+ systemPrompt?: string;
113
+ model?: string;
114
+ }
115
+ declare const DEFAULT_DELEGATE_RESEARCH_TOOL: MultishotToolDefinition;
116
+ declare const DEFAULT_DELEGATE_CODE_TOOL: MultishotToolDefinition;
117
+ declare function createResearchExecutor(config?: DefaultResearcherConfig): MultishotToolExecutor;
118
+ declare function createCodeExecutor(config?: DefaultCoderConfig): MultishotToolExecutor;
119
+ interface DefaultToolsConfig {
120
+ research?: DefaultResearcherConfig;
121
+ code?: DefaultCoderConfig;
122
+ /** When true (default), each tool result is recorded as a typed artifact:
123
+ * research → type='research', code → type='code'. */
124
+ recordArtifacts?: boolean;
125
+ }
126
+ interface DefaultToolsBundle {
127
+ tools: MultishotToolDefinition[];
128
+ executors: Record<string, MultishotToolExecutor>;
129
+ artifactTypeFor: (toolName: string) => string | undefined;
130
+ }
131
+ declare function defaultDelegationTools(config?: DefaultToolsConfig): DefaultToolsBundle;
132
+
133
+ declare const DEFAULT_JUDGE_MODEL = "openai/gpt-4o-mini";
134
+ interface JudgeDimension {
135
+ /** JSON field name + score key. */
136
+ key: string;
137
+ /** Description shown in the judge's user prompt. */
138
+ description: string;
139
+ }
140
+ interface JudgeConfig<TInput> {
141
+ /** Display name (for trace + log). */
142
+ name: string;
143
+ /** Model used for this judge. */
144
+ model?: string;
145
+ /** 0-10 scored dimensions. */
146
+ dimensions: JudgeDimension[];
147
+ /** Judge system prompt — sets persona + JSON-only constraint. */
148
+ systemPrompt: string;
149
+ /** Build the user prompt from the typed input. Must include "Respond with
150
+ * ONLY this JSON: { ... }" listing each dimension key. */
151
+ buildPrompt: (input: TInput) => string;
152
+ /** Optional model + api overrides. */
153
+ apiKey?: string;
154
+ baseUrl?: string;
155
+ }
156
+ interface JudgeScore {
157
+ /** Per-dimension 0-10 score. Missing dims default to 0. */
158
+ dimensions: Record<string, number>;
159
+ /** Mean across dimensions. */
160
+ composite: number;
161
+ /** Free-form 1-2 sentence critique from the judge (when provided). */
162
+ notes: string;
163
+ }
164
+ declare function runJudge<TInput>(judge: JudgeConfig<TInput>, input: TInput): Promise<JudgeScore>;
165
+ /** Convenience: stringified dimension list for inclusion in a judge prompt.
166
+ * Returns lines like `- audience_fit: Does this match what the audience cares about? (0-10)`. */
167
+ declare function renderDimensions(dims: readonly JudgeDimension[]): string;
168
+ /** Convenience: build the "Respond with ONLY this JSON" footer for a judge prompt. */
169
+ declare function renderJsonFooter(dims: readonly JudgeDimension[]): string;
170
+
171
+ interface ConversationJudgeInput<TPersona extends MultishotPersona> {
172
+ transcript: MultishotMessage[];
173
+ persona: TPersona;
174
+ }
175
+ interface ArtifactJudgeInput<TPersona extends MultishotPersona> {
176
+ artifact: MultishotArtifact;
177
+ persona: TPersona;
178
+ }
179
+ interface MultishotJudges<TPersona extends MultishotPersona> {
180
+ /** Scores the full transcript end-to-end (always runs). */
181
+ conversation: JudgeConfig<ConversationJudgeInput<TPersona>>;
182
+ /** Scores each code-type artifact. Optional — omit when domain has no code artifacts. */
183
+ codeReview?: JudgeConfig<ArtifactJudgeInput<TPersona>>;
184
+ /** Scores each non-code (research/content/template) artifact. Optional. */
185
+ contentQuality?: JudgeConfig<ArtifactJudgeInput<TPersona>>;
186
+ /** Which artifact types route to codeReview. Defaults to ['code']. */
187
+ codeArtifactTypes?: string[];
188
+ /** Which artifact types route to contentQuality. Defaults to ['research']. */
189
+ contentArtifactTypes?: string[];
190
+ }
191
+ interface CellCompositeScore {
192
+ composite: number;
193
+ conversation: JudgeScore;
194
+ codeReview?: {
195
+ perArtifact: Array<JudgeScore & {
196
+ turn: number;
197
+ type: string;
198
+ }>;
199
+ composite: number;
200
+ };
201
+ contentQuality?: {
202
+ perArtifact: Array<JudgeScore & {
203
+ turn: number;
204
+ type: string;
205
+ }>;
206
+ composite: number;
207
+ };
208
+ }
209
+ interface RunMultishotMatrixOptions<TPersona extends MultishotPersona> {
210
+ /** AgentProfile axis (matrix primary). */
211
+ profiles: Array<{
212
+ id: string;
213
+ value: AgentProfile;
214
+ }>;
215
+ /** Persona axis. */
216
+ personas: TPersona[];
217
+ /** Persona-shaping callbacks. */
218
+ shape: MultishotShape<TPersona>;
219
+ /** Judge configurations. */
220
+ judges: MultishotJudges<TPersona>;
221
+ /** Tool definitions advertised to the agent. Defaults to delegate_research + delegate_code. */
222
+ tools?: MultishotToolDefinition[];
223
+ /** Map from tool name → inline executor. Must align with `tools`. */
224
+ toolExecutors?: Record<string, MultishotToolExecutor>;
225
+ /** Tool name → artifact type label. Defaults to research/code mapping. */
226
+ artifactTypeFor?: (toolName: string) => string | undefined;
227
+ /** Where per-cell artifacts land. Cells write to `<runDir>/<profileId>/<personaId>/rep-N/`. */
228
+ runDir: string;
229
+ /** Replicates per (profile, persona) cell. */
230
+ reps?: number;
231
+ /** Max conversation turns per cell. */
232
+ maxTurns?: number;
233
+ /** Max concurrent cells. */
234
+ maxConcurrency?: number;
235
+ /** Total $ ceiling across the matrix; cells aborted past this. */
236
+ costCeiling?: number;
237
+ /** Agent model. */
238
+ agentModel?: string;
239
+ /** Driver model. */
240
+ driverModel?: string;
241
+ /** Pass-thru fields. */
242
+ apiKey?: string;
243
+ baseUrl?: string;
244
+ }
245
+ interface CellOutput {
246
+ turns: number;
247
+ toolCalls: number;
248
+ artifactCount: number;
249
+ }
250
+ interface RunMultishotMatrixResult {
251
+ matrix: MatrixResult<CellOutput>;
252
+ }
253
+ declare function runMultishotMatrix<TPersona extends MultishotPersona>(opts: RunMultishotMatrixOptions<TPersona>): Promise<RunMultishotMatrixResult>;
254
+
255
+ interface RunMultishotOptions<TPersona extends MultishotPersona> {
256
+ profile: AgentProfile;
257
+ persona: TPersona;
258
+ shape: MultishotShape<TPersona>;
259
+ /** Tool definitions advertised to the agent. Defaults to delegate_research + delegate_code. */
260
+ tools?: MultishotToolDefinition[];
261
+ /** Map from tool name → executor invoked inline when the agent emits a tool_call. */
262
+ toolExecutors?: Record<string, MultishotToolExecutor>;
263
+ /** Map from tool name → artifact type label written into MultishotArtifact.type.
264
+ * Tools without a mapping still execute, but their results aren't surfaced as
265
+ * typed artifacts (only as tool messages in the transcript). */
266
+ artifactTypeFor?: (toolName: string) => string | undefined;
267
+ maxTurns?: number;
268
+ agentModel?: string;
269
+ driverModel?: string;
270
+ apiKey?: string;
271
+ baseUrl?: string;
272
+ signal?: AbortSignal;
273
+ }
274
+ declare function runMultishot<TPersona extends MultishotPersona>(opts: RunMultishotOptions<TPersona>): Promise<MultishotResult>;
275
+
276
+ export { type ArtifactJudgeInput, type CellCompositeScore, type ConversationJudgeInput, DEFAULT_CODER_MODEL, DEFAULT_DELEGATE_CODE_TOOL, DEFAULT_DELEGATE_RESEARCH_TOOL, DEFAULT_JUDGE_MODEL, DEFAULT_RESEARCHER_MODEL, type DefaultCoderConfig, type DefaultResearcherConfig, type DefaultToolsBundle, type DefaultToolsConfig, type JudgeConfig, type JudgeDimension, type JudgeScore, type MultishotArtifact, MultishotDriverEmptyError, type MultishotJudges, type MultishotMessage, type MultishotPersona, type MultishotResult, type MultishotShape, type MultishotToolDefinition, type MultishotToolExecutor, type RouterCompletionRequest, type RouterCompletionResponse, type RouterToolCall, type RunMultishotMatrixOptions, type RunMultishotMatrixResult, type RunMultishotOptions, createCodeExecutor, createResearchExecutor, defaultDelegationTools, defaultRouterBaseUrl, estimateRouterCost, renderDimensions, renderJsonFooter, requireRouterApiKey, routerCompletion, runJudge, runMultishot, runMultishotMatrix };