fix: integrate audit findings round 1 - tools, worker, scheduler, main agent
- Unify ToolResultEnvelope (output vs content) for built-in tools - Fix shell.run AsyncGenerator consumption in ToolRegistry.call/streaming - Scheduler: consume WorkerResult.status instead of marking all running tasks completed - WorkerProcess/WorkerManager: surface exit events and generate failed/cancelled result - MainAgent: integrate ContextAssembler, Chinese destructive regex, ArchitectureDesigner impact gate - run.ts: pendingConfirmation flow, dispatch extracted, .air files filtered from /results - CapabilityRegistry wired into RuntimeApp and ServiceRegistry; DoctorService uses it - release.ts: findRepoRoot/findBun, run air e2e + depcruise + runtime regression - New gates: release-critical-gates, CLI run command regression - 14/14 e2e gates pass; 3/3 release dry-run pass Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -178,7 +178,7 @@ export class BuiltInToolRegistrar {
|
||||
const { path } = call.arguments as { path: string }
|
||||
const s = statSync(resolve(project_root, path))
|
||||
return { status: "ok", call_id: call.call_id, tool_name: 'fs.stat', type: 'text',
|
||||
content: { path, exists: true, size: s.size, is_dir: s.isDirectory(), is_file: s.isFile(),
|
||||
output: { path, exists: true, size: s.size, is_dir: s.isDirectory(), is_file: s.isFile(),
|
||||
mode: s.mode, mtime: s.mtime.toISOString(), ctime: s.ctime.toISOString() },
|
||||
metadata: { timestamp: new Date().toISOString(), call_id: call.call_id, tool_name: 'fs.stat', type: 'ok' } }
|
||||
} catch (e: any) {
|
||||
@@ -192,7 +192,7 @@ export class BuiltInToolRegistrar {
|
||||
const { pid, signal = 'SIGTERM' } = call.arguments as { pid: number; signal?: string }
|
||||
process.kill(pid, signal as NodeJS.Signals)
|
||||
return { status: "ok", call_id: call.call_id, tool_name: 'process.kill', type: 'text',
|
||||
content: { pid, signal, killed: true },
|
||||
output: { pid, signal, killed: true },
|
||||
metadata: { timestamp: new Date().toISOString(), call_id: call.call_id, tool_name: 'process.kill', type: 'ok' } }
|
||||
} catch (e: any) {
|
||||
return { status: 'error', error: { error_id: call.call_id, kind: 'tool_error', severity: 'error', message: e.message, retryability: 'not_retryable', semantic_signature: 'process.kill' },
|
||||
@@ -204,7 +204,7 @@ export class BuiltInToolRegistrar {
|
||||
try {
|
||||
const { path, base_ref = 'HEAD' } = call.arguments as { path: string; base_ref?: string }
|
||||
execFileSync('git', ['worktree', 'add', path, base_ref], { cwd: project_root, stdio: 'pipe', encoding: 'utf-8' })
|
||||
return { status: "ok", call_id: call.call_id, tool_name, type: 'text', content: { path, base_ref, created: true },
|
||||
return { status: "ok", call_id: call.call_id, tool_name, type: 'text', output: { path, base_ref, created: true },
|
||||
metadata: { timestamp: new Date().toISOString(), call_id: call.call_id, tool_name, type: 'ok' } }
|
||||
} catch (e: any) {
|
||||
return { status: 'error', error: { error_id: call.call_id, kind: 'tool_error', severity: 'error', message: e.message, retryability: 'not_retryable', semantic_signature: tool_name },
|
||||
@@ -216,7 +216,7 @@ export class BuiltInToolRegistrar {
|
||||
try {
|
||||
const { workspace_id } = call.arguments as { workspace_id: string; strategy?: string }
|
||||
execFileSync('git', ['merge', '--no-ff', workspace_id], { cwd: project_root, stdio: 'pipe', encoding: 'utf-8' })
|
||||
return { status: "ok", call_id: call.call_id, tool_name, type: 'text', content: { workspace_id, merged: true },
|
||||
return { status: "ok", call_id: call.call_id, tool_name, type: 'text', output: { workspace_id, merged: true },
|
||||
metadata: { timestamp: new Date().toISOString(), call_id: call.call_id, tool_name, type: 'ok' } }
|
||||
} catch (e: any) {
|
||||
return { status: 'error', error: { error_id: call.call_id, kind: 'tool_error', severity: 'error', message: e.message, retryability: 'not_retryable', semantic_signature: tool_name },
|
||||
@@ -235,7 +235,7 @@ export class BuiltInToolRegistrar {
|
||||
by_ext[ext] = (by_ext[ext] || 0) + 1
|
||||
}
|
||||
return { status: "ok", call_id: call.call_id, tool_name, type: 'text',
|
||||
content: { root: dir, total_files: entries.length, extensions: by_ext },
|
||||
output: { root: dir, total_files: entries.length, extensions: by_ext },
|
||||
metadata: { timestamp: new Date().toISOString(), call_id: call.call_id, tool_name, type: 'ok' } }
|
||||
} catch (e: any) {
|
||||
return { status: 'error', error: { error_id: call.call_id, kind: 'tool_error', severity: 'error', message: e.message, retryability: 'not_retryable', semantic_signature: tool_name },
|
||||
@@ -249,7 +249,7 @@ export class BuiltInToolRegistrar {
|
||||
const dir = join(project_root, '.air', 'shared', 'profiles')
|
||||
if (!existsSync(dir)) mkdirSync(dir, { recursive: true })
|
||||
writeFileSync(join(dir, `${language}.json`), JSON.stringify(profile_json, null, 2))
|
||||
return { status: "ok", call_id: call.call_id, tool_name, type: 'text', content: { language, written: true },
|
||||
return { status: "ok", call_id: call.call_id, tool_name, type: 'text', output: { language, written: true },
|
||||
metadata: { timestamp: new Date().toISOString(), call_id: call.call_id, tool_name, type: 'ok' } }
|
||||
} catch (e: any) {
|
||||
return { status: 'error', error: { error_id: call.call_id, kind: 'tool_error', severity: 'error', message: e.message, retryability: 'not_retryable', semantic_signature: tool_name },
|
||||
@@ -263,7 +263,7 @@ export class BuiltInToolRegistrar {
|
||||
const cmake = existsSync(join(root, 'CMakeLists.txt'))
|
||||
const makefile = existsSync(join(root, 'Makefile'))
|
||||
return { status: "ok", call_id: call.call_id, tool_name, type: 'text',
|
||||
content: { has_cmake: cmake, has_makefile: makefile, build_system: cmake ? 'cmake' : makefile ? 'make' : 'none' },
|
||||
output: { has_cmake: cmake, has_makefile: makefile, build_system: cmake ? 'cmake' : makefile ? 'make' : 'none' },
|
||||
metadata: { timestamp: new Date().toISOString(), call_id: call.call_id, tool_name, type: 'ok' } }
|
||||
} catch (e: any) {
|
||||
return { status: 'error', error: { error_id: call.call_id, kind: 'tool_error', severity: 'error', message: e.message, retryability: 'not_retryable', semantic_signature: tool_name },
|
||||
@@ -277,7 +277,7 @@ export class BuiltInToolRegistrar {
|
||||
const buildDir = join(project_root, 'build')
|
||||
if (!existsSync(buildDir)) mkdirSync(buildDir, { recursive: true })
|
||||
execFileSync('cmake', ['-G', generator, '-DCMAKE_BUILD_TYPE=' + build_type, '..'], { cwd: buildDir, stdio: 'pipe' })
|
||||
return { status: "ok", call_id: call.call_id, tool_name, type: 'text', content: { generator, build_type, configured: true },
|
||||
return { status: "ok", call_id: call.call_id, tool_name, type: 'text', output: { generator, build_type, configured: true },
|
||||
metadata: { timestamp: new Date().toISOString(), call_id: call.call_id, tool_name, type: 'ok' } }
|
||||
} catch (e: any) {
|
||||
return { status: 'error', error: { error_id: call.call_id, kind: 'tool_error', severity: 'error', message: e.message, retryability: 'not_retryable', semantic_signature: tool_name },
|
||||
@@ -291,7 +291,7 @@ export class BuiltInToolRegistrar {
|
||||
const args = target ? ['--build', '.', '--config', config, '--target', target] : ['--build', '.', '--config', config]
|
||||
const out = execFileSync('cmake', args, { cwd: join(project_root, 'build'), stdio: 'pipe', timeout: 300000 })
|
||||
return { status: "ok", call_id: call.call_id, tool_name, type: 'text',
|
||||
content: { built: true, output: out.toString().slice(-500) },
|
||||
output: { built: true, output: out.toString().slice(-500) },
|
||||
metadata: { timestamp: new Date().toISOString(), call_id: call.call_id, tool_name, type: 'ok' } }
|
||||
} catch (e: any) {
|
||||
return { status: 'error', error: { error_id: call.call_id, kind: 'tool_error', severity: 'error', message: e.message, retryability: 'not_retryable', semantic_signature: tool_name },
|
||||
@@ -305,7 +305,7 @@ export class BuiltInToolRegistrar {
|
||||
const args = filter ? ['--output-on-failure', '-R', filter] : ['--output-on-failure']
|
||||
const out = execFileSync('ctest', args, { cwd: join(project_root, 'build'), stdio: 'pipe', timeout: 300000 })
|
||||
return { status: "ok", call_id: call.call_id, tool_name, type: 'text',
|
||||
content: { passed: true, output: out.toString().slice(-1000) },
|
||||
output: { passed: true, output: out.toString().slice(-1000) },
|
||||
metadata: { timestamp: new Date().toISOString(), call_id: call.call_id, tool_name, type: 'ok' } }
|
||||
} catch (e: any) {
|
||||
return { status: 'error', error: { error_id: call.call_id, kind: 'tool_error', severity: 'error', message: e.message, retryability: 'not_retryable', semantic_signature: tool_name },
|
||||
@@ -318,7 +318,7 @@ export class BuiltInToolRegistrar {
|
||||
const { path = 'src' } = (call.arguments || {}) as any
|
||||
const out = execFileSync('cppcheck', ['--enable=all', '--quiet', path], { cwd: project_root, stdio: 'pipe', encoding: 'utf-8', timeout: 120000 })
|
||||
return { status: "ok", call_id: call.call_id, tool_name, type: 'text',
|
||||
content: { output: out.toString().slice(-500), issues_found: 0 },
|
||||
output: { output: out.toString().slice(-500), issues_found: 0 },
|
||||
metadata: { timestamp: new Date().toISOString(), call_id: call.call_id, tool_name, type: 'ok' } }
|
||||
} catch (e: any) {
|
||||
return { status: 'error', error: { error_id: call.call_id, kind: 'tool_error', severity: 'error', message: e.message, retryability: 'not_retryable', semantic_signature: tool_name },
|
||||
@@ -331,7 +331,7 @@ export class BuiltInToolRegistrar {
|
||||
const { file, line = 0, column = 0 } = (call.arguments || {}) as any
|
||||
const out = execFileSync('clangd', ['--check=' + file], { cwd: project_root, stdio: 'pipe', encoding: 'utf-8', timeout: 30000 })
|
||||
return { status: "ok", call_id: call.call_id, tool_name, type: 'text',
|
||||
content: { file, line, column, diagnostics: out.toString().slice(-1000) },
|
||||
output: { file, line, column, diagnostics: out.toString().slice(-1000) },
|
||||
metadata: { timestamp: new Date().toISOString(), call_id: call.call_id, tool_name, type: 'ok' } }
|
||||
} catch (e: any) {
|
||||
return { status: 'error', error: { error_id: call.call_id, kind: 'tool_error', severity: 'error', message: e.message, retryability: 'not_retryable', semantic_signature: tool_name },
|
||||
@@ -344,7 +344,7 @@ export class BuiltInToolRegistrar {
|
||||
const { target } = (call.arguments || {}) as any
|
||||
const out = execFileSync('gdb', ['-batch', '-ex', 'run', '-ex', 'bt', '--', target], { cwd: project_root, stdio: 'pipe', encoding: 'utf-8', timeout: 60000 })
|
||||
return { status: "ok", call_id: call.call_id, tool_name, type: 'text',
|
||||
content: { target, backtrace: out.toString().slice(-2000) },
|
||||
output: { target, backtrace: out.toString().slice(-2000) },
|
||||
metadata: { timestamp: new Date().toISOString(), call_id: call.call_id, tool_name, type: 'ok' } }
|
||||
} catch (e: any) {
|
||||
return { status: 'error', error: { error_id: call.call_id, kind: 'tool_error', severity: 'error', message: e.message, retryability: 'not_retryable', semantic_signature: tool_name },
|
||||
@@ -358,7 +358,7 @@ export class BuiltInToolRegistrar {
|
||||
const content = readFileSync(resolve(project_root, log_path), 'utf-8')
|
||||
const errors = content.split('\n').filter(l => /error|fail|segfault|assert|abort|exception/i.test(l)).slice(0, 50)
|
||||
return { status: "ok", call_id: call.call_id, tool_name, type: 'text',
|
||||
content: { log_path, error_count: errors.length, errors },
|
||||
output: { log_path, error_count: errors.length, errors },
|
||||
metadata: { timestamp: new Date().toISOString(), call_id: call.call_id, tool_name, type: 'ok' } }
|
||||
} catch (e: any) {
|
||||
return { status: 'error', error: { error_id: call.call_id, kind: 'tool_error', severity: 'error', message: e.message, retryability: 'not_retryable', semantic_signature: tool_name },
|
||||
@@ -373,7 +373,7 @@ export class BuiltInToolRegistrar {
|
||||
const tmpFile = join(tmpDir, `screenshot-${Date.now()}.png`)
|
||||
execFileSync('import', ['-window', 'root', tmpFile], { stdio: 'pipe', timeout: 10000 })
|
||||
return { status: "ok", call_id: call.call_id, tool_name, type: 'text',
|
||||
content: { captured: true, path: tmpFile },
|
||||
output: { captured: true, path: tmpFile },
|
||||
metadata: { timestamp: new Date().toISOString(), call_id: call.call_id, tool_name, type: 'ok' } }
|
||||
} catch (e: any) {
|
||||
return { status: 'error', error: { error_id: call.call_id, kind: 'tool_error', severity: 'error', message: `Screenshot not available: ${e.message}`, retryability: 'not_retryable', semantic_signature: tool_name },
|
||||
@@ -388,7 +388,7 @@ export class BuiltInToolRegistrar {
|
||||
if (filter) args.push(filter)
|
||||
const out = execFileSync('tcpdump', args, { stdio: 'pipe', timeout: (duration_sec + 5) * 1000 })
|
||||
return { status: "ok", call_id: call.call_id, tool_name, type: 'text',
|
||||
content: { interface: iface, duration_sec, packets: (String(out) || '').split('\n').length },
|
||||
output: { interface: iface, duration_sec, packets: (String(out) || '').split('\n').length },
|
||||
metadata: { timestamp: new Date().toISOString(), call_id: call.call_id, tool_name, type: 'ok' } }
|
||||
} catch (e: any) {
|
||||
return { status: 'error', error: { error_id: call.call_id, kind: 'tool_error', severity: 'error', message: `Capture not available: ${e.message}`, retryability: 'not_retryable', semantic_signature: tool_name },
|
||||
@@ -399,7 +399,7 @@ export class BuiltInToolRegistrar {
|
||||
'permission.request': async (call: any) => {
|
||||
const { tool_name: tn, reason } = call.arguments as { tool_name: string; reason: string }
|
||||
return { status: "ok", call_id: call.call_id, tool_name, type: 'text',
|
||||
content: { tool_name: tn, reason, status: 'allowed', message: `Permission granted for ${tn}: ${reason}` },
|
||||
output: { tool_name: tn, reason, status: 'allowed', message: `Permission granted for ${tn}: ${reason}` },
|
||||
metadata: { timestamp: new Date().toISOString(), call_id: call.call_id, tool_name, type: 'ok' } }
|
||||
},
|
||||
|
||||
@@ -416,7 +416,7 @@ export class BuiltInToolRegistrar {
|
||||
checks.push({ name: 'project_structure', passed: hasPkg, message: hasPkg ? 'Valid' : 'No package.json' })
|
||||
const allPassed = checks.every(c => c.passed)
|
||||
return { status: "ok", call_id: call.call_id, tool_name, type: 'text',
|
||||
content: { checks, all_passed: allPassed, fixable_count: checks.filter(c => !c.passed).length },
|
||||
output: { checks, all_passed: allPassed, fixable_count: checks.filter(c => !c.passed).length },
|
||||
metadata: { timestamp: new Date().toISOString(), call_id: call.call_id, tool_name, type: 'ok' } }
|
||||
} catch (e: any) {
|
||||
return { status: 'error', error: { error_id: call.call_id, kind: 'tool_error', severity: 'error', message: e.message, retryability: 'not_retryable', semantic_signature: tool_name },
|
||||
@@ -432,7 +432,7 @@ export class BuiltInToolRegistrar {
|
||||
call_id: call.call_id,
|
||||
tool_name,
|
||||
type: 'text',
|
||||
content: { message: `Tool ${tool_name} not yet implemented` },
|
||||
output: { message: `Tool ${tool_name} not yet implemented` },
|
||||
metadata: { timestamp: new Date().toISOString(), call_id: call.call_id, tool_name, type: 'ok' }
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user