Files
reverse-engineering-anything/src/application/EnhancedToolTypes.ts
T
morlutoandCursor Agent f1622fc8b4 feat(native): page retained feature traces (#8585)
* feat(native): page retained feature traces

* fix(snapshot): retain linked source evidence for replay

* test(snapshot): verify linked foreign evidence stays scoped

* docs(mcp): clarify imported residual questions

* docs(mcp): guide trace reference classification

* fix(cli): report result sources when Evidence publication fails

A trace keeps linked sources on the result. Use those records for the
undelivered source closure as well as the bundle, so a refused output
does not report them as not captured.

* ci: rerun pull request checks

The merge of origin/main did not start the CI workflow for this head.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-11-05 03:26:31 +08:00

48 lines
1.7 KiB
TypeScript

import type { z } from "zod";
import { analysisInputErrorFromIssues } from "../domain/inputIssueProjection.js";
import type { AnalysisError } from "../domain/analysisErrorBase.js";
import type { JsonValue } from "../domain/jsonValue.js";
import type { LiteralFeatureReference } from "../domain/native/literalFeatureTrace.js";
import { err, type Result } from "../domain/result.js";
import {
enhancedInputSchemas,
type EnhancedToolName,
} from "../contracts/enhancedInputs.js";
/** A failure that stopped a workflow after it admitted part of its result. */
export interface PartialEnhancedFailure {
readonly ok: false;
readonly error: AnalysisError;
/** The workflow's own result shape, holding only work admitted before the stop. */
readonly partialResult: JsonValue;
}
export type EnhancedOutcome =
| Result<JsonValue, AnalysisError>
| PartialEnhancedFailure;
export type EnhancedResult = Promise<EnhancedOutcome>;
/** Keep the stopping failure primary while retaining the admitted result. */
export const failedWithPartialResult = (
error: AnalysisError,
partialResult: JsonValue,
): PartialEnhancedFailure => ({ ok: false, error, partialResult });
export type TraceReference = LiteralFeatureReference;
/** One enhanced call whose input was parsed at its owning adapter boundary. */
export type ValidatedEnhancedCall = {
[Name in EnhancedToolName]: {
readonly name: Name;
readonly input: z.output<(typeof enhancedInputSchemas)[Name]>;
};
}[EnhancedToolName];
export const invalidEnhancedInput = (
name: EnhancedToolName,
cause: z.ZodError,
input: unknown,
): EnhancedResult =>
Promise.resolve(
err(analysisInputErrorFromIssues(name, cause.issues, input, { cause })),
);