Skip to content

Commit 96982c0

Browse files
authored
Merge pull request #9861 from loopx-project/codex/oar-deep-fusion-phase2
feat(hosts): OAR deep fusion Phase 2 — harden OAR host and migrate DSH, Claude/ACP, and bounded Codex
2 parents 838a0a0 + c9b9f4f commit 96982c0

102 files changed

Lines changed: 21510 additions & 3810 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/presentation/dashboard/package-lock.json‎

Lines changed: 4055 additions & 992 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎apps/presentation/dashboard/package.json‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"preview": "vite preview --host 127.0.0.1",
2525
"smoke:action-packet": "rm -rf /tmp/loopx-action-packet-smoke && tsc --ignoreConfig --target ES2022 --module NodeNext --moduleResolution NodeNext --skipLibCheck --strict --outDir /tmp/loopx-action-packet-smoke smoke/action-packet-smoke.ts src/data/action-packet.ts && node /tmp/loopx-action-packet-smoke/smoke/action-packet-smoke.js",
2626
"smoke:agent-family": "tsc --ignoreConfig --target ES2022 --module ES2022 --moduleResolution Bundler --skipLibCheck --strict --outDir node_modules/.cache/loopx-agent-family src/features/personal-workspace/agent-family.ts && node src/features/personal-workspace/agent-family.test.mjs",
27+
"smoke:oar-observe": "tsc --noEmit --ignoreConfig --target ES2022 --module ES2022 --moduleResolution Bundler --allowImportingTsExtensions --types node --skipLibCheck --strict smoke/oar-observe-smoke.ts src/data/oar-observe.ts && vite build --ssr smoke/oar-observe-smoke.ts --outDir node_modules/.cache/loopx-oar-observe-smoke --emptyOutDir && node node_modules/.cache/loopx-oar-observe-smoke/oar-observe-smoke.js",
2728
"smoke:benchmark-study": "rm -rf node_modules/.cache/loopx-benchmark-study-smoke && tsc --ignoreConfig --target ES2022 --module NodeNext --moduleResolution NodeNext --skipLibCheck --strict --resolveJsonModule --outDir node_modules/.cache/loopx-benchmark-study-smoke smoke/benchmark-study-contract-smoke.ts src/data/benchmark-study.ts && node node_modules/.cache/loopx-benchmark-study-smoke/smoke/benchmark-study-contract-smoke.js",
2829
"smoke:benchmark-study-browser": "node ../../../examples/dashboard-benchmark-study-browser-smoke.mjs",
2930
"smoke:capability-configuration": "rm -rf node_modules/.cache/loopx-capability-configuration-smoke && tsc --ignoreConfig --target ES2022 --module NodeNext --moduleResolution NodeNext --types node --skipLibCheck --strict --outDir node_modules/.cache/loopx-capability-configuration-smoke smoke/capability-configuration-smoke.ts src/data/capability-configuration.ts && node node_modules/.cache/loopx-capability-configuration-smoke/smoke/capability-configuration-smoke.js",
@@ -100,6 +101,7 @@
100101
"smoke:delegation-cancel": "LOOPX_PLAYWRIGHT_PACKAGE=\"$PWD/node_modules/playwright\" node --experimental-strip-types smoke/delegation-read-cancel.ts"
101102
},
102103
"dependencies": {
104+
"@botiverse/oar": "0.142.0",
103105
"@fontsource-variable/geist": "^5.3.0",
104106
"@fontsource-variable/geist-mono": "^5.3.0",
105107
"@tailwindcss/vite": "^4.3.0",
@@ -128,7 +130,15 @@
128130
"vite": "^8.3.4"
129131
},
130132
"overrides": {
133+
"@botiverse/bottega": {
134+
"undici": "^7.30.2"
135+
},
136+
"@earendil-works/pi-coding-agent": {
137+
"minimatch": "11.0.10"
138+
},
139+
"cross-spawn": "^7.1.2",
131140
"nanoid": "3.3.18",
132-
"postcss": "8.5.26"
141+
"postcss": "8.5.26",
142+
"standardwebhooks": "1.3.0"
133143
}
134144
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import assert from "node:assert/strict";
2+
import type { RawEvent } from "@botiverse/oar/browser";
3+
import {
4+
canonicalOarBrandId,
5+
classifyTool,
6+
formatOarTurnFailure,
7+
getOarRuntimeConfigForm,
8+
listOarRuntimeBrands,
9+
listOarRuntimeConfigForms,
10+
reduceOarRecordsToView,
11+
resolveOarRuntimeBrand,
12+
toolActionLabel,
13+
} from "../src/data/oar-observe.ts";
14+
15+
// 1) All 16 OAR brands resolve offline with SVG icons in both light & dark themes.
16+
const lightBrands = listOarRuntimeBrands("light");
17+
const darkBrands = listOarRuntimeBrands("dark");
18+
assert.equal(lightBrands.length, 16);
19+
assert.equal(darkBrands.length, 16);
20+
21+
assert.equal(canonicalOarBrandId("deepseek_harness_segment"), "dsh");
22+
assert.equal(canonicalOarBrandId("claude-code"), "claude");
23+
assert.equal(canonicalOarBrandId("agy-cli"), "antigravity");
24+
assert.equal(canonicalOarBrandId("droid"), "factory");
25+
assert.equal(canonicalOarBrandId("unknown-custom"), null);
26+
27+
const codexDark = resolveOarRuntimeBrand("codex-cli", "dark");
28+
assert.ok(codexDark);
29+
assert.equal(codexDark.id, "codex");
30+
assert.equal(codexDark.name, "Codex");
31+
assert.ok(codexDark.icon?.startsWith("data:image/svg+xml,"));
32+
33+
// 2) Declarative OAR runtime config forms resolve cleanly.
34+
const forms = listOarRuntimeConfigForms();
35+
assert.ok(typeof forms === "object" && forms !== null);
36+
for (const key of Object.keys(forms)) {
37+
assert.ok(getOarRuntimeConfigForm(key) !== null);
38+
}
39+
40+
// 3) Pure @botiverse/oar/observe fold reduces RawEvent[] cleanly in browser-safe code.
41+
const records: RawEvent[] = [
42+
{
43+
sessionId: "sess-ui-1",
44+
agentPath: [],
45+
seq: 0,
46+
receivedAt: 1_700_000_000_000,
47+
kind: "frame",
48+
body: {
49+
type: "scripted/turn",
50+
native: {},
51+
events: [
52+
{ kind: "turn_active" },
53+
{ kind: "text_delta", text: "All tests passed." },
54+
{ kind: "turn_ended", outcome: { kind: "completed" } },
55+
],
56+
},
57+
},
58+
];
59+
const snapshot = reduceOarRecordsToView("sess-ui-1", records, "codex");
60+
assert.equal(snapshot.view.rootSessionId, "sess-ui-1");
61+
assert.equal(snapshot.status.kind, "idle");
62+
assert.ok(snapshot.view.messages.length >= 1);
63+
64+
const action = classifyTool("claude", "Read", '{"file_path":"README.md"}');
65+
assert.equal(action.kind, "read_file");
66+
assert.equal(action.detail, "README.md");
67+
assert.ok(toolActionLabel(action.kind, "done").length > 0);
68+
69+
// 4) Failure advice formatting preserves OAR recovery semantics.
70+
const formatted = formatOarTurnFailure(
71+
{
72+
kind: "failed",
73+
failure: "rate_limited",
74+
reason: "429 too many requests",
75+
status: 429,
76+
},
77+
"Codex",
78+
);
79+
assert.ok(formatted.text.length > 0);
80+
assert.equal(formatted.advice.retry, "now");
81+
assert.equal(formatted.advice.userAction, false);
82+
83+
console.log("Dashboard OAR observe/brands/forms smoke passed");

