wire up /agent/execute and /agent/stop endpoints
- Add runSessionAgent: streaming variant of runAgent that PATCHes VIBN DB after every LLM turn and tool call so frontend can poll live output - Track changed files from write_file / replace_in_file tool calls - Add /agent/execute: receives sessionId + giteaRepo + task, clones repo, scopes workspace to appPath, runs Coder agent async (returns 202 immediately) - Add /agent/stop: sets stopped flag; agent checks between turns and exits cleanly - Agent does NOT commit on completion — leaves changes for user review/approval Made-with: Cursor
This commit is contained in:
1
dist/tools/index.d.ts
vendored
1
dist/tools/index.d.ts
vendored
@@ -7,6 +7,7 @@ import './agent';
|
||||
import './memory';
|
||||
import './skills';
|
||||
import './prd';
|
||||
import './search';
|
||||
export { ALL_TOOLS, executeTool, ToolDefinition } from './registry';
|
||||
export { ToolContext, MemoryUpdate } from './context';
|
||||
export { PROTECTED_GITEA_REPOS, PROTECTED_COOLIFY_PROJECT, PROTECTED_COOLIFY_APPS, assertGiteaWritable, assertCoolifyDeployable } from './security';
|
||||
|
||||
1
dist/tools/index.js
vendored
1
dist/tools/index.js
vendored
@@ -12,6 +12,7 @@ require("./agent");
|
||||
require("./memory");
|
||||
require("./skills");
|
||||
require("./prd");
|
||||
require("./search");
|
||||
// Re-export the public API — identical surface to the old tools.ts
|
||||
var registry_1 = require("./registry");
|
||||
Object.defineProperty(exports, "ALL_TOOLS", { enumerable: true, get: function () { return registry_1.ALL_TOOLS; } });
|
||||
|
||||
1
dist/tools/search.d.ts
vendored
Normal file
1
dist/tools/search.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
78
dist/tools/search.js
vendored
Normal file
78
dist/tools/search.js
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const registry_1 = require("./registry");
|
||||
/**
|
||||
* Web search via DuckDuckGo HTML endpoint.
|
||||
* No API key required. Scrapes result snippets and titles.
|
||||
* Atlas uses this for competitor research, market context, pricing models, etc.
|
||||
*/
|
||||
(0, registry_1.registerTool)({
|
||||
name: 'web_search',
|
||||
description: 'Search the web for current information. Use this to research competitors, market trends, pricing models, existing solutions, technology choices, or any topic the user mentions that would benefit from real-world context. Returns a summary of top search results.',
|
||||
parameters: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
query: {
|
||||
type: 'string',
|
||||
description: 'The search query. Be specific — e.g. "SaaS project management tools pricing 2024" rather than just "project management".'
|
||||
}
|
||||
},
|
||||
required: ['query']
|
||||
},
|
||||
async handler(args) {
|
||||
const query = String(args.query).trim();
|
||||
if (!query)
|
||||
return { error: 'No query provided' };
|
||||
const url = `https://html.duckduckgo.com/html/?q=${encodeURIComponent(query)}`;
|
||||
try {
|
||||
const res = await fetch(url, {
|
||||
headers: {
|
||||
'User-Agent': 'Mozilla/5.0 (compatible; VIBN-Atlas/1.0)',
|
||||
'Accept': 'text/html',
|
||||
},
|
||||
signal: AbortSignal.timeout(15000),
|
||||
});
|
||||
if (!res.ok) {
|
||||
return { error: `Search failed with status ${res.status}` };
|
||||
}
|
||||
const html = await res.text();
|
||||
// Extract result titles and snippets from DuckDuckGo HTML
|
||||
const results = [];
|
||||
// Match result titles
|
||||
const titleMatches = html.matchAll(/class="result__a"[^>]*href="[^"]*"[^>]*>(.*?)<\/a>/gs);
|
||||
const titles = [];
|
||||
for (const m of titleMatches) {
|
||||
const title = m[1].replace(/<[^>]+>/g, '').trim();
|
||||
if (title)
|
||||
titles.push(title);
|
||||
}
|
||||
// Match result snippets
|
||||
const snippetMatches = html.matchAll(/class="result__snippet"[^>]*>(.*?)<\/a>/gs);
|
||||
const snippets = [];
|
||||
for (const m of snippetMatches) {
|
||||
const snippet = m[1].replace(/<[^>]+>/g, '').trim();
|
||||
if (snippet)
|
||||
snippets.push(snippet);
|
||||
}
|
||||
// Combine up to 6 results
|
||||
const count = Math.min(6, Math.max(titles.length, snippets.length));
|
||||
for (let i = 0; i < count; i++) {
|
||||
const title = titles[i] || '';
|
||||
const snippet = snippets[i] || '';
|
||||
if (title || snippet) {
|
||||
results.push(`**${title}**\n${snippet}`);
|
||||
}
|
||||
}
|
||||
if (results.length === 0) {
|
||||
return { error: 'No results found' };
|
||||
}
|
||||
const text = results.join('\n\n');
|
||||
const truncated = text.length > 5000 ? text.slice(0, 5000) + '\n\n[...results truncated]' : text;
|
||||
return { query, results: truncated };
|
||||
}
|
||||
catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
return { error: `Search request failed: ${message}` };
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user