@vfarcic/dot-ai 1.12.0 → 1.14.0
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/dist/core/ai-provider-factory.d.ts.map +1 -1
- package/dist/core/ai-provider-factory.js +18 -3
- package/dist/core/ai-provider.interface.d.ts +9 -0
- package/dist/core/ai-provider.interface.d.ts.map +1 -1
- package/dist/core/git-utils.d.ts.map +1 -1
- package/dist/core/git-utils.js +4 -1
- package/dist/core/internal-tools.d.ts +34 -1
- package/dist/core/internal-tools.d.ts.map +1 -1
- package/dist/core/internal-tools.js +116 -1
- package/dist/core/providers/vercel-provider.d.ts +1 -0
- package/dist/core/providers/vercel-provider.d.ts.map +1 -1
- package/dist/core/providers/vercel-provider.js +40 -5
- package/dist/core/session-events.d.ts +51 -0
- package/dist/core/session-events.d.ts.map +1 -0
- package/dist/core/session-events.js +51 -0
- package/dist/interfaces/rest-api.d.ts +11 -0
- package/dist/interfaces/rest-api.d.ts.map +1 -1
- package/dist/interfaces/rest-api.js +104 -0
- package/dist/interfaces/routes/index.d.ts.map +1 -1
- package/dist/interfaces/routes/index.js +25 -1
- package/dist/interfaces/schemas/index.d.ts +1 -1
- package/dist/interfaces/schemas/index.d.ts.map +1 -1
- package/dist/interfaces/schemas/index.js +8 -2
- package/dist/interfaces/schemas/sessions.d.ts +100 -0
- package/dist/interfaces/schemas/sessions.d.ts.map +1 -1
- package/dist/interfaces/schemas/sessions.js +58 -1
- package/dist/tools/remediate.d.ts +8 -0
- package/dist/tools/remediate.d.ts.map +1 -1
- package/dist/tools/remediate.js +188 -34
- package/package.json +2 -2
- package/prompts/remediate-system.md +5 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-provider-factory.d.ts","sourceRoot":"","sources":["../../src/core/ai-provider-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,UAAU,EACV,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AA8BjC;;;;;;;;;;;;;;GAcG;AACH,qBAAa,iBAAiB;IAC5B;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,UAAU;IA2BnD;;;;;;;;;;OAUG;IACH,MAAM,CAAC,aAAa,IAAI,UAAU;
|
|
1
|
+
{"version":3,"file":"ai-provider-factory.d.ts","sourceRoot":"","sources":["../../src/core/ai-provider-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,UAAU,EACV,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AA8BjC;;;;;;;;;;;;;;GAcG;AACH,qBAAa,iBAAiB;IAC5B;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,UAAU;IA2BnD;;;;;;;;;;OAUG;IACH,MAAM,CAAC,aAAa,IAAI,UAAU;IAqGlC;;;;;OAKG;IACH,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAWrD;;;;OAIG;IACH,MAAM,CAAC,qBAAqB,IAAI,MAAM,EAAE;IAMxC;;;;;OAKG;IACH,MAAM,CAAC,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;CAGxD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,UAAU,CAE7C"}
|
|
@@ -137,6 +137,17 @@ class AIProviderFactory {
|
|
|
137
137
|
// PRD #194: Get custom endpoint URL for OpenAI-compatible LLM APIs
|
|
138
138
|
// Use CUSTOM_LLM_BASE_URL for LLM endpoints (separate from OPENAI_BASE_URL used for embeddings)
|
|
139
139
|
const baseURL = process.env.CUSTOM_LLM_BASE_URL;
|
|
140
|
+
// PRD #443: Parse custom headers from environment variable
|
|
141
|
+
let customHeaders;
|
|
142
|
+
const customHeadersEnv = process.env.CUSTOM_LLM_HEADERS;
|
|
143
|
+
if (customHeadersEnv) {
|
|
144
|
+
try {
|
|
145
|
+
customHeaders = JSON.parse(customHeadersEnv);
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
process.stderr.write(`WARNING: CUSTOM_LLM_HEADERS is not valid JSON: ${customHeadersEnv}. Custom headers will be ignored.\n`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
140
151
|
// Determine effective provider type based on endpoint configuration
|
|
141
152
|
let effectiveProviderType = providerType;
|
|
142
153
|
// PRD #194: Detect OpenRouter and override provider type
|
|
@@ -144,8 +155,11 @@ class AIProviderFactory {
|
|
|
144
155
|
if (baseURL && baseURL.includes('openrouter.ai')) {
|
|
145
156
|
effectiveProviderType = 'openrouter';
|
|
146
157
|
}
|
|
147
|
-
else if (baseURL) {
|
|
148
|
-
//
|
|
158
|
+
else if (baseURL && !process.env.AI_PROVIDER) {
|
|
159
|
+
// PRD #443: Only force 'custom' provider when AI_PROVIDER is NOT explicitly set.
|
|
160
|
+
// If AI_PROVIDER is explicitly set (e.g., 'anthropic'), preserve it so that
|
|
161
|
+
// native provider features (cache control, tool calling format) are retained
|
|
162
|
+
// when using a custom base URL (e.g., corporate Anthropic proxy).
|
|
149
163
|
effectiveProviderType = 'custom';
|
|
150
164
|
}
|
|
151
165
|
return this.create({
|
|
@@ -153,7 +167,8 @@ class AIProviderFactory {
|
|
|
153
167
|
apiKey,
|
|
154
168
|
model,
|
|
155
169
|
debugMode,
|
|
156
|
-
baseURL
|
|
170
|
+
baseURL,
|
|
171
|
+
customHeaders,
|
|
157
172
|
});
|
|
158
173
|
}
|
|
159
174
|
/**
|
|
@@ -50,6 +50,15 @@ export interface AIProviderConfig {
|
|
|
50
50
|
* maxOutputTokens=8192 in API requests.
|
|
51
51
|
*/
|
|
52
52
|
baseURL?: string;
|
|
53
|
+
/** Custom HTTP headers to pass to the AI provider SDK (PRD #443)
|
|
54
|
+
*
|
|
55
|
+
* Parsed from CUSTOM_LLM_HEADERS environment variable (JSON string).
|
|
56
|
+
* Merged with provider-specific default headers (e.g., Anthropic beta header),
|
|
57
|
+
* with custom headers taking precedence.
|
|
58
|
+
*
|
|
59
|
+
* Example: { "version": "2026-02-20", "x-custom-auth": "token123" }
|
|
60
|
+
*/
|
|
61
|
+
customHeaders?: Record<string, string>;
|
|
53
62
|
}
|
|
54
63
|
/**
|
|
55
64
|
* Tool definition for AI providers
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-provider.interface.d.ts","sourceRoot":"","sources":["../../src/core/ai-provider.interface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE;QACL,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,EAAE,MAAM,CAAC;QACtB,2BAA2B,CAAC,EAAE,MAAM,CAAC;QACrC,uBAAuB,CAAC,EAAE,MAAM,CAAC;KAClC,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+BAA+B;IAC/B,MAAM,EAAE,MAAM,CAAC;IAEf,8EAA8E;IAC9E,QAAQ,EAAE,MAAM,CAAC;IAEjB,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,oDAAoD;IACpD,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"ai-provider.interface.d.ts","sourceRoot":"","sources":["../../src/core/ai-provider.interface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE;QACL,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,EAAE,MAAM,CAAC;QACtB,2BAA2B,CAAC,EAAE,MAAM,CAAC;QACrC,uBAAuB,CAAC,EAAE,MAAM,CAAC;KAClC,CAAC;CACH;AAED;;GAEG;AACH,MAAM,W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ply.github.com';
|
|
261
261
|
await git.addConfig('user.name', gitUserName);
|
|
262
262
|
await git.addConfig('user.email', gitUserEmail);
|
|
263
|
-
const
|
|
263
|
+
const finalMessage = process.env.CI === 'true'
|
|
264
|
+
? `${commitMessage} [skip ci]`
|
|
265
|
+
: commitMessage;
|
|
266
|
+
const commitResult = await git.commit(finalMessage);
|
|
264
267
|
if (!commitResult.commit) {
|
|
265
268
|
return {
|
|
266
269
|
commitSha: undefined,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Internal Agentic-Loop Tools (PRD #407)
|
|
2
|
+
* Internal Agentic-Loop Tools (PRD #407, PRD #408)
|
|
3
3
|
*
|
|
4
4
|
* Tools that run locally in the MCP server, available to the AI
|
|
5
5
|
* during investigation loops alongside plugin tools. NOT exposed
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* - git_clone: Clone a Git repo
|
|
10
10
|
* - fs_list: List files at a path
|
|
11
11
|
* - fs_read: Read a file at a path
|
|
12
|
+
* - git_create_pr: Create a PR with file changes (PRD #408)
|
|
12
13
|
*
|
|
13
14
|
* All filesystem operations are scoped to ./tmp/gitops-clones/
|
|
14
15
|
* to prevent path traversal attacks.
|
|
@@ -20,7 +21,39 @@ import type { AITool, ToolExecutor } from './ai-provider.interface.js';
|
|
|
20
21
|
* Exported for testing.
|
|
21
22
|
*/
|
|
22
23
|
export declare function validatePathWithinClones(inputPath: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Returns internal tools available to the AI during investigation.
|
|
26
|
+
* Note: git_create_pr is executor-only and not exposed to investigation.
|
|
27
|
+
*/
|
|
23
28
|
export declare function getInternalTools(): AITool[];
|
|
29
|
+
export interface GitCreatePrInput {
|
|
30
|
+
repoPath: string;
|
|
31
|
+
files: Array<{
|
|
32
|
+
path: string;
|
|
33
|
+
content: string;
|
|
34
|
+
}>;
|
|
35
|
+
title: string;
|
|
36
|
+
body?: string;
|
|
37
|
+
branchName: string;
|
|
38
|
+
baseBranch?: string;
|
|
39
|
+
}
|
|
40
|
+
export type GitCreatePrResult = {
|
|
41
|
+
success: true;
|
|
42
|
+
prUrl: string;
|
|
43
|
+
prNumber: number;
|
|
44
|
+
branch: string;
|
|
45
|
+
baseBranch: string;
|
|
46
|
+
filesChanged: string[];
|
|
47
|
+
} | {
|
|
48
|
+
success: true;
|
|
49
|
+
branch: string;
|
|
50
|
+
baseBranch: string;
|
|
51
|
+
filesChanged: string[];
|
|
52
|
+
error: string;
|
|
53
|
+
} | {
|
|
54
|
+
success: false;
|
|
55
|
+
error: string;
|
|
56
|
+
};
|
|
24
57
|
/**
|
|
25
58
|
* Create a ToolExecutor that handles internal agentic-loop tools.
|
|
26
59
|
* Designed to be passed as the fallbackExecutor to pluginManager.createToolExecutor().
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal-tools.d.ts","sourceRoot":"","sources":["../../src/core/internal-tools.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"internal-tools.d.ts","sourceRoot":"","sources":["../../src/core/internal-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAsBvE;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAUlE;AAkBD;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAkD3C;AAiHD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,iBAAiB,GACzB;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,EAAE,CAAA;CAAE,GAC9G;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC5F;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAgItC;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY,CAqB1E;AAID;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,GAAE,MAAuB,GAAG,IAAI,CAoBxE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Internal Agentic-Loop Tools (PRD #407)
|
|
3
|
+
* Internal Agentic-Loop Tools (PRD #407, PRD #408)
|
|
4
4
|
*
|
|
5
5
|
* Tools that run locally in the MCP server, available to the AI
|
|
6
6
|
* during investigation loops alongside plugin tools. NOT exposed
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* - git_clone: Clone a Git repo
|
|
11
11
|
* - fs_list: List files at a path
|
|
12
12
|
* - fs_read: Read a file at a path
|
|
13
|
+
* - git_create_pr: Create a PR with file changes (PRD #408)
|
|
13
14
|
*
|
|
14
15
|
* All filesystem operations are scoped to ./tmp/gitops-clones/
|
|
15
16
|
* to prevent path traversal attacks.
|
|
@@ -47,6 +48,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
47
48
|
return result;
|
|
48
49
|
};
|
|
49
50
|
})();
|
|
51
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
52
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
53
|
+
};
|
|
50
54
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
55
|
exports.validatePathWithinClones = validatePathWithinClones;
|
|
52
56
|
exports.getInternalTools = getInternalTools;
|
|
@@ -56,6 +60,7 @@ const fs = __importStar(require("fs"));
|
|
|
56
60
|
const path = __importStar(require("path"));
|
|
57
61
|
const git_utils_js_1 = require("./git-utils.js");
|
|
58
62
|
const solution_utils_js_1 = require("./solution-utils.js");
|
|
63
|
+
const simple_git_1 = __importDefault(require("simple-git"));
|
|
59
64
|
const CLONES_SUBDIR = 'gitops-clones';
|
|
60
65
|
const MAX_FILE_SIZE = 100 * 1024; // 100KB
|
|
61
66
|
const DEFAULT_TTL_MS = 60 * 60 * 1000; // 1 hour
|
|
@@ -94,6 +99,10 @@ function repoUrlToDirectoryName(repoUrl) {
|
|
|
94
99
|
}
|
|
95
100
|
}
|
|
96
101
|
// ─── Tool definitions ───
|
|
102
|
+
/**
|
|
103
|
+
* Returns internal tools available to the AI during investigation.
|
|
104
|
+
* Note: git_create_pr is executor-only and not exposed to investigation.
|
|
105
|
+
*/
|
|
97
106
|
function getInternalTools() {
|
|
98
107
|
return [
|
|
99
108
|
{
|
|
@@ -138,6 +147,8 @@ function getInternalTools() {
|
|
|
138
147
|
required: ['path'],
|
|
139
148
|
},
|
|
140
149
|
},
|
|
150
|
+
// git_create_pr is executor-only - not exposed during investigation
|
|
151
|
+
// It's only available via createInternalToolExecutor() during execution
|
|
141
152
|
];
|
|
142
153
|
}
|
|
143
154
|
// ─── Handlers ───
|
|
@@ -235,6 +246,109 @@ function handleFsRead(args) {
|
|
|
235
246
|
}
|
|
236
247
|
return fs.readFileSync(resolved, 'utf-8');
|
|
237
248
|
}
|
|
249
|
+
async function handleGitCreatePr(args) {
|
|
250
|
+
const repoPath = args.repoPath;
|
|
251
|
+
const files = args.files;
|
|
252
|
+
const title = args.title;
|
|
253
|
+
const body = args.body || '';
|
|
254
|
+
const branchName = args.branchName;
|
|
255
|
+
const baseBranch = args.baseBranch || 'main';
|
|
256
|
+
if (!repoPath) {
|
|
257
|
+
return { success: false, error: 'repoPath is required' };
|
|
258
|
+
}
|
|
259
|
+
if (!files || !Array.isArray(files) || files.length === 0) {
|
|
260
|
+
return { success: false, error: 'files array is required and must not be empty' };
|
|
261
|
+
}
|
|
262
|
+
if (!title) {
|
|
263
|
+
return { success: false, error: 'title is required' };
|
|
264
|
+
}
|
|
265
|
+
if (!branchName) {
|
|
266
|
+
return { success: false, error: 'branchName is required' };
|
|
267
|
+
}
|
|
268
|
+
let resolvedRepoPath;
|
|
269
|
+
try {
|
|
270
|
+
resolvedRepoPath = validatePathWithinClones(repoPath);
|
|
271
|
+
}
|
|
272
|
+
catch (err) {
|
|
273
|
+
return {
|
|
274
|
+
success: false,
|
|
275
|
+
error: `Invalid repo path: ${err instanceof Error ? err.message : String(err)}`,
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
if (!fs.existsSync(resolvedRepoPath)) {
|
|
279
|
+
return {
|
|
280
|
+
success: false,
|
|
281
|
+
error: `Repository not found at path: ${repoPath}. It may have been cleaned up.`,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
const stat = fs.statSync(resolvedRepoPath);
|
|
285
|
+
if (!stat.isDirectory()) {
|
|
286
|
+
return { success: false, error: `Path is not a directory: ${repoPath}` };
|
|
287
|
+
}
|
|
288
|
+
try {
|
|
289
|
+
const git = (0, simple_git_1.default)(resolvedRepoPath);
|
|
290
|
+
await git.checkout(baseBranch);
|
|
291
|
+
const pushResult = await (0, git_utils_js_1.pushRepo)(resolvedRepoPath, files, title, {
|
|
292
|
+
branch: branchName,
|
|
293
|
+
});
|
|
294
|
+
const authConfig = (0, git_utils_js_1.getGitAuthConfigFromEnv)();
|
|
295
|
+
const token = await (0, git_utils_js_1.getAuthToken)(authConfig);
|
|
296
|
+
const remotes = await git.getRemotes(true);
|
|
297
|
+
const origin = remotes.find(r => r.name === 'origin');
|
|
298
|
+
if (!origin?.refs?.fetch) {
|
|
299
|
+
return { success: false, error: 'Could not find origin remote URL' };
|
|
300
|
+
}
|
|
301
|
+
const remoteUrl = (0, git_utils_js_1.scrubCredentials)(origin.refs.fetch);
|
|
302
|
+
const repoMatch = remoteUrl.match(/github\.com[/:]([^/]+\/[^/]+?)(?:\.git)?$/);
|
|
303
|
+
if (!repoMatch) {
|
|
304
|
+
return {
|
|
305
|
+
success: true,
|
|
306
|
+
branch: branchName,
|
|
307
|
+
baseBranch,
|
|
308
|
+
filesChanged: pushResult.filesAdded,
|
|
309
|
+
error: 'Automatic PR creation is only supported for GitHub repositories. Changes were pushed to the branch — create a PR/MR manually.',
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
const ownerRepo = repoMatch[1];
|
|
313
|
+
const [owner, repo] = ownerRepo.split('/');
|
|
314
|
+
const prResponse = await fetch(`https://api.github.com/repos/${owner}/${repo}/pulls`, {
|
|
315
|
+
method: 'POST',
|
|
316
|
+
headers: {
|
|
317
|
+
Authorization: `Bearer ${token}`,
|
|
318
|
+
'Content-Type': 'application/json',
|
|
319
|
+
Accept: 'application/vnd.github+json',
|
|
320
|
+
'User-Agent': 'dot-ai-remediate',
|
|
321
|
+
},
|
|
322
|
+
body: JSON.stringify({
|
|
323
|
+
title,
|
|
324
|
+
body,
|
|
325
|
+
head: branchName,
|
|
326
|
+
base: baseBranch,
|
|
327
|
+
}),
|
|
328
|
+
signal: AbortSignal.timeout(30000),
|
|
329
|
+
});
|
|
330
|
+
if (!prResponse.ok) {
|
|
331
|
+
const errorBody = await prResponse.text();
|
|
332
|
+
return {
|
|
333
|
+
success: false,
|
|
334
|
+
error: `GitHub API error (${prResponse.status}): ${errorBody}`,
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
const prData = (await prResponse.json());
|
|
338
|
+
return {
|
|
339
|
+
success: true,
|
|
340
|
+
prUrl: prData.html_url,
|
|
341
|
+
prNumber: prData.number,
|
|
342
|
+
branch: branchName,
|
|
343
|
+
baseBranch,
|
|
344
|
+
filesChanged: pushResult.filesAdded,
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
catch (err) {
|
|
348
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
349
|
+
return { success: false, error: (0, git_utils_js_1.scrubCredentials)(message) };
|
|
350
|
+
}
|
|
351
|
+
}
|
|
238
352
|
// ─── Combined executor ───
|
|
239
353
|
/**
|
|
240
354
|
* Create a ToolExecutor that handles internal agentic-loop tools.
|
|
@@ -245,6 +359,7 @@ function createInternalToolExecutor(sessionId) {
|
|
|
245
359
|
git_clone: (args) => handleGitClone(args, sessionId),
|
|
246
360
|
fs_list: handleFsList,
|
|
247
361
|
fs_read: handleFsRead,
|
|
362
|
+
git_create_pr: handleGitCreatePr,
|
|
248
363
|
};
|
|
249
364
|
return async (toolName, input) => {
|
|
250
365
|
const handler = handlers[toolName];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vercel-provider.d.ts","sourceRoot":"","sources":["../../../src/core/providers/vercel-provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,OAAO,EACL,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,aAAa,EACd,MAAM,0BAA0B,CAAC;AA4DlC,qBAAa,cAAe,YAAW,UAAU;IAC/C,OAAO,CAAC,YAAY,CAAoB;IACxC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,aAAa,CAAiB;gBAE1B,MAAM,EAAE,gBAAgB;
|
|
1
|
+
{"version":3,"file":"vercel-provider.d.ts","sourceRoot":"","sources":["../../../src/core/providers/vercel-provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,OAAO,EACL,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,aAAa,EACd,MAAM,0BAA0B,CAAC;AA4DlC,qBAAa,cAAe,YAAW,UAAU;IAC/C,OAAO,CAAC,YAAY,CAAoB;IACxC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,aAAa,CAAC,CAAyB;IAC/C,OAAO,CAAC,aAAa,CAAiB;gBAE1B,MAAM,EAAE,gBAAgB;IAYpC,OAAO,CAAC,qBAAqB;IAiB7B,OAAO,CAAC,eAAe;IAgIvB,eAAe,IAAI,MAAM;IAIzB,eAAe,IAAI,MAAM;IAIzB,YAAY,IAAI,MAAM;IAItB,aAAa,IAAI,OAAO;IAIxB,OAAO,CAAC,iBAAiB;IAyBnB,WAAW,CACf,OAAO,EAAE,MAAM,EACf,SAAS,GAAE,MAAkB,EAC7B,iBAAiB,CAAC,EAAE;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,GACA,OAAO,CAAC,UAAU,CAAC;IAsJtB;;;;;;;;;;;;OAYG;IACG,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;CA6b/D"}
|
|
@@ -29,6 +29,7 @@ class VercelProvider {
|
|
|
29
29
|
apiKey;
|
|
30
30
|
debugMode;
|
|
31
31
|
baseURL; // PRD #194: Custom endpoint URL for OpenAI-compatible APIs
|
|
32
|
+
customHeaders; // PRD #443: Custom HTTP headers
|
|
32
33
|
modelInstance; // Vercel AI SDK model instance - initialized by initializeModel()
|
|
33
34
|
constructor(config) {
|
|
34
35
|
this.apiKey = config.apiKey;
|
|
@@ -36,6 +37,7 @@ class VercelProvider {
|
|
|
36
37
|
this.model = config.model || this.getDefaultModel();
|
|
37
38
|
this.debugMode = config.debugMode ?? process.env.DEBUG_DOT_AI === 'true';
|
|
38
39
|
this.baseURL = config.baseURL; // PRD #194: Store custom endpoint URL
|
|
40
|
+
this.customHeaders = config.customHeaders; // PRD #443: Store custom headers
|
|
39
41
|
this.validateConfiguration();
|
|
40
42
|
this.initializeModel();
|
|
41
43
|
}
|
|
@@ -51,34 +53,62 @@ class VercelProvider {
|
|
|
51
53
|
try {
|
|
52
54
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Vercel AI SDK provider types vary
|
|
53
55
|
let provider;
|
|
56
|
+
// PRD #443: Helper to build merged headers (provider defaults + custom headers)
|
|
57
|
+
// Custom headers take precedence over provider defaults via spread order
|
|
58
|
+
const mergeHeaders = (providerDefaults) => {
|
|
59
|
+
if (!providerDefaults && !this.customHeaders)
|
|
60
|
+
return undefined;
|
|
61
|
+
return {
|
|
62
|
+
...providerDefaults,
|
|
63
|
+
...this.customHeaders,
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
// PRD #443: Helper for optional baseURL spread
|
|
67
|
+
const baseURLOpt = this.baseURL ? { baseURL: this.baseURL } : {};
|
|
54
68
|
switch (this.providerType) {
|
|
55
69
|
case 'openai':
|
|
56
70
|
provider = (0, openai_1.createOpenAI)({
|
|
57
71
|
apiKey: this.apiKey,
|
|
72
|
+
...baseURLOpt,
|
|
73
|
+
...(mergeHeaders() && { headers: mergeHeaders() }),
|
|
58
74
|
});
|
|
59
75
|
break;
|
|
60
76
|
case 'google':
|
|
61
77
|
case 'google_flash': // PRD #294: Gemini 3 Flash variant
|
|
62
|
-
provider = (0, google_1.createGoogleGenerativeAI)({
|
|
78
|
+
provider = (0, google_1.createGoogleGenerativeAI)({
|
|
79
|
+
apiKey: this.apiKey,
|
|
80
|
+
...baseURLOpt,
|
|
81
|
+
...(mergeHeaders() && { headers: mergeHeaders() }),
|
|
82
|
+
});
|
|
63
83
|
break;
|
|
64
84
|
case 'anthropic':
|
|
65
85
|
case 'anthropic_opus':
|
|
66
86
|
case 'anthropic_haiku':
|
|
67
87
|
provider = (0, anthropic_1.createAnthropic)({
|
|
68
88
|
apiKey: this.apiKey,
|
|
89
|
+
...baseURLOpt,
|
|
69
90
|
// Enable 1M token context window for Claude Sonnet 4 (5x increase from 200K)
|
|
70
91
|
// Required for models like claude-sonnet-4-5-20250929
|
|
71
|
-
|
|
92
|
+
// PRD #443: Custom headers merge with (and can override) the anthropic-beta default
|
|
93
|
+
headers: mergeHeaders({
|
|
72
94
|
'anthropic-beta': 'context-1m-2025-08-07',
|
|
73
|
-
},
|
|
95
|
+
}),
|
|
74
96
|
});
|
|
75
97
|
break;
|
|
76
98
|
case 'xai':
|
|
77
|
-
provider = (0, xai_1.createXai)({
|
|
99
|
+
provider = (0, xai_1.createXai)({
|
|
100
|
+
apiKey: this.apiKey,
|
|
101
|
+
...baseURLOpt,
|
|
102
|
+
...(mergeHeaders() && { headers: mergeHeaders() }),
|
|
103
|
+
});
|
|
78
104
|
break;
|
|
79
105
|
case 'alibaba':
|
|
80
106
|
// PRD #382: Alibaba Qwen 3.5 Plus - uses @ai-sdk/alibaba dedicated SDK
|
|
81
|
-
|
|
107
|
+
// Note: @ai-sdk/alibaba does not accept baseURL (PRD #443 only covers Anthropic/OpenAI/Google/xAI)
|
|
108
|
+
provider = (0, alibaba_1.createAlibaba)({
|
|
109
|
+
apiKey: this.apiKey,
|
|
110
|
+
...(mergeHeaders() && { headers: mergeHeaders() }),
|
|
111
|
+
});
|
|
82
112
|
break;
|
|
83
113
|
case 'kimi':
|
|
84
114
|
// PRD #353: Moonshot AI Kimi K2.5 - uses @ai-sdk/openai-compatible for proper
|
|
@@ -88,6 +118,7 @@ class VercelProvider {
|
|
|
88
118
|
name: 'kimi',
|
|
89
119
|
apiKey: this.apiKey,
|
|
90
120
|
baseURL: 'https://api.moonshot.ai/v1',
|
|
121
|
+
...(mergeHeaders() && { headers: mergeHeaders() }),
|
|
91
122
|
});
|
|
92
123
|
this.modelInstance = provider.chatModel(this.model);
|
|
93
124
|
return; // Early return - model instance already set
|
|
@@ -97,6 +128,7 @@ class VercelProvider {
|
|
|
97
128
|
// 1. Environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION)
|
|
98
129
|
// 2. ~/.aws/credentials file
|
|
99
130
|
// 3. IAM roles (EC2 instance profiles, ECS roles, EKS service accounts)
|
|
131
|
+
// Note: Custom headers not supported - AWS SDK handles auth via credential chain
|
|
100
132
|
provider = (0, amazon_bedrock_1.createAmazonBedrock)({
|
|
101
133
|
region: process.env.AWS_REGION || 'us-east-1',
|
|
102
134
|
});
|
|
@@ -106,6 +138,8 @@ class VercelProvider {
|
|
|
106
138
|
// Use dedicated OpenRouter provider for proper format conversion
|
|
107
139
|
provider = (0, ai_sdk_provider_1.createOpenRouter)({
|
|
108
140
|
apiKey: this.apiKey,
|
|
141
|
+
...baseURLOpt,
|
|
142
|
+
...(mergeHeaders() && { headers: mergeHeaders() }),
|
|
109
143
|
});
|
|
110
144
|
break;
|
|
111
145
|
case 'custom':
|
|
@@ -117,6 +151,7 @@ class VercelProvider {
|
|
|
117
151
|
provider = (0, openai_1.createOpenAI)({
|
|
118
152
|
apiKey: this.apiKey,
|
|
119
153
|
baseURL: this.baseURL,
|
|
154
|
+
...(mergeHeaders() && { headers: mergeHeaders() }),
|
|
120
155
|
});
|
|
121
156
|
// Use .chat() explicitly for custom endpoints to use /chat/completions instead of /responses
|
|
122
157
|
this.modelInstance = provider.chat(this.model);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Event Bus - Real-time event infrastructure for session lifecycle changes
|
|
3
|
+
*
|
|
4
|
+
* Interface-based event bus that broadcasts session state changes for any tool.
|
|
5
|
+
* Default implementation uses in-memory Node.js EventEmitter.
|
|
6
|
+
* Can be swapped to NATS or another external bus via setSessionEventBus().
|
|
7
|
+
*
|
|
8
|
+
* PRD #425: Session List API and SSE Streaming for Remediation Events
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Event payload for session state changes
|
|
12
|
+
*/
|
|
13
|
+
export interface SessionEvent {
|
|
14
|
+
sessionId: string;
|
|
15
|
+
toolName: string;
|
|
16
|
+
status: string;
|
|
17
|
+
issue: string;
|
|
18
|
+
timestamp: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Supported event types
|
|
22
|
+
*/
|
|
23
|
+
export type SessionEventType = 'session-created' | 'session-updated';
|
|
24
|
+
/**
|
|
25
|
+
* Event handler function signature
|
|
26
|
+
*/
|
|
27
|
+
export type SessionEventHandler = (event: SessionEvent) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Event name constants
|
|
30
|
+
*/
|
|
31
|
+
export declare const SESSION_EVENTS: {
|
|
32
|
+
readonly SESSION_CREATED: SessionEventType;
|
|
33
|
+
readonly SESSION_UPDATED: SessionEventType;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Abstract event bus interface. Swap implementations by calling setSessionEventBus().
|
|
37
|
+
*/
|
|
38
|
+
export interface SessionEventBus {
|
|
39
|
+
publish(eventType: SessionEventType, event: SessionEvent): void;
|
|
40
|
+
subscribe(eventType: SessionEventType, handler: SessionEventHandler): void;
|
|
41
|
+
unsubscribe(eventType: SessionEventType, handler: SessionEventHandler): void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get the active session event bus singleton
|
|
45
|
+
*/
|
|
46
|
+
export declare function getSessionEventBus(): SessionEventBus;
|
|
47
|
+
/**
|
|
48
|
+
* Replace the session event bus implementation (for testing or switching to external bus)
|
|
49
|
+
*/
|
|
50
|
+
export declare function setSessionEventBus(bus: SessionEventBus): void;
|
|
51
|
+
//# sourceMappingURL=session-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-events.d.ts","sourceRoot":"","sources":["../../src/core/session-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;AAErE;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,cAAc;8BACa,gBAAgB;8BAChB,gBAAgB;CAC9C,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,SAAS,EAAE,gBAAgB,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IAChE,SAAS,CAAC,SAAS,EAAE,gBAAgB,EAAE,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAC3E,WAAW,CAAC,SAAS,EAAE,gBAAgB,EAAE,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAAC;CAC9E;AAwBD;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,eAAe,CAEpD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI,CAE7D"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Session Event Bus - Real-time event infrastructure for session lifecycle changes
|
|
4
|
+
*
|
|
5
|
+
* Interface-based event bus that broadcasts session state changes for any tool.
|
|
6
|
+
* Default implementation uses in-memory Node.js EventEmitter.
|
|
7
|
+
* Can be swapped to NATS or another external bus via setSessionEventBus().
|
|
8
|
+
*
|
|
9
|
+
* PRD #425: Session List API and SSE Streaming for Remediation Events
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SESSION_EVENTS = void 0;
|
|
13
|
+
exports.getSessionEventBus = getSessionEventBus;
|
|
14
|
+
exports.setSessionEventBus = setSessionEventBus;
|
|
15
|
+
const events_1 = require("events");
|
|
16
|
+
/**
|
|
17
|
+
* Event name constants
|
|
18
|
+
*/
|
|
19
|
+
exports.SESSION_EVENTS = {
|
|
20
|
+
SESSION_CREATED: 'session-created',
|
|
21
|
+
SESSION_UPDATED: 'session-updated',
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* In-memory implementation using Node.js EventEmitter.
|
|
25
|
+
* Suitable for single-process deployments.
|
|
26
|
+
*/
|
|
27
|
+
class InMemorySessionEventBus {
|
|
28
|
+
emitter = new events_1.EventEmitter();
|
|
29
|
+
publish(eventType, event) {
|
|
30
|
+
this.emitter.emit(eventType, event);
|
|
31
|
+
}
|
|
32
|
+
subscribe(eventType, handler) {
|
|
33
|
+
this.emitter.on(eventType, handler);
|
|
34
|
+
}
|
|
35
|
+
unsubscribe(eventType, handler) {
|
|
36
|
+
this.emitter.off(eventType, handler);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
let instance = new InMemorySessionEventBus();
|
|
40
|
+
/**
|
|
41
|
+
* Get the active session event bus singleton
|
|
42
|
+
*/
|
|
43
|
+
function getSessionEventBus() {
|
|
44
|
+
return instance;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Replace the session event bus implementation (for testing or switching to external bus)
|
|
48
|
+
*/
|
|
49
|
+
function setSessionEventBus(bus) {
|
|
50
|
+
instance = bus;
|
|
51
|
+
}
|
|
@@ -230,6 +230,17 @@ export declare class RestApiRouter {
|
|
|
230
230
|
* PRD #320: Supports ?reload=true to regenerate visualization from current session data
|
|
231
231
|
*/
|
|
232
232
|
private handleVisualize;
|
|
233
|
+
/**
|
|
234
|
+
* Handle GET /api/v1/sessions (PRD #425)
|
|
235
|
+
* Lists sessions with optional status filtering and pagination.
|
|
236
|
+
* Returns summary-only data (excludes finalAnalysis).
|
|
237
|
+
*/
|
|
238
|
+
private handleListSessions;
|
|
239
|
+
/**
|
|
240
|
+
* Handle SSE streaming for remediation session events
|
|
241
|
+
* PRD #425: Real-time event stream filtered to toolName='remediate'
|
|
242
|
+
*/
|
|
243
|
+
private handleRemediationSSE;
|
|
233
244
|
/**
|
|
234
245
|
* Handle generic session retrieval requests
|
|
235
246
|
* Returns raw session data for any tool type (remediate, query, recommend, etc.)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest-api.d.ts","sourceRoot":"","sources":["../../src/interfaces/rest-api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAc,MAAM,uBAAuB,CAAC;AAEtE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"rest-api.d.ts","sourceRoot":"","sources":["../../src/interfaces/rest-api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAc,MAAM,uBAAuB,CAAC;AAEtE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAyCtC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAevD;;GAEG;AACH,oBAAY,UAAU;IACpB,EAAE,MAAM;IACR,WAAW,MAAM;IACjB,SAAS,MAAM;IACf,kBAAkB,MAAM;IACxB,qBAAqB,MAAM;IAC3B,WAAW,MAAM;IACjB,mBAAmB,MAAM;CAC1B;AAED;;GAEG;AACH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