File size: 10,797 Bytes
fb62a97 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | // The co-worker's agents as the UI presents them: one entry per graph node (coworker/graph/build.py), grouped as in
// architecture.pdf ("Agents and their jobs"). Engines describe the design; the live provider comes from /api/config.
export type Engine = 'deterministic' | 'local' | 'frontier' | 'human';
export interface AgentDef { node: string; name: string; group: string; engine: Engine; job: string; tone: string }
export const GROUPS = ['Research swarm', 'Test design', 'Data agent', 'Playwright executor', 'Reporter & triage', 'Memory'] as const;
export const AGENTS: AgentDef[] = [
{ node: 'scout', name: 'Scout', group: 'Research swarm', engine: 'deterministic', tone: 'mint',
job: 'Reads the pod read-only: enabled modules, business units, ledgers, roles, usage counts and patch level.' },
{ node: 'research_module', name: 'Research workers', group: 'Research swarm', engine: 'frontier', tone: 'lav',
job: 'One worker pair per module: a web researcher reads public Oracle release notes (allowlisted domains), a pod prober reads setups read-only (local model).' },
{ node: 'synthesizer', name: 'Synthesizer', group: 'Research swarm', engine: 'frontier', tone: 'lav',
job: 'Merges findings into a coverage map ranked by risk and usage, with sources and confidence. Gaps are flagged, not skipped.' },
{ node: 'test_generator', name: 'Test generator', group: 'Test design', engine: 'frontier', tone: 'lav',
job: 'Turns the coverage map into prioritised cases, reusing saved ones and drafting new ones only for what changed.' },
{ node: 'approval_gate', name: 'Approval gate', group: 'Test design', engine: 'human', tone: 'amber',
job: 'Pauses the run until a consultant approves new or changed cases.' },
{ node: 'data_planner', name: 'Data planner', group: 'Data agent', engine: 'local', tone: 'ink',
job: 'Picks the data recipe each case needs, such as an existing supplier or a seeded PO.' },
{ node: 'data_executor', name: 'Data executor', group: 'Data agent', engine: 'deterministic', tone: 'mint',
job: 'Runs REST, BIP or FBDI calls. Read-only on the pod, except seeding on a test pod when allowed.' },
{ node: 'script_builder', name: 'Script builder', group: 'Test design', engine: 'local', tone: 'ink',
job: 'Writes or updates Playwright scripts for approved cases, lints and dry-runs them, then stages them for the library.' },
{ node: 'executor', name: 'Executor', group: 'Playwright executor', engine: 'deterministic', tone: 'mint',
job: 'Runs saved scripts with vault credentials and records traces, video and screenshots. No LLM.' },
{ node: 'sign_in_gate', name: 'Sign-in', group: 'Playwright executor', engine: 'human', tone: 'amber',
job: 'On a pod that signs in through the company identity provider, waits for a person to sign in before the tests run.' },
{ node: 'self_heal', name: 'Self-heal', group: 'Playwright executor', engine: 'local', tone: 'ink',
job: 'On a failed locator, proposes a fix and retries once. Fixes go to human review before they reach the library.' },
{ node: 'triage', name: 'Triage', group: 'Reporter & triage', engine: 'local', tone: 'ink',
job: 'Classifies each failure as UI change, data, timing, environment (pod or network) or real defect, with a confidence score.' },
{ node: 'human_review', name: 'Human review', group: 'Reporter & triage', engine: 'human', tone: 'amber',
job: 'A QA approver confirms real defects, records waivers and assigns owners to flaky tests.' },
{ node: 'ticket', name: 'Ticket', group: 'Reporter & triage', engine: 'deterministic', tone: 'mint',
job: 'Raises tickets for confirmed defects only, after approval.' },
{ node: 'reporter', name: 'Reporter', group: 'Reporter & triage', engine: 'frontier', tone: 'lav',
job: 'GO/NO-GO from the QA rule (reports/generate_report.py), an executive summary from redacted counts, HTML and PDF.' },
{ node: 'learner', name: 'Learner', group: 'Memory', engine: 'deterministic', tone: 'mint',
job: 'Stores run history and failure patterns so the next cycle starts with what this one learned.' },
];
export const AGENT_BY_NODE: Record<string, AgentDef> = Object.fromEntries(AGENTS.map((a) => [a.node, a]));
export const agentName = (node?: string | null) => (node ? AGENT_BY_NODE[node]?.name ?? node.replace(/_/g, ' ') : 'Coordinator');
export const ENGINE_LABEL: Record<Engine, string> = {
deterministic: 'Deterministic', local: 'Local LLM', frontier: 'Frontier LLM', human: 'Human',
};
export const ENGINE_TONE: Record<Engine, string> = { deterministic: 'mint', local: 'ink', frontier: 'lav', human: 'amber' };
/** One colour per business area for the small square marks, stable (derived from the area's code). Never a status
* colour (green, orange, red), so a square can't be misread as a result. */
const AREA_TONES = ['blue', 'violet', 'teal', 'neutral'] as const;
export const areaTone = (module?: string) => AREA_TONES[[...(module ?? '')].reduce((n, c) => n + c.charCodeAt(0), 0) % AREA_TONES.length];
export const MODULE_NAMES: Record<string, string> = {
P2P: 'Procure-to-Pay', AP: 'Payables', O2C: 'Order-to-Cash', R2R: 'Record-to-Report', A2R: 'Acquire-to-Retire', EXP: 'Expenses',
HCM: 'Human Capital', P2M: 'Plan-to-Make', PPM: 'Project Portfolio', SCM: 'Supply Chain', SCP: 'Supply Planning', CX: 'Customer Experience',
// Oracle Fusion business areas (coworker/platform/fusion_catalog.py); a pod's discovery also carries each area's name
PO: 'Purchasing', AR: 'Receivables', GL: 'General Ledger', FA: 'Fixed Assets', CM: 'Cash Management', OM: 'Order Management', INV: 'Inventory',
};
// What each step of the workflow did, in a consultant's words (the step names come from the run's own event log).
export const STEP_WORDS: Record<string, [string, string]> = {
scout: ['Scout', 'Read the test environment'],
research_module: ['Research', 'Read what this patch changes'],
synthesizer: ['Synthesizer', 'Ranked what matters most to test'],
test_generator: ['Test designer', 'Chose the scenarios'],
approval_gate: ['Approval', 'Asked for your approval'],
data_planner: ['Data planner', 'Planned the test data'],
data_executor: ['Data', 'Prepared the test data'],
script_builder: ['Script builder', 'Prepared the test scripts'],
sign_in_gate: ['Sign-in', 'Asked a person to sign in to the pod'],
executor: ['Test runner', 'Runs the scenarios'],
self_heal: ['Self-heal', 'Repaired a screen element that moved'],
triage: ['Failure analysis', 'Worked out why scenarios failed'],
human_review: ['Your review', 'Asked for your decision on failures'],
ticket: ['Tickets', 'Raised tickets for confirmed defects'],
reporter: ['Reporter', 'Applied the readiness rule and wrote the report'],
learner: ['Memory', 'Saved what was learned for next time'],
};
/** The consultant name of an agent ("Test designer"), falling back to the engineering name. */
export const stepName = (node?: string | null) => (node ? STEP_WORDS[node]?.[0] ?? agentName(node) : 'Coordinator');
/** One LLM call record of a run (`RunDetail.llm_calls`, coworker/llm/router.py). */
export interface LlmCall { node: string; task?: string; route: 'stub' | 'local' | 'frontier' | string; provider?: string; model?: string; fallback?: string | null }
export type EngineKind = 'you' | 'rules' | 'local' | 'frontier' | 'mixed';
export interface EngineOnRun { kind: EngineKind; words: string; detail?: string }
/** Design engine in consultant words ("can use"). */
export const ENGINE_WORDS: Record<Engine, string> = { deterministic: 'Built-in rules', local: 'Local AI model', frontier: 'External AI model', human: 'You' };
const callsWord = (n: number) => `${n} call${n === 1 ? '' : 's'}`;
const mostUsed = (calls: LlmCall[]) => {
const by = new Map<string, { n: number; c: LlmCall }>();
for (const c of calls) { const k = `${c.provider ?? ''}|${c.model ?? ''}`; const e = by.get(k); if (e) e.n += 1; else by.set(k, { n: 1, c }); }
return [...by.values()].sort((a, b) => b.n - a.n)[0]?.c;
};
/** What actually did an agent's work on this test run, from the run's own LLM call records (never the design engine). Pure. */
export function agentEngineOnRun(node: string, llmCalls: LlmCall[] | null | undefined, agent: Pick<AgentDef, 'engine'> | undefined): EngineOnRun {
const engine = agent?.engine ?? 'deterministic';
if (engine === 'human') return { kind: 'you', words: 'You' };
const recs = (llmCalls ?? []).filter((c) => c && c.node === node);
if (!recs.length) {
return engine === 'deterministic' ? { kind: 'rules', words: 'Built-in rules' }
: { kind: 'rules', words: 'Built-in rules (no AI model used)', detail: 'This agent can use an AI model, but none was called on this test run.' };
}
const local = recs.filter((c) => c.route === 'local');
const frontier = recs.filter((c) => c.route === 'frontier');
if (local.length && frontier.length) {
return { kind: 'mixed', words: 'Local and external AI models', detail: `${callsWord(local.length)} to the local AI model and ${callsWord(frontier.length)} to the external AI model.` };
}
if (local.length) {
const m = mostUsed(local);
return { kind: 'local', words: `Local AI model · ${m?.model ?? 'model'}`, detail: `${callsWord(local.length)} to ${m?.provider ?? 'the local provider'} ${m?.model ?? ''}. Your data stayed in your environment.`.replace(/ +\./, '.') };
}
if (frontier.length) {
const m = mostUsed(frontier);
return { kind: 'frontier', words: `External AI model · ${m?.model ?? 'model'}`, detail: `${callsWord(frontier.length)} to ${m?.provider ?? 'the external provider'} ${m?.model ?? ''}. Only public or redacted content was sent.`.replace(/ +\./, '.') };
}
const fb = recs.find((c) => c.fallback);
if (fb) return { kind: 'rules', words: 'Built-in rules (the AI model did not answer)', detail: String(fb.fallback).slice(0, 160) };
return { kind: 'rules', words: 'Built-in rules (no AI model on)', detail: 'No AI model was connected when this ran. Settings › AI models.' };
}
/** "AI on this run: …" for the Coordinator, from all the run's LLM call records. Pure. */
export function aiOnRun(llmCalls: LlmCall[] | null | undefined): string {
const calls = llmCalls ?? [];
const local = calls.filter((c) => c.route === 'local');
const frontier = calls.filter((c) => c.route === 'frontier');
if (!local.length && !frontier.length) return calls.length ? 'AI on this run: none, built-in rules only.' : 'AI on this run: none';
const parts = [local.length ? `local model ${mostUsed(local)?.model ?? ''}`.trim() : '', frontier.length ? `external model ${mostUsed(frontier)?.model ?? ''}`.trim() : ''].filter(Boolean);
return `AI on this run: ${parts.join(' and ')} (${callsWord(local.length + frontier.length)}).`;
}
|