veryfront 0.1.522 → 0.1.524

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 (33) hide show
  1. package/esm/deno.d.ts +0 -5
  2. package/esm/deno.js +1 -13
  3. package/esm/src/agent/testing/durable-run-canaries/index.d.ts +2 -0
  4. package/esm/src/agent/testing/durable-run-canaries/index.d.ts.map +1 -0
  5. package/esm/src/agent/testing/durable-run-canaries/index.js +1 -0
  6. package/esm/src/agent/testing/durable-run-canaries/runner.d.ts +102 -0
  7. package/esm/src/agent/testing/durable-run-canaries/runner.d.ts.map +1 -0
  8. package/esm/src/agent/testing/durable-run-canaries/runner.js +372 -0
  9. package/esm/src/agent/testing/index.d.ts +2 -1
  10. package/esm/src/agent/testing/index.d.ts.map +1 -1
  11. package/esm/src/agent/testing/index.js +2 -1
  12. package/esm/src/agent/testing/live-evals/index.d.ts +2 -1
  13. package/esm/src/agent/testing/live-evals/index.d.ts.map +1 -1
  14. package/esm/src/agent/testing/live-evals/index.js +2 -1
  15. package/esm/src/agent/testing/live-evals/request.d.ts +16 -17
  16. package/esm/src/agent/testing/live-evals/request.d.ts.map +1 -1
  17. package/esm/src/agent/testing/live-evals/runner.d.ts +124 -0
  18. package/esm/src/agent/testing/live-evals/runner.d.ts.map +1 -0
  19. package/esm/src/agent/testing/live-evals/runner.js +391 -0
  20. package/esm/src/server/handlers/request/agent-stream.handler.d.ts.map +1 -1
  21. package/esm/src/server/handlers/request/agent-stream.handler.js +10 -1
  22. package/esm/src/utils/version-constant.d.ts +1 -1
  23. package/esm/src/utils/version-constant.js +1 -1
  24. package/package.json +1 -1
  25. package/src/deno.js +1 -13
  26. package/src/src/agent/testing/durable-run-canaries/index.ts +18 -0
  27. package/src/src/agent/testing/durable-run-canaries/runner.ts +582 -0
  28. package/src/src/agent/testing/index.ts +31 -0
  29. package/src/src/agent/testing/live-evals/index.ts +18 -1
  30. package/src/src/agent/testing/live-evals/request.ts +19 -1
  31. package/src/src/agent/testing/live-evals/runner.ts +629 -0
  32. package/src/src/server/handlers/request/agent-stream.handler.ts +18 -1
  33. package/src/src/utils/version-constant.ts +1 -1
