* refactor(config): parse capability settings into exact states * refactor(runtime): encode replay and process outcomes exactly * refactor: make analysis states unrepresentable * refactor(mcp): register canonical schemas with SDK * fix: preserve capability and catalog invariants * fix(build): remove stale compiled modules * fix(replay): update real verifier policy dependency * fix(package): verify the complete MCP catalog * fix(test): supply complete replay reload policy * refactor(contracts): centralize output schema lookup * refactor(mcp): delegate protocol boundaries to SDK * fix(browser): approve real source capture * fix(mcp): preserve catalog guidance
49 lines
1.8 KiB
TypeScript
49 lines
1.8 KiB
TypeScript
import type { HopperDiagnosticType } from "../domain/errors.js";
|
|
import type { ProcessCleanupResult } from "../process/ProcessOwnership.js";
|
|
import type {
|
|
ProviderProcessLaunch,
|
|
ProviderProcessStopResult,
|
|
} from "../process/ProviderProcess.js";
|
|
|
|
/** Sanitized Hopper launcher and owned-shutdown telemetry. */
|
|
export type HopperDiagnostic =
|
|
| { readonly type: "launcher-stderr"; readonly bytes: number }
|
|
| { readonly type: "launcher-exit"; readonly code: number | null }
|
|
| {
|
|
readonly type: "bridge-diagnostic";
|
|
readonly request_id: number;
|
|
readonly code: number;
|
|
readonly category: HopperDiagnosticType;
|
|
readonly message: string;
|
|
}
|
|
| {
|
|
readonly type: "owned-shutdown";
|
|
readonly status: ProviderProcessStopResult["status"];
|
|
readonly launcher_pid: number | null;
|
|
readonly process_group_id: number | null;
|
|
readonly cleanup_signaled: boolean | null;
|
|
readonly reason: string | null;
|
|
};
|
|
|
|
/** Retain actionable ownership coordinates without exposing the run token. */
|
|
export const createOwnedHopperShutdownDiagnostic = (
|
|
launch: ProviderProcessLaunch,
|
|
stopped: ProviderProcessStopResult,
|
|
cleanup: ProcessCleanupResult | undefined,
|
|
): Extract<HopperDiagnostic, { readonly type: "owned-shutdown" }> => ({
|
|
type: "owned-shutdown",
|
|
status: stopped.status,
|
|
launcher_pid: launch.ownership?.leaderPid ?? launch.process.pid ?? null,
|
|
process_group_id: launch.ownership?.processGroupId ?? null,
|
|
cleanup_signaled: cleanup?.cleaned === true ? cleanup.signaled : null,
|
|
reason: stopped.status === "incomplete" ? stopped.reason : null,
|
|
});
|
|
|
|
/** Convert an unexpected cleanup rejection without exposing a stack or token. */
|
|
export const providerCleanupFailure = (
|
|
_cause: unknown,
|
|
): ProcessCleanupResult => ({
|
|
cleaned: false,
|
|
reason: "owned provider cleanup failed",
|
|
});
|