mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-07 15:22:55 +00:00
* refactor: extract agent core package Introduce packages/agent-core as the OpenClaw-owned home for reusable agent loop, harness, session, prompt, and runtime dependency contracts. * refactor: extract shared llm runtime Move provider model registries, stream wrappers, OAuth helpers, and LLM utilities into src/llm with plugin-sdk barrels instead of depending on the old embedded runtime layout. * refactor: remove pi runtime internals Rename remaining Pi-shaped agent surfaces to OpenClaw agent runtime names, delete obsolete Pi docs and package graph checks, and add the third-party notice for incorporated code. * refactor: tighten agent session runtime Make agent-core/runtime dependencies explicit, consolidate compaction and session transcript helpers, and move model/session helpers behind OpenClaw-owned contracts. * refactor: remove static model and pi auth paths Drop static model catalogs and Pi auth bridges, move model/provider facts to manifest-owned runtime contracts, and harden internal embedded-agent utilities. * refactor: remove legacy provider compat paths * docs: remove agent parity notes * fix: skip provider wildcard metadata parsing * refactor: share session extension sdk loading * refactor: inline acpx proxy error formatter * refactor: fold edit recovery into edit tool * fix: accept extension batch separator * test: align startup provider plugin expectations * fix: restore provider-scoped release discovery * test: align static asset packaging expectations * fix: run static provider catalogs during scoped discovery * fix: add provider entry catalogs for scoped live discovery * fix: load lightweight provider catalog entries * fix: refresh provider-scoped plugin metadata * fix: keep provider catalog entries on release live path * fix: keep static manifest models in release live checks * fix: harden release model discovery * fix: reduce OpenAI live cache probe reasoning * fix: disable OpenAI cache probe reasoning * ci: extend OpenAI gateway live timeout * fix: extend live gateway model budget * fix: stabilize release validation regressions * fix: honor provider aliases in model rows * fix: stabilize release validation lanes * fix: stabilize release memory qa * ci: stabilize release validation lanes * ci: prefer ipv4 for live docker node calls * fix: restore shared tool-call stream wrapper * ci: remove legacy pi test shard alias * fix: clean up embedded agent test drift * fix: stabilize runtime alias status * fix: clean up embedded agent ci drift * fix: restore release ci invariants * fix: clean up post-rebase runtime drift * fix: restore release ci checks * fix: restore release ci after rebase * fix: remove stale pi runtime path * test: align compaction runtime expectations * test: update plugin prerelease expectations * fix: handle claude live tool approvals * fix: stabilize release validation gates * fix: finish agent runtime import * test: finish post-rebase agent runtime mocks * fix: keep codex compaction native * fix: stabilize codex app-server hook tests * test: isolate codex diagnostic active run * test: remove codex diagnostic completion race # Conflicts: # extensions/codex/src/app-server/run-attempt.test.ts * ci: fix full release manifest performance run id * refactor: narrow llm plugin sdk boundary * chore: drop generated google boundary stamps * fix: repair rebase fallout * fix: clean up rebased runtime references * fix: decode codex jwt payloads as base64url * fix: preserve shipped pi runtime alias * fix: add scoped sdk virtual modules * fix: decode llm codex oauth jwt as base64url * fix: avoid stale vertex adc negative cache * fix: harden tool arg decoding and codeql path * fix: keep vertex adc negative checks live * refactor: consolidate codex jwt and edit helpers * fix: await codex oauth node runtime imports * fix: preserve sdk tool and notice contracts * fix: preserve shipped compat config boundaries * fix: align codex oauth callback host * fix: terminate agent-core loop streams on failure * fix: keep codex oauth callback alive during fallback * ci: include session tools in critical codeql scans * fix: keep Cloudflare Anthropic provider auth header * docs: redirect legacy pi runtime pages * fix: honor bundled web provider compat discovery * fix: protect session output spill files * fix: keep legacy agent dir env blocked * fix: contain auto-discovered skill symlinks * fix: harden agent core sdk proxy surfaces * fix: restore approval reaction sdk compat * fix: keep live docker runs bounded * fix: keep codex oauth redirect host aligned * fix: resolve post-rebase agent runtime drift * fix: redact anthropic oauth parse failures * fix: preserve responses strict tool shaping * fix: repair agent runtime rebase cleanup * docs: redirect retired parity pages * fix: bound auto-discovered resources to roots * fix: repair post-rebase agent test drift * fix: preserve bundled provider allowlist migration * fix: preserve manifest-owned provider aliases * fix: declare photon image dependency * fix: keep provider headers out of proxy body * fix: preserve shipped env aliases * fix: refresh control ui i18n generated state * fix: quote read fallback paths * fix: preview edits through configured backend * test: satisfy core test typecheck * fix: preserve ZAI usage auth fallback * test: repair codex diagnostic test * fix: repair agent runtime rebase drift * test: finish embedded runner import rename * fix: repair agent runtime rebase integrations * test: align compaction oauth fallback expectations * fix: allow sdk-auth session models * fix: update doctor tool schema import * fix: preserve bedrock plugin region * fix: stream harmony-like prose immediately * ci: include session runtime in codeql shards * fix: repair latest rebase integrations * fix: honor explicit codex websocket transport * fix: keep openai-compatible credentials provider-scoped * fix: refresh sdk api baseline after rebase * fix: route cli runtime aliases through openclaw harness * test: rename stale harness mock expectation * test: rename embedded agent overflow calls * test: clean embedded auth test wording * test: use openclaw stream types in deepinfra cache test * fix: refresh sdk api baseline on latest main * fix: honor bundled discovery compat allowlists * fix: refresh sdk api baseline after latest rebase * fix: remove stale rebase imports * test: rename stale model catalog mock * test: mock renamed doctor runtime modules * fix: map canonical kimi env auth * fix: use internal model registry in bench script * fix: migrate deepinfra provider catalog entry * fix: enforce builtin tool suppression * fix: route compaction auth and proxy payloads safely * refactor: prune unused llm registry leftovers * test: update codex hooks session import * test: fix model picker ci coverage * test: align model picker auth mock types
348 lines
12 KiB
TypeScript
348 lines
12 KiB
TypeScript
import {
|
|
isRecord,
|
|
normalizeOptionalString as readString,
|
|
} from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
import type {
|
|
RuntimeId,
|
|
RuntimeParityCell,
|
|
RuntimeParityDrift,
|
|
RuntimeParityResult,
|
|
} from "./runtime-parity.js";
|
|
import {
|
|
readScenarioRuntimeToolCoverageMetadata,
|
|
type QaRuntimeCapabilityLayer,
|
|
type QaRuntimeToolBucket,
|
|
type QaRuntimeToolExpectedLayer,
|
|
} from "./runtime-tool-metadata.js";
|
|
import type { QaSeedScenarioWithSource } from "./scenario-catalog.js";
|
|
|
|
type QaToolCoverageSuiteScenario = {
|
|
name: string;
|
|
status: "pass" | "fail";
|
|
runtimeParity?: RuntimeParityResult;
|
|
};
|
|
|
|
export type QaToolCoverageSuiteSummary = {
|
|
scenarios: QaToolCoverageSuiteScenario[];
|
|
run?: {
|
|
runtimePair?: [RuntimeId, RuntimeId] | null;
|
|
};
|
|
};
|
|
|
|
export type QaToolCoverageStatus = "pass" | "fail" | "missing" | "not-run";
|
|
export type QaToolCoverageDrift = RuntimeParityDrift | "not-run";
|
|
export type QaToolCoverageBucket = QaRuntimeToolBucket;
|
|
|
|
export type QaToolCoverageRow = {
|
|
tool: string;
|
|
runtimeToolName?: string;
|
|
bucket: QaToolCoverageBucket;
|
|
expectedLayer: QaRuntimeToolExpectedLayer;
|
|
capabilityLayer: QaRuntimeCapabilityLayer;
|
|
required: boolean;
|
|
fixtureCount: number;
|
|
scenarios: string[];
|
|
sourcePaths: string[];
|
|
openclaw: QaToolCoverageStatus;
|
|
codex: QaToolCoverageStatus;
|
|
drift: QaToolCoverageDrift;
|
|
openclawToolCalls: number;
|
|
codexToolCalls: number;
|
|
tracking?: string;
|
|
codexDefaultImpact?: string;
|
|
qaImpact?: string;
|
|
action?: string;
|
|
details?: string;
|
|
};
|
|
|
|
export type QaToolCoverageReport = {
|
|
runtimePair: [RuntimeId, RuntimeId];
|
|
generatedAt: string;
|
|
evaluated: boolean;
|
|
totalTools: number;
|
|
requiredTools: number;
|
|
reportOnlyTools: number;
|
|
trackedTools: number;
|
|
nativeWorkspaceTools: number;
|
|
dynamicIntegrationTools: number;
|
|
searchableDynamicTools: number;
|
|
optionalTools: number;
|
|
passingTools: number;
|
|
failingTools: number;
|
|
rows: QaToolCoverageRow[];
|
|
pass: boolean;
|
|
failures: string[];
|
|
};
|
|
|
|
type ToolFixtureGroup = {
|
|
tool: string;
|
|
scenarios: QaSeedScenarioWithSource[];
|
|
};
|
|
|
|
const PASSING_DRIFTS: ReadonlySet<QaToolCoverageDrift> = new Set(["none", "text-only"]);
|
|
|
|
function normalizeRuntimePair(
|
|
pair: [RuntimeId, RuntimeId] | null | undefined,
|
|
): [RuntimeId, RuntimeId] {
|
|
if (pair?.[0] && pair?.[1]) {
|
|
return pair;
|
|
}
|
|
return ["openclaw", "codex"];
|
|
}
|
|
|
|
function cellStatus(cell: RuntimeParityCell | undefined): QaToolCoverageStatus {
|
|
if (!cell) {
|
|
return "missing";
|
|
}
|
|
return cell.runtimeErrorClass || cell.transportErrorClass ? "fail" : "pass";
|
|
}
|
|
|
|
function toolIdsForScenario(scenario: QaSeedScenarioWithSource): string[] {
|
|
const coverageIds = [
|
|
...(scenario.coverage?.primary ?? []),
|
|
...(scenario.coverage?.secondary ?? []),
|
|
];
|
|
return [
|
|
...new Set(
|
|
coverageIds
|
|
.filter((coverageId) => coverageId.startsWith("tools."))
|
|
.map((coverageId) => coverageId.slice("tools.".length)),
|
|
),
|
|
].toSorted((left, right) => left.localeCompare(right));
|
|
}
|
|
|
|
function groupToolFixtures(scenarios: readonly QaSeedScenarioWithSource[]): ToolFixtureGroup[] {
|
|
const byTool = new Map<string, QaSeedScenarioWithSource[]>();
|
|
for (const scenario of scenarios) {
|
|
if (!scenario.sourcePath.startsWith("qa/scenarios/runtime/tools/")) {
|
|
continue;
|
|
}
|
|
for (const tool of toolIdsForScenario(scenario)) {
|
|
const entries = byTool.get(tool) ?? [];
|
|
entries.push(scenario);
|
|
byTool.set(tool, entries);
|
|
}
|
|
}
|
|
return [...byTool.entries()]
|
|
.map(([tool, groupedScenarios]) => ({
|
|
tool,
|
|
scenarios: groupedScenarios.toSorted((left, right) => left.id.localeCompare(right.id)),
|
|
}))
|
|
.toSorted((left, right) => left.tool.localeCompare(right.tool));
|
|
}
|
|
|
|
function readScenarioTracking(scenario: QaSeedScenarioWithSource): string | undefined {
|
|
const metadata = readScenarioRuntimeToolCoverageMetadata(scenario);
|
|
const config = scenario.execution.config;
|
|
const knownBroken = isRecord(config?.knownBroken) ? config.knownBroken : undefined;
|
|
const knownHarnessGap = isRecord(config?.knownHarnessGap) ? config.knownHarnessGap : undefined;
|
|
const issue =
|
|
metadata.tracking ?? readString(knownHarnessGap?.issue) ?? readString(knownBroken?.issue);
|
|
const reason =
|
|
metadata.reason ?? readString(knownHarnessGap?.reason) ?? readString(knownBroken?.reason);
|
|
if (issue && reason) {
|
|
return `${issue} ${reason}`;
|
|
}
|
|
return issue;
|
|
}
|
|
|
|
function readScenarioRuntimeToolName(scenario: QaSeedScenarioWithSource): string | undefined {
|
|
const config = scenario.execution.config;
|
|
const toolCoverage = isRecord(config?.toolCoverage) ? config.toolCoverage : undefined;
|
|
return readString(toolCoverage?.actualTool) ?? readString(config?.toolName);
|
|
}
|
|
|
|
function summaryByScenarioId(
|
|
summary: QaToolCoverageSuiteSummary | undefined,
|
|
): Map<string, RuntimeParityResult> {
|
|
const byScenarioId = new Map<string, RuntimeParityResult>();
|
|
for (const scenario of summary?.scenarios ?? []) {
|
|
if (scenario.runtimeParity) {
|
|
byScenarioId.set(scenario.runtimeParity.scenarioId, scenario.runtimeParity);
|
|
}
|
|
}
|
|
return byScenarioId;
|
|
}
|
|
|
|
function mergeScenarioResults(
|
|
scenarios: readonly QaSeedScenarioWithSource[],
|
|
results: ReadonlyMap<string, RuntimeParityResult>,
|
|
) {
|
|
const scenarioResults = scenarios
|
|
.map((scenario) => results.get(scenario.id))
|
|
.filter((result): result is RuntimeParityResult => Boolean(result));
|
|
if (scenarioResults.length === 0) {
|
|
return undefined;
|
|
}
|
|
const failingResult =
|
|
scenarioResults.find((result) => !PASSING_DRIFTS.has(result.drift)) ?? scenarioResults[0];
|
|
return failingResult;
|
|
}
|
|
|
|
function isPassingToolCoverageDrift(drift: QaToolCoverageDrift, evaluated: boolean) {
|
|
return PASSING_DRIFTS.has(drift) || (!evaluated && drift === "not-run");
|
|
}
|
|
|
|
function countRuntimeToolCalls(
|
|
result: RuntimeParityResult | undefined,
|
|
runtime: RuntimeId,
|
|
toolName: string | undefined,
|
|
) {
|
|
if (!result || !toolName) {
|
|
return 0;
|
|
}
|
|
const cell = runtime === "openclaw" ? result.cells.openclaw : result.cells.codex;
|
|
return cell.toolCalls.filter((call) => call.tool === toolName).length;
|
|
}
|
|
|
|
function buildRow(params: {
|
|
group: ToolFixtureGroup;
|
|
results: ReadonlyMap<string, RuntimeParityResult>;
|
|
}): QaToolCoverageRow {
|
|
const result = mergeScenarioResults(params.group.scenarios, params.results);
|
|
const tracking = params.group.scenarios.map(readScenarioTracking).find(Boolean);
|
|
const metadata = params.group.scenarios
|
|
.map(readScenarioRuntimeToolCoverageMetadata)
|
|
.find((entry) => entry.required);
|
|
const fallbackMetadata = readScenarioRuntimeToolCoverageMetadata(params.group.scenarios[0]);
|
|
const rowMetadata = metadata ?? fallbackMetadata;
|
|
const runtimeToolName = params.group.scenarios.map(readScenarioRuntimeToolName).find(Boolean);
|
|
return {
|
|
tool: params.group.tool,
|
|
...(runtimeToolName ? { runtimeToolName } : {}),
|
|
bucket: rowMetadata.bucket,
|
|
expectedLayer: rowMetadata.expectedLayer,
|
|
capabilityLayer: rowMetadata.capabilityLayer,
|
|
required: rowMetadata.required,
|
|
fixtureCount: params.group.scenarios.length,
|
|
scenarios: params.group.scenarios.map((scenario) => scenario.id),
|
|
sourcePaths: params.group.scenarios.map((scenario) => scenario.sourcePath),
|
|
openclaw: result ? cellStatus(result.cells.openclaw) : "not-run",
|
|
codex: result ? cellStatus(result.cells.codex) : "not-run",
|
|
drift: result?.drift ?? "not-run",
|
|
openclawToolCalls: countRuntimeToolCalls(result, "openclaw", runtimeToolName),
|
|
codexToolCalls: countRuntimeToolCalls(result, "codex", runtimeToolName),
|
|
...(tracking ? { tracking } : {}),
|
|
...(rowMetadata.codexDefaultImpact
|
|
? { codexDefaultImpact: rowMetadata.codexDefaultImpact }
|
|
: {}),
|
|
...(rowMetadata.qaImpact ? { qaImpact: rowMetadata.qaImpact } : {}),
|
|
...(rowMetadata.action ? { action: rowMetadata.action } : {}),
|
|
...(result?.driftDetails ? { details: result.driftDetails } : {}),
|
|
};
|
|
}
|
|
|
|
function coverageFailureForRow(row: QaToolCoverageRow): string | undefined {
|
|
if (!row.required || row.tracking) {
|
|
return undefined;
|
|
}
|
|
if (row.drift === "not-run") {
|
|
return `${row.tool} drift=not-run`;
|
|
}
|
|
if (row.openclaw !== "pass" || row.codex !== "pass") {
|
|
return `${row.tool} status openclaw=${row.openclaw} codex=${row.codex}`;
|
|
}
|
|
if (row.drift === "failure-mode") {
|
|
return `${row.tool} drift=failure-mode${row.details ? ` (${row.details})` : ""}`;
|
|
}
|
|
if (row.runtimeToolName && row.openclawToolCalls === 0) {
|
|
return `${row.tool} missing openclaw tool call ${row.runtimeToolName}`;
|
|
}
|
|
if (row.runtimeToolName && row.codexToolCalls === 0) {
|
|
return `${row.tool} missing codex tool call ${row.runtimeToolName}`;
|
|
}
|
|
return undefined;
|
|
}
|
|
|
|
export function buildQaToolCoverageReport(params: {
|
|
scenarios: readonly QaSeedScenarioWithSource[];
|
|
summary?: QaToolCoverageSuiteSummary;
|
|
runtimePair?: [RuntimeId, RuntimeId];
|
|
generatedAt?: string;
|
|
}): QaToolCoverageReport {
|
|
const results = summaryByScenarioId(params.summary);
|
|
const rows = groupToolFixtures(params.scenarios).map((group) =>
|
|
buildRow({
|
|
group,
|
|
results,
|
|
}),
|
|
);
|
|
const evaluated = Boolean(params.summary);
|
|
const failures = evaluated
|
|
? rows.map(coverageFailureForRow).filter((failure): failure is string => Boolean(failure))
|
|
: [];
|
|
return {
|
|
runtimePair: normalizeRuntimePair(params.runtimePair ?? params.summary?.run?.runtimePair),
|
|
generatedAt: params.generatedAt ?? new Date().toISOString(),
|
|
evaluated,
|
|
totalTools: rows.length,
|
|
requiredTools: rows.filter((row) => row.required).length,
|
|
reportOnlyTools: rows.filter((row) => !row.required || Boolean(row.tracking)).length,
|
|
trackedTools: rows.filter((row) => Boolean(row.tracking)).length,
|
|
nativeWorkspaceTools: rows.filter((row) => row.bucket === "codex-native-workspace").length,
|
|
dynamicIntegrationTools: rows.filter((row) => row.bucket === "openclaw-dynamic-integration")
|
|
.length,
|
|
searchableDynamicTools: rows.filter(
|
|
(row) => row.capabilityLayer === "openclaw-dynamic-searchable",
|
|
).length,
|
|
optionalTools: rows.filter((row) => row.bucket === "optional-profile-or-plugin").length,
|
|
passingTools: evaluated
|
|
? rows.filter(
|
|
(row) =>
|
|
row.required &&
|
|
!row.tracking &&
|
|
row.openclaw === "pass" &&
|
|
row.codex === "pass" &&
|
|
(isPassingToolCoverageDrift(row.drift, true) || !coverageFailureForRow(row)),
|
|
).length
|
|
: 0,
|
|
failingTools: failures.length,
|
|
rows,
|
|
pass: failures.length === 0,
|
|
failures,
|
|
};
|
|
}
|
|
|
|
export function renderQaToolCoverageMarkdownReport(report: QaToolCoverageReport): string {
|
|
const lines = [
|
|
`# OpenClaw Runtime Tool Coverage — ${report.runtimePair[0]} vs ${report.runtimePair[1]}`,
|
|
"",
|
|
`- Generated at: ${report.generatedAt}`,
|
|
`- Mode: ${report.evaluated ? "runtime summary" : "catalog inventory"}`,
|
|
`- Tools: ${report.totalTools}`,
|
|
`- Required tools: ${report.requiredTools}`,
|
|
`- Report-only tools: ${report.reportOnlyTools}`,
|
|
`- Tracked issue rows: ${report.trackedTools}`,
|
|
`- Codex-native workspace tools: ${report.nativeWorkspaceTools}`,
|
|
`- OpenClaw dynamic integration tools: ${report.dynamicIntegrationTools}`,
|
|
`- Searchable/deferred dynamic tools: ${report.searchableDynamicTools}`,
|
|
`- Optional/profile/plugin-dependent tools: ${report.optionalTools}`,
|
|
`- Passing tools: ${report.passingTools}`,
|
|
`- Failing tools: ${report.failingTools}`,
|
|
`- Verdict: ${report.pass ? "pass" : "fail"}`,
|
|
"",
|
|
"| Tool | Bucket | Expected layer | Capability layer | Required | Fixtures | OpenClaw | Codex | Drift | Codex default impact | QA impact | Action | Tracking |",
|
|
"| --- | --- | --- | --- | --- | ---: | --- | --- | --- | --- | --- | --- | --- |",
|
|
];
|
|
|
|
for (const row of report.rows) {
|
|
lines.push(
|
|
`| ${row.tool} | ${row.bucket} | ${row.expectedLayer} | ${row.capabilityLayer} | ${row.required ? "yes" : "no"} | ${row.fixtureCount} | ${row.openclaw} | ${row.codex} | ${row.drift} | ${row.codexDefaultImpact ?? ""} | ${row.qaImpact ?? ""} | ${row.action ?? ""} | ${row.tracking ?? ""} |`,
|
|
);
|
|
}
|
|
|
|
if (report.failures.length > 0) {
|
|
lines.push("", "## Gate Failures", "");
|
|
for (const failure of report.failures) {
|
|
lines.push(`- ${failure}`);
|
|
}
|
|
}
|
|
|
|
lines.push("", "## Fixture Sources", "");
|
|
for (const row of report.rows) {
|
|
lines.push(`- ${row.tool}: ${row.scenarios.join(", ")}`);
|
|
}
|
|
|
|
return `${lines.join("\n").trimEnd()}\n`;
|
|
}
|