@@ -0,0 +1,124 @@
1
+ import { type AgUiSseProgressSnapshot as EvalProgressSnapshot, type ParsedAgUiSseRun as ParsedRun } from "../../index.js";
2
+ import { type LiveEvalRuntime } from "./performance.js";
3
+ import { type LiveEvalCaseMetadata } from "./report.js";
4
+ import { type LiveEvalResultRecord } from "./result.js";
5
+ export interface PreparedLiveEvalInput {
6
+ prompt?: string;
7
+ metadata?: Record<string, string>;
8
+ verificationContext?: LiveEvalContext;
9
+ cleanup?: () => Promise<void>;
10
+ startSidecar?: () => Promise<(() => Promise<void>) | void>;
11
+ }
12
+ export interface LiveEvalContext {
13
+ apiUrl: string;
14
+ authToken: string;
15
+ projectId: string | null;
16
+ }
17
+ export interface LiveEvalCase {
18
+ readonly id: string;
19
+ readonly label: string;
20
+ readonly prompt?: string;
21
+ allowedTools?: string[];
22
+ forceRuntimeOverrides?: boolean;
23
+ requireProject?: boolean;
24
+ maxSteps?: number;
25
+ expectedEventSubsequence?: string[];
26
+ metadata?: LiveEvalCaseMetadata;
27
+ prepare?: (context: LiveEvalContext) => Promise<PreparedLiveEvalInput>;
28
+ verify: (run: ParsedRun, prepared: PreparedLiveEvalInput | null) => string | null | Promise<string | null>;
29
+ }
30
+ interface FileCheckInput {
31
+ filePath: string;
32
+ requiredContent?: string[];
33
+ description?: string;
34
+ }
35
+ export interface LiveEvalProjectFile {
36
+ path: string;
37
+ content: string;
38
+ }
39
+ export interface LiveEvalProjectFileReaderInput {
40
+ filePath: string;
41
+ requestTimeoutMs: number;
42
+ }
43
+ export interface LiveEvalRunnerConfig {
44
+ endpoint: string;
45
+ authToken: string;
46
+ apiUrl: string;
47
+ projectId: string | null;
48
+ branchId: string | null;
49
+ model: string | null;
50
+ requestTimeoutMs: number;
51
+ progressLogIntervalMs: number;
52
+ enableLlmJudge: boolean;
53
+ fetch?: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
54
+ log?: (message: string) => void;
55
+ readProjectFile?: (input: LiveEvalProjectFileReaderInput) => Promise<LiveEvalProjectFile | null>;
56
+ }
57
+ interface LiveEvalJudgeInput {
58
+ question: string;
59
+ criteria: string;
60
+ }
61
+ interface LiveEvalJudgeRequest extends LiveEvalJudgeInput {
62
+ answer: string;
63
+ }
64
+ interface LiveEvalJudgeResult {
65
+ pass: boolean;
66
+ reason: string;
67
+ }
68
+ declare function collectPreparedArtifactPaths(prepared: PreparedLiveEvalInput | null): string[];
69
+ interface LiveEvalResultContext {
70
+ id: string;
71
+ label: string;
72
+ runtime: LiveEvalRuntime;
73
+ startedAt: number;
74
+ conversationId?: string | null;
75
+ artifactPaths?: string[];
76
+ }
77
+ interface LiveEvalRunArtifactsInput {
78
+ run: ParsedRun;
79
+ runId?: string;
80
+ traceSignature: string;
81
+ }
82
+ interface LiveEvalRunArtifacts {
83
+ runId?: string;
84
+ traceSignature: string;
85
+ toolStarts: string[];
86
+ toolArgsPreview: string;
87
+ textPreview: string;
88
+ }
89
+ declare function createLiveEvalRunArtifacts(input: LiveEvalRunArtifactsInput): LiveEvalRunArtifacts;
90
+ declare function createFailedRunEvalResult(input: {
91
+ details: string;
92
+ context: LiveEvalResultContext;
93
+ runArtifacts: LiveEvalRunArtifacts;
94
+ }): LiveEvalResultRecord;
95
+ declare function createPassedRunEvalResult(input: {
96
+ details: string;
97
+ context: LiveEvalResultContext;
98
+ runArtifacts: LiveEvalRunArtifacts;
99
+ }): LiveEvalResultRecord;
100
+ declare function createStreamingFailureEvalResult(input: {
101
+ details: string;
102
+ context: LiveEvalResultContext;
103
+ progress: EvalProgressSnapshot;
104
+ }): LiveEvalResultRecord;
105
+ declare function extractRunId(run: ParsedRun): string | null;
106
+ export declare function hasFinished(run: ParsedRun): boolean;
107
+ export declare function containsSkillLoad(run: ParsedRun, skillId: string): boolean;
108
+ export declare function countStepStartedEvents(run: ParsedRun): number;
109
+ export declare function createLiveEvalCaseSupport(config: LiveEvalRunnerConfig): {
110
+ runEval: (testCase: LiveEvalCase, runtime: LiveEvalRuntime) => Promise<LiveEvalResultRecord>;
111
+ verifyFileExists: (input: FileCheckInput) => Promise<string | null>;
112
+ withJudge: (structuralVerify: (run: ParsedRun) => string | null, judgeInput: LiveEvalJudgeInput) => (run: ParsedRun) => Promise<string | null>;
113
+ judgeLlm: (input: LiveEvalJudgeRequest) => Promise<LiveEvalJudgeResult>;
114
+ };
115
+ export declare const liveEvalRunnerInternals: {
116
+ collectPreparedArtifactPaths: typeof collectPreparedArtifactPaths;
117
+ createFailedRunEvalResult: typeof createFailedRunEvalResult;
118
+ createLiveEvalRunArtifacts: typeof createLiveEvalRunArtifacts;
119
+ createPassedRunEvalResult: typeof createPassedRunEvalResult;
120
+ createStreamingFailureEvalResult: typeof createStreamingFailureEvalResult;
121
+ extractRunId: typeof extractRunId;
122
+ };
123
+ export {};
124
+ //# sourceMappingURL=runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../../../src/src/agent/testing/live-evals/runner.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,uBAAuB,IAAI,oBAAoB,EAIpD,KAAK,gBAAgB,IAAI,SAAS,EACnC,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAIL,KAAK,oBAAoB,EAC1B,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,mBAAmB,CAAC,EAAE,eAAe,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,YAAY,CA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,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC7F,gBAAgB,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACpE,SAAS,EAAE,CACT,gBAAgB,EAAE,CAAC,GAAG,EAAE,SAAS,KAAK,MAAM,GAAG,IAAI,EACnD,UAAU,EAAE,kBAAkB,KAC3B,CAAC,GAAG,EAAE,SAAS,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAChD,QAAQ,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACzE,CAoIA;AAED,eAAO,MAAM,uBAAuB;;;;;;;CAOnC,CAAC"}
@@ -0,0 +1,391 @@
1
+ import * as dntShim from "../../../../_dnt.shims.js";
2
+ import { agUiSseEventTypes, buildAgUiSseTraceSignature as buildTraceSignature, getAgUiSseStringField as getStringField, parseAgUiSseResponse as parseSseResponse, } from "../../index.js";
3
+ import { buildFailureSuffix, buildProgressLine, containsOrderedSubsequence } from "./formatting.js";
4
+ import { buildLiveEvalRequestBody } from "./request.js";
5
+ import { createFailedEvalResult, createPassedEvalResult, createSkippedEvalResult, } from "./result.js";
6
+ function resolveFetch(config) {
7
+ return config.fetch ?? fetch;
8
+ }
9
+ function createLiveEvalJudgeSupport(config) {
10
+ async function judgeLlm(input) {
11
+ try {
12
+ const body = buildLiveEvalRequestBody({
13
+ testCaseId: "llm-judge",
14
+ prompt: `You are an eval judge. Grade the following answer.
15
+
16
+ QUESTION: ${input.question}
17
+
18
+ ANSWER: ${input.answer}
19
+
20
+ CRITERIA: ${input.criteria}
21
+
22
+ Respond with exactly one line: PASS or FAIL followed by a brief reason.
23
+ Example: "PASS — correctly explains the pattern with accurate details"
24
+ Example: "FAIL — mentions the wrong file convention"`,
25
+ projectId: null,
26
+ allowedTools: [],
27
+ forceRuntimeOverrides: true,
28
+ maxSteps: 2,
29
+ });
30
+ const response = await resolveFetch(config)(config.endpoint, {
31
+ method: "POST",
32
+ headers: {
33
+ "Content-Type": "application/json",
34
+ Authorization: `Bearer ${config.authToken}`,
35
+ },
36
+ body: JSON.stringify(body),
37
+ signal: AbortSignal.timeout(30_000),
38
+ });
39
+ const run = await parseSseResponse(response);
40
+ if (run.responseStatus !== 200) {
41
+ return { pass: false, reason: `judge returned HTTP ${run.responseStatus}` };
42
+ }
43
+ const line = run.text
44
+ .split("\n")
45
+ .map((value) => value.trim())
46
+ .find((value) => value.length > 0) ?? "";
47
+ if (line.toUpperCase().startsWith("PASS")) {
48
+ return { pass: true, reason: line };
49
+ }
50
+ return { pass: false, reason: line || "judge returned no decision" };
51
+ }
52
+ catch (error) {
53
+ return {
54
+ pass: false,
55
+ reason: error instanceof Error ? error.message : String(error),
56
+ };
57
+ }
58
+ }
59
+ function withJudge(structuralVerify, judgeInput) {
60
+ return async (run) => {
61
+ const structuralFailure = structuralVerify(run);
62
+ if (structuralFailure) {
63
+ return structuralFailure;
64
+ }
65
+ if (!config.enableLlmJudge) {
66
+ return null;
67
+ }
68
+ const judgment = await judgeLlm({
69
+ question: judgeInput.question,
70
+ answer: run.text,
71
+ criteria: judgeInput.criteria,
72
+ });
73
+ return judgment.pass ? null : `LLM judge: ${judgment.reason}`;
74
+ };
75
+ }
76
+ return {
77
+ judgeLlm,
78
+ withJudge,
79
+ };
80
+ }
81
+ function createInitialProgressSnapshot() {
82
+ return {
83
+ eventCount: 0,
84
+ lastEventType: null,
85
+ lastToolCallName: null,
86
+ toolStarts: [],
87
+ textLength: 0,
88
+ };
89
+ }
90
+ function isUnrefableTimer(value) {
91
+ return typeof value === "object" && value !== null && "unref" in value &&
92
+ typeof value.unref === "function";
93
+ }
94
+ function maybeUnrefTimer(timer) {
95
+ if (isUnrefableTimer(timer)) {
96
+ timer.unref();
97
+ }
98
+ }
99
+ function createLiveEvalProgressReporter(input) {
100
+ let latestProgress = createInitialProgressSnapshot();
101
+ const progressTimer = dntShim.setInterval(() => {
102
+ input.log(buildProgressLine({
103
+ caseId: input.caseId,
104
+ startedAt: input.startedAt,
105
+ progress: latestProgress,
106
+ }));
107
+ }, input.intervalMs);
108
+ maybeUnrefTimer(progressTimer);
109
+ return {
110
+ stop: () => {
111
+ clearInterval(progressTimer);
112
+ },
113
+ update: (snapshot) => {
114
+ latestProgress = snapshot;
115
+ },
116
+ getSnapshot: () => latestProgress,
117
+ };
118
+ }
119
+ function collectPreparedArtifactPaths(prepared) {
120
+ if (!prepared?.metadata) {
121
+ return [];
122
+ }
123
+ return [
124
+ ...new Set(Object.entries(prepared.metadata)
125
+ .filter(([key, value]) => key.toLowerCase().includes("path") && value.length > 0)
126
+ .map(([, value]) => value)),
127
+ ].sort();
128
+ }
129
+ function extractPreparedConversationId(prepared) {
130
+ return typeof prepared?.metadata?.conversationId === "string" &&
131
+ prepared.metadata.conversationId.length > 0
132
+ ? prepared.metadata.conversationId
133
+ : null;
134
+ }
135
+ function createLiveEvalRunArtifacts(input) {
136
+ return {
137
+ ...(input.runId ? { runId: input.runId } : {}),
138
+ traceSignature: input.traceSignature,
139
+ toolStarts: input.run.toolStarts,
140
+ toolArgsPreview: input.run.toolArgs.join(" | ").slice(0, 1000),
141
+ textPreview: input.run.text.slice(0, 280),
142
+ };
143
+ }
144
+ function createFailedRunEvalResult(input) {
145
+ return createFailedEvalResult({
146
+ id: input.context.id,
147
+ label: input.context.label,
148
+ runtime: input.context.runtime,
149
+ details: input.details,
150
+ startedAt: input.context.startedAt,
151
+ ...(input.context.conversationId ? { conversationId: input.context.conversationId } : {}),
152
+ ...(input.runArtifacts.runId ? { runId: input.runArtifacts.runId } : {}),
153
+ ...(input.context.artifactPaths?.length ? { artifactPaths: input.context.artifactPaths } : {}),
154
+ traceSignature: input.runArtifacts.traceSignature,
155
+ toolStarts: input.runArtifacts.toolStarts,
156
+ toolArgsPreview: input.runArtifacts.toolArgsPreview,
157
+ textPreview: input.runArtifacts.textPreview,
158
+ });
159
+ }
160
+ function createPassedRunEvalResult(input) {
161
+ return createPassedEvalResult({
162
+ id: input.context.id,
163
+ label: input.context.label,
164
+ runtime: input.context.runtime,
165
+ details: input.details,
166
+ startedAt: input.context.startedAt,
167
+ ...(input.context.conversationId ? { conversationId: input.context.conversationId } : {}),
168
+ ...(input.runArtifacts.runId ? { runId: input.runArtifacts.runId } : {}),
169
+ ...(input.context.artifactPaths?.length ? { artifactPaths: input.context.artifactPaths } : {}),
170
+ traceSignature: input.runArtifacts.traceSignature,
171
+ toolStarts: input.runArtifacts.toolStarts,
172
+ toolArgsPreview: input.runArtifacts.toolArgsPreview,
173
+ textPreview: input.runArtifacts.textPreview,
174
+ });
175
+ }
176
+ function createStreamingFailureEvalResult(input) {
177
+ return createFailedEvalResult({
178
+ id: input.context.id,
179
+ label: input.context.label,
180
+ runtime: input.context.runtime,
181
+ details: `${input.details}${buildFailureSuffix(input.progress)}`,
182
+ startedAt: input.context.startedAt,
183
+ ...(input.context.conversationId ? { conversationId: input.context.conversationId } : {}),
184
+ ...(input.context.artifactPaths?.length ? { artifactPaths: input.context.artifactPaths } : {}),
185
+ toolStarts: input.progress.toolStarts,
186
+ textPreview: input.progress.textLength > 0
187
+ ? `${input.progress.textLength} characters streamed`
188
+ : undefined,
189
+ });
190
+ }
191
+ function createLiveEvalResultContext(input) {
192
+ return {
193
+ id: input.testCase.id,
194
+ label: input.testCase.label,
195
+ runtime: input.runtime,
196
+ startedAt: input.startedAt,
197
+ ...(input.conversationId ? { conversationId: input.conversationId } : {}),
198
+ ...(input.artifactPaths.length > 0 ? { artifactPaths: input.artifactPaths } : {}),
199
+ };
200
+ }
201
+ function buildLiveEvalRunBody(input) {
202
+ const customBody = typeof input.prepared?.metadata?.customBody === "string"
203
+ ? input.prepared.metadata.customBody
204
+ : null;
205
+ if (customBody) {
206
+ return JSON.parse(customBody);
207
+ }
208
+ return buildLiveEvalRequestBody({
209
+ testCaseId: input.testCase.id,
210
+ prompt: input.prepared?.prompt ?? input.testCase.prompt ?? "",
211
+ metadata: input.prepared?.metadata,
212
+ projectId: input.config.projectId && input.testCase.requireProject
213
+ ? input.config.projectId
214
+ : null,
215
+ ...(input.config.branchId ? { branchId: input.config.branchId } : {}),
216
+ ...(input.config.model ? { model: input.config.model } : {}),
217
+ ...(input.conversationId ? { conversationId: input.conversationId } : {}),
218
+ allowedTools: input.testCase.allowedTools,
219
+ forceRuntimeOverrides: input.testCase.forceRuntimeOverrides,
220
+ maxSteps: input.testCase.maxSteps,
221
+ });
222
+ }
223
+ async function resolveCompletedLiveEvalRun(input) {
224
+ const traceSignature = buildTraceSignature(input.run.eventTypes);
225
+ const runArtifacts = createLiveEvalRunArtifacts({
226
+ run: input.run,
227
+ runId: input.runId,
228
+ traceSignature,
229
+ });
230
+ const failure = await input.testCase.verify(input.run, input.prepared);
231
+ if (!failure && input.testCase.expectedEventSubsequence) {
232
+ if (!containsOrderedSubsequence(input.run.eventTypes, input.testCase.expectedEventSubsequence)) {
233
+ return createFailedRunEvalResult({
234
+ context: input.context,
235
+ details: `Expected AG-UI event subsequence ${input.testCase.expectedEventSubsequence.join(" -> ")}, got ${traceSignature}`,
236
+ runArtifacts,
237
+ });
238
+ }
239
+ }
240
+ if (failure) {
241
+ return createFailedRunEvalResult({
242
+ context: input.context,
243
+ details: failure,
244
+ runArtifacts,
245
+ });
246
+ }
247
+ return createPassedRunEvalResult({
248
+ context: input.context,
249
+ details: `OK: ${input.run.toolStarts.join(", ") || "no tools"} | ${input.run.text.slice(0, 140) || "no text"}`,
250
+ runArtifacts,
251
+ });
252
+ }
253
+ function extractRunId(run) {
254
+ for (const event of run.events) {
255
+ const runId = getStringField(event, "runId") ?? getStringField(event, "run_id");
256
+ if (runId) {
257
+ return runId;
258
+ }
259
+ }
260
+ return null;
261
+ }
262
+ export function hasFinished(run) {
263
+ return run.eventTypes.includes(agUiSseEventTypes.runFinished) && !run.runError;
264
+ }
265
+ export function containsSkillLoad(run, skillId) {
266
+ return run.toolStarts.includes("load_skill") && run.toolArgs.join("").includes(skillId);
267
+ }
268
+ export function countStepStartedEvents(run) {
269
+ return run.eventTypes.filter((eventType) => eventType === agUiSseEventTypes.stepStarted).length;
270
+ }
271
+ export function createLiveEvalCaseSupport(config) {
272
+ const fetchImpl = resolveFetch(config);
273
+ const log = config.log ?? console.log;
274
+ const { judgeLlm, withJudge } = createLiveEvalJudgeSupport(config);
275
+ async function verifyFileExists(input) {
276
+ if (!config.projectId || !config.readProjectFile) {
277
+ return null;
278
+ }
279
+ const file = await config.readProjectFile({
280
+ filePath: input.filePath,
281
+ requestTimeoutMs: config.requestTimeoutMs,
282
+ });
283
+ if (!file) {
284
+ return `${input.description ?? input.filePath}: file not found in project after task completed`;
285
+ }
286
+ if (!file.content || file.content.trim().length === 0) {
287
+ return `${input.description ?? input.filePath}: file exists but is empty`;
288
+ }
289
+ if (input.requiredContent) {
290
+ const missing = input.requiredContent.filter((keyword) => !file.content.toLowerCase().includes(keyword.toLowerCase()));
291
+ if (missing.length > 0) {
292
+ return `${input.description ?? input.filePath}: missing required content: ${missing.join(", ")}. Got: ${file.content.slice(0, 200)}`;
293
+ }
294
+ }
295
+ return null;
296
+ }
297
+ async function runEval(testCase, runtime) {
298
+ const startedAt = Date.now();
299
+ if (testCase.requireProject && !config.projectId) {
300
+ return createSkippedEvalResult({
301
+ id: testCase.id,
302
+ label: testCase.label,
303
+ runtime,
304
+ details: "Skipped because AG_UI_EVAL_PROJECT_ID is not set.",
305
+ startedAt,
306
+ });
307
+ }
308
+ const prepared = testCase.prepare
309
+ ? await testCase.prepare({
310
+ apiUrl: config.apiUrl,
311
+ authToken: config.authToken,
312
+ projectId: config.projectId,
313
+ })
314
+ : null;
315
+ const preparedConversationId = extractPreparedConversationId(prepared);
316
+ const preparedArtifactPaths = collectPreparedArtifactPaths(prepared);
317
+ const resultContext = createLiveEvalResultContext({
318
+ testCase,
319
+ runtime,
320
+ startedAt,
321
+ conversationId: preparedConversationId,
322
+ artifactPaths: preparedArtifactPaths,
323
+ });
324
+ try {
325
+ const sidecarCleanup = prepared?.startSidecar ? await prepared.startSidecar() : undefined;
326
+ const progressReporter = createLiveEvalProgressReporter({
327
+ caseId: testCase.id,
328
+ startedAt,
329
+ intervalMs: config.progressLogIntervalMs,
330
+ log,
331
+ });
332
+ const body = buildLiveEvalRunBody({
333
+ config,
334
+ testCase,
335
+ prepared,
336
+ conversationId: preparedConversationId,
337
+ });
338
+ try {
339
+ const response = await fetchImpl(config.endpoint, {
340
+ method: "POST",
341
+ headers: {
342
+ "Content-Type": "application/json",
343
+ Authorization: `Bearer ${config.authToken}`,
344
+ },
345
+ body: JSON.stringify(body),
346
+ signal: AbortSignal.timeout(config.requestTimeoutMs),
347
+ });
348
+ log(`[stream] ${runtime}:${testCase.id} HTTP ${response.status}`);
349
+ const run = await parseSseResponse(response, {
350
+ onProgress: progressReporter.update,
351
+ });
352
+ return resolveCompletedLiveEvalRun({
353
+ testCase,
354
+ run,
355
+ prepared,
356
+ context: resultContext,
357
+ runId: extractRunId(run) ?? undefined,
358
+ });
359
+ }
360
+ catch (error) {
361
+ const message = error instanceof Error ? error.message : String(error);
362
+ return createStreamingFailureEvalResult({
363
+ context: resultContext,
364
+ details: message,
365
+ progress: progressReporter.getSnapshot(),
366
+ });
367
+ }
368
+ finally {
369
+ progressReporter.stop();
370
+ await sidecarCleanup?.();
371
+ }
372
+ }
373
+ finally {
374
+ await prepared?.cleanup?.();
375
+ }
376
+ }
377
+ return {
378
+ judgeLlm,
379
+ runEval,
380
+ verifyFileExists,
381
+ withJudge,
382
+ };
383
+ }
384
+ export const liveEvalRunnerInternals = {
385
+ collectPreparedArtifactPaths,
386
+ createFailedRunEvalResult,
387
+ createLiveEvalRunArtifacts,
388
+ createPassedRunEvalResult,
389
+ createStreamingFailureEvalResult,
390
+ extractRunId,
391
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"agent-stream.handler.d.ts","sourceRoot":"","sources":["../../../../../src/src/server/handlers/request/agent-stream.handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,yBAAyB,EAC/B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAEL,KAAK,+BAA+B,EACrC,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,4BAA4B,EAE7B,MAAM,2CAA2C,CAAC;AAmBnD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAmB,aAAa,EAAE,MAAM,aAAa,CAAC;AAKnG,MAAM,WAAW,sBACf,SAAQ,yBAAyB,EAAE,+BAA+B;IAClE,4BAA4B,CAAC,EAAE,OAAO,4BAA4B,CAAC;CACpE;AA4ED,qBAAa,kBAAmB,SAAQ,WAAW;IASrC,OAAO,CAAC,QAAQ,CAAC,IAAI;IARjC,QAAQ,EAAE,eAAe,CAMvB;gBAE2B,IAAI,GAAE,sBAAoC;IAIvE,OAAO,CAAC,sBAAsB;IAwBxB,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;CAgHxE"}
1
+ {"version":3,"file":"agent-stream.handler.d.ts","sourceRoot":"","sources":["../../../../../src/src/server/handlers/request/agent-stream.handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,yBAAyB,EAC/B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAEL,KAAK,+BAA+B,EACrC,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,4BAA4B,EAE7B,MAAM,2CAA2C,CAAC;AAwBnD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAmB,aAAa,EAAE,MAAM,aAAa,CAAC;AAKnG,MAAM,WAAW,sBACf,SAAQ,yBAAyB,EAAE,+BAA+B;IAClE,4BAA4B,CAAC,EAAE,OAAO,4BAA4B,CAAC;CACpE;AAwFD,qBAAa,kBAAmB,SAAQ,WAAW;IASrC,OAAO,CAAC,QAAQ,CAAC,IAAI;IARjC,QAAQ,EAAE,eAAe,CAMvB;gBAE2B,IAAI,GAAE,sBAAoC;IAIvE,OAAO,CAAC,sBAAsB;IAwBxB,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;CAgHxE"}
@@ -5,6 +5,7 @@ import { resolveRuntimeOwnerInvokeUrl, RUNTIME_OWNER_INVOKE_URL_HEADER, } from "
5
5
  import { ControlPlaneRequestError, verifyControlPlaneRequest, } from "../../../internal-agents/control-plane-auth.js";
6
6
  import { INTERNAL_AGENT_STREAM_MAX_BODY_BYTES, InternalAgentRequestBodyTooLargeError, readInternalAgentRequestBody, } from "../../../internal-agents/request-body.js";
7
7
  import { AgentRunAlreadyExistsError, agentRunSessionManager, } from "../../../internal-agents/session-manager.js";
8
+ import { buildRuntimeAgentControlPlaneStreamRequestFromInvocation, RuntimeAgentRunInvocationSchema, } from "../../../agent/runtime/agent-invocation-contract.js";
8
9
  import { getInternalAgentStreamRequestSchema, toRuntimeRunAgentInput, } from "../../../internal-agents/schema.js";
9
10
  import { BaseHandler } from "../response/base.js";
10
11
  import { PRIORITY_MEDIUM_API } from "../../../utils/constants/index.js";
@@ -58,6 +59,14 @@ function setResponseHeader(target, key, value) {
58
59
  headers,
59
60
  });
60
61
  }
