@gracker/smartperfetto 1.0.15 → 1.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/agents/base/baseAgent.d.ts.map +1 -1
- package/dist/agent/agents/base/baseAgent.js +5 -1
- package/dist/agent/agents/base/baseAgent.js.map +1 -1
- package/dist/agent/context/enhancedSessionContext.d.ts +5 -0
- package/dist/agent/context/enhancedSessionContext.d.ts.map +1 -1
- package/dist/agent/context/enhancedSessionContext.js +13 -0
- package/dist/agent/context/enhancedSessionContext.js.map +1 -1
- package/dist/agent/core/conclusionContract.d.ts +23 -1
- package/dist/agent/core/conclusionContract.d.ts.map +1 -1
- package/dist/agent/core/conclusionGenerator.d.ts.map +1 -1
- package/dist/agent/core/conclusionGenerator.js +223 -27
- package/dist/agent/core/conclusionGenerator.js.map +1 -1
- package/dist/agent/core/executors/directSkillExecutor.d.ts.map +1 -1
- package/dist/agent/core/executors/directSkillExecutor.js +6 -12
- package/dist/agent/core/executors/directSkillExecutor.js.map +1 -1
- package/dist/agent/core/orchestratorTypes.d.ts +6 -0
- package/dist/agent/core/orchestratorTypes.d.ts.map +1 -1
- package/dist/agent/core/orchestratorTypes.js.map +1 -1
- package/dist/agent/experts/crossDomain/moduleExpertInvoker.d.ts.map +1 -1
- package/dist/agent/experts/crossDomain/moduleExpertInvoker.js +4 -1
- package/dist/agent/experts/crossDomain/moduleExpertInvoker.js.map +1 -1
- package/dist/agent/scene/sceneStage1Runner.d.ts +1 -1
- package/dist/agent/scene/sceneStage1Runner.d.ts.map +1 -1
- package/dist/agent/scene/sceneStage1Runner.js +1 -1
- package/dist/agent/scene/sceneStage1Runner.js.map +1 -1
- package/dist/agent/scene/sceneStoryService.d.ts +1 -1
- package/dist/agent/scene/sceneStoryService.d.ts.map +1 -1
- package/dist/agent/scene/sceneStoryService.js +4 -1
- package/dist/agent/scene/sceneStoryService.js.map +1 -1
- package/dist/agent/types/agentProtocol.d.ts.map +1 -1
- package/dist/agent/types/agentProtocol.js +4 -1
- package/dist/agent/types/agentProtocol.js.map +1 -1
- package/dist/agent/types.d.ts +7 -0
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/agentOpenAI/openAiConfig.d.ts +2 -0
- package/dist/agentOpenAI/openAiConfig.d.ts.map +1 -1
- package/dist/agentOpenAI/openAiConfig.js +3 -0
- package/dist/agentOpenAI/openAiConfig.js.map +1 -1
- package/dist/agentOpenAI/openAiRuntime.d.ts +8 -0
- package/dist/agentOpenAI/openAiRuntime.d.ts.map +1 -1
- package/dist/agentOpenAI/openAiRuntime.js +293 -58
- package/dist/agentOpenAI/openAiRuntime.js.map +1 -1
- package/dist/agentRuntime/runtimeHealth.d.ts +1 -0
- package/dist/agentRuntime/runtimeHealth.d.ts.map +1 -1
- package/dist/agentv3/artifactStore.d.ts +5 -0
- package/dist/agentv3/artifactStore.d.ts.map +1 -1
- package/dist/agentv3/artifactStore.js +3 -0
- package/dist/agentv3/artifactStore.js.map +1 -1
- package/dist/agentv3/claudeMcpServer.d.ts.map +1 -1
- package/dist/agentv3/claudeMcpServer.js +125 -86
- package/dist/agentv3/claudeMcpServer.js.map +1 -1
- package/dist/agentv3/claudeRuntime.d.ts.map +1 -1
- package/dist/agentv3/claudeRuntime.js +147 -65
- package/dist/agentv3/claudeRuntime.js.map +1 -1
- package/dist/agentv3/claudeSseBridge.d.ts +6 -0
- package/dist/agentv3/claudeSseBridge.d.ts.map +1 -1
- package/dist/agentv3/claudeSseBridge.js +1 -0
- package/dist/agentv3/claudeSseBridge.js.map +1 -1
- package/dist/agentv3/sessionStateSnapshot.d.ts +23 -0
- package/dist/agentv3/sessionStateSnapshot.d.ts.map +1 -1
- package/dist/assistant/application/agentAnalyzeSessionService.d.ts +6 -0
- package/dist/assistant/application/agentAnalyzeSessionService.d.ts.map +1 -1
- package/dist/assistant/application/agentAnalyzeSessionService.js +9 -3
- package/dist/assistant/application/agentAnalyzeSessionService.js.map +1 -1
- package/dist/assistant/application/assistantApplicationService.d.ts.map +1 -1
- package/dist/assistant/application/assistantApplicationService.js +3 -1
- package/dist/assistant/application/assistantApplicationService.js.map +1 -1
- package/dist/cli-user/commands/report.js +64 -0
- package/dist/cli-user/commands/report.js.map +1 -1
- package/dist/cli-user/io/paths.d.ts +3 -0
- package/dist/cli-user/io/paths.d.ts.map +1 -1
- package/dist/cli-user/io/paths.js +6 -0
- package/dist/cli-user/io/paths.js.map +1 -1
- package/dist/cli-user/io/sessionStore.d.ts +1 -0
- package/dist/cli-user/io/sessionStore.d.ts.map +1 -1
- package/dist/cli-user/io/sessionStore.js +5 -0
- package/dist/cli-user/io/sessionStore.js.map +1 -1
- package/dist/cli-user/repl/renderer.d.ts +8 -0
- package/dist/cli-user/repl/renderer.d.ts.map +1 -1
- package/dist/cli-user/repl/renderer.js.map +1 -1
- package/dist/cli-user/services/cliAnalyzeService.d.ts +3 -0
- package/dist/cli-user/services/cliAnalyzeService.d.ts.map +1 -1
- package/dist/cli-user/services/cliAnalyzeService.js +103 -1
- package/dist/cli-user/services/cliAnalyzeService.js.map +1 -1
- package/dist/cli-user/services/turnPersistence.d.ts +0 -10
- package/dist/cli-user/services/turnPersistence.d.ts.map +1 -1
- package/dist/cli-user/services/turnPersistence.js +62 -0
- package/dist/cli-user/services/turnPersistence.js.map +1 -1
- package/dist/routes/agentReportRoutes.d.ts +1 -0
- package/dist/routes/agentReportRoutes.d.ts.map +1 -1
- package/dist/routes/agentReportRoutes.js +13 -2
- package/dist/routes/agentReportRoutes.js.map +1 -1
- package/dist/routes/agentResumeRoutes.d.ts.map +1 -1
- package/dist/routes/agentResumeRoutes.js +51 -5
- package/dist/routes/agentResumeRoutes.js.map +1 -1
- package/dist/routes/agentRoutes.d.ts.map +1 -1
- package/dist/routes/agentRoutes.js +524 -130
- package/dist/routes/agentRoutes.js.map +1 -1
- package/dist/scripts/verifyAgentSseScrolling.js +142 -2
- package/dist/scripts/verifyAgentSseScrolling.js.map +1 -1
- package/dist/services/agentEventStore.d.ts.map +1 -1
- package/dist/services/agentEventStore.js +13 -3
- package/dist/services/agentEventStore.js.map +1 -1
- package/dist/services/agentReportData.d.ts +3 -0
- package/dist/services/agentReportData.d.ts.map +1 -1
- package/dist/services/agentReportData.js.map +1 -1
- package/dist/services/agentResultNormalizer.d.ts +15 -3
- package/dist/services/agentResultNormalizer.d.ts.map +1 -1
- package/dist/services/agentResultNormalizer.js +344 -6
- package/dist/services/agentResultNormalizer.js.map +1 -1
- package/dist/services/analysisResultSnapshotPipeline.d.ts +3 -0
- package/dist/services/analysisResultSnapshotPipeline.d.ts.map +1 -1
- package/dist/services/analysisResultSnapshotPipeline.js +3 -0
- package/dist/services/analysisResultSnapshotPipeline.js.map +1 -1
- package/dist/services/analysisResultSnapshotStore.d.ts.map +1 -1
- package/dist/services/analysisResultSnapshotStore.js +34 -2
- package/dist/services/analysisResultSnapshotStore.js.map +1 -1
- package/dist/services/enterpriseSchema.d.ts.map +1 -1
- package/dist/services/enterpriseSchema.js +11 -0
- package/dist/services/enterpriseSchema.js.map +1 -1
- package/dist/services/evidence/evidenceContractBuilder.d.ts +11 -0
- package/dist/services/evidence/evidenceContractBuilder.d.ts.map +1 -0
- package/dist/services/evidence/evidenceContractBuilder.js +546 -0
- package/dist/services/evidence/evidenceContractBuilder.js.map +1 -0
- package/dist/services/finalResultQualityGate.d.ts +18 -0
- package/dist/services/finalResultQualityGate.d.ts.map +1 -0
- package/dist/services/finalResultQualityGate.js +283 -0
- package/dist/services/finalResultQualityGate.js.map +1 -0
- package/dist/services/htmlReportGenerator.d.ts +8 -1
- package/dist/services/htmlReportGenerator.d.ts.map +1 -1
- package/dist/services/htmlReportGenerator.js +129 -42
- package/dist/services/htmlReportGenerator.js.map +1 -1
- package/dist/services/persistAgentSession.d.ts +2 -0
- package/dist/services/persistAgentSession.d.ts.map +1 -1
- package/dist/services/persistAgentSession.js +17 -1
- package/dist/services/persistAgentSession.js.map +1 -1
- package/dist/services/processIdentity/identityContractMapper.d.ts +14 -0
- package/dist/services/processIdentity/identityContractMapper.d.ts.map +1 -0
- package/dist/services/processIdentity/identityContractMapper.js +135 -0
- package/dist/services/processIdentity/identityContractMapper.js.map +1 -0
- package/dist/services/processIdentity/types.d.ts +5 -0
- package/dist/services/processIdentity/types.d.ts.map +1 -1
- package/dist/services/processIdentity/types.js.map +1 -1
- package/dist/services/skillEngine/skillExecutor.d.ts +14 -2
- package/dist/services/skillEngine/skillExecutor.d.ts.map +1 -1
- package/dist/services/skillEngine/skillExecutor.js +133 -13
- package/dist/services/skillEngine/skillExecutor.js.map +1 -1
- package/dist/services/skillEngine/types.d.ts +2 -0
- package/dist/services/skillEngine/types.d.ts.map +1 -1
- package/dist/services/verifier/claimVerificationRunner.d.ts +20 -0
- package/dist/services/verifier/claimVerificationRunner.d.ts.map +1 -0
- package/dist/services/verifier/claimVerificationRunner.js +88 -0
- package/dist/services/verifier/claimVerificationRunner.js.map +1 -0
- package/dist/services/verifier/deterministicClaimVerifier.d.ts +8 -0
- package/dist/services/verifier/deterministicClaimVerifier.d.ts.map +1 -0
- package/dist/services/verifier/deterministicClaimVerifier.js +178 -0
- package/dist/services/verifier/deterministicClaimVerifier.js.map +1 -0
- package/dist/types/claimVerification.d.ts +38 -0
- package/dist/types/claimVerification.d.ts.map +1 -0
- package/dist/types/claimVerification.js +6 -0
- package/dist/types/claimVerification.js.map +1 -0
- package/dist/types/dataContract.d.ts +32 -0
- package/dist/types/dataContract.d.ts.map +1 -1
- package/dist/types/dataContract.js +7 -0
- package/dist/types/dataContract.js.map +1 -1
- package/dist/types/evidenceContract.d.ts +100 -0
- package/dist/types/evidenceContract.d.ts.map +1 -0
- package/dist/types/evidenceContract.js +6 -0
- package/dist/types/evidenceContract.js.map +1 -0
- package/dist/types/identityContract.d.ts +57 -0
- package/dist/types/identityContract.d.ts.map +1 -0
- package/dist/types/identityContract.js +6 -0
- package/dist/types/identityContract.js.map +1 -0
- package/dist/types/multiTraceComparison.d.ts +3 -0
- package/dist/types/multiTraceComparison.d.ts.map +1 -1
- package/package.json +3 -2
- package/skills/atomic/process_identity_resolver.skill.yaml +130 -1
- package/skills/atomic/process_slice_cpu_hotspots.skill.yaml +321 -0
- package/skills/atomic/startup_slow_reasons.skill.yaml +102 -17
- package/skills/composite/startup_analysis.skill.yaml +16 -0
- package/strategies/anr.strategy.md +2 -2
- package/strategies/game.strategy.md +1 -1
- package/strategies/general.strategy.md +1 -1
- package/strategies/prompt-openai-final-report-continuation-en.template.md +12 -0
- package/strategies/prompt-openai-final-report-continuation-zh.template.md +12 -0
- package/strategies/prompt-output-format.template.md +1 -1
- package/strategies/scrolling.strategy.md +1 -0
- package/strategies/startup.strategy.md +4 -1
|
@@ -1437,7 +1437,7 @@ function createClaudeMcpServer(options) {
|
|
|
1437
1437
|
if (summary && success && rows.length > 0) {
|
|
1438
1438
|
const summaryResult = (0, sqlSummarizer_1.summarizeSqlResult)(result.columns, result.rows);
|
|
1439
1439
|
if (emitUpdate) {
|
|
1440
|
-
emittedEvidence = emitSqlSummaryDataEnvelope(emitUpdate, summaryResult, finalSql, injected, traceProvenance, producer);
|
|
1440
|
+
emittedEvidence = emitSqlSummaryDataEnvelope(emitUpdate, summaryResult, finalSql, injected, traceProvenance, producer, processIdentityWarning);
|
|
1441
1441
|
}
|
|
1442
1442
|
return {
|
|
1443
1443
|
content: [{
|
|
@@ -1466,10 +1466,10 @@ function createClaudeMcpServer(options) {
|
|
|
1466
1466
|
};
|
|
1467
1467
|
}
|
|
1468
1468
|
if (emitUpdate && success && result.columns.length > 0) {
|
|
1469
|
-
emittedEvidence = emitSqlDataEnvelope(emitUpdate, result.columns, rows, finalSql, injected, traceProvenance, producer);
|
|
1469
|
+
emittedEvidence = emitSqlDataEnvelope(emitUpdate, result.columns, rows, finalSql, injected, traceProvenance, producer, processIdentityWarning);
|
|
1470
1470
|
}
|
|
1471
1471
|
else if (emitUpdate && !success) {
|
|
1472
|
-
emittedEvidence = emitSqlDiagnosticDataEnvelope(emitUpdate, result.error || (0, outputLanguage_1.localize)(outputLanguage, 'SQL 执行失败', 'SQL execution failed'), finalSql, injected, traceProvenance, producer, outputLanguage);
|
|
1472
|
+
emittedEvidence = emitSqlDiagnosticDataEnvelope(emitUpdate, result.error || (0, outputLanguage_1.localize)(outputLanguage, 'SQL 执行失败', 'SQL execution failed'), finalSql, injected, traceProvenance, producer, processIdentityWarning, outputLanguage);
|
|
1473
1473
|
}
|
|
1474
1474
|
return {
|
|
1475
1475
|
content: [{
|
|
@@ -1503,7 +1503,7 @@ function createClaudeMcpServer(options) {
|
|
|
1503
1503
|
traceId,
|
|
1504
1504
|
traceSide: 'current',
|
|
1505
1505
|
});
|
|
1506
|
-
const emittedEvidence = emitUpdate ? emitSqlDiagnosticDataEnvelope(emitUpdate, errMsg, sql, undefined, traceProvenance, producer, outputLanguage) : undefined;
|
|
1506
|
+
const emittedEvidence = emitUpdate ? emitSqlDiagnosticDataEnvelope(emitUpdate, errMsg, sql, undefined, traceProvenance, producer, undefined, outputLanguage) : undefined;
|
|
1507
1507
|
emitUpdate?.({
|
|
1508
1508
|
type: 'progress',
|
|
1509
1509
|
content: {
|
|
@@ -1615,6 +1615,10 @@ function createClaudeMcpServer(options) {
|
|
|
1615
1615
|
try {
|
|
1616
1616
|
const effectiveParams = normalizeSkillParams(params, packageName);
|
|
1617
1617
|
const producer = createEvidenceProducerContext('invoke_skill', { skillId, params: effectiveParams }, (0, outputLanguage_1.localize)(outputLanguage, `调用 Skill ${skillId},收集本阶段结构化证据。`, `Run Skill ${skillId} to collect structured evidence for this phase.`));
|
|
1618
|
+
const skillTraceProvenance = (0, traceProcessorConnectionModel_1.buildTraceProcessorQueryProvenance)({
|
|
1619
|
+
traceId,
|
|
1620
|
+
traceSide: 'current',
|
|
1621
|
+
});
|
|
1618
1622
|
emitUpdate?.({
|
|
1619
1623
|
type: 'progress',
|
|
1620
1624
|
content: {
|
|
@@ -1649,8 +1653,82 @@ function createClaudeMcpServer(options) {
|
|
|
1649
1653
|
// Persist to disk (fire-and-forget) for cross-session learning
|
|
1650
1654
|
logSqlErrorFixPair(errorPair, knowledgeScope).catch(() => { });
|
|
1651
1655
|
}
|
|
1656
|
+
// Artifact mode stores displayResults before emitting DataEnvelopes so
|
|
1657
|
+
// evidence meta can carry the same artifact ids that the model sees.
|
|
1658
|
+
let artifacts;
|
|
1659
|
+
let diagnosticsArtifactId;
|
|
1660
|
+
let synthesizeArtifacts;
|
|
1661
|
+
const artifactIdsByStepId = new Map();
|
|
1662
|
+
if (artifactStore && result.displayResults?.length) {
|
|
1663
|
+
artifacts = result.displayResults.map(dr => {
|
|
1664
|
+
const artId = artifactStore.store({
|
|
1665
|
+
skillId: result.skillId || skillId,
|
|
1666
|
+
stepId: dr.stepId,
|
|
1667
|
+
layer: dr.layer,
|
|
1668
|
+
title: dr.title,
|
|
1669
|
+
data: dr.data,
|
|
1670
|
+
diagnostics: undefined,
|
|
1671
|
+
planPhaseId: producer.planPhaseId,
|
|
1672
|
+
planPhaseTitle: producer.planPhaseTitle,
|
|
1673
|
+
planPhaseGoal: producer.planPhaseGoal,
|
|
1674
|
+
sourceToolCallId: producer.sourceToolCallId,
|
|
1675
|
+
paramsHash: producer.paramsHash,
|
|
1676
|
+
identityResolution: result.identityResolution,
|
|
1677
|
+
});
|
|
1678
|
+
if (dr.stepId)
|
|
1679
|
+
artifactIdsByStepId.set(dr.stepId, artId);
|
|
1680
|
+
const summary = artifactStore.generateCompactSummary(artId);
|
|
1681
|
+
return summary;
|
|
1682
|
+
}).filter((summary) => Boolean(summary));
|
|
1683
|
+
}
|
|
1684
|
+
// Store diagnostics as a separate artifact if present, even for
|
|
1685
|
+
// diagnostics-only skill results that do not emit displayResults.
|
|
1686
|
+
if (artifactStore && result.diagnostics && Array.isArray(result.diagnostics) && result.diagnostics.length > 0) {
|
|
1687
|
+
diagnosticsArtifactId = artifactStore.store({
|
|
1688
|
+
skillId: result.skillId || skillId,
|
|
1689
|
+
stepId: '_diagnostics',
|
|
1690
|
+
layer: 'diagnosis',
|
|
1691
|
+
title: `${skillId} diagnostics`,
|
|
1692
|
+
data: { columns: ['diagnostic'], rows: result.diagnostics.map((d) => [d]) },
|
|
1693
|
+
diagnostics: result.diagnostics,
|
|
1694
|
+
planPhaseId: producer.planPhaseId,
|
|
1695
|
+
planPhaseTitle: producer.planPhaseTitle,
|
|
1696
|
+
planPhaseGoal: producer.planPhaseGoal,
|
|
1697
|
+
sourceToolCallId: producer.sourceToolCallId,
|
|
1698
|
+
paramsHash: producer.paramsHash,
|
|
1699
|
+
identityResolution: result.identityResolution,
|
|
1700
|
+
});
|
|
1701
|
+
}
|
|
1702
|
+
// Store synthesizeData entries as artifacts too — these contain the
|
|
1703
|
+
// raw step data that would otherwise overflow token limits.
|
|
1704
|
+
if (artifactStore && result.synthesizeData && Array.isArray(result.synthesizeData) && result.synthesizeData.length > 0) {
|
|
1705
|
+
synthesizeArtifacts = result.synthesizeData
|
|
1706
|
+
.filter((sd) => sd.data && sd.success !== false)
|
|
1707
|
+
.map((sd) => {
|
|
1708
|
+
const normalizedData = normalizeSynthesizeDataForStorage(sd.data);
|
|
1709
|
+
const artId = artifactStore.store({
|
|
1710
|
+
skillId: result.skillId || skillId,
|
|
1711
|
+
stepId: sd.stepId,
|
|
1712
|
+
layer: sd.layer || 'synthesize',
|
|
1713
|
+
title: sd.stepName || sd.stepId,
|
|
1714
|
+
data: normalizedData,
|
|
1715
|
+
planPhaseId: producer.planPhaseId,
|
|
1716
|
+
planPhaseTitle: producer.planPhaseTitle,
|
|
1717
|
+
planPhaseGoal: producer.planPhaseGoal,
|
|
1718
|
+
sourceToolCallId: producer.sourceToolCallId,
|
|
1719
|
+
paramsHash: producer.paramsHash,
|
|
1720
|
+
identityResolution: result.identityResolution,
|
|
1721
|
+
});
|
|
1722
|
+
return {
|
|
1723
|
+
artifactId: artId,
|
|
1724
|
+
stepId: sd.stepId,
|
|
1725
|
+
rowCount: normalizedData.rows?.length ?? 0,
|
|
1726
|
+
columns: normalizedData.columns ?? [],
|
|
1727
|
+
};
|
|
1728
|
+
});
|
|
1729
|
+
}
|
|
1652
1730
|
if (emitUpdate && result.displayResults?.length) {
|
|
1653
|
-
emitSkillDataEnvelopes(result.displayResults, result.skillId || skillId, emitUpdate,
|
|
1731
|
+
emitSkillDataEnvelopes(result.displayResults, result.skillId || skillId, emitUpdate, skillTraceProvenance, producer, result.identityResolution, artifactIdsByStepId);
|
|
1654
1732
|
}
|
|
1655
1733
|
if (onSkillResult && result.success && result.displayResults?.length) {
|
|
1656
1734
|
onSkillResult({ skillId: result.skillId || skillId, displayResults: result.displayResults });
|
|
@@ -1688,72 +1766,9 @@ function createClaudeMcpServer(options) {
|
|
|
1688
1766
|
};
|
|
1689
1767
|
}
|
|
1690
1768
|
}
|
|
1691
|
-
// Artifact mode:
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
const artId = artifactStore.store({
|
|
1695
|
-
skillId: result.skillId || skillId,
|
|
1696
|
-
stepId: dr.stepId,
|
|
1697
|
-
layer: dr.layer,
|
|
1698
|
-
title: dr.title,
|
|
1699
|
-
data: dr.data,
|
|
1700
|
-
diagnostics: undefined,
|
|
1701
|
-
planPhaseId: producer.planPhaseId,
|
|
1702
|
-
planPhaseTitle: producer.planPhaseTitle,
|
|
1703
|
-
planPhaseGoal: producer.planPhaseGoal,
|
|
1704
|
-
sourceToolCallId: producer.sourceToolCallId,
|
|
1705
|
-
paramsHash: producer.paramsHash,
|
|
1706
|
-
});
|
|
1707
|
-
const summary = artifactStore.generateCompactSummary(artId);
|
|
1708
|
-
return summary;
|
|
1709
|
-
});
|
|
1710
|
-
// Store diagnostics as a separate artifact if present
|
|
1711
|
-
let diagnosticsArtifactId;
|
|
1712
|
-
if (result.diagnostics && Array.isArray(result.diagnostics) && result.diagnostics.length > 0) {
|
|
1713
|
-
diagnosticsArtifactId = artifactStore.store({
|
|
1714
|
-
skillId: result.skillId || skillId,
|
|
1715
|
-
stepId: '_diagnostics',
|
|
1716
|
-
layer: 'diagnosis',
|
|
1717
|
-
title: `${skillId} diagnostics`,
|
|
1718
|
-
data: { columns: ['diagnostic'], rows: result.diagnostics.map((d) => [d]) },
|
|
1719
|
-
diagnostics: result.diagnostics,
|
|
1720
|
-
planPhaseId: producer.planPhaseId,
|
|
1721
|
-
planPhaseTitle: producer.planPhaseTitle,
|
|
1722
|
-
planPhaseGoal: producer.planPhaseGoal,
|
|
1723
|
-
sourceToolCallId: producer.sourceToolCallId,
|
|
1724
|
-
paramsHash: producer.paramsHash,
|
|
1725
|
-
});
|
|
1726
|
-
}
|
|
1727
|
-
// Store synthesizeData entries as artifacts too — these contain the raw step data
|
|
1728
|
-
// (e.g. batch_frame_root_cause with 487 rows) that would otherwise overflow token limits.
|
|
1729
|
-
// Claude can fetch them on demand via fetch_artifact with pagination.
|
|
1730
|
-
let synthesizeArtifacts;
|
|
1731
|
-
if (result.synthesizeData && Array.isArray(result.synthesizeData) && result.synthesizeData.length > 0) {
|
|
1732
|
-
synthesizeArtifacts = result.synthesizeData
|
|
1733
|
-
.filter((sd) => sd.data && sd.success !== false)
|
|
1734
|
-
.map((sd) => {
|
|
1735
|
-
// synthesizeData entries have data as array-of-objects or { columns, rows }
|
|
1736
|
-
const normalizedData = normalizeSynthesizeDataForStorage(sd.data);
|
|
1737
|
-
const artId = artifactStore.store({
|
|
1738
|
-
skillId: result.skillId || skillId,
|
|
1739
|
-
stepId: sd.stepId,
|
|
1740
|
-
layer: sd.layer || 'synthesize',
|
|
1741
|
-
title: sd.stepName || sd.stepId,
|
|
1742
|
-
data: normalizedData,
|
|
1743
|
-
planPhaseId: producer.planPhaseId,
|
|
1744
|
-
planPhaseTitle: producer.planPhaseTitle,
|
|
1745
|
-
planPhaseGoal: producer.planPhaseGoal,
|
|
1746
|
-
sourceToolCallId: producer.sourceToolCallId,
|
|
1747
|
-
paramsHash: producer.paramsHash,
|
|
1748
|
-
});
|
|
1749
|
-
return {
|
|
1750
|
-
artifactId: artId,
|
|
1751
|
-
stepId: sd.stepId,
|
|
1752
|
-
rowCount: normalizedData.rows?.length ?? 0,
|
|
1753
|
-
columns: normalizedData.columns ?? [],
|
|
1754
|
-
};
|
|
1755
|
-
});
|
|
1756
|
-
}
|
|
1769
|
+
// Artifact mode: return compact references whenever any fetchable
|
|
1770
|
+
// artifact was created.
|
|
1771
|
+
if (artifactStore && (artifacts?.length || diagnosticsArtifactId || synthesizeArtifacts?.length)) {
|
|
1757
1772
|
return {
|
|
1758
1773
|
content: [{
|
|
1759
1774
|
type: 'text',
|
|
@@ -1762,6 +1777,7 @@ function createClaudeMcpServer(options) {
|
|
|
1762
1777
|
skillId: result.skillId,
|
|
1763
1778
|
skillName: result.skillName,
|
|
1764
1779
|
...(result.error ? { error: result.error } : {}),
|
|
1780
|
+
...(result.identityResolution ? { identityResolution: result.identityResolution } : {}),
|
|
1765
1781
|
artifacts,
|
|
1766
1782
|
...(diagnosticsArtifactId ? { diagnosticsArtifactId } : {}),
|
|
1767
1783
|
...(synthesizeArtifacts && synthesizeArtifacts.length > 0
|
|
@@ -1782,6 +1798,7 @@ function createClaudeMcpServer(options) {
|
|
|
1782
1798
|
skillId: result.skillId,
|
|
1783
1799
|
skillName: result.skillName,
|
|
1784
1800
|
...(result.error ? { error: result.error } : {}),
|
|
1801
|
+
...(result.identityResolution ? { identityResolution: result.identityResolution } : {}),
|
|
1785
1802
|
...(vendorOverrideHint ? { vendorOverride: vendorOverrideHint } : {}),
|
|
1786
1803
|
displayResults: result.displayResults?.map(dr => ({
|
|
1787
1804
|
stepId: dr.stepId,
|
|
@@ -2072,7 +2089,8 @@ function createClaudeMcpServer(options) {
|
|
|
2072
2089
|
success: true,
|
|
2073
2090
|
detail: effectiveDetail,
|
|
2074
2091
|
...result,
|
|
2075
|
-
sourceToolCallId: producer.sourceToolCallId,
|
|
2092
|
+
sourceToolCallId: result?.sourceToolCallId || producer.sourceToolCallId,
|
|
2093
|
+
fetchedByToolCallId: producer.sourceToolCallId,
|
|
2076
2094
|
paramsHash: producer.paramsHash,
|
|
2077
2095
|
planPhaseId: producer.planPhaseId,
|
|
2078
2096
|
planPhaseTitle: producer.planPhaseTitle,
|
|
@@ -3552,7 +3570,7 @@ function createClaudeMcpServer(options) {
|
|
|
3552
3570
|
const summaryResult = (0, sqlSummarizer_1.summarizeSqlResult)(result.columns, result.rows);
|
|
3553
3571
|
const durationMs = Date.now() - sqlStart;
|
|
3554
3572
|
if (emitUpdate) {
|
|
3555
|
-
emittedEvidence = emitSqlSummaryDataEnvelope(emitUpdate, summaryResult, finalSql, injected, traceProvenance, producer);
|
|
3573
|
+
emittedEvidence = emitSqlSummaryDataEnvelope(emitUpdate, summaryResult, finalSql, injected, traceProvenance, producer, processIdentityWarning);
|
|
3556
3574
|
}
|
|
3557
3575
|
const text = JSON.stringify({
|
|
3558
3576
|
success: true,
|
|
@@ -3576,10 +3594,10 @@ function createClaudeMcpServer(options) {
|
|
|
3576
3594
|
}
|
|
3577
3595
|
const durationMs = Date.now() - sqlStart;
|
|
3578
3596
|
if (emitUpdate && success && result.columns.length > 0) {
|
|
3579
|
-
emittedEvidence = emitSqlDataEnvelope(emitUpdate, result.columns, rows, finalSql, injected, traceProvenance, producer);
|
|
3597
|
+
emittedEvidence = emitSqlDataEnvelope(emitUpdate, result.columns, rows, finalSql, injected, traceProvenance, producer, processIdentityWarning);
|
|
3580
3598
|
}
|
|
3581
3599
|
else if (emitUpdate && !success) {
|
|
3582
|
-
emittedEvidence = emitSqlDiagnosticDataEnvelope(emitUpdate, result.error || (0, outputLanguage_1.localize)(outputLanguage, 'SQL 执行失败', 'SQL execution failed'), finalSql, injected, traceProvenance, producer);
|
|
3600
|
+
emittedEvidence = emitSqlDiagnosticDataEnvelope(emitUpdate, result.error || (0, outputLanguage_1.localize)(outputLanguage, 'SQL 执行失败', 'SQL execution failed'), finalSql, injected, traceProvenance, producer, processIdentityWarning);
|
|
3583
3601
|
}
|
|
3584
3602
|
const text = JSON.stringify({
|
|
3585
3603
|
success,
|
|
@@ -3609,7 +3627,7 @@ function createClaudeMcpServer(options) {
|
|
|
3609
3627
|
traceId: targetTraceId,
|
|
3610
3628
|
traceSide: trace,
|
|
3611
3629
|
});
|
|
3612
|
-
const emittedEvidence = emitUpdate ? emitSqlDiagnosticDataEnvelope(emitUpdate, e.message, sql, undefined, traceProvenance, producer, outputLanguage) : undefined;
|
|
3630
|
+
const emittedEvidence = emitUpdate ? emitSqlDiagnosticDataEnvelope(emitUpdate, e.message, sql, undefined, traceProvenance, producer, undefined, outputLanguage) : undefined;
|
|
3613
3631
|
return {
|
|
3614
3632
|
content: [{
|
|
3615
3633
|
type: 'text',
|
|
@@ -3668,8 +3686,8 @@ function createClaudeMcpServer(options) {
|
|
|
3668
3686
|
traceSide: 'reference',
|
|
3669
3687
|
});
|
|
3670
3688
|
const [currentResult, refResult] = await Promise.all([
|
|
3671
|
-
skillExecutor.execute(skillId, traceId, effectiveParams),
|
|
3672
|
-
skillExecutor.execute(skillId, referenceTraceId, refParams),
|
|
3689
|
+
skillExecutor.execute(skillId, traceId, effectiveParams, { __traceSide: 'current' }),
|
|
3690
|
+
skillExecutor.execute(skillId, referenceTraceId, refParams, { __traceSide: 'reference' }),
|
|
3673
3691
|
]);
|
|
3674
3692
|
const compareDuration = Date.now() - compareStart;
|
|
3675
3693
|
// Schema alignment: check which steps are comparable
|
|
@@ -3690,14 +3708,14 @@ function createClaudeMcpServer(options) {
|
|
|
3690
3708
|
...baseProducer,
|
|
3691
3709
|
sourceToolCallId: `${baseProducer.sourceToolCallId}:current`,
|
|
3692
3710
|
producerReason: (0, outputLanguage_1.localize)(outputLanguage, `当前 Trace 对比 Skill ${skillId} 结果。`, `Current trace result for comparison Skill ${skillId}.`),
|
|
3693
|
-
});
|
|
3711
|
+
}, currentResult.identityResolution);
|
|
3694
3712
|
}
|
|
3695
3713
|
if (emitUpdate && refResult.displayResults?.length) {
|
|
3696
3714
|
emitSkillDataEnvelopes(refResult.displayResults, skillId, emitUpdate, referenceTraceProvenance, {
|
|
3697
3715
|
...baseProducer,
|
|
3698
3716
|
sourceToolCallId: `${baseProducer.sourceToolCallId}:reference`,
|
|
3699
3717
|
producerReason: (0, outputLanguage_1.localize)(outputLanguage, `参考 Trace 对比 Skill ${skillId} 结果。`, `Reference trace result for comparison Skill ${skillId}.`),
|
|
3700
|
-
});
|
|
3718
|
+
}, refResult.identityResolution);
|
|
3701
3719
|
}
|
|
3702
3720
|
// Build compact comparison summary for Claude
|
|
3703
3721
|
const buildStepSummary = (results) => results.map(r => ({
|
|
@@ -3717,6 +3735,7 @@ function createClaudeMcpServer(options) {
|
|
|
3717
3735
|
stepCount: currentResult.displayResults?.length || 0,
|
|
3718
3736
|
steps: buildStepSummary(currentResult.displayResults || []),
|
|
3719
3737
|
diagnosticCount: currentResult.diagnostics?.length || 0,
|
|
3738
|
+
identityResolution: currentResult.identityResolution,
|
|
3720
3739
|
error: currentResult.error,
|
|
3721
3740
|
},
|
|
3722
3741
|
reference: {
|
|
@@ -3727,6 +3746,7 @@ function createClaudeMcpServer(options) {
|
|
|
3727
3746
|
stepCount: refResult.displayResults?.length || 0,
|
|
3728
3747
|
steps: buildStepSummary(refResult.displayResults || []),
|
|
3729
3748
|
diagnosticCount: refResult.diagnostics?.length || 0,
|
|
3749
|
+
identityResolution: refResult.identityResolution,
|
|
3730
3750
|
error: refResult.error,
|
|
3731
3751
|
},
|
|
3732
3752
|
alignment: {
|
|
@@ -3932,7 +3952,7 @@ function producerEnvelopeOptions(producer) {
|
|
|
3932
3952
|
};
|
|
3933
3953
|
}
|
|
3934
3954
|
/** Emit a DataEnvelope for SQL query results. */
|
|
3935
|
-
function emitSqlDataEnvelope(emit, columns, rows, sql, stdlibInjectedModules, traceProvenance, producer) {
|
|
3955
|
+
function emitSqlDataEnvelope(emit, columns, rows, sql, stdlibInjectedModules, traceProvenance, producer, processIdentityWarning) {
|
|
3936
3956
|
const { evidenceRefId, queryHash } = stableSqlEvidenceRefId(sql, columns, rows, traceProvenance, producer);
|
|
3937
3957
|
const envelope = (0, dataContract_1.createDataEnvelope)({ columns, rows }, {
|
|
3938
3958
|
type: 'sql_result',
|
|
@@ -3949,6 +3969,7 @@ function emitSqlDataEnvelope(emit, columns, rows, sql, stdlibInjectedModules, tr
|
|
|
3949
3969
|
traceId: traceProvenance?.traceId,
|
|
3950
3970
|
queryHash,
|
|
3951
3971
|
...producerEnvelopeOptions(producer),
|
|
3972
|
+
processIdentityWarning,
|
|
3952
3973
|
intent: 'ad_hoc_sql_verification',
|
|
3953
3974
|
});
|
|
3954
3975
|
emit({
|
|
@@ -3968,7 +3989,7 @@ function emitSqlDataEnvelope(emit, columns, rows, sql, stdlibInjectedModules, tr
|
|
|
3968
3989
|
return { evidenceRefId, queryHash };
|
|
3969
3990
|
}
|
|
3970
3991
|
/** Emit a DataEnvelope for SQL summary-mode results. */
|
|
3971
|
-
function emitSqlSummaryDataEnvelope(emit, summary, sql, stdlibInjectedModules, traceProvenance, producer) {
|
|
3992
|
+
function emitSqlSummaryDataEnvelope(emit, summary, sql, stdlibInjectedModules, traceProvenance, producer, processIdentityWarning) {
|
|
3972
3993
|
const { evidenceRefId, queryHash } = stableSqlEvidenceRefId(sql, summary.columns, summary.sampleRows, traceProvenance, producer, 'summary');
|
|
3973
3994
|
const envelope = (0, dataContract_1.createDataEnvelope)({
|
|
3974
3995
|
summary: {
|
|
@@ -3987,6 +4008,7 @@ function emitSqlSummaryDataEnvelope(emit, summary, sql, stdlibInjectedModules, t
|
|
|
3987
4008
|
traceId: traceProvenance?.traceId,
|
|
3988
4009
|
queryHash,
|
|
3989
4010
|
...producerEnvelopeOptions(producer),
|
|
4011
|
+
processIdentityWarning,
|
|
3990
4012
|
intent: 'ad_hoc_sql_summary',
|
|
3991
4013
|
});
|
|
3992
4014
|
emit({
|
|
@@ -4006,7 +4028,7 @@ function emitSqlSummaryDataEnvelope(emit, summary, sql, stdlibInjectedModules, t
|
|
|
4006
4028
|
return { evidenceRefId, queryHash };
|
|
4007
4029
|
}
|
|
4008
4030
|
/** Emit a diagnostic DataEnvelope for failed SQL so missing tables remain explainable. */
|
|
4009
|
-
function emitSqlDiagnosticDataEnvelope(emit, error, sql, stdlibInjectedModules, traceProvenance, producer, outputLanguage = outputLanguage_1.DEFAULT_OUTPUT_LANGUAGE) {
|
|
4031
|
+
function emitSqlDiagnosticDataEnvelope(emit, error, sql, stdlibInjectedModules, traceProvenance, producer, processIdentityWarning, outputLanguage = outputLanguage_1.DEFAULT_OUTPUT_LANGUAGE) {
|
|
4010
4032
|
const { evidenceRefId, queryHash } = stableSqlEvidenceRefId(sql, [], [[error]], traceProvenance, producer, 'diagnostic');
|
|
4011
4033
|
const envelope = (0, dataContract_1.createDataEnvelope)({
|
|
4012
4034
|
text: [
|
|
@@ -4026,6 +4048,7 @@ function emitSqlDiagnosticDataEnvelope(emit, error, sql, stdlibInjectedModules,
|
|
|
4026
4048
|
traceId: traceProvenance?.traceId,
|
|
4027
4049
|
queryHash,
|
|
4028
4050
|
...producerEnvelopeOptions(producer),
|
|
4051
|
+
processIdentityWarning,
|
|
4029
4052
|
intent: 'ad_hoc_sql_diagnostic',
|
|
4030
4053
|
});
|
|
4031
4054
|
emit({
|
|
@@ -4057,13 +4080,22 @@ function inferSqlColumnType(col) {
|
|
|
4057
4080
|
* Convert skill DisplayResults to DataEnvelopes and emit as SSE 'data' events.
|
|
4058
4081
|
* This enables interactive tables (clickable timestamps, expandable rows) in the frontend.
|
|
4059
4082
|
*/
|
|
4060
|
-
function emitSkillDataEnvelopes(displayResults, skillId, emit, traceProvenance, producer) {
|
|
4083
|
+
function emitSkillDataEnvelopes(displayResults, skillId, emit, traceProvenance, producer, identityResolution, artifactIdsByStepId) {
|
|
4061
4084
|
const envelopes = displayResults
|
|
4062
|
-
.filter(dr =>
|
|
4085
|
+
.filter(dr => Boolean(dr.data))
|
|
4063
4086
|
.map(dr => {
|
|
4064
4087
|
const explicitColumns = dr.columnDefinitions;
|
|
4065
|
-
const
|
|
4088
|
+
const drForEnvelope = {
|
|
4089
|
+
...dr,
|
|
4090
|
+
metadataConfig: dr.metadataConfig || (Array.isArray(dr.metadataFields)
|
|
4091
|
+
? { fields: dr.metadataFields }
|
|
4092
|
+
: undefined),
|
|
4093
|
+
};
|
|
4094
|
+
const envelope = (0, dataContract_1.displayResultToEnvelope)(drForEnvelope, skillId, explicitColumns);
|
|
4066
4095
|
const evidenceRefId = stableSkillEvidenceRefId(skillId, envelope.meta.stepId, envelope.display.title, envelope.data, traceProvenance, producer);
|
|
4096
|
+
const artifactId = envelope.meta.stepId
|
|
4097
|
+
? artifactIdsByStepId?.get(envelope.meta.stepId)
|
|
4098
|
+
: undefined;
|
|
4067
4099
|
const withEvidence = {
|
|
4068
4100
|
...envelope,
|
|
4069
4101
|
meta: {
|
|
@@ -4071,6 +4103,13 @@ function emitSkillDataEnvelopes(displayResults, skillId, emit, traceProvenance,
|
|
|
4071
4103
|
evidenceRefId,
|
|
4072
4104
|
traceSide: traceProvenance?.traceSide,
|
|
4073
4105
|
traceId: traceProvenance?.traceId,
|
|
4106
|
+
...(artifactId ? { artifactId, sourceArtifactId: artifactId } : {}),
|
|
4107
|
+
...(identityResolution ? {
|
|
4108
|
+
identityRefId: identityResolution.identityRefId,
|
|
4109
|
+
identityStatus: identityResolution.status,
|
|
4110
|
+
identityWarnings: identityResolution.warnings,
|
|
4111
|
+
identityResolution,
|
|
4112
|
+
} : {}),
|
|
4074
4113
|
...producerEnvelopeOptions(producer),
|
|
4075
4114
|
intent: 'skill_structured_result',
|
|
4076
4115
|
},
|