Files
bare-operating-system/packages/bare-os-coreutils/test/agent-config-surface.test.mjs
T
2026-04-27 01:00:06 -04:00

108 lines
3.4 KiB
JavaScript

import test from 'brittle'
import { readFileSync } from 'node:fs'
const STATE = readFileSync(new URL('../lib/agent-state.js', import.meta.url), 'utf8')
const TOOLS = readFileSync(new URL('../lib/agent-tools.js', import.meta.url), 'utf8')
const OPENAI = readFileSync(new URL('../lib/agent-openai.js', import.meta.url), 'utf8')
const TUI = readFileSync(new URL('../lib/agent-tui.js', import.meta.url), 'utf8')
test('agent-state exposes reasoning config keys', async (t) => {
for (const key of [
'show_reasoning',
'reasoning_mode',
'reasoning_max_chars',
'reasoning_include_tools'
]) {
t.ok(STATE.includes(key), 'missing key in agent-state.js: ' + key)
}
})
test('agent-state exposes bridge policy keys', async (t) => {
for (const key of [
'allow_bridge_mutations',
'allow_host_notifications',
'allow_host_actions',
'emergency_stop_mutations'
]) {
t.ok(STATE.includes(key), 'missing key in agent-state.js: ' + key)
}
})
test('agent-state exposes autonomous mode config keys', async (t) => {
for (const key of [
'autonomous_mode_enabled',
'autonomous_max_runtime_ms',
'autonomous_completion_required_checks',
'autonomous_allow_paths',
'autonomous_deny_ops',
'autonomous_active',
'autonomous_started_at_ms',
'autonomous_stop_requested',
'autonomous_goal',
'autonomous_status',
'autonomous_last_error'
]) {
t.ok(STATE.includes(key), 'missing autonomous key in agent-state.js: ' + key)
}
})
test('agent-tools exposes agent ops tools', async (t) => {
for (const toolName of [
'list_services',
'service_status',
'list_timers',
'read_cron_log',
'read_audit_log',
'read_boot_policy',
'read_kernel_extension_resolution',
'get_initd_graph',
'read_unit_journal',
'inspect_ipc_backpressure',
'get_network_summary',
'tail_telemetry_streams',
'pkg_index_lookup',
'list_verification_scripts',
'run_maintenance_gate',
'run_contract_checks',
'summarize_build_drift',
'get_hrpc_bridge_health',
'get_hrpc_allowlist_status',
'emit_host_notification',
'request_host_action',
'autonomous_run',
'autonomous_run_status',
'autonomous_run_stop',
'verification_hints',
'runtime_diagnostic_bundle'
]) {
t.ok(TOOLS.includes("name: '" + toolName + "'"), 'missing tool definition: ' + toolName)
}
})
test('agent-openai parses reasoning deltas when present', async (t) => {
t.ok(OPENAI.includes('delta_reasoning'))
t.ok(OPENAI.includes('reasoning_content'))
t.ok(OPENAI.includes('response.reasoning_summary_text.delta'))
t.ok(OPENAI.includes('response_shape_keys'))
})
test('agent-tui contains groq provider profile/request shaping', async (t) => {
t.ok(TUI.includes("provider === 'groq'"))
t.ok(TUI.includes('https://api.groq.com/openai/v1'))
t.ok(TUI.includes('body.parallel_tool_calls'))
t.ok(TUI.includes('body.max_completion_tokens'))
})
test('agent-tui contains autonomous loop controls and completion gates', async (t) => {
t.ok(TUI.includes('bareAgentAutonomousSettings'))
t.ok(TUI.includes('autonomous run stopped by request'))
t.ok(TUI.includes('autonomous run stopped (timebox expired)'))
t.ok(TUI.includes('Autonomous completion gates failed for checks'))
t.ok(TUI.includes('autonomous completion gates passed'))
})
test('agent-tui embeds operating contract appendix', async (t) => {
t.ok(TUI.includes('BARE_AGENT_OPERATING_CONTRACT'))
t.ok(TUI.includes('verification_hints'))
})