62
+ function parseAgentStreamPayload(rawPayload) {
63
+ const internalAgentStreamRequestSchema = getInternalAgentStreamRequestSchema();
64
+ const invocation = RuntimeAgentRunInvocationSchema.safeParse(rawPayload);
65
+ if (invocation.success) {
66
+ return internalAgentStreamRequestSchema.parse(buildRuntimeAgentControlPlaneStreamRequestFromInvocation(invocation.data));
67
+ }
68
+ return internalAgentStreamRequestSchema.parse(rawPayload);
69
+ }
61
70
  export class AgentStreamHandler extends BaseHandler {
62
71
  deps;
63
72
  metadata = {
@@ -92,7 +101,7 @@ export class AgentStreamHandler extends BaseHandler {
92
101
  .withSecurity(ctx.securityConfig ?? undefined, req);
93
102
  try {
94
103
  const rawBody = await readInternalAgentRequestBody(req, INTERNAL_AGENT_STREAM_MAX_BODY_BYTES);
95
- const payload = getInternalAgentStreamRequestSchema().parse(JSON.parse(rawBody));
104
+ const payload = parseAgentStreamPayload(JSON.parse(rawBody));
96
105
  await verifyControlPlaneRequest(req, ctx, rawBody, {
97
106
  expectedSubject: payload.runId,
98
107
  expectedSurface: "studio",
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.1.522";
1
+ export declare const VERSION = "0.1.524";
2
2
  //# sourceMappingURL=version-constant.d.ts.map
@@ -1,3 +1,3 @@
1
1
  // Keep in sync with deno.json version.
2
2
  // scripts/release.ts updates this constant during releases.
3
- export const VERSION = "0.1.522";
3
+ export const VERSION = "0.1.524";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veryfront",
3
- "version": "0.1.522",
3
+ "version": "0.1.524",
4
4
  "description": "The simplest way to build AI-powered apps",
5
5
  "keywords": [
6
6
  "react",
package/src/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.522",
3
+ "version": "0.1.524",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "workspace": [
@@ -296,9 +296,6 @@ export default {
296
296
  "strict": true,
297
297
  "noImplicitAny": true,
298
298
  "noUncheckedIndexedAccess": true,
299
- "types": [
300
- "npm:@types/react@19.2.14"
301
- ],
302
299
  "lib": [
303
300
  "deno.window",
304
301
  "dom",
@@ -431,14 +428,5 @@ export default {
431
428
  "semiColons": true,
432
429
  "singleQuote": false,
433
430
  "proseWrap": "preserve"
434
- },
435
- "allowScripts": {
436
- "allow": [
437
- "npm:sharp@0.33.5",
438
- "npm:onnxruntime-node@1.21.0"
439
- ],
440
- "deny": [
441
- "npm:protobufjs@7.5.4"
442
- ]
443
431
  }
444
432
  };
@@ -0,0 +1,18 @@
1
+ export {
2
+ createDurableRunCanaryApiClient,
3
+ createDurableRunCanaryRunner,
4
+ type DurableRunCanaryApiClient,
5
+ type DurableRunCanaryApiConfig,
6
+ type DurableRunCanaryCase,
7
+ type DurableRunCanaryCreateRootRunInput,
8
+ type DurableRunCanaryMessage,
9
+ type DurableRunCanaryPreparedCase,
10
+ type DurableRunCanaryResult,
11
+ type DurableRunCanaryRunnerConfig,
12
+ durableRunCanaryRunnerInternals,
13
+ type DurableRunCanaryRunSummary,
14
+ type DurableRunCanarySendUserMessageInput,
15
+ type DurableRunCanaryStartRunInput,
16
+ getDurableRunCanaryMessageSchema,
17
+ parseDurableRunCanaryRunSummary,
18
+ } from "./runner.js";