ARCH: прикрепить debug MCP discovery
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
} from "./assistantAddressTurnFinalizeRuntimeAdapter";
|
||||
import { applyAssistantCapabilityBindingResponseGuard } from "./assistantCapabilityBindingResponseGuard";
|
||||
import { attachAssistantCapabilityRuntimeBinding } from "./assistantCapabilityRuntimeBindingAdapter";
|
||||
import { attachAssistantMcpDiscoveryDebug } from "./assistantMcpDiscoveryDebugAttachment";
|
||||
import { attachAssistantRuntimeContractShadow } from "./assistantRuntimeContractResolver";
|
||||
import { attachAssistantStateTransition } from "./assistantStateTransitionRuntimeAdapter";
|
||||
import { attachAssistantTruthAnswerPolicy } from "./assistantTruthAnswerPolicyRuntimeAdapter";
|
||||
@@ -267,13 +268,16 @@ export function runAssistantAddressLaneResponseRuntime<ResponseType = AssistantM
|
||||
addressRuntimeMeta: input.llmPreDecomposeMeta,
|
||||
replyType: normalizeAddressReplyType(input.addressLane.reply_type)
|
||||
});
|
||||
const debugWithMcpDiscovery = attachAssistantMcpDiscoveryDebug(debugWithCapabilityBinding, {
|
||||
addressRuntimeMeta: input.llmPreDecomposeMeta
|
||||
});
|
||||
const guardedResponse = applyAssistantCapabilityBindingResponseGuard({
|
||||
assistantReply: safeAddressReply,
|
||||
replyType: normalizeAddressReplyType(input.addressLane.reply_type),
|
||||
capabilityBinding: debugWithCapabilityBinding.assistant_capability_binding_v1
|
||||
capabilityBinding: debugWithMcpDiscovery.assistant_capability_binding_v1
|
||||
});
|
||||
const debugWithResponseGuard = {
|
||||
...debugWithCapabilityBinding,
|
||||
...debugWithMcpDiscovery,
|
||||
capability_binding_response_guard: guardedResponse.audit
|
||||
};
|
||||
const finalization = finalizeAddressTurnSafe({
|
||||
|
||||
@@ -24,6 +24,7 @@ import type {
|
||||
TemporalGuardAudit
|
||||
} from "./assistantRuntimeGuards";
|
||||
import { attachAssistantCapabilityRuntimeBinding } from "./assistantCapabilityRuntimeBindingAdapter";
|
||||
import { attachAssistantMcpDiscoveryDebug } from "./assistantMcpDiscoveryDebugAttachment";
|
||||
import { attachAssistantRuntimeContractShadow } from "./assistantRuntimeContractResolver";
|
||||
import { attachAssistantStateTransition } from "./assistantStateTransitionRuntimeAdapter";
|
||||
import { attachAssistantTruthAnswerPolicy } from "./assistantTruthAnswerPolicyRuntimeAdapter";
|
||||
@@ -333,6 +334,7 @@ export function buildDeepAnalysisDebugPayload(input: DeepAnalysisDebugPayloadInp
|
||||
address_llm_predecompose_contract: input.addressRuntimeMetaForDeep?.predecomposeContract ?? null,
|
||||
address_semantic_extraction_contract: input.addressRuntimeMetaForDeep?.semanticExtractionContract ?? null,
|
||||
orchestration_contract_v1: input.addressRuntimeMetaForDeep?.orchestrationContract ?? null,
|
||||
assistant_mcp_discovery_entry_point_v1: input.addressRuntimeMetaForDeep?.mcpDiscoveryRuntimeEntryPoint ?? null,
|
||||
assistant_outcome_class_v1: input.outcomeClassV1,
|
||||
assistant_orchestration_contracts_v1: input.assistantOrchestrationContractsV1,
|
||||
answer_contract_stage4_v1: answerContractStage4Audit,
|
||||
@@ -356,10 +358,13 @@ export function buildDeepAnalysisDebugPayload(input: DeepAnalysisDebugPayloadInp
|
||||
coverageReport: input.coverageReport as unknown as Record<string, unknown>,
|
||||
replyType: "deep_analysis"
|
||||
});
|
||||
return attachAssistantCapabilityRuntimeBinding(debugWithStateTransition, {
|
||||
const debugWithCapabilityBinding = attachAssistantCapabilityRuntimeBinding(debugWithStateTransition, {
|
||||
addressRuntimeMeta: input.addressRuntimeMetaForDeep as unknown as Record<string, unknown> | null | undefined,
|
||||
groundingStatus: input.groundingCheck.status,
|
||||
coverageReport: input.coverageReport as unknown as Record<string, unknown>,
|
||||
replyType: "deep_analysis"
|
||||
});
|
||||
return attachAssistantMcpDiscoveryDebug(debugWithCapabilityBinding, {
|
||||
addressRuntimeMeta: input.addressRuntimeMetaForDeep as unknown as Record<string, unknown> | null | undefined
|
||||
}) as unknown as AssistantDebugPayload;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
import type { AssistantMcpDiscoveryRuntimeEntryPointContract } from "./assistantMcpDiscoveryRuntimeEntryPoint";
|
||||
|
||||
export interface AssistantMcpDiscoveryDebugAttachmentFields {
|
||||
assistant_mcp_discovery_entry_point_v1: AssistantMcpDiscoveryRuntimeEntryPointContract | null;
|
||||
mcp_discovery_entry_status: string | null;
|
||||
mcp_discovery_attempted: boolean;
|
||||
mcp_discovery_hot_runtime_wired: false;
|
||||
mcp_discovery_bridge_status: string | null;
|
||||
mcp_discovery_answer_mode: string | null;
|
||||
mcp_discovery_business_fact_answer_allowed: boolean;
|
||||
mcp_discovery_user_facing_response_allowed: boolean;
|
||||
mcp_discovery_requires_clarification: boolean;
|
||||
}
|
||||
|
||||
export interface AttachAssistantMcpDiscoveryDebugInput {
|
||||
entryPoint?: unknown;
|
||||
addressRuntimeMeta?: Record<string, unknown> | null;
|
||||
}
|
||||
|
||||
function toRecordObject(value: unknown): Record<string, unknown> | null {
|
||||
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
||||
return null;
|
||||
}
|
||||
return value as Record<string, unknown>;
|
||||
}
|
||||
|
||||
function toNonEmptyString(value: unknown): string | null {
|
||||
if (value === null || value === undefined) {
|
||||
return null;
|
||||
}
|
||||
const text = String(value).trim();
|
||||
return text.length > 0 ? text : null;
|
||||
}
|
||||
|
||||
function isMcpDiscoveryEntryPointContract(value: unknown): value is AssistantMcpDiscoveryRuntimeEntryPointContract {
|
||||
const record = toRecordObject(value);
|
||||
return (
|
||||
record?.schema_version === "assistant_mcp_discovery_runtime_entry_point_v1" &&
|
||||
record?.policy_owner === "assistantMcpDiscoveryRuntimeEntryPoint"
|
||||
);
|
||||
}
|
||||
|
||||
function resolveEntryPoint(input: AttachAssistantMcpDiscoveryDebugInput): AssistantMcpDiscoveryRuntimeEntryPointContract | null {
|
||||
if (isMcpDiscoveryEntryPointContract(input.entryPoint)) {
|
||||
return input.entryPoint;
|
||||
}
|
||||
const runtimeMetaEntryPoint =
|
||||
input.addressRuntimeMeta?.mcpDiscoveryRuntimeEntryPoint ??
|
||||
input.addressRuntimeMeta?.assistantMcpDiscoveryRuntimeEntryPoint ??
|
||||
input.addressRuntimeMeta?.assistant_mcp_discovery_entry_point_v1;
|
||||
return isMcpDiscoveryEntryPointContract(runtimeMetaEntryPoint) ? runtimeMetaEntryPoint : null;
|
||||
}
|
||||
|
||||
export function buildAssistantMcpDiscoveryDebugAttachmentFields(
|
||||
input: AttachAssistantMcpDiscoveryDebugInput
|
||||
): AssistantMcpDiscoveryDebugAttachmentFields {
|
||||
const entryPoint = resolveEntryPoint(input);
|
||||
const bridge = toRecordObject(entryPoint?.bridge);
|
||||
const answerDraft = toRecordObject(bridge?.answer_draft);
|
||||
|
||||
return {
|
||||
assistant_mcp_discovery_entry_point_v1: entryPoint,
|
||||
mcp_discovery_entry_status: toNonEmptyString(entryPoint?.entry_status),
|
||||
mcp_discovery_attempted: Boolean(entryPoint?.discovery_attempted),
|
||||
mcp_discovery_hot_runtime_wired: false,
|
||||
mcp_discovery_bridge_status: toNonEmptyString(bridge?.bridge_status),
|
||||
mcp_discovery_answer_mode: toNonEmptyString(answerDraft?.answer_mode),
|
||||
mcp_discovery_business_fact_answer_allowed: bridge?.business_fact_answer_allowed === true,
|
||||
mcp_discovery_user_facing_response_allowed: bridge?.user_facing_response_allowed === true,
|
||||
mcp_discovery_requires_clarification: bridge?.requires_user_clarification === true
|
||||
};
|
||||
}
|
||||
|
||||
export function attachAssistantMcpDiscoveryDebug<T extends Record<string, unknown>>(
|
||||
debugPayload: T,
|
||||
input: AttachAssistantMcpDiscoveryDebugInput
|
||||
): T & AssistantMcpDiscoveryDebugAttachmentFields {
|
||||
return {
|
||||
...debugPayload,
|
||||
...buildAssistantMcpDiscoveryDebugAttachmentFields(input)
|
||||
};
|
||||
}
|
||||
@@ -86,6 +86,7 @@ export interface AssistantAddressRuntimeMetaForDeep {
|
||||
predecomposeContract?: Record<string, unknown> | null;
|
||||
semanticExtractionContract?: Record<string, unknown> | null;
|
||||
orchestrationContract?: Record<string, unknown> | null;
|
||||
mcpDiscoveryRuntimeEntryPoint?: Record<string, unknown> | null;
|
||||
}
|
||||
|
||||
export interface AssistantRequirement {
|
||||
|
||||
Reference in New Issue
Block a user