AnthropicallyHuggingFaces's picture
Sync full ProjectOS monorepo from GitHub 7f633f5
a8f4b72 verified
Raw History Blame Contribute Delete
2.3 kB
import { randomUUID } from 'node:crypto';
import { getCouncilTemplate } from '../../council-engine/src/index.mjs';
import { evaluateExecutionGate } from '../../governance-fabric/src/index.mjs';
const intentRules = [
['governance', /policy|permission|trust|privacy|risk|approval|audit/],
['infrastructure', /deploy|database|docker|runtime|infrastructure|install|server/],
['architecture', /design|architecture|system|structure|interface|boundary/],
['implementation', /build|implement|code|create|app|feature|fix|change/],
['evolution', /improv|evol|compare|roadmap|gap|frontier|obsolete/]
];
export function classifyIntent(question) {
const normalized = String(question ?? '').trim().toLowerCase();
for (const [intent, expression] of intentRules) {
if (expression.test(normalized)) return intent;
}
return 'research';
}
export function createPlanDraft({ question, project = '', integrations = {} }) {
const cleanQuestion = String(question ?? '').trim();
if (!cleanQuestion) throw new TypeError('A question is required to create a plan.');
if (cleanQuestion.length > 700) throw new RangeError('Questions must be 700 characters or fewer.');
const intent = classifyIntent(cleanQuestion);
const council = getCouncilTemplate(intent);
const gate = evaluateExecutionGate({ integrations, hasApproval: false });
const projectName = String(project ?? '').trim() || 'Workspace level';
return {
id: randomUUID(),
question: cleanQuestion,
project: projectName,
intent,
council: council.name,
agents: council.agents,
model: 'Not configured',
datasets: String(project ?? '').trim() ? `${projectName} project context (local prototype)` : 'No dataset connected',
tools: 'No tool adapters configured',
logic: 'Draft created; feasibility has not been verified against a runtime.',
governance: `${gate.status}: ${gate.reason}`,
governanceGate: gate,
status: 'Draft',
executionReady: gate.allowed,
created: new Date().toISOString()
};
}
export class OperationsAgent {
createCouncil(task) {
const plan = createPlanDraft({ question: task });
console.log(`Creating ${plan.council} for ${task}`);
return plan.agents;
}
plan(task, project) {
return createPlanDraft({ question: task, project });
}
}