mirror of
https://github.com/morluto/rea.git
synced 2026-10-22 05:42:31 -05:00
feat(javascript): return a retained summary view on request (#1568)
analyze_javascript_application returns the complete application graph inline, which repeats tens of kilobytes even for a few source lines and exceeds the default 10 MiB MCP frame for a 300-function source file. The new optional detail input keeps complete delivery by default. With detail "summary" the server records the complete analysis Evidence in the session and returns its inspect_analysis_view summary, whose parent_evidence_id lets callers page modules, select items, or pass the retained reference to application workflows. A server without Evidence retention refuses summary detail with capability_unavailable rather than returning a summary whose analysis cannot be reached. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
649661dc8b
commit
c19e15a2b3
9 files changed
+279
-7
No files matched your search
@@ -3,7 +3,9 @@ import { z } from "zod";
|
||||
import { ANALYSIS_VIEW_PROVIDER } from "../InvestigationProviders.js";
|
||||
import type { EvidenceLookup } from "../EvidenceInputResolver.js";
|
||||
import { resolveEvidenceInput } from "../EvidenceInputResolver.js";
|
||||
import type { EvidenceWriter } from "../investigation/InvestigationRecordPort.js";
|
||||
import type { AnalysisError } from "../../domain/analysisErrorBase.js";
|
||||
import { AnalysisCapabilityUnavailableError } from "../../domain/analysisErrorCore.js";
|
||||
import { analysisInputErrorFromIssues } from "../../domain/inputIssueProjection.js";
|
||||
import { EvidenceIntegrityError } from "../../domain/evidenceErrors.js";
|
||||
import {
|
||||
@@ -76,6 +78,47 @@ export const inspectAnalysisViewValidated = (
|
||||
return ok(createAnalysisViewEvidence(input, parent, projected.value));
|
||||
};
|
||||
|
||||
/** Session Evidence ownership required to deliver a view instead of a complete record. */
|
||||
export interface AnalysisViewRetention {
|
||||
readonly evidenceById: EvidenceLookup | undefined;
|
||||
readonly recordEvidence: EvidenceWriter["recordEvidence"] | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retain complete analysis Evidence in the session, then project its summary
|
||||
* view from the retained record. Callers page or select the rest through
|
||||
* inspect_analysis_view with the view's parent Evidence ID.
|
||||
*/
|
||||
export const summarizeRetainedAnalysis = (
|
||||
evidence: Evidence,
|
||||
retention: AnalysisViewRetention,
|
||||
): Result<Evidence, AnalysisError> => {
|
||||
if (
|
||||
retention.recordEvidence === undefined ||
|
||||
retention.evidenceById === undefined
|
||||
)
|
||||
return err(
|
||||
new AnalysisCapabilityUnavailableError(
|
||||
ANALYSIS_VIEW_PROVIDER.id,
|
||||
evidence.operation,
|
||||
"summary detail requires a server session that retains Evidence for later views",
|
||||
{
|
||||
userMessage:
|
||||
"This server does not retain Evidence. Select detail complete to receive the complete analysis inline.",
|
||||
},
|
||||
),
|
||||
);
|
||||
const recorded = retention.recordEvidence(evidence);
|
||||
if (!recorded.ok) return recorded;
|
||||
return inspectAnalysisViewValidated(
|
||||
{
|
||||
source: { kind: "retained-evidence", evidence_id: evidence.evidence_id },
|
||||
view: { kind: "summary" },
|
||||
},
|
||||
retention.evidenceById,
|
||||
);
|
||||
};
|
||||
|
||||
const resolveAnalysisViewSource = (
|
||||
source: InspectAnalysisViewInput["source"],
|
||||
lookup: EvidenceLookup | undefined,
|
||||
|
||||
Reference in new issue
Block a user