veryfront 0.1.893 → 0.1.895
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.
- package/esm/deno.d.ts +3 -0
- package/esm/deno.js +4 -1
- package/esm/src/discovery/import-rewriter.d.ts +1 -1
- package/esm/src/discovery/import-rewriter.d.ts.map +1 -1
- package/esm/src/discovery/import-rewriter.js +1 -0
- package/esm/src/discovery/transpiler.d.ts.map +1 -1
- package/esm/src/discovery/transpiler.js +2 -0
- package/esm/src/metrics/index.d.ts +31 -0
- package/esm/src/metrics/index.d.ts.map +1 -0
- package/esm/src/metrics/index.js +110 -0
- package/esm/src/server/handlers/request/project-run-execute.handler.d.ts +1 -0
- package/esm/src/server/handlers/request/project-run-execute.handler.d.ts.map +1 -1
- package/esm/src/server/handlers/request/project-run-execute.handler.js +80 -6
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +5 -1
package/esm/deno.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ declare namespace _default {
|
|
|
25
25
|
"./agent": string;
|
|
26
26
|
"./agent/identity": string;
|
|
27
27
|
"./eval": string;
|
|
28
|
+
"./metrics": string;
|
|
28
29
|
"./eval/agent-service": string;
|
|
29
30
|
"./channels/control-plane": string;
|
|
30
31
|
"./channels/invoke": string;
|
|
@@ -95,6 +96,7 @@ declare namespace _default {
|
|
|
95
96
|
"veryfront/embedding": string;
|
|
96
97
|
"veryfront/runs": string;
|
|
97
98
|
"veryfront/eval": string;
|
|
99
|
+
"veryfront/metrics": string;
|
|
98
100
|
"veryfront/eval/agent-service": string;
|
|
99
101
|
"veryfront/agent/identity": string;
|
|
100
102
|
"veryfront/agent/react": string;
|
|
@@ -179,6 +181,7 @@ declare namespace _default {
|
|
|
179
181
|
"#veryfront/errors": string;
|
|
180
182
|
"#veryfront/eval": string;
|
|
181
183
|
"#veryfront/eval/agent-service": string;
|
|
184
|
+
"#veryfront/metrics": string;
|
|
182
185
|
"#veryfront/extensions/eval": string;
|
|
183
186
|
"#veryfront/html": string;
|
|
184
187
|
"#veryfront/mcp": string;
|
package/esm/deno.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
"name": "veryfront",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.895",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"nodeModulesDir": "auto",
|
|
6
6
|
"minimumDependencyAge": {
|
|
@@ -81,6 +81,7 @@ export default {
|
|
|
81
81
|
"./agent": "./src/agent/index.ts",
|
|
82
82
|
"./agent/identity": "./src/agent/identity-contracts.ts",
|
|
83
83
|
"./eval": "./src/eval/index.ts",
|
|
84
|
+
"./metrics": "./src/metrics/index.ts",
|
|
84
85
|
"./eval/agent-service": "./src/eval/agent-service.ts",
|
|
85
86
|
"./channels/control-plane": "./src/channels/control-plane.ts",
|
|
86
87
|
"./channels/invoke": "./src/channels/invoke.ts",
|
|
@@ -151,6 +152,7 @@ export default {
|
|
|
151
152
|
"veryfront/embedding": "./src/embedding/index.ts",
|
|
152
153
|
"veryfront/runs": "./src/runs/index.ts",
|
|
153
154
|
"veryfront/eval": "./src/eval/index.ts",
|
|
155
|
+
"veryfront/metrics": "./src/metrics/index.ts",
|
|
154
156
|
"veryfront/eval/agent-service": "./src/eval/agent-service.ts",
|
|
155
157
|
"veryfront/agent/identity": "./src/agent/identity-contracts.ts",
|
|
156
158
|
"veryfront/agent/react": "./src/agent/react/index.ts",
|
|
@@ -235,6 +237,7 @@ export default {
|
|
|
235
237
|
"#veryfront/errors": "./src/errors/index.ts",
|
|
236
238
|
"#veryfront/eval": "./src/eval/index.ts",
|
|
237
239
|
"#veryfront/eval/agent-service": "./src/eval/agent-service.ts",
|
|
240
|
+
"#veryfront/metrics": "./src/metrics/index.ts",
|
|
238
241
|
"#veryfront/extensions/eval": "./src/extensions/eval/index.ts",
|
|
239
242
|
"#veryfront/html": "./src/html/index.ts",
|
|
240
243
|
"#veryfront/mcp": "./src/mcp/index.ts",
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* (Deno, Node.js) and handles veryfront package resolution.
|
|
6
6
|
*/
|
|
7
7
|
import { createFileSystem } from "../platform/compat/fs.js";
|
|
8
|
-
export declare const DISCOVERY_GLOBAL_VERYFRONT_MODULES: readonly ["veryfront/agent", "veryfront/tool", "veryfront/platform", "veryfront/prompt", "veryfront/resource", "veryfront/embedding", "veryfront/workflow", "veryfront/work", "veryfront/eval", "veryfront/schemas"];
|
|
8
|
+
export declare const DISCOVERY_GLOBAL_VERYFRONT_MODULES: readonly ["veryfront/agent", "veryfront/tool", "veryfront/platform", "veryfront/prompt", "veryfront/resource", "veryfront/embedding", "veryfront/workflow", "veryfront/work", "veryfront/eval", "veryfront/metrics", "veryfront/schemas"];
|
|
9
9
|
interface DenoRewriteOptions {
|
|
10
10
|
compiled?: boolean;
|
|
11
11
|
resolveSpecifier?: (specifier: string) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-rewriter.d.ts","sourceRoot":"","sources":["../../../src/src/discovery/import-rewriter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAI5D,eAAO,MAAM,kCAAkC,
|
|
1
|
+
{"version":3,"file":"import-rewriter.d.ts","sourceRoot":"","sources":["../../../src/src/discovery/import-rewriter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAI5D,eAAO,MAAM,kCAAkC,2OAYrC,CAAC;AAEX,UAAU,kBAAkB;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;CAClD;AAkHD;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,kBAAuB,GAC/B,MAAM,CA2BR;AAqFD;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,EACvC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,CA2PjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transpiler.d.ts","sourceRoot":"","sources":["../../../src/src/discovery/transpiler.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"transpiler.d.ts","sourceRoot":"","sources":["../../../src/src/discovery/transpiler.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAyIvD;;GAEG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,OAAO,CAAC,CAkGlB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C"}
|
|
@@ -22,6 +22,7 @@ import * as embeddingMod from "../embedding/index.js";
|
|
|
22
22
|
import * as workflowMod from "../workflow/index.js";
|
|
23
23
|
import * as workMod from "../work/index.js";
|
|
24
24
|
import * as evalMod from "../eval/index.js";
|
|
25
|
+
import * as metricsMod from "../metrics/index.js";
|
|
25
26
|
import * as schemasMod from "../schemas/index.js";
|
|
26
27
|
const transpileCache = new Map();
|
|
27
28
|
// Setup veryfront modules as globals for compiled binary support
|
|
@@ -42,6 +43,7 @@ async function ensureVeryfrontGlobals() {
|
|
|
42
43
|
"veryfront/workflow": workflowMod,
|
|
43
44
|
"veryfront/work": workMod,
|
|
44
45
|
"veryfront/eval": evalMod,
|
|
46
|
+
"veryfront/metrics": metricsMod,
|
|
45
47
|
"veryfront/schemas": schemasMod,
|
|
46
48
|
};
|
|
47
49
|
dntShim.dntGlobalThis.__VERYFRONT_MODULES__ = modules;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime/application metric hooks for project code.
|
|
3
|
+
*
|
|
4
|
+
* @module metrics
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { metrics } from "veryfront/metrics";
|
|
9
|
+
*
|
|
10
|
+
* metrics.counter("vf_eval_result_total", 1, { provider: "openai" });
|
|
11
|
+
* metrics.histogram("vf_eval_latency_ms", 420, { model: "gpt-5" });
|
|
12
|
+
* metrics.gauge("vf_eval_queue_depth", 3);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
import "../../_dnt.polyfills.js";
|
|
16
|
+
export type MetricAttributeValue = string | number | boolean | null | undefined;
|
|
17
|
+
export type MetricAttributes = Record<string, MetricAttributeValue>;
|
|
18
|
+
export interface MetricInstrumentOptions {
|
|
19
|
+
description?: string;
|
|
20
|
+
unit?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function counter(name: string, value?: number, attributes?: MetricAttributes, options?: MetricInstrumentOptions): void;
|
|
23
|
+
export declare function histogram(name: string, value: number, attributes?: MetricAttributes, options?: MetricInstrumentOptions): void;
|
|
24
|
+
export declare function gauge(name: string, value: number, attributes?: MetricAttributes, options?: MetricInstrumentOptions): void;
|
|
25
|
+
export declare const metrics: {
|
|
26
|
+
counter: typeof counter;
|
|
27
|
+
histogram: typeof histogram;
|
|
28
|
+
gauge: typeof gauge;
|
|
29
|
+
__resetForTests(): void;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/metrics/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,yBAAyB,CAAC;AAYjC,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;AAChF,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;AAEpE,MAAM,WAAW,uBAAuB;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAqFD,wBAAgB,OAAO,CACrB,IAAI,EAAE,MAAM,EACZ,KAAK,SAAI,EACT,UAAU,CAAC,EAAE,gBAAgB,EAC7B,OAAO,CAAC,EAAE,uBAAuB,GAChC,IAAI,CAEN;AAED,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,UAAU,CAAC,EAAE,gBAAgB,EAC7B,OAAO,CAAC,EAAE,uBAAuB,GAChC,IAAI,CAEN;AAED,wBAAgB,KAAK,CACnB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,UAAU,CAAC,EAAE,gBAAgB,EAC7B,OAAO,CAAC,EAAE,uBAAuB,GAChC,IAAI,CASN;AAED,eAAO,MAAM,OAAO;;;;uBAIC,IAAI;CAKxB,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime/application metric hooks for project code.
|
|
3
|
+
*
|
|
4
|
+
* @module metrics
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { metrics } from "veryfront/metrics";
|
|
9
|
+
*
|
|
10
|
+
* metrics.counter("vf_eval_result_total", 1, { provider: "openai" });
|
|
11
|
+
* metrics.histogram("vf_eval_latency_ms", 420, { model: "gpt-5" });
|
|
12
|
+
* metrics.gauge("vf_eval_queue_depth", 3);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
import "../../_dnt.polyfills.js";
|
|
16
|
+
import { getGlobalMetricsAPI, } from "../observability/tracing/api-shim.js";
|
|
17
|
+
import { getCurrentRequestContext } from "../platform/adapters/fs/veryfront/request-context.js";
|
|
18
|
+
const counters = new Map();
|
|
19
|
+
const histograms = new Map();
|
|
20
|
+
const gauges = new Map();
|
|
21
|
+
function getMeter() {
|
|
22
|
+
return getGlobalMetricsAPI()?.getMeter("veryfront.project.metrics");
|
|
23
|
+
}
|
|
24
|
+
function normalizeAttributes(attributes) {
|
|
25
|
+
const normalized = {};
|
|
26
|
+
for (const [key, value] of Object.entries(attributes ?? {})) {
|
|
27
|
+
if (value === null || value === undefined)
|
|
28
|
+
continue;
|
|
29
|
+
normalized[key] = value;
|
|
30
|
+
}
|
|
31
|
+
const context = getCurrentRequestContext();
|
|
32
|
+
if (context?.projectId)
|
|
33
|
+
normalized.project_id = context.projectId;
|
|
34
|
+
if (context?.projectSlug)
|
|
35
|
+
normalized.project_slug = context.projectSlug;
|
|
36
|
+
if (context?.environmentName)
|
|
37
|
+
normalized.environment = context.environmentName;
|
|
38
|
+
return normalized;
|
|
39
|
+
}
|
|
40
|
+
function attributesKey(attributes) {
|
|
41
|
+
return JSON.stringify(Object.entries(attributes)
|
|
42
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
43
|
+
.map(([key, value]) => [key, value]));
|
|
44
|
+
}
|
|
45
|
+
function getCounter(name, options) {
|
|
46
|
+
const cached = counters.get(name);
|
|
47
|
+
if (cached)
|
|
48
|
+
return cached;
|
|
49
|
+
const meter = getMeter();
|
|
50
|
+
if (!meter)
|
|
51
|
+
return null;
|
|
52
|
+
const counter = meter.createCounter(name, options);
|
|
53
|
+
counters.set(name, counter);
|
|
54
|
+
return counter;
|
|
55
|
+
}
|
|
56
|
+
function getHistogram(name, options) {
|
|
57
|
+
const cached = histograms.get(name);
|
|
58
|
+
if (cached)
|
|
59
|
+
return cached;
|
|
60
|
+
const meter = getMeter();
|
|
61
|
+
if (!meter)
|
|
62
|
+
return null;
|
|
63
|
+
const histogram = meter.createHistogram(name, options);
|
|
64
|
+
histograms.set(name, histogram);
|
|
65
|
+
return histogram;
|
|
66
|
+
}
|
|
67
|
+
function getGauge(name, options) {
|
|
68
|
+
const cached = gauges.get(name);
|
|
69
|
+
if (cached)
|
|
70
|
+
return cached;
|
|
71
|
+
const meter = getMeter();
|
|
72
|
+
if (!meter)
|
|
73
|
+
return null;
|
|
74
|
+
const samples = new Map();
|
|
75
|
+
const instrument = meter.createObservableGauge(name, options);
|
|
76
|
+
instrument.addCallback((result) => {
|
|
77
|
+
for (const sample of samples.values()) {
|
|
78
|
+
result.observe(sample.value, sample.attributes);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
const gauge = { instrument, samples };
|
|
82
|
+
gauges.set(name, gauge);
|
|
83
|
+
return gauge;
|
|
84
|
+
}
|
|
85
|
+
export function counter(name, value = 1, attributes, options) {
|
|
86
|
+
getCounter(name, options)?.add(value, normalizeAttributes(attributes));
|
|
87
|
+
}
|
|
88
|
+
export function histogram(name, value, attributes, options) {
|
|
89
|
+
getHistogram(name, options)?.record(value, normalizeAttributes(attributes));
|
|
90
|
+
}
|
|
91
|
+
export function gauge(name, value, attributes, options) {
|
|
92
|
+
const normalizedAttributes = normalizeAttributes(attributes);
|
|
93
|
+
const target = getGauge(name, options);
|
|
94
|
+
if (!target)
|
|
95
|
+
return;
|
|
96
|
+
target.samples.set(attributesKey(normalizedAttributes), {
|
|
97
|
+
value,
|
|
98
|
+
attributes: normalizedAttributes,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
export const metrics = {
|
|
102
|
+
counter,
|
|
103
|
+
histogram,
|
|
104
|
+
gauge,
|
|
105
|
+
__resetForTests() {
|
|
106
|
+
counters.clear();
|
|
107
|
+
histograms.clear();
|
|
108
|
+
gauges.clear();
|
|
109
|
+
},
|
|
110
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-run-execute.handler.d.ts","sourceRoot":"","sources":["../../../../../src/src/server/handlers/request/project-run-execute.handler.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,KAAK,cAAc,EAAgB,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAW,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC3F,OAAO,EAAE,KAAK,cAAc,EAAgB,MAAM,4BAA4B,CAAC;AAE/E,OAAO,EACL,KAAK,6BAA6B,EAEnC,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EAGd,UAAU,EACV,cAAc,EACf,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,KAAK,kBAAkB,EAAoB,MAAM,sCAAsC,CAAC;AAEjG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAGvE,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAmB,aAAa,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"project-run-execute.handler.d.ts","sourceRoot":"","sources":["../../../../../src/src/server/handlers/request/project-run-execute.handler.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,KAAK,cAAc,EAAgB,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAW,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC3F,OAAO,EAAE,KAAK,cAAc,EAAgB,MAAM,4BAA4B,CAAC;AAE/E,OAAO,EACL,KAAK,6BAA6B,EAEnC,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,E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oBAAoB,CAClB,MAAM,CAAC,EAAE,oBAAoB,GAC5B,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACpD,OAAO,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAClF,sBAAsB,CAAC,MAAM,EAAE,6BAA6B,GAAG,gBAAgB,CAAC;IAChF,sBAAsB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3D,sBAAsB,CAAC,KAAK,EAAE;QAC5B,OAAO,EAAE,wBAAwB,CAAC;QAClC,GAAG,EAAE,cAAc,CAAC;QACpB,GAAG,EAAE,OAAO,CAAC;KACd,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACvC,wBAAwB,CAAC,KAAK,EAAE;QAC9B,OAAO,EAAE,wBAAwB,CAAC;QAClC,GAAG,EAAE,cAAc,CAAC;QACpB,GAAG,EAAE,OAAO,CAAC;KACd,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACvC,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,GAAG,IAAI,MAAM,CAAC;CACf;AAwzBD,qBAAa,wBAAyB,SAAQ,WAAW;IAS3C,OAAO,CAAC,QAAQ,CAAC,IAAI;IARjC,QAAQ,EAAE,eAAe,CAMvB;gBAE2B,IAAI,GAAE,4BAA0C;IAIvE,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;CAsExE"}
|
|
@@ -19,6 +19,7 @@ import { PRIORITY_MEDIUM_API } from "../../../utils/constants/index.js";
|
|
|
19
19
|
const EXECUTE_PATH_REGEX = /^\/api\/control-plane\/runs\/([^/]+)\/execute$/;
|
|
20
20
|
const DEFAULT_WORKFLOW_STATUS_POLL_INTERVAL_MS = 100;
|
|
21
21
|
const DEFAULT_WORKFLOW_STATUS_TIMEOUT_MS = 15 * 60 * 1_000;
|
|
22
|
+
const DEFAULT_LOCAL_AG_UI_PORT = 3001;
|
|
22
23
|
const WORKFLOW_PERSISTENCE_REQUIRED_ERROR = "Workflow paused but runtime workflow persistence is not configured";
|
|
23
24
|
function isRecord(value) {
|
|
24
25
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -30,6 +31,22 @@ function parseRecord(value) {
|
|
|
30
31
|
throw new Error("Expected object");
|
|
31
32
|
return value;
|
|
32
33
|
}
|
|
34
|
+
function parseOptionalUrl(value, fieldName) {
|
|
35
|
+
if (value === undefined)
|
|
36
|
+
return undefined;
|
|
37
|
+
if (typeof value !== "string" || value.length === 0)
|
|
38
|
+
throw new Error(`Invalid ${fieldName}`);
|
|
39
|
+
try {
|
|
40
|
+
const url = new URL(value);
|
|
41
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
42
|
+
throw new Error(`Invalid ${fieldName}`);
|
|
43
|
+
}
|
|
44
|
+
return url.toString();
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
throw new Error(`Invalid ${fieldName}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
33
50
|
function parseExecuteRequest(value, pathRunId) {
|
|
34
51
|
if (!isRecord(value))
|
|
35
52
|
throw new Error("Expected object");
|
|
@@ -60,6 +77,7 @@ function parseExecuteRequest(value, pathRunId) {
|
|
|
60
77
|
kind,
|
|
61
78
|
target,
|
|
62
79
|
projectId,
|
|
80
|
+
runtimeAgUiEndpoint: parseOptionalUrl(value.runtimeAgUiEndpoint, "runtimeAgUiEndpoint"),
|
|
63
81
|
config: parseRecord(value.config),
|
|
64
82
|
input: parseRecord(value.input),
|
|
65
83
|
};
|
|
@@ -225,12 +243,68 @@ async function executeWorkflowRun(request, ctx, deps) {
|
|
|
225
243
|
function getRuntimeApiToken(req, ctx) {
|
|
226
244
|
return req.headers.get("x-token") ?? ctx.proxyToken ?? ctx.requestContext?.token ?? "";
|
|
227
245
|
}
|
|
228
|
-
function
|
|
246
|
+
function getHeaderFirstValue(value) {
|
|
247
|
+
return value?.split(",")[0]?.trim() || undefined;
|
|
248
|
+
}
|
|
249
|
+
function getForwardedProtocol(req) {
|
|
250
|
+
const value = getHeaderFirstValue(req.headers.get("x-forwarded-proto"))?.replace(/:$/, "");
|
|
251
|
+
return value === "http" || value === "https" ? `${value}:` : undefined;
|
|
252
|
+
}
|
|
253
|
+
function getRequestOriginCandidates(req) {
|
|
254
|
+
const url = new URL(req.url);
|
|
255
|
+
const protocols = new Set([url.protocol]);
|
|
256
|
+
const forwardedProtocol = getForwardedProtocol(req);
|
|
257
|
+
if (forwardedProtocol)
|
|
258
|
+
protocols.add(forwardedProtocol);
|
|
259
|
+
const hosts = new Set([url.host]);
|
|
260
|
+
const hostHeader = getHeaderFirstValue(req.headers.get("host"));
|
|
261
|
+
const forwardedHost = getHeaderFirstValue(req.headers.get("x-forwarded-host"));
|
|
262
|
+
if (hostHeader)
|
|
263
|
+
hosts.add(hostHeader);
|
|
264
|
+
if (forwardedHost)
|
|
265
|
+
hosts.add(forwardedHost);
|
|
266
|
+
const origins = new Set();
|
|
267
|
+
for (const protocol of protocols) {
|
|
268
|
+
for (const host of hosts) {
|
|
269
|
+
origins.add(`${protocol}//${host}`);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return origins;
|
|
273
|
+
}
|
|
274
|
+
function isRequestSiblingAgUiEndpoint(endpoint, req) {
|
|
275
|
+
try {
|
|
276
|
+
const endpointUrl = new URL(endpoint);
|
|
277
|
+
if (endpointUrl.pathname !== "/api/ag-ui")
|
|
278
|
+
return false;
|
|
279
|
+
return getRequestOriginCandidates(req).has(endpointUrl.origin);
|
|
280
|
+
}
|
|
281
|
+
catch {
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
function isLocalHostname(hostname) {
|
|
286
|
+
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1";
|
|
287
|
+
}
|
|
288
|
+
function getRuntimeLocalPort(req) {
|
|
229
289
|
const url = new URL(req.url);
|
|
230
|
-
url.
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
290
|
+
const requestPort = isLocalHostname(url.hostname) ? url.port : "";
|
|
291
|
+
for (const value of [getHostEnv("PORT"), getHostEnv("VERYFRONT_PORT"), requestPort]) {
|
|
292
|
+
if (!value)
|
|
293
|
+
continue;
|
|
294
|
+
const port = Number.parseInt(value, 10);
|
|
295
|
+
if (Number.isInteger(port) && port > 0 && port <= 65_535)
|
|
296
|
+
return port;
|
|
297
|
+
}
|
|
298
|
+
return DEFAULT_LOCAL_AG_UI_PORT;
|
|
299
|
+
}
|
|
300
|
+
function getLocalAgUiEndpoint(req) {
|
|
301
|
+
return `http://127.0.0.1:${getRuntimeLocalPort(req)}/api/ag-ui`;
|
|
302
|
+
}
|
|
303
|
+
function resolveEvalAgUiEndpoint(req, endpoint) {
|
|
304
|
+
if (endpoint && !isRequestSiblingAgUiEndpoint(endpoint, req)) {
|
|
305
|
+
return endpoint;
|
|
306
|
+
}
|
|
307
|
+
return getLocalAgUiEndpoint(req);
|
|
234
308
|
}
|
|
235
309
|
function createRuntimeApiClient(req, ctx) {
|
|
236
310
|
const apiUrl = getEnvironmentConfig().apiBaseUrl;
|
|
@@ -478,7 +552,7 @@ function createEvalAdapterConfig(input) {
|
|
|
478
552
|
throw new Error("Missing project runtime API token");
|
|
479
553
|
}
|
|
480
554
|
return {
|
|
481
|
-
endpoint:
|
|
555
|
+
endpoint: resolveEvalAgUiEndpoint(input.req, input.request.runtimeAgUiEndpoint),
|
|
482
556
|
authToken,
|
|
483
557
|
agentId: getEvalTargetAgentId(input.definition),
|
|
484
558
|
projectId: input.request.projectId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "veryfront",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.895",
|
|
4
4
|
"description": "The simplest way to build AI-powered apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -81,6 +81,10 @@
|
|
|
81
81
|
"import": "./esm/src/eval/index.js",
|
|
82
82
|
"types": "./esm/src/eval/index.d.ts"
|
|
83
83
|
},
|
|
84
|
+
"./metrics": {
|
|
85
|
+
"import": "./esm/src/metrics/index.js",
|
|
86
|
+
"types": "./esm/src/metrics/index.d.ts"
|
|
87
|
+
},
|
|
84
88
|
"./eval/agent-service": {
|
|
85
89
|
"import": "./esm/src/eval/agent-service.js",
|
|
86
90
|
"types": "./esm/src/eval/agent-service.d.ts"
|