@agentv/core 0.7.3 → 0.7.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentv/core",
3
- "version": "0.7.3",
3
+ "version": "0.7.5",
4
4
  "description": "Primitive runtime components for AgentV",
5
5
  "type": "module",
6
6
  "repository": {
@@ -1,158 +0,0 @@
1
- // src/evaluation/file-utils.ts
2
- import { constants } from "node:fs";
3
- import { access, readFile } from "node:fs/promises";
4
- import path from "node:path";
5
- async function fileExists(filePath) {
6
- try {
7
- await access(filePath, constants.F_OK);
8
- return true;
9
- } catch {
10
- return false;
11
- }
12
- }
13
- async function readTextFile(filePath) {
14
- const content = await readFile(filePath, "utf8");
15
- return content.replace(/\r\n/g, "\n");
16
- }
17
- async function findGitRoot(startPath) {
18
- let currentDir = path.dirname(path.resolve(startPath));
19
- const root = path.parse(currentDir).root;
20
- while (currentDir !== root) {
21
- const gitPath = path.join(currentDir, ".git");
22
- if (await fileExists(gitPath)) {
23
- return currentDir;
24
- }
25
- const parentDir = path.dirname(currentDir);
26
- if (parentDir === currentDir) {
27
- break;
28
- }
29
- currentDir = parentDir;
30
- }
31
- return null;
32
- }
33
- function buildDirectoryChain(filePath, repoRoot) {
34
- const directories = [];
35
- const seen = /* @__PURE__ */ new Set();
36
- const boundary = path.resolve(repoRoot);
37
- let current = path.resolve(path.dirname(filePath));
38
- while (current !== void 0) {
39
- if (!seen.has(current)) {
40
- directories.push(current);
41
- seen.add(current);
42
- }
43
- if (current === boundary) {
44
- break;
45
- }
46
- const parent = path.dirname(current);
47
- if (parent === current) {
48
- break;
49
- }
50
- current = parent;
51
- }
52
- if (!seen.has(boundary)) {
53
- directories.push(boundary);
54
- }
55
- return directories;
56
- }
57
- function buildSearchRoots(evalPath, repoRoot) {
58
- const uniqueRoots = [];
59
- const addRoot = (root) => {
60
- const normalized = path.resolve(root);
61
- if (!uniqueRoots.includes(normalized)) {
62
- uniqueRoots.push(normalized);
63
- }
64
- };
65
- let currentDir = path.dirname(evalPath);
66
- let reachedBoundary = false;
67
- while (!reachedBoundary) {
68
- addRoot(currentDir);
69
- const parentDir = path.dirname(currentDir);
70
- if (currentDir === repoRoot || parentDir === currentDir) {
71
- reachedBoundary = true;
72
- } else {
73
- currentDir = parentDir;
74
- }
75
- }
76
- addRoot(repoRoot);
77
- addRoot(process.cwd());
78
- return uniqueRoots;
79
- }
80
- function trimLeadingSeparators(value) {
81
- const trimmed = value.replace(/^[/\\]+/, "");
82
- return trimmed.length > 0 ? trimmed : value;
83
- }
84
- async function resolveFileReference(rawValue, searchRoots) {
85
- const displayPath = trimLeadingSeparators(rawValue);
86
- const potentialPaths = [];
87
- if (path.isAbsolute(rawValue)) {
88
- potentialPaths.push(path.normalize(rawValue));
89
- }
90
- for (const base of searchRoots) {
91
- potentialPaths.push(path.resolve(base, displayPath));
92
- }
93
- const attempted = [];
94
- const seen = /* @__PURE__ */ new Set();
95
- for (const candidate of potentialPaths) {
96
- const absoluteCandidate = path.resolve(candidate);
97
- if (seen.has(absoluteCandidate)) {
98
- continue;
99
- }
100
- seen.add(absoluteCandidate);
101
- attempted.push(absoluteCandidate);
102
- if (await fileExists(absoluteCandidate)) {
103
- return { displayPath, resolvedPath: absoluteCandidate, attempted };
104
- }
105
- }
106
- return { displayPath, attempted };
107
- }
108
-
109
- // src/evaluation/providers/types.ts
110
- var AGENT_PROVIDER_KINDS = [
111
- "codex",
112
- "vscode",
113
- "vscode-insiders"
114
- ];
115
- var KNOWN_PROVIDERS = [
116
- "azure",
117
- "anthropic",
118
- "gemini",
119
- "codex",
120
- "cli",
121
- "mock",
122
- "vscode",
123
- "vscode-insiders"
124
- ];
125
- var PROVIDER_ALIASES = [
126
- "azure-openai",
127
- // alias for "azure"
128
- "google",
129
- // alias for "gemini"
130
- "google-gemini",
131
- // alias for "gemini"
132
- "codex-cli",
133
- // alias for "codex"
134
- "openai",
135
- // legacy/future support
136
- "bedrock",
137
- // legacy/future support
138
- "vertex"
139
- // legacy/future support
140
- ];
141
- var TARGETS_SCHEMA_V2 = "agentv-targets-v2.1";
142
- function isAgentProvider(provider) {
143
- return provider ? AGENT_PROVIDER_KINDS.includes(provider.kind) : false;
144
- }
145
-
146
- export {
147
- fileExists,
148
- readTextFile,
149
- findGitRoot,
150
- buildDirectoryChain,
151
- buildSearchRoots,
152
- resolveFileReference,
153
- KNOWN_PROVIDERS,
154
- PROVIDER_ALIASES,
155
- TARGETS_SCHEMA_V2,
156
- isAgentProvider
157
- };
158
- //# sourceMappingURL=chunk-UQLHF3T7.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/evaluation/file-utils.ts","../src/evaluation/providers/types.ts"],"sourcesContent":["import { constants } from \"node:fs\";\r\nimport { access, readFile } from \"node:fs/promises\";\r\nimport path from \"node:path\";\r\n\r\nexport async function fileExists(filePath: string): Promise<boolean> {\r\n try {\r\n await access(filePath, constants.F_OK);\r\n return true;\r\n } catch {\r\n return false;\r\n }\r\n}\r\n\r\n/**\r\n * Read a text file and normalize line endings to LF (\\n).\r\n * This ensures consistent behavior across Windows (CRLF) and Unix (LF) systems.\r\n */\r\nexport async function readTextFile(filePath: string): Promise<string> {\r\n const content = await readFile(filePath, \"utf8\");\r\n return content.replace(/\\r\\n/g, \"\\n\");\r\n}\r\n\r\n/**\r\n * Find git repository root by walking up the directory tree.\r\n */\r\nexport async function findGitRoot(startPath: string): Promise<string | null> {\r\n let currentDir = path.dirname(path.resolve(startPath));\r\n const root = path.parse(currentDir).root;\r\n\r\n while (currentDir !== root) {\r\n const gitPath = path.join(currentDir, \".git\");\r\n if (await fileExists(gitPath)) {\r\n return currentDir;\r\n }\r\n\r\n const parentDir = path.dirname(currentDir);\r\n if (parentDir === currentDir) {\r\n break;\r\n }\r\n currentDir = parentDir;\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Build a chain of directories walking from a file's location up to repo root.\r\n * Used for discovering configuration files like targets.yaml or config.yaml.\r\n */\r\nexport function buildDirectoryChain(filePath: string, repoRoot: string): readonly string[] {\r\n const directories: string[] = [];\r\n const seen = new Set<string>();\r\n const boundary = path.resolve(repoRoot);\r\n let current: string | undefined = path.resolve(path.dirname(filePath));\r\n\r\n while (current !== undefined) {\r\n if (!seen.has(current)) {\r\n directories.push(current);\r\n seen.add(current);\r\n }\r\n if (current === boundary) {\r\n break;\r\n }\r\n const parent = path.dirname(current);\r\n if (parent === current) {\r\n break;\r\n }\r\n current = parent;\r\n }\r\n\r\n if (!seen.has(boundary)) {\r\n directories.push(boundary);\r\n }\r\n\r\n return directories;\r\n}\r\n\r\n/**\r\n * Build search roots for file resolution, matching yaml-parser behavior.\r\n * Searches from eval file directory up to repo root.\r\n */\r\nexport function buildSearchRoots(evalPath: string, repoRoot: string): readonly string[] {\r\n const uniqueRoots: string[] = [];\r\n const addRoot = (root: string): void => {\r\n const normalized = path.resolve(root);\r\n if (!uniqueRoots.includes(normalized)) {\r\n uniqueRoots.push(normalized);\r\n }\r\n };\r\n\r\n let currentDir = path.dirname(evalPath);\r\n let reachedBoundary = false;\r\n while (!reachedBoundary) {\r\n addRoot(currentDir);\r\n const parentDir = path.dirname(currentDir);\r\n if (currentDir === repoRoot || parentDir === currentDir) {\r\n reachedBoundary = true;\r\n } else {\r\n currentDir = parentDir;\r\n }\r\n }\r\n\r\n addRoot(repoRoot);\r\n addRoot(process.cwd());\r\n return uniqueRoots;\r\n}\r\n\r\n/**\r\n * Trim leading path separators for display.\r\n */\r\nfunction trimLeadingSeparators(value: string): string {\r\n const trimmed = value.replace(/^[/\\\\]+/, \"\");\r\n return trimmed.length > 0 ? trimmed : value;\r\n}\r\n\r\n/**\r\n * Resolve a file reference using search roots, matching yaml-parser behavior.\r\n */\r\nexport async function resolveFileReference(\r\n rawValue: string,\r\n searchRoots: readonly string[],\r\n): Promise<{\r\n readonly displayPath: string;\r\n readonly resolvedPath?: string;\r\n readonly attempted: readonly string[];\r\n}> {\r\n const displayPath = trimLeadingSeparators(rawValue);\r\n const potentialPaths: string[] = [];\r\n\r\n if (path.isAbsolute(rawValue)) {\r\n potentialPaths.push(path.normalize(rawValue));\r\n }\r\n\r\n for (const base of searchRoots) {\r\n potentialPaths.push(path.resolve(base, displayPath));\r\n }\r\n\r\n const attempted: string[] = [];\r\n const seen = new Set<string>();\r\n for (const candidate of potentialPaths) {\r\n const absoluteCandidate = path.resolve(candidate);\r\n if (seen.has(absoluteCandidate)) {\r\n continue;\r\n }\r\n seen.add(absoluteCandidate);\r\n attempted.push(absoluteCandidate);\r\n if (await fileExists(absoluteCandidate)) {\r\n return { displayPath, resolvedPath: absoluteCandidate, attempted };\r\n }\r\n }\r\n\r\n return { displayPath, attempted };\r\n}\r\n","import type { AxChatRequest, AxAI } from \"@ax-llm/ax\";\r\n\r\nimport type { JsonObject } from \"../types.js\";\r\n\r\ntype ChatPrompt = AxChatRequest[\"chatPrompt\"];\r\n\r\nexport type ProviderKind =\r\n | \"azure\"\r\n | \"anthropic\"\r\n | \"gemini\"\r\n | \"codex\"\r\n | \"cli\"\r\n | \"mock\"\r\n | \"vscode\"\r\n | \"vscode-insiders\";\r\n\r\n/**\r\n * Agent providers that have filesystem access and don't need unwrapped guidelines.\r\n * These providers read files directly from the filesystem using file:// URIs.\r\n */\r\nexport const AGENT_PROVIDER_KINDS: readonly ProviderKind[] = [\r\n \"codex\",\r\n \"vscode\",\r\n \"vscode-insiders\",\r\n] as const;\r\n\r\n/**\r\n * List of all supported provider kinds.\r\n * This is the source of truth for provider validation.\r\n */\r\nexport const KNOWN_PROVIDERS: readonly ProviderKind[] = [\r\n \"azure\",\r\n \"anthropic\",\r\n \"gemini\",\r\n \"codex\",\r\n \"cli\",\r\n \"mock\",\r\n \"vscode\",\r\n \"vscode-insiders\",\r\n] as const;\r\n\r\n/**\r\n * Provider aliases that are accepted in target definitions.\r\n * These map to the canonical ProviderKind values.\r\n */\r\nexport const PROVIDER_ALIASES: readonly string[] = [\r\n \"azure-openai\", // alias for \"azure\"\r\n \"google\", // alias for \"gemini\"\r\n \"google-gemini\", // alias for \"gemini\"\r\n \"codex-cli\", // alias for \"codex\"\r\n \"openai\", // legacy/future support\r\n \"bedrock\", // legacy/future support\r\n \"vertex\", // legacy/future support\r\n] as const;\r\n\r\n/**\r\n * Schema identifier for targets.yaml files (version 2).\r\n */\r\nexport const TARGETS_SCHEMA_V2 = \"agentv-targets-v2.1\";\r\n\r\nexport interface ProviderRequest {\r\n readonly question: string;\r\n readonly guidelines?: string;\r\n readonly guideline_patterns?: readonly string[];\r\n readonly chatPrompt?: ChatPrompt;\r\n readonly inputFiles?: readonly string[];\r\n readonly evalCaseId?: string;\r\n readonly attempt?: number;\r\n readonly maxOutputTokens?: number;\r\n readonly temperature?: number;\r\n readonly metadata?: JsonObject;\r\n readonly signal?: AbortSignal;\r\n}\r\n\r\nexport interface ProviderResponse {\r\n readonly text: string;\r\n readonly reasoning?: string;\r\n readonly raw?: unknown;\r\n readonly usage?: JsonObject;\r\n}\r\n\r\n/**\r\n * Type guard to check if a provider is an agent provider with filesystem access.\r\n * Agent providers read files directly and don't need unwrapped guideline content.\r\n */\r\nexport function isAgentProvider(provider: Provider | undefined): boolean {\r\n return provider ? AGENT_PROVIDER_KINDS.includes(provider.kind) : false;\r\n}\r\n\r\nexport interface Provider {\r\n readonly id: string;\r\n readonly kind: ProviderKind;\r\n readonly targetName: string;\r\n invoke(request: ProviderRequest): Promise<ProviderResponse>;\r\n /**\r\n * Optional capability marker for provider-managed batching (single session handling multiple requests).\r\n */\r\n readonly supportsBatch?: boolean;\r\n /**\r\n * Optional batch invocation hook. When defined alongside supportsBatch=true,\r\n * the orchestrator may send multiple requests in a single provider session.\r\n */\r\n invokeBatch?(requests: readonly ProviderRequest[]): Promise<readonly ProviderResponse[]>;\r\n /**\r\n * Optional access to the underlying AxAI instance.\r\n * This enables using advanced Ax features like structured output signatures.\r\n */\r\n getAxAI?(): AxAI;\r\n}\r\n\r\nexport type EnvLookup = Readonly<Record<string, string | undefined>>;\r\n\r\nexport interface TargetDefinition {\r\n readonly name: string;\r\n readonly provider: ProviderKind | string;\r\n readonly settings?: Record<string, unknown> | undefined;\r\n readonly judge_target?: string | undefined;\r\n readonly workers?: number | undefined;\r\n}\r\n"],"mappings":";AAAA,SAAS,iBAAiB;AAC1B,SAAS,QAAQ,gBAAgB;AACjC,OAAO,UAAU;AAEjB,eAAsB,WAAW,UAAoC;AACnE,MAAI;AACF,UAAM,OAAO,UAAU,UAAU,IAAI;AACrC,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAMA,eAAsB,aAAa,UAAmC;AACpE,QAAM,UAAU,MAAM,SAAS,UAAU,MAAM;AAC/C,SAAO,QAAQ,QAAQ,SAAS,IAAI;AACtC;AAKA,eAAsB,YAAY,WAA2C;AAC3E,MAAI,aAAa,KAAK,QAAQ,KAAK,QAAQ,SAAS,CAAC;AACrD,QAAM,OAAO,KAAK,MAAM,UAAU,EAAE;AAEpC,SAAO,eAAe,MAAM;AAC1B,UAAM,UAAU,KAAK,KAAK,YAAY,MAAM;AAC5C,QAAI,MAAM,WAAW,OAAO,GAAG;AAC7B,aAAO;AAAA,IACT;AAEA,UAAM,YAAY,KAAK,QAAQ,UAAU;AACzC,QAAI,cAAc,YAAY;AAC5B;AAAA,IACF;AACA,iBAAa;AAAA,EACf;AAEA,SAAO;AACT;AAMO,SAAS,oBAAoB,UAAkB,UAAqC;AACzF,QAAM,cAAwB,CAAC;AAC/B,QAAM,OAAO,oBAAI,IAAY;AAC7B,QAAM,WAAW,KAAK,QAAQ,QAAQ;AACtC,MAAI,UAA8B,KAAK,QAAQ,KAAK,QAAQ,QAAQ,CAAC;AAErE,SAAO,YAAY,QAAW;AAC5B,QAAI,CAAC,KAAK,IAAI,OAAO,GAAG;AACtB,kBAAY,KAAK,OAAO;AACxB,WAAK,IAAI,OAAO;AAAA,IAClB;AACA,QAAI,YAAY,UAAU;AACxB;AAAA,IACF;AACA,U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