‎apps/presentation/dashboard/src/data/chat.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -844,14 +844,18 @@ export type AgentModelDiscovery = {
844844
ok: true;
845845
schema_version: "loopx_chat_agent_model_options_v1";
846846
agent_id: string;
847+
oar_runtime_id?: string;
847848
supported: boolean;
848-
model: { id: string; label: string; selected: string; options: AgentModelOption[] } | null;
849-
reasoning_effort?: { id: string; label: string; selected: string; options: AgentModelOption[] } | null;
849+
model: { id: string; label: string; selected: string | null; options: AgentModelOption[] } | null;
850+
reasoning_effort?: { id: string; label: string; selected: string | null; options: AgentModelOption[] } | null;
850851
};
851852

852-
export function discoverAgentModelOptions(agentId: string, signal?: AbortSignal, goalId?: string, modelId?: string) {
853+
export function discoverAgentModelOptions(
854+
agentId: string, signal?: AbortSignal, context: { goalId?: string; projectRef?: string; modelId?: string } = {},
855+
) {
853856
return requestJson<AgentModelDiscovery>("/api/chat/agent-model-options", {
854-
method: "POST", signal, body: JSON.stringify({agent_id: agentId, ...(goalId ? {goal_id: goalId} : {}), ...(modelId ? {agent_model_id: modelId} : {})}),
857+
method: "POST", signal, body: JSON.stringify({agent_id: agentId, ...(context.projectRef ? {project_ref: context.projectRef} : {}),
858+
...(context.goalId ? {goal_id: context.goalId} : {}), ...(context.modelId ? {agent_model_id: context.modelId} : {})}),
855859
});
856860
}
857861

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
/**
2+
* Browser-safe OAR observability, branding, and runtime configuration form
3+
* adapter for LoopX Dashboard.
4+
*
5+
* Imports ONLY browser-safe `@botiverse/oar` subpaths (`@botiverse/oar/observe`,
6+
* `@botiverse/oar/brands`, `@botiverse/oar/forms`) with zero Node built-ins.
7+
*/
8+
import type { RawEvent, TurnOutcome } from "@botiverse/oar/browser";
9+
import {
10+
runtimeBrandIcon,
11+
runtimeBrands,
12+
type RuntimeBrand,
13+
} from "@botiverse/oar/brands";
14+
import {
15+
configForms,
16+
type RuntimeConfigForm,
17+
} from "@botiverse/oar/forms";
18+
import {
19+
classifyTool,
20+
contextUsageOf,
21+
failureAdvice,
22+
failureText,
23+
groupToolActivity,
24+
initialConversation,
25+
initialSessionView,
26+
initialTaskState,
27+
noticeText,
28+
noticeTone,
29+
observeStalls,
30+
phaseLabel,
31+
reduceConversation,
32+
reduceSessionView,
33+
reduceTaskState,
34+
statusOf,
35+
taskStatusLabel,
36+
toolActionLabel,
37+
toolGroupSummary,
38+
usageOf,
39+
type AgentStatus,
40+
type ConversationState,
41+
type FailureAdvice,
42+
type SessionView,
43+
type StallInfo,
44+
type TaskState,
45+
} from "@botiverse/oar/observe";
46+
47+
export type OarThemeMode = "light" | "dark";
48+
49+
export interface OarRuntimeBrandSummary {
50+
readonly id: string;
51+
readonly name: string;
52+
readonly icon: string | null;
53+
}
54+
55+
export interface OarReducedSessionSnapshot {
56+
readonly view: SessionView;
57+
readonly conversation: ConversationState;
58+
readonly tasks: TaskState;
59+
readonly status: AgentStatus;
60+
readonly phaseText: string;
61+
readonly usage: ReturnType<typeof usageOf>["value"];
62+
readonly contextUsage: ReturnType<typeof contextUsageOf>["value"];
63+
}
64+
65+
const RUNTIME_BRAND_ALIASES: Readonly<Record<string, keyof typeof runtimeBrands>> = {
66+
codex: "codex",
67+
"codex-cli": "codex",
68+
codex_cli: "codex",
69+
claude: "claude",
70+
"claude-code": "claude",
71+
claude_code: "claude",
72+
dsh: "dsh",
73+
"deepseek-harness": "dsh",
74+
deepseek_harness: "dsh",
75+
deepseek_harness_segment: "dsh",
76+
pi: "pi",
77+
"pi-cli": "pi",
78+
"pi-durable": "pi-durable",
79+
pi_durable: "pi-durable",
80+
opencode: "opencode",
81+
opencode2: "opencode",
82+
antigravity: "antigravity",
83+
"antigravity-cli": "antigravity",
84+
"agy-cli": "antigravity",
85+
agy: "antigravity",
86+
kimi: "kimi",
87+
"kimi-cli": "kimi",
88+
qwen: "qwen",
89+
devin: "devin",
90+
factory: "factory",
91+
droid: "factory",
92+
grok: "grok",
93+
codebuddy: "codebuddy",
94+
qoder: "qoder",
95+
qodercli: "qoder",
96+
cursor: "cursor",
97+
"cursor-cli": "cursor",
98+
bottega: "bottega",
99+
};
100+
101+
/** Normalize a LoopX agent_id or adapter alias onto its canonical OAR brand key. */
102+
export function canonicalOarBrandId(rawId: string): keyof typeof runtimeBrands | null {
103+
const token = rawId.trim().toLowerCase();
104+
return RUNTIME_BRAND_ALIASES[token] ?? null;
105+
}
106+
107+
/** Resolve offline SVG brand icon + display label for any OAR runtime or alias. */
108+
export function resolveOarRuntimeBrand(
109+
runtimeOrAgentId: string,
110+
theme: OarThemeMode = "light",
111+
): OarRuntimeBrandSummary | null {
112+
const canonical = canonicalOarBrandId(runtimeOrAgentId);
113+
if (!canonical) return null;
114+
const brand = runtimeBrands[canonical] as RuntimeBrand;
115+
return {
116+
id: canonical,
117+
name: brand.name,
118+
icon: runtimeBrandIcon(brand, theme),
119+
};
120+
}
121+
122+
/** Return all 16 OAR built-in runtime brands resolved for the active theme. */
123+
export function listOarRuntimeBrands(theme: OarThemeMode = "light"): readonly OarRuntimeBrandSummary[] {
124+
return (Object.keys(runtimeBrands) as (keyof typeof runtimeBrands)[]).map((id) => {
125+
const brand = runtimeBrands[id] as RuntimeBrand;
126+
return {
127+
id,
128+
name: brand.name,
129+
icon: runtimeBrandIcon(brand, theme),
130+
};
131+
});
132+
}
133+
134+
/** Look up OAR's declarative configuration form schema for a runtime ID or alias. */
135+
export function getOarRuntimeConfigForm(runtimeOrAgentId: string): RuntimeConfigForm | null {
136+
const canonical = canonicalOarBrandId(runtimeOrAgentId);
137+
if (!canonical) return null;
138+
return configForms[canonical] ?? null;
139+
}
140+
141+
/** Return all declared OAR runtime configuration forms indexed by runtime ID. */
142+
export function listOarRuntimeConfigForms(): Readonly<Record<string, RuntimeConfigForm>> {
143+
return configForms;
144+
}
145+
146+
/**
147+
* Pure fold from OAR `RawEvent[]` records into Dashboard-ready session view,
148+
* conversation transcript, task state, agent status, and usage projections.
149+
*/
150+
export function reduceOarRecordsToView(
151+
sessionId: string,
152+
records: readonly RawEvent[],
153+
runtimeId?: string,
154+
): OarReducedSessionSnapshot {
155+
let view = initialSessionView(sessionId);
156+
let conversation = initialConversation();
157+
let tasks = initialTaskState();
158+
for (const record of records) {
159+
view = reduceSessionView(view, record, sessionId);
160+
conversation = reduceConversation(conversation, record, sessionId);
161+
tasks = reduceTaskState(tasks, record);
162+
}
163+
const status = statusOf(records, sessionId).value;
164+
const phase = status.kind === "running" ? phaseLabel(status.phase, runtimeId) : status.kind;
165+
return {
166+
view,
167+
conversation,
168+
tasks,
169+
status,
170+
phaseText: phase,
171+
usage: usageOf(records, sessionId).value,
172+
contextUsage: contextUsageOf(records, sessionId).value,
173+
};
174+
}
175+
176+
/** Format a failed OAR `TurnOutcome` into user-safe message + typed recovery advice. */
177+
export function formatOarTurnFailure(
178+
outcome: Extract<TurnOutcome, { readonly kind: "failed" }>,
179+
runtimeName = "Agent",
180+
): {
181+
readonly text: string;
182+
readonly advice: FailureAdvice;
183+
} {
184+
const credential = "credential" in outcome ? outcome.credential : undefined;
185+
return {
186+
text: failureText(outcome.failure, runtimeName, credential),
187+
advice: failureAdvice(outcome.failure),
188+
};
189+
}
190+
191+
export {
192+
classifyTool,
193+
groupToolActivity,
194+
noticeText,
195+
noticeTone,
196+
observeStalls,
197+
phaseLabel,
198+
taskStatusLabel,
199+
toolActionLabel,
200+
toolGroupSummary,
201+
type StallInfo,
202+
};

‎apps/presentation/dashboard/src/features/personal-workspace/agent-family.ts‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,25 @@ export const AGENT_FAMILY_ROOTS = [
2020
"coco",
2121
"openai",
2222
"anthropic",
23+
"dsh",
24+
"pi",
25+
"opencode",
26+
"antigravity",
27+
"agy",
28+
"kimi",
29+
"qwen",
30+
"devin",
31+
"factory",
32+
"grok",
33+
"codebuddy",
34+
"qoder",
35+
"cursor",
36+
"bottega",
2337
] as const;
2438

2539
export type AgentFamilyRoot = (typeof AGENT_FAMILY_ROOTS)[number];
2640

27-
const GENERIC_ADAPTER_KINDS = new Set(["acp", "status_projection"]);
41+
const GENERIC_ADAPTER_KINDS = new Set(["acp", "oar_runtime", "status_projection"]);
2842

2943
/** Return the bounded family root for an id, or the normalized id itself. */
3044
export function agentFamily(agentId: string): string {

0 commit comments

Comments
 (0)